@rspress/core 1.11.1 → 1.12.0

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.
package/dist/loader.js CHANGED
@@ -10,10 +10,13 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
10
10
  });
11
11
 
12
12
  // src/node/mdx/loader.ts
13
- import path6 from "path";
14
- import { createProcessor } from "@mdx-js/mdx";
13
+ import path8 from "path";
14
+ import { pathToFileURL } from "url";
15
+ import { createProcessor as createProcessor2 } from "@mdx-js/mdx";
16
+ import { isProduction as isProduction2 } from "@rspress/shared";
15
17
  import { logger as logger2 } from "@rspress/shared/logger";
16
18
  import { loadFrontMatter } from "@rspress/shared/node-utils";
19
+ import fs2 from "fs-extra";
17
20
 
18
21
  // src/node/utils/normalizePath.ts
19
22
  import os from "os";
@@ -26,6 +29,31 @@ function normalizePath(id) {
26
29
  return path.posix.normalize(isWindows ? slash(id) : id);
27
30
  }
28
31
 
32
+ // src/node/constants.ts
33
+ import path2 from "path";
34
+ import { fileURLToPath } from "url";
35
+ import { RSPRESS_TEMP_DIR } from "@rspress/shared";
36
+ var importStatementRegex = /import\s+(.*?)\s+from\s+['"](.*?)['"];?/gm;
37
+ var dirname = path2.dirname(fileURLToPath(new URL(import.meta.url)));
38
+ var PACKAGE_ROOT = path2.join(dirname, "..");
39
+ var CLIENT_ENTRY = path2.join(
40
+ PACKAGE_ROOT,
41
+ "dist",
42
+ "runtime",
43
+ "clientEntry.js"
44
+ );
45
+ var SSR_ENTRY = path2.join(
46
+ PACKAGE_ROOT,
47
+ "dist",
48
+ "runtime",
49
+ "ssrEntry.js"
50
+ );
51
+ var TEMP_DIR = path2.join(
52
+ process.cwd(),
53
+ "node_modules",
54
+ RSPRESS_TEMP_DIR
55
+ );
56
+
29
57
  // src/node/utils/getASTNodeImport.ts
30
58
  var getASTNodeImport = (name, from) => ({
31
59
  type: "mdxjsEsm",
@@ -54,6 +82,97 @@ var getASTNodeImport = (name, from) => ({
54
82
  }
55
83
  });
56
84
 
85
+ // src/node/utils/flattenMdxContent.ts
86
+ import path3 from "path";
87
+ import enhancedResolve from "enhanced-resolve";
88
+ import fs from "@rspress/shared/fs-extra";
89
+ import { createProcessor } from "@mdx-js/mdx";
90
+ import { MDX_REGEXP } from "@rspress/shared";
91
+ var { CachedInputFileSystem, ResolverFactory } = enhancedResolve;
92
+ var processor = createProcessor();
93
+ var resolver;
94
+ var startFlatten = false;
95
+ async function resolveDepPath(importPath, importer, alias) {
96
+ if (!resolver) {
97
+ resolver = ResolverFactory.createResolver({
98
+ fileSystem: new CachedInputFileSystem(fs),
99
+ extensions: [".mdx", ".md"],
100
+ alias
101
+ });
102
+ }
103
+ const resolveResult = await new Promise((resolve, reject) => {
104
+ resolver.resolve(
105
+ {
106
+ importer
107
+ },
108
+ importer,
109
+ importPath,
110
+ {},
111
+ (err, filePath) => {
112
+ if (err) {
113
+ return reject(err);
114
+ }
115
+ if (!filePath) {
116
+ return reject(
117
+ new Error(
118
+ `Empty result when resolving ${importPath} from ${importer}`
119
+ )
120
+ );
121
+ }
122
+ return resolve(filePath);
123
+ }
124
+ );
125
+ });
126
+ return resolveResult;
127
+ }
128
+ async function flattenMdxContent(content, basePath, alias) {
129
+ if (!importStatementRegex.test(content)) {
130
+ return content;
131
+ }
132
+ let result = content;
133
+ if (!startFlatten) {
134
+ resolver = ResolverFactory.createResolver({
135
+ fileSystem: new CachedInputFileSystem(fs),
136
+ extensions: [".mdx", ".md", ".js"],
137
+ alias
138
+ });
139
+ startFlatten = true;
140
+ }
141
+ let ast;
142
+ try {
143
+ ast = processor.parse(content);
144
+ } catch (e) {
145
+ return content;
146
+ }
147
+ const importNodes = ast.children.filter((node) => node.type === "mdxjsEsm").map((node) => {
148
+ return node.data?.estree?.body || [];
149
+ }).flat().filter((node) => node.type === "ImportDeclaration");
150
+ for (const importNode of importNodes) {
151
+ const id = importNode.specifiers[0].local.name;
152
+ const importPath = importNode.source.value;
153
+ let absoluteImportPath;
154
+ try {
155
+ absoluteImportPath = await resolveDepPath(
156
+ importPath,
157
+ path3.dirname(basePath),
158
+ alias
159
+ );
160
+ } catch (e) {
161
+ continue;
162
+ }
163
+ if (MDX_REGEXP.test(absoluteImportPath)) {
164
+ const importedContent = fs.readFileSync(absoluteImportPath, "utf-8");
165
+ const replacedValue = await flattenMdxContent(
166
+ importedContent,
167
+ absoluteImportPath,
168
+ alias
169
+ );
170
+ result = result.replace(new RegExp(`<${id}\\s*/>`), () => replacedValue);
171
+ }
172
+ }
173
+ return result;
174
+ }
175
+
57
176
  // src/node/utils/extractTextAndId.ts
58
177
  var extractTextAndId = (title) => {
59
178
  const customIdReg = /{#.*}/;
@@ -71,8 +190,15 @@ function escapeMarkdownHeadingIds(content) {
71
190
  );
72
191
  }
73
192
 
193
+ // src/node/runtimeModule/routeData.ts
194
+ import { addLeadingSlash } from "@rspress/shared";
195
+ var normalizeRoutePath = (routePath) => {
196
+ const result = routePath.replace(/\.(.*)?$/, "").replace(/index$/, "");
197
+ return addLeadingSlash(result);
198
+ };
199
+
74
200
  // src/node/mdx/options.ts
75
- import path5 from "path";
201
+ import path7 from "path";
76
202
  import remarkGFM from "remark-gfm";
77
203
  import rehypePluginExternalLinks from "rehype-external-links";
78
204
 
@@ -198,7 +324,7 @@ function create(node) {
198
324
  }
199
325
 
200
326
  // src/node/mdx/remarkPlugins/normalizeLink.ts
201
- import path2 from "path";
327
+ import path4 from "path";
202
328
  import { visit as visit3 } from "unist-util-visit";
203
329
  import { normalizeHref, parseUrl, isExternalUrl, slash as slash2 } from "@rspress/shared";
204
330
  var remarkPluginNormalizeLink = ({ base, root, cleanUrls }) => (tree, file) => {
@@ -219,19 +345,19 @@ var remarkPluginNormalizeLink = ({ base, root, cleanUrls }) => (tree, file) => {
219
345
  node.url = url + (hash ? `#${hash}` : "");
220
346
  return;
221
347
  }
222
- const extname = path2.extname(url);
348
+ const extname = path4.extname(url);
223
349
  if (extname === ".md" || extname === ".mdx") {
224
350
  url = url.replace(extname, "");
225
351
  }
226
- const relativePath = path2.relative(root, file.path);
352
+ const relativePath = path4.relative(root, file.path);
227
353
  if (url.startsWith(".")) {
228
- url = path2.posix.join(slash2(path2.dirname(relativePath)), url);
354
+ url = path4.posix.join(slash2(path4.dirname(relativePath)), url);
229
355
  }
230
356
  url = normalizeHref(url, cleanUrls);
231
357
  if (hash) {
232
358
  url += `#${hash}`;
233
359
  }
234
- node.url = path2.posix.join(base, url);
360
+ node.url = path4.posix.join(base, url);
235
361
  }
236
362
  );
237
363
  const normalizeImageUrl = (imageUrl) => {
@@ -310,24 +436,15 @@ var remarkPluginNormalizeLink = ({ base, root, cleanUrls }) => (tree, file) => {
310
436
  };
311
437
 
312
438
  // src/node/mdx/remarkPlugins/checkDeadLink.ts
313
- import path3 from "path";
439
+ import path5 from "path";
314
440
  import { visit as visit4 } from "unist-util-visit";
315
441
  import { logger } from "@rspress/shared/logger";
316
442
  import { cleanUrl, isProduction } from "@rspress/shared";
317
-
318
- // src/node/runtimeModule/routeData.ts
319
- import { addLeadingSlash } from "@rspress/shared";
320
- var normalizeRoutePath = (routePath) => {
321
- const result = routePath.replace(/\.(.*)?$/, "").replace(/index$/, "");
322
- return addLeadingSlash(result);
323
- };
324
-
325
- // src/node/mdx/remarkPlugins/checkDeadLink.ts
326
443
  var IGNORE_REGEXP = /^(https?|mailto|tel|#)/;
327
444
  function checkLinks(links, filepath, root, routeService) {
328
445
  const errorInfos = [];
329
446
  links.filter((link) => !IGNORE_REGEXP.test(link)).map((link) => normalizePath(link)).forEach((link) => {
330
- const relativePath = path3.relative(root, filepath);
447
+ const relativePath = path5.relative(root, filepath);
331
448
  if (!routeService.isExistRoute(cleanUrl(link))) {
332
449
  errorInfos.push(
333
450
  `Internal link to ${link} is dead, check it in ${relativePath}`
@@ -358,7 +475,7 @@ var remarkCheckDeadLinks = (checkLink) => {
358
475
  if (!url.startsWith("http") && !url.startsWith("https")) {
359
476
  const normalizeUrl = normalizeRoutePath(
360
477
  // fix: windows path
361
- url?.split(path3.sep).join("/")?.split("#")[0]
478
+ url?.split(path5.sep).join("/")?.split("#")[0]
362
479
  );
363
480
  internalLinks.add(normalizeUrl);
364
481
  }
@@ -368,13 +485,13 @@ var remarkCheckDeadLinks = (checkLink) => {
368
485
  };
369
486
 
370
487
  // src/node/mdx/remarkPlugins/builtin.ts
371
- import path4 from "path";
488
+ import path6 from "path";
372
489
  var remarkBuiltin = ({
373
490
  globalComponents
374
491
  }) => {
375
492
  return (tree) => {
376
493
  const demos = globalComponents.map((componentPath) => {
377
- const filename = path4.parse(componentPath).name;
494
+ const filename = path6.parse(componentPath).name;
378
495
  const componentName = filename[0].toUpperCase() + filename.slice(1);
379
496
  return getASTNodeImport(componentName, componentPath);
380
497
  });
@@ -406,7 +523,7 @@ async function createMDXOptions(docDirectory, config, checkDeadLinks, routeServi
406
523
  const defaultLang = config?.lang || "";
407
524
  return {
408
525
  providerImportSource: "@mdx-js/react",
409
- format: path5.extname(filepath).slice(1),
526
+ format: path7.extname(filepath).slice(1),
410
527
  remarkPlugins: [
411
528
  remarkGFM,
412
529
  remarkPluginToc,
@@ -453,9 +570,45 @@ async function createMDXOptions(docDirectory, config, checkDeadLinks, routeServi
453
570
  }
454
571
 
455
572
  // src/node/mdx/loader.ts
573
+ async function triggerReload() {
574
+ const siteDataModulePath = path8.join(
575
+ TEMP_DIR,
576
+ "runtime",
577
+ `${"virtual-site-data" /* SiteData */}.mjs`
578
+ );
579
+ const { default: siteData } = await import(pathToFileURL(siteDataModulePath).href);
580
+ await fs2.writeFile(
581
+ siteDataModulePath,
582
+ `export default ${JSON.stringify({
583
+ ...siteData,
584
+ timestamp: Date.now().toString()
585
+ })}`
586
+ );
587
+ }
588
+ function createCheckPageMetaUpdateFn() {
589
+ const pageMetaMap = /* @__PURE__ */ new Map();
590
+ return (modulePath, pageMeta) => {
591
+ const prevMeta = pageMetaMap.get(modulePath);
592
+ const deserializedMeta = JSON.stringify(pageMeta);
593
+ pageMetaMap.set(modulePath, deserializedMeta);
594
+ if (!prevMeta) {
595
+ return;
596
+ }
597
+ if (prevMeta !== deserializedMeta) {
598
+ setTimeout(async () => {
599
+ logger2.info(
600
+ `⭐️ Page metadata changed, rspress will trigger page reload...`
601
+ );
602
+ await triggerReload();
603
+ });
604
+ }
605
+ };
606
+ }
607
+ var checkPageMetaUpdate = createCheckPageMetaUpdateFn();
456
608
  async function mdxLoader(context, source, callback) {
457
609
  const options = context.getOptions();
458
610
  const filepath = context.resourcePath;
611
+ const { alias } = context._compiler.options.resolve;
459
612
  context.cacheable(true);
460
613
  let pageMeta = {
461
614
  title: "",
@@ -468,8 +621,9 @@ async function mdxLoader(context, source, callback) {
468
621
  docDirectory,
469
622
  true
470
623
  );
471
- const preprocessedContent = escapeMarkdownHeadingIds(content);
472
- const isHomePage = frontmatter.pageType === "home";
624
+ const preprocessedContent = escapeMarkdownHeadingIds(
625
+ await flattenMdxContent(content, filepath, alias)
626
+ );
473
627
  let enableMdxRs;
474
628
  const mdxRs = config?.markdown?.mdxRs ?? true;
475
629
  if (typeof mdxRs === "object") {
@@ -488,7 +642,7 @@ async function mdxLoader(context, source, callback) {
488
642
  filepath,
489
643
  pluginDriver
490
644
  );
491
- const compiler = createProcessor(mdxOptions);
645
+ const compiler = createProcessor2(mdxOptions);
492
646
  compiler.data("pageMeta", {
493
647
  toc: [],
494
648
  title: ""
@@ -520,17 +674,15 @@ async function mdxLoader(context, source, callback) {
520
674
  checkLinks(links, filepath, docDirectory, routeService);
521
675
  }
522
676
  }
523
- const result = `${// Why do we add the frontmatter to the compiled result?
524
- // 1. Inject the frontmatter to the compiled result, so that we can get the frontmatter in the mdx content
525
- // 2. Fix the home page won't update when the frontmatter is changed. When the frontmatter in the mdx of home page is changed, the home page will not be updated. The reason is that the home page component isn't the mdx module compiled currently. But the frontmatter of the mdx module have sincerely changed. So we reload the page and the home page will be updated.
526
- // In react-refresh, if a module can be hot updated, all the its exports need to be component(function/class & upper case first letter), otherwise it will trigger a full reload.
527
- // In this case, we export a component named `export` to make the home page can be hot updated after the frontmatter is changed.
528
- isHomePage ? "export" : ""} const frontmatter = ${JSON.stringify(frontmatter)};
677
+ if (!isProduction2()) {
678
+ checkPageMetaUpdate(filepath, pageMeta);
679
+ }
680
+ const result = `const frontmatter = ${JSON.stringify(frontmatter)};
529
681
  ${compileResult}
530
682
  MDXContent.__RSPRESS_PAGE_META = {};
531
683
 
532
684
  MDXContent.__RSPRESS_PAGE_META["${encodeURIComponent(
533
- normalizePath(path6.relative(docDirectory, filepath))
685
+ normalizePath(path8.relative(docDirectory, filepath))
534
686
  )}"] = ${JSON.stringify(pageMeta)};
535
687
  `;
536
688
  callback(null, result);
@@ -540,7 +692,9 @@ MDXContent.__RSPRESS_PAGE_META["${encodeURIComponent(
540
692
  }
541
693
  }
542
694
  export {
543
- mdxLoader as default
695
+ createCheckPageMetaUpdateFn,
696
+ mdxLoader as default,
697
+ triggerReload
544
698
  };
545
699
 
546
700
  //# sourceMappingURL=loader.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;AAAA,OAAOA,WAAU;AAEjB,SAAS,uBAAuB;AAEhC,SAAS,UAAAC,eAAc;AACvB,SAAS,uBAAuB;;;ACLhC,OAAO,QAAQ;AACf,OAAO,UAAU;AAEV,IAAM,YAAY,GAAG,SAAS,MAAM;AAEpC,SAAS,MAAM,GAAmB;AACvC,SAAO,EAAE,QAAQ,OAAO,GAAG;AAC7B;AAEO,SAAS,cAAc,IAAoB;AAChD,SAAO,KAAK,MAAM,UAAU,YAAY,MAAM,EAAE,IAAI,EAAE;AACxD;;;ACPO,IAAM,mBAAmB,CAAC,MAAc,UAC5C;AAAA,EACC,MAAM;AAAA,EACN,OAAO,UAAU,IAAI,SAAS,KAAK,UAAU,IAAI,CAAC;AAAA,EAClD,MAAM;AAAA,IACJ,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,MAAM;AAAA,QACJ;AAAA,UACE,MAAM;AAA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,EAAE,OAAO,OAAO,QAAQ,EAAE;AAC7D,aAAS,EAAE,SAAS,EAAE,SAAS,MAAM,GAAG,QAAQ,iBAAiB,CAAC;AAAA,EACpE;AACF","names":["path","logger","visit","slash"],"sources":["../src/node/mdx/loader.ts","../src/node/utils/normalizePath.ts","../src/node/utils/getASTNodeImport.ts","../src/node/utils/extractTextAndId.ts","../src/node/utils/escapeHeadingIds.ts","../src/node/mdx/options.ts","../src/node/mdx/remarkPlugins/toc.ts","../src/node/mdx/rehypePlugins/codeMeta.ts","../src/node/mdx/rehypePlugins/headerAnchor.ts","../src/node/mdx/remarkPlugins/normalizeLink.ts","../src/node/mdx/remarkPlugins/checkDeadLink.ts","../src/node/runtimeModule/routeData.ts","../src/node/mdx/remarkPlugins/builtin.ts"],"sourcesContent":["import path from 'path';\nimport type { Rspack } from '@rsbuild/core';\nimport { createProcessor } from '@mdx-js/mdx';\nimport type { Header, UserConfig } from '@rspress/shared';\nimport { logger } from '@rspress/shared/logger';\nimport { loadFrontMatter } from '@rspress/shared/node-utils';\nimport type { RouteService } from '../route/RouteService';\nimport { normalizePath, escapeMarkdownHeadingIds } from '../utils';\nimport { PluginDriver } from '../PluginDriver';\nimport { createMDXOptions } from './options';\nimport { TocItem } from './remarkPlugins/toc';\nimport { checkLinks } from './remarkPlugins/checkDeadLink';\n\ninterface LoaderOptions {\n config: UserConfig;\n docDirectory: string;\n checkDeadLinks: boolean;\n routeService: RouteService;\n pluginDriver: PluginDriver;\n}\n\nexport interface PageMeta {\n toc: TocItem[];\n title: string;\n frontmatter?: Record<string, any>;\n}\n\nexport default async function mdxLoader(\n context: Rspack.LoaderContext<LoaderOptions>,\n source: string,\n callback: Rspack.LoaderContext['callback'],\n) {\n const options = context.getOptions();\n const filepath = context.resourcePath;\n context.cacheable(true);\n\n let pageMeta = {\n title: '',\n toc: [],\n } as PageMeta;\n\n const { config, docDirectory, checkDeadLinks, routeService, pluginDriver } =\n options;\n\n const { frontmatter, content } = loadFrontMatter(\n source,\n filepath,\n docDirectory,\n true,\n );\n\n // preprocessor\n const preprocessedContent = escapeMarkdownHeadingIds(content);\n const isHomePage = frontmatter.pageType === 'home';\n\n let enableMdxRs;\n const mdxRs = config?.markdown?.mdxRs ?? true;\n if (typeof mdxRs === 'object') {\n enableMdxRs =\n typeof mdxRs?.include === 'function' ? mdxRs.include(filepath) : true;\n } else {\n enableMdxRs = mdxRs;\n }\n\n try {\n let compileResult: string;\n if (!enableMdxRs) {\n const mdxOptions = await createMDXOptions(\n docDirectory,\n config,\n checkDeadLinks,\n routeService,\n filepath,\n pluginDriver,\n );\n const compiler = createProcessor(mdxOptions);\n\n compiler.data('pageMeta', {\n toc: [],\n title: '',\n });\n const vFile = await compiler.process({\n value: preprocessedContent,\n path: filepath,\n });\n\n compileResult = String(vFile);\n pageMeta = {\n ...(compiler.data('pageMeta') as {\n toc: Header[];\n title: string;\n }),\n frontmatter,\n } as PageMeta;\n } else {\n const { compile } = require('@rspress/mdx-rs');\n\n // TODO: Cannot get correct toc from mdx which has internal components\n const { toc, links, title, code } = await compile({\n value: preprocessedContent,\n filepath,\n root: docDirectory,\n development: process.env.NODE_ENV !== 'production',\n });\n\n compileResult = code;\n pageMeta = {\n toc,\n title,\n frontmatter,\n };\n // We should check dead links in mdx-rs mode\n if (checkDeadLinks) {\n checkLinks(links, filepath, docDirectory, routeService);\n }\n }\n // Note: encode filename to be compatible with Windows\n\n const result = `${\n // Why do we add the frontmatter to the compiled result?\n // 1. Inject the frontmatter to the compiled result, so that we can get the frontmatter in the mdx content\n // 2. Fix the home page won't update when the frontmatter is changed. When the frontmatter in the mdx of home page is changed, the home page will not be updated. The reason is that the home page component isn't the mdx module compiled currently. But the frontmatter of the mdx module have sincerely changed. So we reload the page and the home page will be updated.\n // In react-refresh, if a module can be hot updated, all the its exports need to be component(function/class & upper case first letter), otherwise it will trigger a full reload.\n // In this case, we export a component named `export` to make the home page can be hot updated after the frontmatter is changed.\n isHomePage ? 'export' : ''\n } const frontmatter = ${JSON.stringify(frontmatter)};\n${compileResult}\nMDXContent.__RSPRESS_PAGE_META = {};\n\nMDXContent.__RSPRESS_PAGE_META[\"${encodeURIComponent(\n normalizePath(path.relative(docDirectory, filepath)),\n )}\"] = ${JSON.stringify(pageMeta)};\n`;\n callback(null, result);\n } catch (e) {\n logger.error(`MDX compile error: ${e.message} in ${filepath}`);\n callback({ message: e.message, name: `${filepath} compile error` });\n }\n}\n","import os from 'os';\nimport path from 'path';\n\nexport const isWindows = os.platform() === 'win32';\n\nexport function slash(p: string): string {\n return p.replace(/\\\\/g, '/');\n}\n\nexport function normalizePath(id: string): string {\n return path.posix.normalize(isWindows ? slash(id) : id);\n}\n","import type { MdxjsEsm } from 'mdast-util-mdxjs-esm';\n\n// Construct import statement for AST\n// Such as: import image1 from './test.png'\nexport const getASTNodeImport = (name: string, from: string) =>\n ({\n type: 'mdxjsEsm',\n value: `import ${name} from ${JSON.stringify(from)}`,\n data: {\n estree: {\n type: 'Program',\n sourceType: 'module',\n body: [\n {\n type: 'ImportDeclaration',\n specifiers: [\n {\n type: 'ImportDefaultSpecifier',\n local: { type: 'Identifier', name },\n },\n ],\n source: {\n type: 'Literal',\n value: from,\n raw: `${JSON.stringify(from)}`,\n },\n },\n ],\n },\n },\n } as MdxjsEsm);\n","/**\n * hello world {#custom-id} -> { text: 'hello world', id: 'custom-id' }\n */\nexport const extractTextAndId = (title: string) => {\n const customIdReg = /{#.*}/;\n const text = title.replace(customIdReg, '').trimEnd();\n const customId = title.match(customIdReg)?.[0]?.slice(2, -1) || '';\n return [text, customId];\n};\n","/**\n * Support custom id like `#hello world {#custom-id}`\n * Avoid https://mdxjs.com/docs/troubleshooting-mdx/#could-not-parse-expression-with-acorn-error\n */\nexport function escapeMarkdownHeadingIds(content: string): string {\n const markdownHeadingRegexp = /(?:^|\\n)#{1,6}(?!#).*/g;\n return content.replace(markdownHeadingRegexp, substring =>\n substring\n .replace('{#', '\\\\{#')\n // prevent duplicate escaping\n .replace('\\\\\\\\{#', '\\\\{#'),\n );\n}\n","import path from 'path';\nimport remarkGFM from 'remark-gfm';\nimport { Options } from '@mdx-js/loader';\nimport { UserConfig } from '@rspress/shared';\nimport { PluggableList } from 'unified';\nimport rehypePluginExternalLinks from 'rehype-external-links';\nimport type { RouteService } from '../route/RouteService';\nimport type { PluginDriver } from '../PluginDriver';\nimport { remarkPluginToc } from './remarkPlugins/toc';\nimport { rehypePluginCodeMeta } from './rehypePlugins/codeMeta';\nimport { rehypeHeaderAnchor } from './rehypePlugins/headerAnchor';\nimport { remarkPluginNormalizeLink } from './remarkPlugins/normalizeLink';\nimport { remarkCheckDeadLinks } from './remarkPlugins/checkDeadLink';\nimport { remarkBuiltin } from './remarkPlugins/builtin';\n\nexport async function createMDXOptions(\n docDirectory: string,\n config: UserConfig,\n checkDeadLinks: boolean,\n routeService: RouteService,\n filepath: string,\n pluginDriver: PluginDriver,\n): Promise<Options> {\n const cleanUrls = Boolean(config?.route?.cleanUrls);\n const {\n remarkPlugins: remarkPluginsFromConfig = [],\n rehypePlugins: rehypePluginsFromConfig = [],\n globalComponents: globalComponentsFromConfig = [],\n } = config?.markdown || {};\n const rspressPlugins = pluginDriver.getPlugins();\n const remarkPluginsFromPlugins = rspressPlugins.flatMap(\n plugin => plugin.markdown?.remarkPlugins || [],\n ) as PluggableList;\n const rehypePluginsFromPlugins = rspressPlugins.flatMap(\n plugin => plugin.markdown?.rehypePlugins || [],\n ) as PluggableList;\n const globalComponents = [\n ...rspressPlugins.flatMap(\n plugin => plugin.markdown?.globalComponents || [],\n ),\n ...globalComponentsFromConfig,\n ];\n const defaultLang = config?.lang || '';\n return {\n providerImportSource: '@mdx-js/react',\n format: path.extname(filepath).slice(1) as 'mdx' | 'md',\n remarkPlugins: [\n remarkGFM,\n remarkPluginToc,\n [\n remarkPluginNormalizeLink,\n {\n base: config?.base || '',\n cleanUrls,\n defaultLang,\n root: docDirectory,\n },\n ],\n checkDeadLinks && [\n remarkCheckDeadLinks,\n {\n root: docDirectory,\n base: config?.base || '',\n routeService,\n },\n ],\n globalComponents.length && [\n remarkBuiltin,\n {\n globalComponents,\n },\n ],\n ...remarkPluginsFromConfig,\n ...remarkPluginsFromPlugins,\n ].filter(Boolean) as PluggableList,\n rehypePlugins: [\n rehypeHeaderAnchor,\n rehypePluginCodeMeta,\n [\n rehypePluginExternalLinks,\n {\n target: '_blank',\n rel: 'noopener noreferrer',\n },\n ],\n ...rehypePluginsFromConfig,\n ...rehypePluginsFromPlugins,\n ],\n };\n}\n","import type { Plugin } from 'unified';\nimport { visitChildren } from 'unist-util-visit-children';\nimport Slugger from 'github-slugger';\nimport type { Root } from 'hast';\nimport { Processor } from '@mdx-js/mdx/lib/core';\nimport { PageMeta } from '../loader';\nimport { extractTextAndId } from '../../utils';\n\nexport interface TocItem {\n id: string;\n text: string;\n depth: number;\n}\n\ninterface ChildNode {\n type: 'link' | 'text' | 'inlineCode' | 'strong';\n value: string;\n children?: ChildNode[];\n}\n\ninterface Heading {\n type: string;\n depth?: number;\n children?: ChildNode[];\n}\n\nexport const parseToc = (tree: Root) => {\n let title = '';\n const toc: TocItem[] = [];\n const slugger = new Slugger();\n visitChildren((node: Heading) => {\n if (node.type !== 'heading' || !node.depth || !node.children) {\n return;\n }\n\n // Collect h1, use first h1 as title\n if (node.depth === 1 && title.length === 0) {\n title = node.children[0].value;\n }\n\n // Collect h2 ~ h4\n if (node.depth > 1 && node.depth < 5) {\n let customId = '';\n const text = node.children\n .map((child: ChildNode) => {\n if (child.type === 'link' || child.type === 'strong') {\n return child.children\n ?.map(item => (item.type === 'text' ? item.value : ''))\n .join('');\n }\n if (child.type === 'text') {\n const [textPart, idPart] = extractTextAndId(child.value);\n customId = idPart;\n return textPart;\n }\n if (child.type === 'inlineCode') {\n return child.value;\n }\n return '';\n })\n .join('');\n const id = customId ? customId : slugger.slug(text);\n const { depth } = node;\n toc.push({ id, text, depth });\n }\n })(tree);\n return {\n title,\n toc,\n };\n};\n\nexport const remarkPluginToc: Plugin<[], Root> = function (this: Processor) {\n const data = this.data() as {\n pageMeta: PageMeta;\n };\n return (tree: Root) => {\n const { toc, title } = parseToc(tree);\n data.pageMeta.toc = toc;\n if (title) {\n data.pageMeta.title = title;\n }\n };\n};\n","import type { Plugin } from 'unified';\nimport { visit } from 'unist-util-visit';\nimport type { Root } from 'hast';\n\nexport const rehypePluginCodeMeta: Plugin<[], Root> = () => {\n return tree => {\n visit(tree, 'element', node => {\n // <pre><code>...</code></pre>\n // 1. Find pre element\n if (\n node.tagName === 'pre' &&\n node.children[0]?.type === 'element' &&\n node.children[0].tagName === 'code'\n ) {\n const codeNode = node.children[0];\n // language-xxx\n const meta = (codeNode.data?.meta as string) || '';\n codeNode.properties.meta = meta;\n }\n });\n };\n};\n","import { headingRank } from 'hast-util-heading-rank';\nimport { visit } from 'unist-util-visit';\nimport GithubSlugger from 'github-slugger';\nimport type { Plugin } from 'unified';\nimport type { Root, Element } from 'hast';\nimport { extractTextAndId } from '../../utils';\n\n/**\n * Generate `id`s for headings and applies to headings with `id`s.\n * same as rehype-slug + rehype-autolink-headings, but support custom id.\n */\nexport const rehypeHeaderAnchor: Plugin<[], Root> = () => {\n const slugger = new GithubSlugger();\n return function (tree) {\n visit(tree, 'element', function (node) {\n if (headingRank(node as any)) {\n // generate id\n if (!node.properties.id) {\n const [text, customId] = collectHeaderText(node);\n node.properties.id = customId || slugger.slug(text);\n }\n // apply to headings\n node.children.unshift(create(node));\n }\n });\n };\n};\n\nexport const collectHeaderText = (node: Element) => {\n let text = '';\n let id = '';\n node.children.forEach(child => {\n if (child.type === 'text') {\n const [textPart, idPart] = extractTextAndId(child.value);\n child.value = textPart;\n text += textPart;\n id = idPart;\n }\n if (child.type === 'element') {\n child.children.forEach(c => {\n if (c.type === 'text') {\n text += c.value;\n }\n });\n }\n });\n return [text, id];\n};\n\n/**\n * Create an `a`.\n *\n * @param {Readonly<Element>} node\n * Related heading.\n * @returns {Element}\n * Link.\n */\nfunction create(node: Element): Element {\n return {\n type: 'element',\n tagName: 'a',\n properties: {\n class: 'header-anchor',\n ariaHidden: 'true',\n href: `#${node.properties.id}`,\n },\n children: [\n {\n type: 'text',\n value: '#',\n },\n ],\n };\n}\n","import path from 'path';\nimport type { Plugin } from 'unified';\nimport { visit } from 'unist-util-visit';\nimport type { Root } from 'mdast';\nimport type { MdxjsEsm } from 'mdast-util-mdxjs-esm';\nimport { normalizeHref, parseUrl, isExternalUrl, slash } from '@rspress/shared';\nimport { getASTNodeImport } from '@/node/utils/getASTNodeImport';\n\ninterface LinkNode {\n type: string;\n url?: string;\n}\n\n/**\n * Remark plugin to normalize a link href\n */\nexport const remarkPluginNormalizeLink: Plugin<\n [{ base: string; root: string; cleanUrls: boolean }],\n Root\n> =\n ({ base, root, cleanUrls }) =>\n (tree, file) => {\n const images: MdxjsEsm[] = [];\n visit(\n tree,\n (node: LinkNode) => node.type === 'link',\n (node: LinkNode) => {\n if (!node.url) {\n return;\n }\n if (node.url.startsWith('#')) {\n node.url = `#${node.url.slice(1)}`;\n return;\n }\n\n // eslint-disable-next-line prefer-const\n let { url, hash } = parseUrl(node.url);\n\n if (isExternalUrl(url)) {\n node.url = url + (hash ? `#${hash}` : '');\n return;\n }\n\n const extname = path.extname(url);\n\n if (extname === '.md' || extname === '.mdx') {\n url = url.replace(extname, '');\n }\n\n const relativePath = path.relative(root, file.path);\n if (url.startsWith('.')) {\n url = path.posix.join(slash(path.dirname(relativePath)), url);\n }\n\n url = normalizeHref(url, cleanUrls);\n\n if (hash) {\n url += `#${hash}`;\n }\n node.url = path.posix.join(base, url);\n },\n );\n\n const normalizeImageUrl = (imageUrl: string): string => {\n if (isExternalUrl(imageUrl) || imageUrl.startsWith('/')) {\n return '';\n }\n\n return imageUrl;\n };\n\n const getMdxSrcAttrbute = (tempVar: string) => {\n return {\n type: 'mdxJsxAttribute',\n name: 'src',\n value: {\n type: 'mdxJsxAttributeValueExpression',\n value: tempVar,\n data: {\n estree: {\n type: 'Program',\n sourceType: 'module',\n body: [\n {\n type: 'ExpressionStatement',\n expression: {\n type: 'Identifier',\n name: tempVar,\n },\n },\n ],\n },\n },\n },\n };\n };\n\n visit(tree, 'image', node => {\n const { url } = node;\n if (!url) {\n return;\n }\n\n const imagePath = normalizeImageUrl(url);\n if (!imagePath) {\n return;\n }\n // relative path\n const tempVariableName = `image${images.length}`;\n\n Object.assign(node, {\n type: 'mdxJsxFlowElement',\n name: 'img',\n children: [],\n attributes: [\n node.alt && {\n type: 'mdxJsxAttribute',\n name: 'alt',\n value: node.alt,\n },\n getMdxSrcAttrbute(tempVariableName),\n ].filter(Boolean),\n });\n\n images.push(getASTNodeImport(tempVariableName, imagePath));\n });\n\n visit(tree, ['mdxJsxFlowElement', 'mdxJsxTextElement'], (node: any) => {\n // get all img src\n if (node.name !== 'img') {\n return;\n }\n\n const src = node.attributes.find((attr: any) => attr.name === 'src');\n\n if (!src?.value || typeof src?.value !== 'string') {\n return;\n }\n\n const imagePath = normalizeImageUrl(src.value);\n\n if (!imagePath) {\n return;\n }\n\n const tempVariableName = `image${images.length}`;\n\n Object.assign(src, getMdxSrcAttrbute(tempVariableName));\n\n images.push(getASTNodeImport(tempVariableName, imagePath));\n });\n\n tree.children.unshift(...images);\n };\n","import path from 'path';\nimport { visit } from 'unist-util-visit';\nimport type { Plugin } from 'unified';\nimport { logger } from '@rspress/shared/logger';\nimport { cleanUrl, isProduction } from '@rspress/shared';\nimport { normalizeRoutePath } from '@/node/runtimeModule/routeData';\nimport type { RouteService } from '@/node/route/RouteService';\nimport { normalizePath } from '@/node/utils';\n\nexport interface DeadLinkCheckOptions {\n root: string;\n base: string;\n routeService: RouteService;\n}\n\nconst IGNORE_REGEXP = /^(https?|mailto|tel|#)/;\n\nexport function checkLinks(\n links: string[],\n filepath: string,\n root: string,\n routeService: RouteService,\n) {\n const errorInfos: string[] = [];\n links\n .filter(link => !IGNORE_REGEXP.test(link))\n .map(link => normalizePath(link))\n .forEach(link => {\n const relativePath = path.relative(root, filepath);\n\n if (!routeService.isExistRoute(cleanUrl(link))) {\n errorInfos.push(\n `Internal link to ${link} is dead, check it in ${relativePath}`,\n );\n }\n });\n // output error info\n if (errorInfos.length > 0) {\n errorInfos?.forEach(err => {\n logger.error(err);\n });\n if (isProduction()) {\n throw new Error('Dead link found');\n }\n }\n}\n\n/**\n * Remark plugin to check dead links\n */\nexport const remarkCheckDeadLinks: Plugin<\n DeadLinkCheckOptions[]\n> = checkLink => {\n const { root, routeService } = checkLink;\n\n return (tree, vfile) => {\n const internalLinks = new Set<string>();\n\n visit(tree, 'link', (node: { url: string }) => {\n const { url } = node;\n if (!url) {\n return;\n }\n if (internalLinks.has(url)) {\n return;\n }\n\n if (!url.startsWith('http') && !url.startsWith('https')) {\n const normalizeUrl = normalizeRoutePath(\n // fix: windows path\n url?.split(path.sep).join('/')?.split('#')[0],\n );\n internalLinks.add(normalizeUrl);\n }\n });\n\n checkLinks(Array.from(internalLinks), vfile.path, root, routeService);\n };\n};\n","import { addLeadingSlash } from '@rspress/shared';\nimport { FactoryContext, RuntimeModuleID } from '.';\n\nexport const normalizeRoutePath = (routePath: string) => {\n const result = routePath.replace(/\\.(.*)?$/, '').replace(/index$/, '');\n return addLeadingSlash(result);\n};\n\nexport async function routeVMPlugin(context: FactoryContext) {\n const { routeService } = context;\n // client: The components of route is lazy loaded\n return {\n [RuntimeModuleID.RouteForClient]: routeService.generateRoutesCode(false),\n [RuntimeModuleID.RouteForSSR]: routeService.generateRoutesCode(true),\n };\n}\n","import path from 'path';\nimport type { Plugin } from 'unified';\nimport type { Root } from 'mdast';\nimport type { MdxjsEsm } from 'mdast-util-mdxjs-esm';\nimport { getASTNodeImport } from '@/node/utils/getASTNodeImport';\n\n/**\n * A remark plugin to import all builtin components.\n * @param options configure the global components.\n * @returns A unified transformer.\n */\nexport const remarkBuiltin: Plugin<[{ globalComponents: string[] }], Root> = ({\n globalComponents,\n}) => {\n return tree => {\n const demos: MdxjsEsm[] = globalComponents.map(componentPath => {\n const filename = path.parse(componentPath).name;\n const componentName = filename[0].toUpperCase() + filename.slice(1);\n return getASTNodeImport(componentName, componentPath);\n });\n\n tree.children.unshift(...demos);\n };\n};\n"]}
1
+ {"version":3,"mappings":";;;;;;;;;;;;AAAA,OAAOA,WAAU;AACjB,SAAS,qBAAqB;AAE9B,SAAS,mBAAAC,wBAAuB;AAChC,SAAS,gBAAAC,qBAAkD;AAC3D,SAAS,UAAAC,eAAc;AACvB,SAAS,uBAAuB;AAChC,OAAOC,SAAQ;;;ACPf,OAAO,QAAQ;AACf,OAAO,UAAU;AAEV,IAAM,YAAY,GAAG,SAAS,MAAM;AAEpC,SAAS,MAAM,GAAmB;AACvC,SAAO,EAAE,QAAQ,OAAO,GAAG;AAC7B;AAEO,SAAS,cAAc,IAAoB;AAChD,SAAO,KAAK,MAAM,UAAU,YAAY,MAAM,EAAE,IAAI,EAAE;AACxD;;;ACXA,OAAOJ,WAAU;AACjB,SAAS,qBAAqB;AAC9B,SAAS,wBAAwB;AAI1B,IAAM,uBAAuB;AAGpC,IAAM,UAAUA,MAAK,QAAQ,cAAc,IAAI,IAAI,YAAY,GAAG,CAAC,CAAC;AAE7D,IAAM,eAAeA,MAAK,KAAK,SAAS,IAAI;AAE5C,IAAM,eAAeA,MAAK;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,YAAYA,MAAK;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAWO,IAAM,WAAWA,MAAK;AAAA,EAC3B,QAAQ,IAAI;AAAA,EACZ;AAAA,EACA;AACF;;;ACpCO,IAAM,mBAAmB,CAAC,MAAc,UAC5C;AAAA,EACC,MAAM;AAAA,EACN,OAAO,UAAU,IAAI,SAAS,KAAK,UAAU,IAAI,CAAC;AAAA,EAClD,MAAM;AAAA,IACJ,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,MAAM;AAAA,QACJ;AAAA,UACE,MAAM;AAAA,UACN,YAAY;AAAA,YACV;AAAA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A,IACxC;AAEA,UAAM,SAAS,uBAAuB,KAAK,UAAU,WAAW,CAAC;AAAA,EACnE,aAAa;AAAA;AAAA;AAAA,kCAGmB;AAAA,MAC5B,cAAcF,MAAK,SAAS,cAAc,QAAQ,CAAC;AAAA,IACrD,CAAC,QAAQ,KAAK,UAAU,QAAQ,CAAC;AAAA;AAEjC,aAAS,MAAM,MAAM;AAAA,EACvB,SAAS,GAAG;AACV,IAAAG,QAAO,MAAM,sBAAsB,EAAE,OAAO,OAAO,QAAQ,EAAE;AAC7D,aAAS,EAAE,SAAS,EAAE,SAAS,MAAM,GAAG,QAAQ,iBAAiB,CAAC;AAAA,EACpE;AACF","names":["path","createProcessor","isProduction","logger","fs","visit","slash"],"sources":["../src/node/mdx/loader.ts","../src/node/utils/normalizePath.ts","../src/node/constants.ts","../src/node/utils/getASTNodeImport.ts","../src/node/utils/flattenMdxContent.ts","../src/node/utils/extractTextAndId.ts","../src/node/utils/escapeHeadingIds.ts","../src/node/runtimeModule/routeData.ts","../src/node/mdx/options.ts","../src/node/mdx/remarkPlugins/toc.ts","../src/node/mdx/rehypePlugins/codeMeta.ts","../src/node/mdx/rehypePlugins/headerAnchor.ts","../src/node/mdx/remarkPlugins/normalizeLink.ts","../src/node/mdx/remarkPlugins/checkDeadLink.ts","../src/node/mdx/remarkPlugins/builtin.ts"],"sourcesContent":["import path from 'path';\nimport { pathToFileURL } from 'url';\nimport type { Rspack } from '@rsbuild/core';\nimport { createProcessor } from '@mdx-js/mdx';\nimport { isProduction, type Header, type UserConfig } from '@rspress/shared';\nimport { logger } from '@rspress/shared/logger';\nimport { loadFrontMatter } from '@rspress/shared/node-utils';\nimport fs from 'fs-extra';\nimport type { RouteService } from '../route/RouteService';\nimport {\n normalizePath,\n escapeMarkdownHeadingIds,\n flattenMdxContent,\n} from '../utils';\nimport { PluginDriver } from '../PluginDriver';\nimport { TEMP_DIR } from '../constants';\nimport { RuntimeModuleID } from '../runtimeModule';\nimport { createMDXOptions } from './options';\nimport { TocItem } from './remarkPlugins/toc';\nimport { checkLinks } from './remarkPlugins/checkDeadLink';\n\ninterface LoaderOptions {\n config: UserConfig;\n docDirectory: string;\n checkDeadLinks: boolean;\n routeService: RouteService;\n pluginDriver: PluginDriver;\n}\n\nexport interface PageMeta {\n toc: TocItem[];\n title: string;\n frontmatter?: Record<string, any>;\n}\n\nexport async function triggerReload() {\n const siteDataModulePath = path.join(\n TEMP_DIR,\n 'runtime',\n `${RuntimeModuleID.SiteData}.mjs`,\n );\n const { default: siteData } = await import(\n pathToFileURL(siteDataModulePath).href\n );\n await fs.writeFile(\n siteDataModulePath,\n `export default ${JSON.stringify({\n ...siteData,\n timestamp: Date.now().toString(),\n })}`,\n );\n}\n\nexport function createCheckPageMetaUpdateFn() {\n const pageMetaMap = new Map<string, string>();\n return (modulePath: string, pageMeta: PageMeta) => {\n const prevMeta = pageMetaMap.get(modulePath);\n const deserializedMeta = JSON.stringify(pageMeta);\n pageMetaMap.set(modulePath, deserializedMeta);\n\n if (!prevMeta) {\n return;\n }\n\n if (prevMeta !== deserializedMeta) {\n setTimeout(async () => {\n logger.info(\n `⭐️ Page metadata changed, rspress will trigger page reload...`,\n );\n await triggerReload();\n });\n }\n };\n}\n\nconst checkPageMetaUpdate = createCheckPageMetaUpdateFn();\n\nexport default async function mdxLoader(\n context: Rspack.LoaderContext<LoaderOptions>,\n source: string,\n callback: Rspack.LoaderContext['callback'],\n) {\n const options = context.getOptions();\n const filepath = context.resourcePath;\n const { alias } = context._compiler.options.resolve;\n context.cacheable(true);\n let pageMeta = {\n title: '',\n toc: [],\n } as PageMeta;\n\n const { config, docDirectory, checkDeadLinks, routeService, pluginDriver } =\n options;\n\n const { frontmatter, content } = loadFrontMatter(\n source,\n filepath,\n docDirectory,\n true,\n );\n\n // preprocessor\n const preprocessedContent = escapeMarkdownHeadingIds(\n await flattenMdxContent(content, filepath, alias as Record<string, string>),\n );\n\n let enableMdxRs;\n const mdxRs = config?.markdown?.mdxRs ?? true;\n if (typeof mdxRs === 'object') {\n enableMdxRs =\n typeof mdxRs?.include === 'function' ? mdxRs.include(filepath) : true;\n } else {\n enableMdxRs = mdxRs;\n }\n\n try {\n let compileResult: string;\n if (!enableMdxRs) {\n const mdxOptions = await createMDXOptions(\n docDirectory,\n config,\n checkDeadLinks,\n routeService,\n filepath,\n pluginDriver,\n );\n const compiler = createProcessor(mdxOptions);\n\n compiler.data('pageMeta', {\n toc: [],\n title: '',\n });\n const vFile = await compiler.process({\n value: preprocessedContent,\n path: filepath,\n });\n\n compileResult = String(vFile);\n pageMeta = {\n ...(compiler.data('pageMeta') as {\n toc: Header[];\n title: string;\n }),\n frontmatter,\n } as PageMeta;\n } else {\n const { compile } = require('@rspress/mdx-rs');\n\n // TODO: Cannot get correct toc from mdx which has internal components\n const { toc, links, title, code } = await compile({\n value: preprocessedContent,\n filepath,\n root: docDirectory,\n development: process.env.NODE_ENV !== 'production',\n });\n\n compileResult = code;\n pageMeta = {\n toc,\n title,\n frontmatter,\n };\n // We should check dead links in mdx-rs mode\n if (checkDeadLinks) {\n checkLinks(links, filepath, docDirectory, routeService);\n }\n }\n\n // If page meta changed, we trigger page reload to ensure the page is up to date.\n if (!isProduction()) {\n checkPageMetaUpdate(filepath, pageMeta);\n }\n\n const result = `const frontmatter = ${JSON.stringify(frontmatter)};\n${compileResult}\nMDXContent.__RSPRESS_PAGE_META = {};\n\nMDXContent.__RSPRESS_PAGE_META[\"${encodeURIComponent(\n normalizePath(path.relative(docDirectory, filepath)),\n )}\"] = ${JSON.stringify(pageMeta)};\n`;\n callback(null, result);\n } catch (e) {\n logger.error(`MDX compile error: ${e.message} in ${filepath}`);\n callback({ message: e.message, name: `${filepath} compile error` });\n }\n}\n","import os from 'os';\nimport path from 'path';\n\nexport const isWindows = os.platform() === 'win32';\n\nexport function slash(p: string): string {\n return p.replace(/\\\\/g, '/');\n}\n\nexport function normalizePath(id: string): string {\n return path.posix.normalize(isWindows ? slash(id) : id);\n}\n","import path from 'path';\nimport { fileURLToPath } from 'url';\nimport { RSPRESS_TEMP_DIR } from '@rspress/shared';\n\nexport const isProduction = () => process.env.NODE_ENV === 'production';\n\nexport const importStatementRegex = /import\\s+(.*?)\\s+from\\s+['\"](.*?)['\"];?/gm;\n\n// @ts-expect-error\nconst dirname = path.dirname(fileURLToPath(new URL(import.meta.url)));\n\nexport const PACKAGE_ROOT = path.join(dirname, '..');\n\nexport const CLIENT_ENTRY = path.join(\n PACKAGE_ROOT,\n 'dist',\n 'runtime',\n 'clientEntry.js',\n);\n\nexport const SSR_ENTRY = path.join(\n PACKAGE_ROOT,\n 'dist',\n 'runtime',\n 'ssrEntry.js',\n);\n\nexport const OUTPUT_DIR = 'doc_build';\n\nexport const APP_HTML_MARKER = '<!--<?- DOC_CONTENT ?>-->';\nexport const HEAD_MARKER = '<!--<?- HEAD ?>-->';\nexport const META_GENERATOR = '<!--<?- GENERATOR ?>-->';\nexport const HTML_START_TAG = '<html';\nexport const BODY_START_TAG = '<body';\n\nexport const PUBLIC_DIR = 'public';\nexport const TEMP_DIR = path.join(\n process.cwd(),\n 'node_modules',\n RSPRESS_TEMP_DIR,\n);\n","import type { MdxjsEsm } from 'mdast-util-mdxjs-esm';\n\n// Construct import statement for AST\n// Such as: import image1 from './test.png'\nexport const getASTNodeImport = (name: string, from: string) =>\n ({\n type: 'mdxjsEsm',\n value: `import ${name} from ${JSON.stringify(from)}`,\n data: {\n estree: {\n type: 'Program',\n sourceType: 'module',\n body: [\n {\n type: 'ImportDeclaration',\n specifiers: [\n {\n type: 'ImportDefaultSpecifier',\n local: { type: 'Identifier', name },\n },\n ],\n source: {\n type: 'Literal',\n value: from,\n raw: `${JSON.stringify(from)}`,\n },\n },\n ],\n },\n },\n } as MdxjsEsm);\n","import path from 'path';\nimport enhancedResolve from 'enhanced-resolve';\nimport type { Resolver } from 'enhanced-resolve';\nimport fs from '@rspress/shared/fs-extra';\nimport { createProcessor } from '@mdx-js/mdx';\nimport type { Root } from 'hast';\nimport { MDX_REGEXP } from '@rspress/shared';\nimport { importStatementRegex } from '../constants';\n\nconst { CachedInputFileSystem, ResolverFactory } = enhancedResolve;\nconst processor = createProcessor();\nlet resolver: Resolver;\nlet startFlatten = false;\n\nexport async function resolveDepPath(\n importPath: string,\n importer: string,\n alias: Record<string, string | string[]>,\n) {\n if (!resolver) {\n resolver = ResolverFactory.createResolver({\n fileSystem: new CachedInputFileSystem(fs),\n extensions: ['.mdx', '.md'],\n alias,\n });\n }\n const resolveResult = await new Promise<string>((resolve, reject) => {\n resolver.resolve(\n {\n importer,\n },\n importer,\n importPath,\n {},\n (err, filePath) => {\n if (err) {\n return reject(err);\n }\n if (!filePath) {\n return reject(\n new Error(\n `Empty result when resolving ${importPath} from ${importer}`,\n ),\n );\n }\n return resolve(filePath);\n },\n );\n });\n return resolveResult;\n}\n\ninterface ImportNode {\n type: 'ImportDeclaration';\n specifiers: { local: { name: string } }[];\n source: { value: string };\n}\n\nexport async function flattenMdxContent(\n content: string,\n basePath: string,\n alias: Record<string, string | string[]>,\n): Promise<string> {\n // Performance optimization: if the content does not contain any import statement, we can skip the parsing process\n\n if (!importStatementRegex.test(content)) {\n return content;\n }\n let result = content;\n // We should update the resolver instanceof because the alias should be passed to it\n // If we reuse the resolver instance in `detectReactVersion` method, the resolver will lose the alias info and cannot resolve path correctly in mdx files.\n if (!startFlatten) {\n resolver = ResolverFactory.createResolver({\n fileSystem: new CachedInputFileSystem(fs),\n extensions: ['.mdx', '.md', '.js'],\n alias,\n });\n startFlatten = true;\n }\n let ast: Root;\n try {\n ast = processor.parse(content) as Root;\n } catch (e) {\n // Fallback: if mdx parse failed, just return the content\n return content;\n }\n const importNodes = ast.children\n .filter(node => node.type === 'mdxjsEsm')\n .map(node => {\n return (node.data?.estree as { body: ImportNode[] })?.body || [];\n })\n .flat()\n .filter(node => node.type === 'ImportDeclaration');\n for (const importNode of importNodes) {\n // import Comp from './a';\n // id: Comp\n // importPath: './a'\n const id = importNode.specifiers[0].local.name;\n const importPath = importNode.source.value;\n\n let absoluteImportPath: string;\n try {\n absoluteImportPath = await resolveDepPath(\n importPath,\n path.dirname(basePath),\n alias,\n );\n } catch (e) {\n continue;\n }\n\n if (MDX_REGEXP.test(absoluteImportPath)) {\n // replace import statement with the content of the imported file\n const importedContent = fs.readFileSync(absoluteImportPath, 'utf-8');\n const replacedValue = await flattenMdxContent(\n importedContent,\n absoluteImportPath,\n alias,\n );\n result = result.replace(new RegExp(`<${id}\\\\s*/>`), () => replacedValue);\n }\n }\n\n return result;\n}\n","/**\n * hello world {#custom-id} -> { text: 'hello world', id: 'custom-id' }\n */\nexport const extractTextAndId = (title: string) => {\n const customIdReg = /{#.*}/;\n const text = title.replace(customIdReg, '').trimEnd();\n const customId = title.match(customIdReg)?.[0]?.slice(2, -1) || '';\n return [text, customId];\n};\n","/**\n * Support custom id like `#hello world {#custom-id}`\n * Avoid https://mdxjs.com/docs/troubleshooting-mdx/#could-not-parse-expression-with-acorn-error\n */\nexport function escapeMarkdownHeadingIds(content: string): string {\n const markdownHeadingRegexp = /(?:^|\\n)#{1,6}(?!#).*/g;\n return content.replace(markdownHeadingRegexp, substring =>\n substring\n .replace('{#', '\\\\{#')\n // prevent duplicate escaping\n .replace('\\\\\\\\{#', '\\\\{#'),\n );\n}\n","import { addLeadingSlash } from '@rspress/shared';\nimport { FactoryContext, RuntimeModuleID } from '.';\n\nexport const normalizeRoutePath = (routePath: string) => {\n const result = routePath.replace(/\\.(.*)?$/, '').replace(/index$/, '');\n return addLeadingSlash(result);\n};\n\nexport async function routeVMPlugin(context: FactoryContext) {\n const { routeService } = context;\n // client: The components of route is lazy loaded\n return {\n [RuntimeModuleID.RouteForClient]: routeService.generateRoutesCode(false),\n [RuntimeModuleID.RouteForSSR]: routeService.generateRoutesCode(true),\n };\n}\n","import path from 'path';\nimport remarkGFM from 'remark-gfm';\nimport { Options } from '@mdx-js/loader';\nimport { UserConfig } from '@rspress/shared';\nimport { PluggableList } from 'unified';\nimport rehypePluginExternalLinks from 'rehype-external-links';\nimport type { RouteService } from '../route/RouteService';\nimport type { PluginDriver } from '../PluginDriver';\nimport { remarkPluginToc } from './remarkPlugins/toc';\nimport { rehypePluginCodeMeta } from './rehypePlugins/codeMeta';\nimport { rehypeHeaderAnchor } from './rehypePlugins/headerAnchor';\nimport { remarkPluginNormalizeLink } from './remarkPlugins/normalizeLink';\nimport { remarkCheckDeadLinks } from './remarkPlugins/checkDeadLink';\nimport { remarkBuiltin } from './remarkPlugins/builtin';\n\nexport async function createMDXOptions(\n docDirectory: string,\n config: UserConfig,\n checkDeadLinks: boolean,\n routeService: RouteService,\n filepath: string,\n pluginDriver: PluginDriver,\n): Promise<Options> {\n const cleanUrls = Boolean(config?.route?.cleanUrls);\n const {\n remarkPlugins: remarkPluginsFromConfig = [],\n rehypePlugins: rehypePluginsFromConfig = [],\n globalComponents: globalComponentsFromConfig = [],\n } = config?.markdown || {};\n const rspressPlugins = pluginDriver.getPlugins();\n const remarkPluginsFromPlugins = rspressPlugins.flatMap(\n plugin => plugin.markdown?.remarkPlugins || [],\n ) as PluggableList;\n const rehypePluginsFromPlugins = rspressPlugins.flatMap(\n plugin => plugin.markdown?.rehypePlugins || [],\n ) as PluggableList;\n const globalComponents = [\n ...rspressPlugins.flatMap(\n plugin => plugin.markdown?.globalComponents || [],\n ),\n ...globalComponentsFromConfig,\n ];\n const defaultLang = config?.lang || '';\n return {\n providerImportSource: '@mdx-js/react',\n format: path.extname(filepath).slice(1) as 'mdx' | 'md',\n remarkPlugins: [\n remarkGFM,\n remarkPluginToc,\n [\n remarkPluginNormalizeLink,\n {\n base: config?.base || '',\n cleanUrls,\n defaultLang,\n root: docDirectory,\n },\n ],\n checkDeadLinks && [\n remarkCheckDeadLinks,\n {\n root: docDirectory,\n base: config?.base || '',\n routeService,\n },\n ],\n globalComponents.length && [\n remarkBuiltin,\n {\n globalComponents,\n },\n ],\n ...remarkPluginsFromConfig,\n ...remarkPluginsFromPlugins,\n ].filter(Boolean) as PluggableList,\n rehypePlugins: [\n rehypeHeaderAnchor,\n rehypePluginCodeMeta,\n [\n rehypePluginExternalLinks,\n {\n target: '_blank',\n rel: 'noopener noreferrer',\n },\n ],\n ...rehypePluginsFromConfig,\n ...rehypePluginsFromPlugins,\n ],\n };\n}\n","import type { Plugin } from 'unified';\nimport { visitChildren } from 'unist-util-visit-children';\nimport Slugger from 'github-slugger';\nimport type { Root } from 'hast';\nimport { Processor } from '@mdx-js/mdx/lib/core';\nimport { PageMeta } from '../loader';\nimport { extractTextAndId } from '../../utils';\n\nexport interface TocItem {\n id: string;\n text: string;\n depth: number;\n}\n\ninterface ChildNode {\n type: 'link' | 'text' | 'inlineCode' | 'strong';\n value: string;\n children?: ChildNode[];\n}\n\ninterface Heading {\n type: string;\n depth?: number;\n children?: ChildNode[];\n}\n\nexport const parseToc = (tree: Root) => {\n let title = '';\n const toc: TocItem[] = [];\n const slugger = new Slugger();\n visitChildren((node: Heading) => {\n if (node.type !== 'heading' || !node.depth || !node.children) {\n return;\n }\n\n // Collect h1, use first h1 as title\n if (node.depth === 1 && title.length === 0) {\n title = node.children[0].value;\n }\n\n // Collect h2 ~ h4\n if (node.depth > 1 && node.depth < 5) {\n let customId = '';\n const text = node.children\n .map((child: ChildNode) => {\n if (child.type === 'link' || child.type === 'strong') {\n return child.children\n ?.map(item => (item.type === 'text' ? item.value : ''))\n .join('');\n }\n if (child.type === 'text') {\n const [textPart, idPart] = extractTextAndId(child.value);\n customId = idPart;\n return textPart;\n }\n if (child.type === 'inlineCode') {\n return child.value;\n }\n return '';\n })\n .join('');\n const id = customId ? customId : slugger.slug(text);\n const { depth } = node;\n toc.push({ id, text, depth });\n }\n })(tree);\n return {\n title,\n toc,\n };\n};\n\nexport const remarkPluginToc: Plugin<[], Root> = function (this: Processor) {\n const data = this.data() as {\n pageMeta: PageMeta;\n };\n return (tree: Root) => {\n const { toc, title } = parseToc(tree);\n data.pageMeta.toc = toc;\n if (title) {\n data.pageMeta.title = title;\n }\n };\n};\n","import type { Plugin } from 'unified';\nimport { visit } from 'unist-util-visit';\nimport type { Root } from 'hast';\n\nexport const rehypePluginCodeMeta: Plugin<[], Root> = () => {\n return tree => {\n visit(tree, 'element', node => {\n // <pre><code>...</code></pre>\n // 1. Find pre element\n if (\n node.tagName === 'pre' &&\n node.children[0]?.type === 'element' &&\n node.children[0].tagName === 'code'\n ) {\n const codeNode = node.children[0];\n // language-xxx\n const meta = (codeNode.data?.meta as string) || '';\n codeNode.properties.meta = meta;\n }\n });\n };\n};\n","import { headingRank } from 'hast-util-heading-rank';\nimport { visit } from 'unist-util-visit';\nimport GithubSlugger from 'github-slugger';\nimport type { Plugin } from 'unified';\nimport type { Root, Element } from 'hast';\nimport { extractTextAndId } from '../../utils';\n\n/**\n * Generate `id`s for headings and applies to headings with `id`s.\n * same as rehype-slug + rehype-autolink-headings, but support custom id.\n */\nexport const rehypeHeaderAnchor: Plugin<[], Root> = () => {\n const slugger = new GithubSlugger();\n return function (tree) {\n visit(tree, 'element', function (node) {\n if (headingRank(node as any)) {\n // generate id\n if (!node.properties.id) {\n const [text, customId] = collectHeaderText(node);\n node.properties.id = customId || slugger.slug(text);\n }\n // apply to headings\n node.children.unshift(create(node));\n }\n });\n };\n};\n\nexport const collectHeaderText = (node: Element) => {\n let text = '';\n let id = '';\n node.children.forEach(child => {\n if (child.type === 'text') {\n const [textPart, idPart] = extractTextAndId(child.value);\n child.value = textPart;\n text += textPart;\n id = idPart;\n }\n if (child.type === 'element') {\n child.children.forEach(c => {\n if (c.type === 'text') {\n text += c.value;\n }\n });\n }\n });\n return [text, id];\n};\n\n/**\n * Create an `a`.\n *\n * @param {Readonly<Element>} node\n * Related heading.\n * @returns {Element}\n * Link.\n */\nfunction create(node: Element): Element {\n return {\n type: 'element',\n tagName: 'a',\n properties: {\n class: 'header-anchor',\n ariaHidden: 'true',\n href: `#${node.properties.id}`,\n },\n children: [\n {\n type: 'text',\n value: '#',\n },\n ],\n };\n}\n","import path from 'path';\nimport type { Plugin } from 'unified';\nimport { visit } from 'unist-util-visit';\nimport type { Root } from 'mdast';\nimport type { MdxjsEsm } from 'mdast-util-mdxjs-esm';\nimport { normalizeHref, parseUrl, isExternalUrl, slash } from '@rspress/shared';\nimport { getASTNodeImport } from '@/node/utils/getASTNodeImport';\n\ninterface LinkNode {\n type: string;\n url?: string;\n}\n\n/**\n * Remark plugin to normalize a link href\n */\nexport const remarkPluginNormalizeLink: Plugin<\n [{ base: string; root: string; cleanUrls: boolean }],\n Root\n> =\n ({ base, root, cleanUrls }) =>\n (tree, file) => {\n const images: MdxjsEsm[] = [];\n visit(\n tree,\n (node: LinkNode) => node.type === 'link',\n (node: LinkNode) => {\n if (!node.url) {\n return;\n }\n if (node.url.startsWith('#')) {\n node.url = `#${node.url.slice(1)}`;\n return;\n }\n\n // eslint-disable-next-line prefer-const\n let { url, hash } = parseUrl(node.url);\n\n if (isExternalUrl(url)) {\n node.url = url + (hash ? `#${hash}` : '');\n return;\n }\n\n const extname = path.extname(url);\n\n if (extname === '.md' || extname === '.mdx') {\n url = url.replace(extname, '');\n }\n\n const relativePath = path.relative(root, file.path);\n if (url.startsWith('.')) {\n url = path.posix.join(slash(path.dirname(relativePath)), url);\n }\n\n url = normalizeHref(url, cleanUrls);\n\n if (hash) {\n url += `#${hash}`;\n }\n node.url = path.posix.join(base, url);\n },\n );\n\n const normalizeImageUrl = (imageUrl: string): string => {\n if (isExternalUrl(imageUrl) || imageUrl.startsWith('/')) {\n return '';\n }\n\n return imageUrl;\n };\n\n const getMdxSrcAttrbute = (tempVar: string) => {\n return {\n type: 'mdxJsxAttribute',\n name: 'src',\n value: {\n type: 'mdxJsxAttributeValueExpression',\n value: tempVar,\n data: {\n estree: {\n type: 'Program',\n sourceType: 'module',\n body: [\n {\n type: 'ExpressionStatement',\n expression: {\n type: 'Identifier',\n name: tempVar,\n },\n },\n ],\n },\n },\n },\n };\n };\n\n visit(tree, 'image', node => {\n const { url } = node;\n if (!url) {\n return;\n }\n\n const imagePath = normalizeImageUrl(url);\n if (!imagePath) {\n return;\n }\n // relative path\n const tempVariableName = `image${images.length}`;\n\n Object.assign(node, {\n type: 'mdxJsxFlowElement',\n name: 'img',\n children: [],\n attributes: [\n node.alt && {\n type: 'mdxJsxAttribute',\n name: 'alt',\n value: node.alt,\n },\n getMdxSrcAttrbute(tempVariableName),\n ].filter(Boolean),\n });\n\n images.push(getASTNodeImport(tempVariableName, imagePath));\n });\n\n visit(tree, ['mdxJsxFlowElement', 'mdxJsxTextElement'], (node: any) => {\n // get all img src\n if (node.name !== 'img') {\n return;\n }\n\n const src = node.attributes.find((attr: any) => attr.name === 'src');\n\n if (!src?.value || typeof src?.value !== 'string') {\n return;\n }\n\n const imagePath = normalizeImageUrl(src.value);\n\n if (!imagePath) {\n return;\n }\n\n const tempVariableName = `image${images.length}`;\n\n Object.assign(src, getMdxSrcAttrbute(tempVariableName));\n\n images.push(getASTNodeImport(tempVariableName, imagePath));\n });\n\n tree.children.unshift(...images);\n };\n","import path from 'path';\nimport { visit } from 'unist-util-visit';\nimport type { Plugin } from 'unified';\nimport { logger } from '@rspress/shared/logger';\nimport { cleanUrl, isProduction } from '@rspress/shared';\nimport { normalizeRoutePath } from '@/node/runtimeModule/routeData';\nimport type { RouteService } from '@/node/route/RouteService';\nimport { normalizePath } from '@/node/utils';\n\nexport interface DeadLinkCheckOptions {\n root: string;\n base: string;\n routeService: RouteService;\n}\n\nconst IGNORE_REGEXP = /^(https?|mailto|tel|#)/;\n\nexport function checkLinks(\n links: string[],\n filepath: string,\n root: string,\n routeService: RouteService,\n) {\n const errorInfos: string[] = [];\n links\n .filter(link => !IGNORE_REGEXP.test(link))\n .map(link => normalizePath(link))\n .forEach(link => {\n const relativePath = path.relative(root, filepath);\n\n if (!routeService.isExistRoute(cleanUrl(link))) {\n errorInfos.push(\n `Internal link to ${link} is dead, check it in ${relativePath}`,\n );\n }\n });\n // output error info\n if (errorInfos.length > 0) {\n errorInfos?.forEach(err => {\n logger.error(err);\n });\n if (isProduction()) {\n throw new Error('Dead link found');\n }\n }\n}\n\n/**\n * Remark plugin to check dead links\n */\nexport const remarkCheckDeadLinks: Plugin<\n DeadLinkCheckOptions[]\n> = checkLink => {\n const { root, routeService } = checkLink;\n\n return (tree, vfile) => {\n const internalLinks = new Set<string>();\n\n visit(tree, 'link', (node: { url: string }) => {\n const { url } = node;\n if (!url) {\n return;\n }\n if (internalLinks.has(url)) {\n return;\n }\n\n if (!url.startsWith('http') && !url.startsWith('https')) {\n const normalizeUrl = normalizeRoutePath(\n // fix: windows path\n url?.split(path.sep).join('/')?.split('#')[0],\n );\n internalLinks.add(normalizeUrl);\n }\n });\n\n checkLinks(Array.from(internalLinks), vfile.path, root, routeService);\n };\n};\n","import path from 'path';\nimport type { Plugin } from 'unified';\nimport type { Root } from 'mdast';\nimport type { MdxjsEsm } from 'mdast-util-mdxjs-esm';\nimport { getASTNodeImport } from '@/node/utils/getASTNodeImport';\n\n/**\n * A remark plugin to import all builtin components.\n * @param options configure the global components.\n * @returns A unified transformer.\n */\nexport const remarkBuiltin: Plugin<[{ globalComponents: string[] }], Root> = ({\n globalComponents,\n}) => {\n return tree => {\n const demos: MdxjsEsm[] = globalComponents.map(componentPath => {\n const filename = path.parse(componentPath).name;\n const componentName = filename[0].toUpperCase() + filename.slice(1);\n return getASTNodeImport(componentName, componentPath);\n });\n\n tree.children.unshift(...demos);\n };\n};\n"]}
@@ -9,11 +9,7 @@ import {
9
9
  } from "@rspress/runtime";
10
10
  import { HelmetProvider } from "react-helmet-async";
11
11
  import React, { useContext, useLayoutEffect } from "react";
12
- import {
13
- cleanUrl,
14
- isProduction,
15
- MDX_REGEXP
16
- } from "@rspress/shared";
12
+ import { cleanUrl, MDX_REGEXP } from "@rspress/shared";
17
13
  import globalComponents from "virtual-global-components";
18
14
  import "virtual-global-styles";
19
15
  const { default: Theme } = require("@theme");
@@ -51,13 +47,7 @@ async function initPageData(routePath) {
51
47
  pageType: frontmatter?.pageType || "doc",
52
48
  title,
53
49
  frontmatter,
54
- // Trade off:
55
- // 1. the `extractPageInfo` includes complete toc even if import doc fragments, because we use `flattenMdxContent` function to make all doc fragments' toc included.However, it is only computed once when build
56
- // 2. the mod.toc is not complete toc, but it is computed every time through loader when doc changed
57
- // We choose the better solutions for different environments:
58
- // In production, we use the extractPageInfo.toc to ensure the toc is complete and accurate.
59
- // In development, we use the mod.toc to ensure the toc is up to date to ensure DX.However, we cannot ensure the complete toc info when including doc fragments.
60
- toc: isProduction() ? extractPageInfo?.toc : toc
50
+ toc
61
51
  }
62
52
  };
63
53
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "1.11.1",
3
+ "version": "1.12.0",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -24,6 +24,7 @@
24
24
  "./theme": {
25
25
  "default": "./theme.ts"
26
26
  },
27
+ "./theme.css": "./theme.css",
27
28
  "./runtime": {
28
29
  "default": "./runtime.ts"
29
30
  }
@@ -40,10 +41,10 @@
40
41
  "@mdx-js/loader": "2.2.1",
41
42
  "@mdx-js/mdx": "2.2.1",
42
43
  "@mdx-js/react": "2.2.1",
43
- "@modern-js/utils": "2.46.1",
44
- "@rsbuild/core": "0.3.1",
45
- "@rsbuild/plugin-react": "0.3.1",
46
- "@rsbuild/plugin-svgr": "0.3.1",
44
+ "@modern-js/utils": "2.47.0",
45
+ "@rsbuild/core": "0.4.0",
46
+ "@rsbuild/plugin-react": "0.4.0",
47
+ "@rsbuild/plugin-svgr": "0.4.0",
47
48
  "@rspress/mdx-rs": "0.4.3",
48
49
  "body-scroll-lock": "4.0.0-beta.0",
49
50
  "copy-to-clipboard": "^3.3.3",
@@ -80,19 +81,19 @@
80
81
  "unist-util-visit": "^4.1.1",
81
82
  "unist-util-visit-children": "^2.0.1",
82
83
  "yaml-front-matter": "^4.1.1",
83
- "@rspress/theme-default": "1.11.1",
84
- "@rspress/runtime": "1.11.1",
85
- "@rspress/plugin-last-updated": "1.11.1",
86
- "@rspress/plugin-auto-nav-sidebar": "1.11.1",
87
- "@rspress/plugin-medium-zoom": "1.11.1",
88
- "@rspress/shared": "1.11.1",
89
- "@rspress/plugin-container-syntax": "1.11.1"
84
+ "@rspress/theme-default": "1.12.0",
85
+ "@rspress/runtime": "1.12.0",
86
+ "@rspress/plugin-medium-zoom": "1.12.0",
87
+ "@rspress/plugin-last-updated": "1.12.0",
88
+ "@rspress/plugin-auto-nav-sidebar": "1.12.0",
89
+ "@rspress/plugin-container-syntax": "1.12.0",
90
+ "@rspress/shared": "1.12.0"
90
91
  },
91
92
  "devDependencies": {
92
93
  "tailwindcss": "^3.2.7",
93
- "@modern-js/plugin-tailwindcss": "2.46.1",
94
- "@modern-js/tsconfig": "2.46.1",
95
- "@modern-js/types": "2.46.1",
94
+ "@modern-js/plugin-tailwindcss": "2.47.0",
95
+ "@modern-js/tsconfig": "2.47.0",
96
+ "@modern-js/types": "2.47.0",
96
97
  "@types/body-scroll-lock": "^3.1.0",
97
98
  "@types/fs-extra": "^9.0.13",
98
99
  "@types/hast": "^2.3.4",