@rspress/core 1.9.3 → 1.10.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/index.js CHANGED
@@ -1,7 +1,12 @@
1
1
  import { createRequire } from "module";
2
2
  const { url } = import.meta;
3
3
  const require = createRequire(url);
4
+ var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
10
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
11
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
7
12
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -10,6 +15,25 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
10
15
  return require.apply(this, arguments);
11
16
  throw Error('Dynamic require of "' + x + '" is not supported');
12
17
  });
18
+ var __commonJS = (cb, mod) => function __require2() {
19
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") {
23
+ for (let key of __getOwnPropNames(from))
24
+ if (!__hasOwnProp.call(to, key) && key !== except)
25
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
+ }
27
+ return to;
28
+ };
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
+ // If the importer is in node compatibility mode or this is not an ESM
31
+ // file that has been converted to a CommonJS file using a Babel-
32
+ // compatible transform (i.e. "__esModule" has not been set), then set
33
+ // "default" to the CommonJS "module.exports" for node compatibility.
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
13
37
  var __publicField = (obj, key, value) => {
14
38
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
15
39
  return value;
@@ -37,20 +61,180 @@ var __privateMethod = (obj, member, method) => {
37
61
  return method;
38
62
  };
39
63
 
40
- // src/node/dev.ts
41
- import { removeLeadingSlash as removeLeadingSlash2 } from "@rspress/shared";
42
- import { logger as logger3 } from "@rspress/shared/logger";
64
+ // package.json
65
+ var require_package = __commonJS({
66
+ "package.json"(exports, module) {
67
+ module.exports = {
68
+ name: "@rspress/core",
69
+ version: "1.10.0",
70
+ description: "The Rspress Documentation Framework",
71
+ bugs: "https://github.com/web-infra-dev/rspress/issues",
72
+ repository: {
73
+ type: "git",
74
+ url: "https://github.com/web-infra-dev/rspress",
75
+ directory: "packages/cli/core"
76
+ },
77
+ license: "MIT",
78
+ type: "module",
79
+ "jsnext:source": "./src/index.ts",
80
+ types: "./dist/index.d.ts",
81
+ main: "./dist/index.js",
82
+ module: "./dist/node/index.js",
83
+ exports: {
84
+ ".": {
85
+ types: "./dist/index.d.ts",
86
+ import: "./dist/index.js"
87
+ },
88
+ "./dist/*": "./dist/*",
89
+ "./package.json": "./package.json",
90
+ "./theme": {
91
+ default: "./theme.ts"
92
+ },
93
+ "./runtime": {
94
+ default: "./runtime.ts"
95
+ }
96
+ },
97
+ scripts: {
98
+ dev: "modern build -w",
99
+ build: "modern build",
100
+ reset: "rimraf ./**/node_modules",
101
+ lint: "modern lint",
102
+ change: "modern change",
103
+ bump: "modern bump",
104
+ pre: "modern pre",
105
+ "change-status": "modern change-status",
106
+ "gen-release-note": "modern gen-release-note",
107
+ release: "modern release",
108
+ new: "modern new",
109
+ test: "vitest run --passWithNoTests",
110
+ upgrade: "modern upgrade"
111
+ },
112
+ engines: {
113
+ node: ">=14.17.6"
114
+ },
115
+ eslintIgnore: [
116
+ "node_modules/",
117
+ "dist/"
118
+ ],
119
+ dependencies: {
120
+ "@loadable/component": "5.15.2",
121
+ "@mdx-js/loader": "2.2.1",
122
+ "@mdx-js/mdx": "2.2.1",
123
+ "@mdx-js/react": "2.2.1",
124
+ "@modern-js/utils": "2.46.0",
125
+ "@rsbuild/core": "0.3.1",
126
+ "@rsbuild/plugin-react": "0.3.1",
127
+ "@rsbuild/plugin-svgr": "0.3.1",
128
+ "@rspress/theme-default": "workspace:*",
129
+ "@rspress/runtime": "workspace:*",
130
+ "@rspress/plugin-medium-zoom": "workspace:*",
131
+ "@rspress/plugin-last-updated": "workspace:*",
132
+ "@rspress/plugin-auto-nav-sidebar": "workspace:*",
133
+ "@rspress/mdx-rs": "0.4.3",
134
+ "@rspress/plugin-container-syntax": "workspace:*",
135
+ "@rspress/shared": "workspace:*",
136
+ "body-scroll-lock": "4.0.0-beta.0",
137
+ "copy-to-clipboard": "^3.3.3",
138
+ "enhanced-resolve": "5.12.0",
139
+ flexsearch: "0.6.32",
140
+ "fs-extra": "10.1.0",
141
+ "github-slugger": "^2.0.0",
142
+ "hast-util-from-html": "^1.0.0",
143
+ "hast-util-heading-rank": "^3.0.0",
144
+ "html-to-text": "^9.0.3",
145
+ htmr: "^1.0.2",
146
+ "is-html": "^3.0.0",
147
+ "lodash-es": "^4.17.21",
148
+ "mdast-util-mdxjs-esm": "^1.3.0",
149
+ "node-fetch": "3.3.0",
150
+ nprogress: "^0.2.0",
151
+ postcss: "8.4.21",
152
+ react: "^18.2.0",
153
+ "react-dom": "^18.2.0",
154
+ "react-helmet-async": "^1.3.0",
155
+ "react-lazy-with-preload": "^2.2.1",
156
+ "react-syntax-highlighter": "^15.5.0",
157
+ "rehype-external-links": "^2.0.1",
158
+ "rehype-stringify": "^9.0.3",
159
+ remark: "^14.0.2",
160
+ "remark-gfm": "3.0.1",
161
+ "remark-html": "^15.0.1",
162
+ "remark-parse": "^10.0.1",
163
+ "remark-rehype": "^10.1.0",
164
+ "rspack-plugin-virtual-module": "0.1.12",
165
+ "source-map": "0.7.4",
166
+ "string-replace-loader": "^3.1.0",
167
+ unified: "^10.1.2",
168
+ "unist-util-visit": "^4.1.1",
169
+ "unist-util-visit-children": "^2.0.1",
170
+ "yaml-front-matter": "^4.1.1"
171
+ },
172
+ devDependencies: {
173
+ tailwindcss: "^3.2.7",
174
+ "@modern-js/plugin-tailwindcss": "2.46.0",
175
+ "@modern-js/tsconfig": "2.46.0",
176
+ "@modern-js/types": "2.46.0",
177
+ "@types/body-scroll-lock": "^3.1.0",
178
+ "@types/fs-extra": "^9.0.13",
179
+ "@types/hast": "^2.3.4",
180
+ "@types/html-to-text": "^8.1.1",
181
+ "@types/jest": "^26.0.9",
182
+ "@types/lodash-es": "^4.17.6",
183
+ "@types/mdast": "^3.0.10",
184
+ "@types/node": "^14",
185
+ "@types/nprogress": "^0.2.0",
186
+ "@types/react": "^18",
187
+ "@types/react-dom": "^18",
188
+ "@types/yaml-front-matter": "^4.1.0",
189
+ husky: "^8",
190
+ "lint-staged": "~13.1.0",
191
+ "@biomejs/biome": "1.5.2",
192
+ rimraf: "^3.0.2",
193
+ typescript: "^5",
194
+ vite: "^4.0.5",
195
+ vitest: "0.33.0",
196
+ webpack: "^5.88.1"
197
+ },
198
+ sideEffects: [
199
+ "*.css",
200
+ "*.less",
201
+ "*.sass",
202
+ "*.scss",
203
+ "**/virtual-global-styles.js",
204
+ "virtual-global-styles",
205
+ "./src/theme-default/styles/index.ts"
206
+ ],
207
+ files: [
208
+ "bin",
209
+ "dist",
210
+ "src/runtime",
211
+ "src/theme-default",
212
+ "src/shared",
213
+ "index.html",
214
+ "runtime.ts",
215
+ "theme.ts",
216
+ "loader.cjs",
217
+ "compiled"
218
+ ],
219
+ publishConfig: {
220
+ access: "public",
221
+ provenance: true,
222
+ registry: "https://registry.npmjs.org/"
223
+ }
224
+ };
225
+ }
226
+ });
43
227
 
44
228
  // src/node/initRsbuild.ts
45
229
  import path10 from "path";
46
- import fs8 from "@rspress/shared/fs-extra";
47
230
  import {
231
+ removeLeadingSlash as removeLeadingSlash2,
48
232
  MDX_REGEXP as MDX_REGEXP3,
49
233
  RSPRESS_TEMP_DIR as RSPRESS_TEMP_DIR2,
50
234
  isDebugMode,
51
235
  removeTrailingSlash
52
236
  } from "@rspress/shared";
53
- import sirv from "sirv";
237
+ import fs8 from "@rspress/shared/fs-extra";
54
238
 
55
239
  // tailwind.config.ts
56
240
  var tailwindConfig = {
@@ -144,6 +328,7 @@ var SSR_ENTRY = path.join(
144
328
  var OUTPUT_DIR = "doc_build";
145
329
  var APP_HTML_MARKER = "<!--<?- DOC_CONTENT ?>-->";
146
330
  var HEAD_MARKER = "<!--<?- HEAD ?>-->";
331
+ var META_GENERATOR = "<!--<?- GENERATOR ?>-->";
147
332
  var HTML_START_TAG = "<html";
148
333
  var BODY_START_TAG = "<body";
149
334
  var PUBLIC_DIR = "public";
@@ -542,7 +727,23 @@ async function flattenMdxContent(content, basePath, alias) {
542
727
  // src/node/runtimeModule/siteData/extractPageData.ts
543
728
  async function extractPageData(replaceRules, alias, domain, root, routeService2) {
544
729
  return Promise.all(
545
- routeService2.getRoutes().filter((route) => MDX_REGEXP2.test(route.absolutePath)).map(async (route, index) => {
730
+ routeService2.getRoutes().map(async (route, index) => {
731
+ const defaultIndexInfo = {
732
+ id: index,
733
+ title: "",
734
+ content: "",
735
+ routePath: route.routePath,
736
+ lang: route.lang,
737
+ toc: [],
738
+ domain,
739
+ frontmatter: {},
740
+ version: route.version,
741
+ _filepath: route.absolutePath,
742
+ _relativePath: path5.relative(root, route.absolutePath)
743
+ };
744
+ if (!MDX_REGEXP2.test(route.absolutePath)) {
745
+ return defaultIndexInfo;
746
+ }
546
747
  let content = await fs3.readFile(route.absolutePath, "utf8");
547
748
  const { frontmatter, content: strippedFrontMatter } = loadFrontMatter(
548
749
  content,
@@ -551,10 +752,7 @@ async function extractPageData(replaceRules, alias, domain, root, routeService2)
551
752
  );
552
753
  Object.keys(frontmatter).forEach((key) => {
553
754
  if (typeof frontmatter[key] === "string") {
554
- frontmatter[key] = applyReplaceRules(
555
- frontmatter[key],
556
- replaceRules
557
- );
755
+ frontmatter[key] = applyReplaceRules(frontmatter[key], replaceRules);
558
756
  }
559
757
  });
560
758
  const flattenContent = await flattenMdxContent(
@@ -629,21 +827,15 @@ ${item.text}#
629
827
  };
630
828
  });
631
829
  return {
632
- id: index,
830
+ ...defaultIndexInfo,
633
831
  title: frontmatter.title || title,
634
- routePath: route.routePath,
635
- lang: route.lang,
636
832
  toc,
637
- domain,
638
833
  // Stripped frontmatter content
639
834
  content,
640
835
  frontmatter: {
641
836
  ...frontmatter,
642
837
  __content: void 0
643
- },
644
- version: route.version,
645
- _filepath: route.absolutePath,
646
- _relativePath: path5.relative(root, route.absolutePath)
838
+ }
647
839
  };
648
840
  })
649
841
  );
@@ -1240,8 +1432,6 @@ async function createInternalBuildConfig(userDocRoot, config, isSSR, routeServic
1240
1432
  const themeDir = await fs10.pathExists(CUSTOM_THEME_DIR) ? CUSTOM_THEME_DIR : DEFAULT_THEME;
1241
1433
  const checkDeadLinks = (config?.markdown?.checkDeadLinks && !isSSR) ?? false;
1242
1434
  const base = config?.base ?? "";
1243
- const publicDir = path10.join(userDocRoot, "public");
1244
- const isPublicDirExist = await fs10.pathExists(publicDir);
1245
1435
  const assetPrefix = isProduction() ? removeTrailingSlash(config?.builderConfig?.output?.assetPrefix ?? base) : "";
1246
1436
  const reactVersion = await detectReactVersion();
1247
1437
  const normalizeIcon = (icon) => {
@@ -1263,16 +1453,19 @@ async function createInternalBuildConfig(userDocRoot, config, isSSR, routeServic
1263
1453
  };
1264
1454
  return {
1265
1455
  server: {
1266
- port: !isProduction() && process.env.PORT ? Number(process.env.PORT) : void 0
1456
+ port: !isProduction() && process.env.PORT ? Number(process.env.PORT) : void 0,
1457
+ printUrls: ({ urls }) => {
1458
+ return urls.map((url) => `${url}/${removeLeadingSlash2(base)}`);
1459
+ },
1460
+ publicDir: {
1461
+ name: path10.join(userDocRoot, PUBLIC_DIR)
1462
+ }
1267
1463
  },
1268
1464
  dev: {
1269
1465
  progressBar: false,
1270
1466
  // Serve static files
1271
1467
  setupMiddlewares: [
1272
1468
  (middlewares) => {
1273
- if (isPublicDirExist) {
1274
- middlewares.unshift(sirv(publicDir));
1275
- }
1276
1469
  middlewares.unshift(serveSearchIndexMiddleware(config));
1277
1470
  }
1278
1471
  ]
@@ -1288,8 +1481,6 @@ async function createInternalBuildConfig(userDocRoot, config, isSSR, routeServic
1288
1481
  // `root` must be a relative path in Rsbuild
1289
1482
  root: path10.isAbsolute(outDir) ? path10.relative(cwd, outDir) : outDir
1290
1483
  },
1291
- // Disable production source map, it is useless for doc site
1292
- disableSourceMap: isProduction(),
1293
1484
  overrideBrowserslist: browserslist,
1294
1485
  assetPrefix
1295
1486
  },
@@ -1375,7 +1566,7 @@ async function initRsbuild(rootDir, config, pluginDriver, isSSR = false, extraRs
1375
1566
  pluginDriver
1376
1567
  });
1377
1568
  const {
1378
- default: { createRsbuild, mergeRsbuildConfig }
1569
+ default: { createRsbuild, mergeRsbuildConfig: mergeRsbuildConfig2 }
1379
1570
  } = await import("@rsbuild/core");
1380
1571
  const { pluginReact } = await import("@rsbuild/plugin-react");
1381
1572
  const { pluginSvgr } = await import("@rsbuild/plugin-svgr");
@@ -1387,7 +1578,7 @@ async function initRsbuild(rootDir, config, pluginDriver, isSSR = false, extraRs
1387
1578
  pluginDriver
1388
1579
  );
1389
1580
  const rsbuild = await createRsbuild({
1390
- rsbuildConfig: mergeRsbuildConfig(
1581
+ rsbuildConfig: mergeRsbuildConfig2(
1391
1582
  internalRsbuildConfig,
1392
1583
  ...config?.plugins?.map((plugin) => plugin.builderConfig ?? {}) || [],
1393
1584
  config?.builderConfig || {},
@@ -1583,7 +1774,6 @@ _isProd = new WeakMap();
1583
1774
  // src/node/dev.ts
1584
1775
  async function dev(options) {
1585
1776
  const { docDirectory, config, extraBuilderConfig } = options;
1586
- const base = config?.base ?? "";
1587
1777
  const isProd = false;
1588
1778
  const pluginDriver = new PluginDriver(config, isProd);
1589
1779
  await pluginDriver.init();
@@ -1598,15 +1788,8 @@ async function dev(options) {
1598
1788
  extraBuilderConfig
1599
1789
  );
1600
1790
  const { server } = await builder.startDevServer({
1601
- printURLs: (urls) => {
1602
- return urls.map(({ label, url }) => ({
1603
- label,
1604
- url: `${url}/${removeLeadingSlash2(base)}`
1605
- }));
1606
- },
1607
1791
  // We will support the following options in the future
1608
- getPortSilently: true,
1609
- logger: logger3
1792
+ getPortSilently: true
1610
1793
  });
1611
1794
  await pluginDriver.afterBuild();
1612
1795
  return server;
@@ -1626,7 +1809,7 @@ import {
1626
1809
  withBase as withBase3,
1627
1810
  isDebugMode as isDebugMode2
1628
1811
  } from "@rspress/shared";
1629
- import { logger as logger4 } from "@rspress/shared/logger";
1812
+ import { logger as logger3 } from "@rspress/shared/logger";
1630
1813
  var CHECK_DARK_LIGHT_SCRIPT = `
1631
1814
  <script id="check-dark-light">
1632
1815
  ;(() => {
@@ -1668,29 +1851,26 @@ async function bundle(docDirectory, config, pluginDriver, enableSSG) {
1668
1851
  );
1669
1852
  await clientBuilder.build();
1670
1853
  }
1671
- const publicDir = join3(docDirectory, PUBLIC_DIR);
1672
- if (await fs9.pathExists(publicDir)) {
1673
- await fs9.copy(publicDir, outputDir);
1674
- }
1675
1854
  } finally {
1676
1855
  await writeSearchIndex(config);
1677
1856
  }
1678
1857
  }
1679
1858
  async function renderPages(appDirectory, config, pluginDriver, enableSSG) {
1680
- logger4.info("Rendering pages...");
1859
+ logger3.info("Rendering pages...");
1681
1860
  const startTime = Date.now();
1682
1861
  const outputPath = config?.outDir ?? join3(appDirectory, OUTPUT_DIR);
1683
1862
  const ssrBundlePath = join3(outputPath, "ssr", "main.cjs");
1684
1863
  try {
1685
1864
  const { default: fs10 } = await import("@rspress/shared/fs-extra");
1865
+ const { version } = await Promise.resolve().then(() => __toESM(require_package()));
1686
1866
  let render = null;
1687
1867
  if (enableSSG) {
1688
1868
  try {
1689
1869
  const { default: ssrExports } = await import(pathToFileURL(ssrBundlePath).toString());
1690
1870
  ({ render } = ssrExports);
1691
1871
  } catch (e) {
1692
- logger4.error(e);
1693
- logger4.warn(
1872
+ logger3.error(e);
1873
+ logger3.warn(
1694
1874
  `Failed to load SSR bundle: ${ssrBundlePath}, fallback to CSR.`
1695
1875
  );
1696
1876
  }
@@ -1715,13 +1895,16 @@ async function renderPages(appDirectory, config, pluginDriver, enableSSG) {
1715
1895
  try {
1716
1896
  ({ appHtml } = await render(routePath, helmetContext.context));
1717
1897
  } catch (e) {
1718
- logger4.warn(
1898
+ logger3.warn(
1719
1899
  `page "${routePath}" render error: ${e.message}, fallback to CSR.`
1720
1900
  );
1721
1901
  }
1722
1902
  }
1723
1903
  const { helmet } = helmetContext.context;
1724
1904
  let html = htmlTemplate.replace(APP_HTML_MARKER, () => appHtml).replace(
1905
+ META_GENERATOR,
1906
+ () => `<meta name="generator" content="Rspress v${version}">`
1907
+ ).replace(
1725
1908
  HEAD_MARKER,
1726
1909
  (config?.head || []).concat([
1727
1910
  helmet?.title?.toString(),
@@ -1761,9 +1944,9 @@ async function renderPages(appDirectory, config, pluginDriver, enableSSG) {
1761
1944
  }
1762
1945
  await fs10.remove(join3(outputPath, "html"));
1763
1946
  const totalTime = Date.now() - startTime;
1764
- logger4.success(`Pages rendered in ${chalk2.yellow(totalTime)} ms.`);
1947
+ logger3.success(`Pages rendered in ${chalk2.yellow(totalTime)} ms.`);
1765
1948
  } catch (e) {
1766
- logger4.error(`Pages render error: ${e.stack}`);
1949
+ logger3.error(`Pages render error: ${e.stack}`);
1767
1950
  throw e;
1768
1951
  }
1769
1952
  }
@@ -1781,41 +1964,32 @@ async function build(options) {
1781
1964
  }
1782
1965
 
1783
1966
  // src/node/serve.ts
1784
- import sirv2 from "sirv";
1785
- import compression from "compression";
1786
- import polka from "polka";
1967
+ import { mergeRsbuildConfig } from "@rsbuild/core";
1787
1968
  async function serve(options) {
1788
1969
  const { config, port: userPort, host: userHost } = options;
1789
1970
  const envPort = process.env.PORT;
1790
1971
  const envHost = process.env.HOST;
1791
- const port = envPort || userPort || 4173;
1792
- const host = envHost || userHost || "localhost";
1793
- const base = config?.base?.replace(/^\//, "").replace(/\/$/, "") || "";
1794
- const compress = compression();
1795
- const serve2 = sirv2(config?.outDir || OUTPUT_DIR, {
1796
- etag: true,
1797
- maxAge: 31536e3,
1798
- immutable: true
1972
+ const { builderConfig } = config;
1973
+ const port = Number(
1974
+ envPort || userPort || builderConfig?.server?.port || 4173
1975
+ );
1976
+ const host = envHost || userHost || builderConfig?.server?.host || "localhost";
1977
+ config.builderConfig = mergeRsbuildConfig(builderConfig, {
1978
+ server: {
1979
+ port,
1980
+ host
1981
+ }
1799
1982
  });
1800
- if (base) {
1801
- polka().use(base, compress, serve2).listen(port, host, (err) => {
1802
- if (err) {
1803
- throw err;
1804
- }
1805
- console.log(
1806
- `Preview server running at http://${host}:${port}/${base}/
1807
- `
1808
- );
1809
- });
1810
- } else {
1811
- polka().use(compress, serve2).listen(port, host, (err) => {
1812
- if (err) {
1813
- throw err;
1814
- }
1815
- console.log(`Preview server running at http://${host}:${port}/
1816
- `);
1817
- });
1818
- }
1983
+ const pluginDriver = new PluginDriver(config, true);
1984
+ await pluginDriver.init();
1985
+ const modifiedConfig = await pluginDriver.modifyConfig();
1986
+ const builder = await initRsbuild(
1987
+ config.root,
1988
+ modifiedConfig,
1989
+ pluginDriver,
1990
+ false
1991
+ );
1992
+ await builder.preview();
1819
1993
  }
1820
1994
 
1821
1995
  // src/index.ts
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAqB,sBAAAA,2BAA0B;AAE/C,SAAS,UAAAC,eAAc;;;ACFvB,OAAOC,YAAU;AAEjB,OAAOC,SAAQ;AACf;AAAA,EACE,cAAAC;AAAA,EACA,oBAAAC;AAAA,EACA;AAAA,EACA;AAAA,OACK;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OAAO,WAAW,YAAY;AACpC,QAAM,OAAO,WAAW,YAAY;AACpC,QAAM,OAAO,QAAQ,MAAM,QAAQ,OAAO,EAAE,EAAE,QAAQ,OAAO,EAAE,KAAK;AACpE,QAAM,WAAW,YAAY;AAC7B,QAAMC,SAAQD,MAAK,QAAQ,UAAU,YAAY;AAAA,IAC/C,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,EACb,CAAC;AAED,MAAI,MAAM;AACR,UAAM,EACH,IAAI,MAAM,UAAUC,MAAK,EACzB,OAAO,MAAM,MAAM,CAAC,QAAe;AAClC,UAAI,KAAK;AACP,cAAM;AAAA,MACR;AACA,cAAQ;AAAA,QACN,oCAAoC,IAAI,IAAI,IAAI,IAAI,IAAI;AAAA;AAAA,MAC1D;AAAA,IACF,CAAC;AAAA,EACL,OAAO;AACL,UAAM,EACH,IAAI,UAAUA,MAAK,EACnB,OAAO,MAAM,MAAM,CAAC,QAAe;AAClC,UAAI,KAAK;AACP,cAAM;AAAA,MACR;AACA,cAAQ,IAAI,oCAAoC,IAAI,IAAI,IAAI;AAAA,CAAK;AAAA,IACnE,CAAC;AAAA,EACL;AACF;;;ACtDA,cAAc","names":["removeLeadingSlash","logger","path","fs","MDX_REGEXP","RSPRESS_TEMP_DIR","routeService","addLeadingSlash","page","normalizeSidebar","sidebar","resolver","enhancedResolve","CachedInputFileSystem","ResolverFactory","domain","join","SEARCH_INDEX_NAME","withBase","filepath","config","dirname","chalk","isDebugMode","sirv","serve"],"sources":["../src/node/dev.ts","../src/node/initRsbuild.ts","../tailwind.config.ts","../src/node/constants.ts","../src/node/runtimeModule/index.ts","../src/node/runtimeModule/routeData.ts","../src/node/runtimeModule/siteData/index.ts","../src/node/runtimeModule/siteData/normalizeThemeConfig.ts","../src/node/utils/applyReplaceRules.ts","../src/node/runtimeModule/i18n.ts","../src/node/runtimeModule/siteData/extractPageData.ts","../src/node/utils/normalizePath.ts","../src/node/utils/getPageKey.ts","../src/node/utils/createHash.ts","../src/node/utils/detectReactVersion.ts","../src/node/utils/flattenMdxContent.ts","../src/node/runtimeModule/globalUIComponents.ts","../src/node/runtimeModule/globalStyles.ts","../src/node/runtimeModule/searchHooks.ts","../src/node/runtimeModule/prismLanguages.ts","../src/node/searchIndex.ts","../src/node/route/RouteService.ts","../src/node/route/init.ts","../src/node/PluginDriver.ts","../src/node/build.ts","../src/node/serve.ts","../src/index.ts"],"sourcesContent":["import { UserConfig, removeLeadingSlash } from '@rspress/shared';\nimport type { RsbuildConfig } from '@rsbuild/core';\nimport { logger } from '@rspress/shared/logger';\nimport { initRsbuild } from './initRsbuild';\nimport { writeSearchIndex } from './searchIndex';\nimport { PluginDriver } from './PluginDriver';\n\ninterface ServerInstance {\n close: () => Promise<void>;\n}\n\ninterface DevOptions {\n appDirectory: string;\n docDirectory: string;\n config: UserConfig;\n extraBuilderConfig?: RsbuildConfig;\n}\n\nexport async function dev(options: DevOptions): Promise<ServerInstance> {\n const { docDirectory, config, extraBuilderConfig } = options;\n const base = config?.base ?? '';\n const isProd = false;\n const pluginDriver = new PluginDriver(config, isProd);\n await pluginDriver.init();\n\n try {\n const modifiedConfig = await pluginDriver.modifyConfig();\n await pluginDriver.beforeBuild();\n // empty temp dir before build\n // await fs.emptyDir( TEMP_DIR);\n const builder = await initRsbuild(\n docDirectory,\n modifiedConfig,\n pluginDriver,\n false,\n extraBuilderConfig,\n );\n const { server } = await builder.startDevServer({\n printURLs: urls => {\n return urls.map(({ label, url }) => ({\n label,\n url: `${url}/${removeLeadingSlash(base)}`,\n }));\n },\n // We will support the following options in the future\n getPortSilently: true,\n logger,\n });\n\n await pluginDriver.afterBuild();\n return server;\n } finally {\n await writeSearchIndex(config);\n }\n}\n","import path from 'path';\nimport type { UserConfig } from '@rspress/shared';\nimport fs from '@rspress/shared/fs-extra';\nimport {\n MDX_REGEXP,\n RSPRESS_TEMP_DIR,\n isDebugMode,\n removeTrailingSlash,\n} from '@rspress/shared';\nimport type { RsbuildInstance, RsbuildConfig } from '@rsbuild/core';\nimport sirv from 'sirv';\nimport { tailwindConfig } from '../../tailwind.config';\nimport {\n CLIENT_ENTRY,\n SSR_ENTRY,\n PACKAGE_ROOT,\n OUTPUT_DIR,\n isProduction,\n PUBLIC_DIR,\n} from './constants';\nimport { rsbuildPluginDocVM } from './runtimeModule';\nimport { serveSearchIndexMiddleware } from './searchIndex';\nimport { detectReactVersion, resolveReactAlias } from './utils';\nimport { initRouteService } from './route/init';\nimport { PluginDriver } from './PluginDriver';\nimport { RouteService } from './route/RouteService';\n\nexport interface MdxRsLoaderCallbackContext {\n resourcePath: string;\n links: string[];\n root: string;\n base: string;\n}\n\nasync function createInternalBuildConfig(\n userDocRoot: string,\n config: UserConfig,\n isSSR: boolean,\n routeService: RouteService,\n pluginDriver: PluginDriver,\n): Promise<RsbuildConfig> {\n const cwd = process.cwd();\n const { default: fs } = await import('@rspress/shared/fs-extra');\n const CUSTOM_THEME_DIR =\n config?.themeDir ?? path.join(process.cwd(), 'theme');\n const outDir = config?.outDir ?? OUTPUT_DIR;\n const DEFAULT_THEME = require.resolve('@rspress/theme-default');\n const themeDir = (await fs.pathExists(CUSTOM_THEME_DIR))\n ? CUSTOM_THEME_DIR\n : DEFAULT_THEME;\n const checkDeadLinks = (config?.markdown?.checkDeadLinks && !isSSR) ?? false;\n const base = config?.base ?? '';\n\n const publicDir = path.join(userDocRoot, 'public');\n const isPublicDirExist = await fs.pathExists(publicDir);\n // In production, we need to add assetPrefix in asset path\n const assetPrefix = isProduction()\n ? removeTrailingSlash(config?.builderConfig?.output?.assetPrefix ?? base)\n : '';\n const reactVersion = await detectReactVersion();\n\n const normalizeIcon = (icon: string | undefined) => {\n if (!icon) {\n return undefined;\n }\n\n if (path.isAbsolute(icon)) {\n return path.join(userDocRoot, PUBLIC_DIR, icon);\n }\n\n return icon;\n };\n\n // Using latest browserslist in development to improve build performance\n const browserslist = {\n web: isProduction()\n ? ['chrome >= 87', 'edge >= 88', 'firefox >= 78', 'safari >= 14']\n : [\n 'last 1 chrome version',\n 'last 1 firefox version',\n 'last 1 safari version',\n ],\n node: ['node >= 14'],\n };\n\n return {\n server: {\n port:\n !isProduction() && process.env.PORT\n ? Number(process.env.PORT)\n : undefined,\n },\n dev: {\n progressBar: false,\n // Serve static files\n setupMiddlewares: [\n middlewares => {\n if (isPublicDirExist) {\n middlewares.unshift(sirv(publicDir));\n }\n\n middlewares.unshift(serveSearchIndexMiddleware(config));\n },\n ],\n },\n html: {\n title: config?.title,\n favicon: normalizeIcon(config?.icon),\n template: path.join(PACKAGE_ROOT, 'index.html'),\n },\n output: {\n targets: isSSR ? ['node'] : ['web'],\n distPath: {\n // `root` must be a relative path in Rsbuild\n root: path.isAbsolute(outDir) ? path.relative(cwd, outDir) : outDir,\n },\n // Disable production source map, it is useless for doc site\n disableSourceMap: isProduction(),\n overrideBrowserslist: browserslist,\n assetPrefix,\n },\n source: {\n entry: {\n index: isSSR ? SSR_ENTRY : CLIENT_ENTRY,\n },\n alias: {\n '@mdx-js/react': require.resolve('@mdx-js/react'),\n '@theme': themeDir,\n '@/theme-default': DEFAULT_THEME,\n '@rspress/core': PACKAGE_ROOT,\n 'react-lazy-with-preload': require.resolve('react-lazy-with-preload'),\n 'react-syntax-highlighter': path.dirname(\n require.resolve('react-syntax-highlighter/package.json'),\n ),\n ...(await resolveReactAlias(reactVersion)),\n },\n include: [PACKAGE_ROOT, path.join(cwd, 'node_modules', RSPRESS_TEMP_DIR)],\n define: {\n 'process.env.__ASSET_PREFIX__': JSON.stringify(assetPrefix),\n 'process.env.__SSR__': JSON.stringify(isSSR),\n 'process.env.__IS_REACT_18__': JSON.stringify(reactVersion === 18),\n 'process.env.TEST': JSON.stringify(process.env.TEST),\n },\n },\n performance: {\n // No need to print the server bundles size\n printFileSize: !isSSR,\n },\n tools: {\n postcss(config) {\n // In debug mode, we should use tailwindcss to build the theme source code\n if (isDebugMode()) {\n try {\n config.postcssOptions.plugins.push(\n require('tailwindcss')({\n config: {\n ...tailwindConfig,\n content: [\n path.join(PACKAGE_ROOT, 'src', 'theme-default', '**/*'),\n ],\n },\n }),\n );\n } catch (e) {\n // if require tailwindcss failed, skip\n }\n }\n },\n bundlerChain(chain, { CHAIN_ID }) {\n const swcLoaderOptions = chain.module\n .rule(CHAIN_ID.RULE.JS)\n .use(CHAIN_ID.USE.SWC)\n .get('options');\n\n chain.module\n .rule('MDX')\n .type('javascript/auto')\n .test(MDX_REGEXP)\n .oneOf('MDXCompile')\n .use('builtin:swc-loader')\n .loader('builtin:swc-loader')\n .options(swcLoaderOptions)\n .end()\n .use('mdx-loader')\n .loader(require.resolve('../loader.cjs'))\n .options({\n config,\n docDirectory: userDocRoot,\n checkDeadLinks,\n routeService,\n pluginDriver,\n })\n .end()\n .use('string-replace-loader')\n .loader(require.resolve('string-replace-loader'))\n .options({\n multiple: config?.replaceRules || [],\n });\n\n if (chain.plugins.has(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH)) {\n chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).tap(options => {\n options[0] ??= {};\n options[0].include = [/\\.([cm]js|[jt]sx?|flow)$/i, MDX_REGEXP];\n return options;\n });\n }\n\n chain.resolve.extensions.prepend('.md').prepend('.mdx').prepend('.mjs');\n },\n },\n };\n}\n\nexport async function initRsbuild(\n rootDir: string,\n config: UserConfig,\n pluginDriver: PluginDriver,\n isSSR = false,\n extraRsbuildConfig?: RsbuildConfig,\n): Promise<RsbuildInstance> {\n const cwd = process.cwd();\n const userDocRoot = path.resolve(rootDir || config?.root || cwd);\n const builderPlugins = config?.builderPlugins ?? [];\n // We use a temp dir to store runtime files, so we can separate client and server build\n // and we should empty temp dir before build\n const runtimeTempDir = path.join(RSPRESS_TEMP_DIR, 'runtime');\n const runtimeAbsTempDir = path.join(cwd, 'node_modules', runtimeTempDir);\n await fs.ensureDir(runtimeAbsTempDir);\n\n const routeService = await initRouteService({\n config,\n runtimeTempDir: runtimeAbsTempDir,\n scanDir: userDocRoot,\n pluginDriver,\n });\n const {\n default: { createRsbuild, mergeRsbuildConfig },\n } = await import('@rsbuild/core');\n const { pluginReact } = await import('@rsbuild/plugin-react');\n const { pluginSvgr } = await import('@rsbuild/plugin-svgr');\n\n const internalRsbuildConfig = await createInternalBuildConfig(\n userDocRoot,\n config,\n isSSR,\n routeService,\n pluginDriver,\n );\n\n const rsbuild = await createRsbuild({\n rsbuildConfig: mergeRsbuildConfig(\n internalRsbuildConfig,\n ...(config?.plugins?.map(plugin => plugin.builderConfig ?? {}) || []),\n config?.builderConfig || {},\n extraRsbuildConfig || {},\n ),\n });\n\n rsbuild.addPlugins([\n rsbuildPluginDocVM({\n userDocRoot,\n config,\n isSSR,\n runtimeTempDir,\n routeService,\n pluginDriver,\n }),\n pluginReact(),\n pluginSvgr({\n svgDefaultExport: 'component',\n }),\n ...builderPlugins,\n ]);\n\n return rsbuild;\n}\n","import { Config } from 'tailwindcss';\n\nexport const tailwindConfig: Config = {\n content: [],\n darkMode: 'class',\n theme: {\n backgroundColor: ctx => ({\n ...ctx.theme('colors'),\n white: 'var(--rp-c-bg)',\n soft: 'var(--rp-c-bg-soft)',\n mute: 'var(--rp-c-bg-mute)',\n }),\n extend: {\n borderRadius: {\n '4xl': '2rem',\n },\n breakpoints: {\n xs: '640px',\n sm: '768px',\n md: '960px',\n lg: '1280px',\n },\n maxWidth: {\n '60': '15rem',\n },\n maxHeight: {\n '60': '15rem',\n },\n colors: {\n brand: {\n DEFAULT: 'var(--rp-c-brand)',\n light: 'var(--rp-c-brand-light)',\n dark: 'var(--rp-c-brand-dark)',\n lighter: 'var(--rp-c-brand-lighter)',\n darker: 'var(--rp-c-brand-darker)',\n },\n text: {\n 1: 'var(--rp-c-text-1)',\n 2: 'var(--rp-c-text-2)',\n 3: 'var(--rp-c-text-3)',\n 4: 'var(--rp-c-text-4)',\n },\n divider: {\n DEFAULT: 'var(--rp-c-divider)',\n light: 'var(--rp-c-divider-light)',\n dark: 'var(--rp-c-divider-dark)',\n },\n gray: {\n light: {\n 1: 'var(--rp-c-gray-light-1)',\n 2: 'var(--rp-c-gray-light-2)',\n 3: 'var(--rp-c-gray-light-3)',\n 4: 'var(--rp-c-gray-light-4)',\n 5: 'var(--rp-c-gray-light-5)',\n },\n },\n dark: {\n light: {\n 1: 'var(--rp-c-dark-light-1)',\n 2: 'var(--rp-c-dark-light-2)',\n 3: 'var(--rp-c-dark-light-3)',\n 4: 'var(--rp-c-dark-light-4)',\n 5: 'var(--rp-c-dark-light-5)',\n },\n },\n },\n },\n },\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 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 { UserConfig } from '@rspress/shared';\nimport type { RsbuildPlugin } from '@rsbuild/core';\nimport { RspackVirtualModulePlugin } from 'rspack-plugin-virtual-module';\nimport { RouteService } from '../route/RouteService';\nimport { PluginDriver } from '../PluginDriver';\nimport { routeVMPlugin } from './routeData';\nimport { siteDataVMPlugin } from './siteData/index';\nimport { i18nVMPlugin } from './i18n';\nimport { globalUIComponentsVMPlugin } from './globalUIComponents';\nimport { globalStylesVMPlugin } from './globalStyles';\nimport { searchHookVMPlugin } from './searchHooks';\nimport { prismLanguageVMPlugin } from './prismLanguages';\n\nexport interface FactoryContext {\n userDocRoot: string;\n config: UserConfig;\n isSSR: boolean;\n runtimeTempDir: string;\n alias: Record<string, string | string[]>;\n routeService: RouteService;\n pluginDriver: PluginDriver;\n}\n\ntype RuntimeModuleFactory = (\n context: FactoryContext,\n) => Record<string, string> | Promise<Record<string, string>>;\n\nexport const runtimeModuleFactory: RuntimeModuleFactory[] = [\n /**\n * Generate route data for client and server runtime\n */\n routeVMPlugin,\n /**\n * Generate search index and site data for client runtime\n */\n siteDataVMPlugin,\n /**\n * Generate global components from config and plugins\n */\n globalUIComponentsVMPlugin,\n /**\n * Generate global styles from config and plugins\n */\n globalStylesVMPlugin,\n /**\n * Generate i18n text for client runtime\n */\n i18nVMPlugin,\n /**\n * Generate search hook module\n */\n searchHookVMPlugin,\n /**\n * Generate prism languages module\n */\n prismLanguageVMPlugin,\n];\n\n// We will use this plugin to generate runtime module in browser, which is important to ensure the client have access to some compile-time data\n// TODO: We can separate the compile-time data generation and runtime module generation logic instead of putting them together(such as `siteDataVMPlugin` plugin, it does too much thing) to make it more clear\nexport function rsbuildPluginDocVM(\n factoryContext: Omit<FactoryContext, 'alias'>,\n): RsbuildPlugin {\n const { pluginDriver } = factoryContext;\n return {\n name: 'rsbuild-plugin-doc-vm',\n setup(api) {\n api.modifyBundlerChain(async bundlerChain => {\n // The order should be sync\n const alias = bundlerChain.resolve.alias.entries();\n const runtimeModule: Record<string, string> = {};\n // Add internal runtime module\n for (const factory of runtimeModuleFactory) {\n const moduleResult = await factory({\n ...factoryContext,\n alias,\n });\n Object.assign(runtimeModule, moduleResult);\n }\n // Add runtime module from outer plugins\n const modulesByPlugin = await pluginDriver.addRuntimeModules();\n Object.keys(modulesByPlugin).forEach(key => {\n if (runtimeModule[key]) {\n throw new Error(\n `The runtime module ${key} is duplicated, please check your plugin`,\n );\n }\n runtimeModule[key] = modulesByPlugin[key];\n });\n bundlerChain\n .plugin(`rspress-runtime-module`)\n .use(\n new RspackVirtualModulePlugin(\n runtimeModule,\n factoryContext.runtimeTempDir,\n ),\n );\n });\n },\n };\n}\n\nexport enum RuntimeModuleID {\n GlobalStyles = 'virtual-global-styles',\n GlobalComponents = 'virtual-global-components',\n RouteForClient = 'virtual-routes',\n RouteForSSR = 'virtual-routes-ssr',\n SiteData = 'virtual-site-data',\n SearchIndexHash = 'virtual-search-index-hash',\n I18nText = 'virtual-i18n-text',\n SearchHooks = 'virtual-search-hooks',\n PrismLanguages = 'virtual-prism-languages',\n}\n\nexport const runtimeModuleIDs = [\n RuntimeModuleID.GlobalStyles,\n RuntimeModuleID.GlobalComponents,\n RuntimeModuleID.RouteForClient,\n RuntimeModuleID.RouteForSSR,\n RuntimeModuleID.SiteData,\n RuntimeModuleID.SearchIndexHash,\n RuntimeModuleID.I18nText,\n RuntimeModuleID.SearchHooks,\n RuntimeModuleID.PrismLanguages,\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 { PageIndexInfo, SEARCH_INDEX_NAME } from '@rspress/shared';\nimport fs from '@rspress/shared/fs-extra';\nimport { FactoryContext, RuntimeModuleID } from '..';\nimport { normalizeThemeConfig } from './normalizeThemeConfig';\nimport { extractPageData } from './extractPageData';\nimport { createHash } from '@/node/utils';\nimport { TEMP_DIR } from '@/node/constants';\n\n// How can we let the client runtime access the `indexHash`?\n// We can only do something after the Rspack build process becuase the index hash is generated within Rspack build process.There are two ways to do this:\n// 1. insert window.__INDEX_HASH__ = 'xxx' into the html template manually\n// 2. replace the `__INDEX_HASH__` placeholder in the html template with the real index hash after Rspack build\nexport const indexHash = '';\n\nfunction deletePriviteKey<T>(obj: T): T {\n if (typeof obj !== 'object' || obj === null) {\n return obj;\n }\n const newObj = { ...obj };\n Object.keys(newObj).forEach(key => {\n if (key.startsWith('_')) {\n delete newObj[key];\n }\n });\n return newObj;\n}\n\nexport async function siteDataVMPlugin(context: FactoryContext) {\n const { config, alias, userDocRoot, routeService, pluginDriver } = context;\n const userConfig = config;\n const replaceRules = userConfig?.replaceRules || [];\n // If the dev server restart when config file, we will reuse the siteData instead of extracting the siteData from source files again.\n const domain =\n userConfig?.search && userConfig?.search?.mode === 'remote'\n ? userConfig?.search.domain ?? ''\n : '';\n const pages = (\n await extractPageData(\n replaceRules,\n alias,\n domain,\n userDocRoot,\n routeService,\n )\n ).filter(Boolean);\n // modify page index by plugins\n await pluginDriver.modifySearchIndexData(pages);\n\n // Categorize pages, sorted by language, and write search index to file\n const pagesByLang = pages.reduce((acc, page) => {\n if (!acc[page.lang]) {\n acc[page.lang] = [];\n }\n if (page.frontmatter?.pageType === 'home') {\n return acc;\n }\n acc[page.lang].push(page);\n return acc;\n }, {} as Record<string, PageIndexInfo[]>);\n\n const indexHashByLang = {} as Record<string, string>;\n\n // Generate search index by different languages, file name is {SEARCH_INDEX_NAME}.{lang}.{hash}.json\n await Promise.all(\n Object.keys(pagesByLang).map(async lang => {\n // Avoid writing filepath in compile-time\n const stringfiedIndex = JSON.stringify(\n pagesByLang[lang].map(deletePriviteKey),\n );\n const indexHash = createHash(stringfiedIndex);\n indexHashByLang[lang] = indexHash;\n await fs.ensureDir(TEMP_DIR);\n await fs.writeFile(\n path.join(\n TEMP_DIR,\n `${SEARCH_INDEX_NAME}${lang ? `.${lang}` : ''}.${indexHash}.json`,\n ),\n stringfiedIndex,\n );\n }),\n );\n\n // Run extendPageData hook in plugins\n await Promise.all(\n pages.map(async pageData => pluginDriver.extendPageData(pageData)),\n );\n\n const siteData = {\n title: userConfig?.title || '',\n description: userConfig?.description || '',\n icon: userConfig?.icon || '',\n route: userConfig?.route,\n themeConfig: normalizeThemeConfig(userConfig, pages),\n base: userConfig?.base || '/',\n lang: userConfig?.lang || '',\n locales: userConfig?.locales || userConfig.themeConfig?.locales || [],\n logo: userConfig?.logo || '',\n ssg: userConfig?.ssg ?? true,\n multiVersion: {\n default: userConfig?.multiVersion?.default || '',\n versions: userConfig?.multiVersion?.versions || [],\n },\n search: userConfig?.search ?? { mode: 'local' },\n pages: pages.map(page => {\n const { content, id, domain, _filepath, ...rest } = page;\n return rest;\n }),\n markdown: {\n showLineNumbers: userConfig?.markdown?.showLineNumbers ?? false,\n defaultWrapCode: userConfig?.markdown?.defaultWrapCode ?? false,\n codeHighlighter: userConfig?.markdown?.codeHighlighter || 'prism',\n },\n };\n\n return {\n [`${RuntimeModuleID.SiteData}.mjs`]: `export default ${JSON.stringify(\n siteData,\n )}`,\n [RuntimeModuleID.SearchIndexHash]: `export default ${JSON.stringify(\n indexHashByLang,\n )}`,\n };\n}\n","import {\n UserConfig,\n DefaultThemeConfig,\n NormalizedDefaultThemeConfig,\n SidebarItem,\n SidebarGroup,\n NormalizedSidebarGroup,\n PageIndexInfo,\n NavItemWithLink,\n withBase,\n addLeadingSlash,\n isExternalUrl,\n withoutBase,\n NavItem,\n Sidebar,\n SidebarDivider,\n} from '@rspress/shared';\nimport { applyReplaceRules } from '../../utils/applyReplaceRules';\nimport { getI18nData } from '../i18n';\n\nexport function normalizeThemeConfig(\n docConfig: UserConfig,\n pages: PageIndexInfo[] = [],\n): NormalizedDefaultThemeConfig {\n const {\n locales: siteLocales,\n base = '',\n lang,\n replaceRules = [],\n multiVersion,\n } = docConfig;\n const { versions = [] } = multiVersion || {};\n const hasMultiVersion = versions.length > 0;\n docConfig.themeConfig = docConfig.themeConfig || {};\n const { themeConfig } = docConfig;\n const locales = siteLocales ?? (themeConfig?.locales || []);\n const i18nTextData = getI18nData(docConfig);\n // In following code, we will normalize the theme config reference to the pages data extracted from mdx files\n const normalizeLinkPrefix = (link = '', currentLang = '') => {\n if (\n !currentLang ||\n !link ||\n withoutBase(link, base).startsWith(`/${currentLang}`) ||\n isExternalUrl(link) ||\n // In multi version case, we have got the complete link prefix in `plugin-auto-nav-sidebar` and does not need to add the lang prefix\n hasMultiVersion\n ) {\n return link;\n }\n // if lang exists, we should add the lang prefix to the link\n // such /guide -> /en/guide\n return lang === currentLang\n ? link\n : `/${currentLang}${addLeadingSlash(link)}`;\n };\n\n const getI18nText = (key = '', currentLang = '') => {\n const text = i18nTextData[key]?.[currentLang];\n return text || key;\n };\n // Normalize sidebar\n const normalizeSidebar = (\n sidebar?: DefaultThemeConfig['sidebar'],\n currentLang = '',\n ): NormalizedDefaultThemeConfig['sidebar'] => {\n const normalizedSidebar: NormalizedDefaultThemeConfig['sidebar'] = {};\n if (!sidebar) {\n return {};\n }\n const normalizeSidebarItem = (\n item: SidebarGroup | SidebarItem | SidebarDivider | string,\n ): NormalizedSidebarGroup | SidebarItem | SidebarDivider => {\n if (typeof item === 'object' && 'items' in item) {\n return {\n text: applyReplaceRules(\n getI18nText(item.text, currentLang),\n replaceRules,\n ),\n link: normalizeLinkPrefix(item.link),\n collapsed: item.collapsed ?? false,\n collapsible: item.collapsible ?? true,\n tag: item.tag,\n items: item.items.map(subItem => {\n return normalizeSidebarItem(subItem);\n }),\n };\n }\n\n if (typeof item === 'object' && 'dividerType' in item) {\n return item;\n }\n\n if (typeof item === 'string') {\n const normalizedItem = normalizeLinkPrefix(item, currentLang);\n const page = pages.find(\n page => page.routePath === withBase(normalizedItem, base),\n );\n return {\n text: applyReplaceRules(page?.title || '', replaceRules),\n link: normalizedItem,\n };\n }\n\n return {\n text: applyReplaceRules(\n getI18nText(item.text, currentLang),\n replaceRules,\n ),\n link: normalizeLinkPrefix(item.link),\n tag: item.tag,\n };\n };\n\n const normalizeSidebar = (sidebar: Sidebar) => {\n Object.keys(sidebar).forEach(key => {\n const value = sidebar[key];\n normalizedSidebar[key] = value.map(normalizeSidebarItem);\n });\n };\n\n normalizeSidebar(sidebar);\n\n return normalizedSidebar;\n };\n\n const normalizeNav = (\n nav?: DefaultThemeConfig['nav'],\n currentLang?: string,\n ) => {\n if (!nav) {\n return [];\n }\n const transformNavItem = (navItem: NavItem) => {\n const text = applyReplaceRules(\n getI18nText(navItem.text, currentLang),\n replaceRules,\n );\n if ('link' in navItem) {\n return {\n ...navItem,\n text,\n link: normalizeLinkPrefix(navItem.link, currentLang),\n };\n }\n\n if ('items' in navItem) {\n return {\n ...navItem,\n text,\n items: navItem.items.map((item: NavItemWithLink) => {\n return {\n ...item,\n text: applyReplaceRules(\n getI18nText(item.text, currentLang),\n replaceRules,\n ),\n link: normalizeLinkPrefix(item.link, currentLang),\n };\n }),\n };\n }\n\n return navItem;\n };\n\n if (Array.isArray(nav)) {\n return nav.map(transformNavItem);\n }\n\n // Multi version case\n return Object.entries(nav).reduce((acc, [key, value]) => {\n acc[key] = value.map(transformNavItem);\n return acc;\n }, {});\n };\n\n /**\n * There are two place the user will define the locales:\n * 1. in the `doc.locales` (the site config)\n * 2. in the `doc.themeConfig.locales`\n * The locales in the theme config will override the locales in the site config.\n *\n * For nav and sidebar, we prefer the locales in the `themeConfig.nav` and `themeConfig.sidebar` if it exists. And the frameowork will generate complete nav and sidebar for each locale and place them in the `themeConfig.locales` field.\n */\n if (locales.length) {\n themeConfig.locales = locales.map(({ lang: currentLang, label }) => {\n const localeInThemeConfig = themeConfig.locales?.find(\n locale => locale.lang === currentLang,\n );\n return {\n lang: currentLang,\n label,\n ...(localeInThemeConfig || {}),\n sidebar: normalizeSidebar(\n localeInThemeConfig?.sidebar ?? themeConfig.sidebar,\n currentLang,\n ),\n nav: normalizeNav(\n localeInThemeConfig?.nav ?? themeConfig.nav,\n currentLang,\n ),\n };\n });\n } else {\n themeConfig.sidebar = normalizeSidebar(themeConfig?.sidebar);\n themeConfig.nav = normalizeNav(themeConfig?.nav);\n }\n return themeConfig as NormalizedDefaultThemeConfig;\n}\n","import { ReplaceRule } from '@rspress/shared';\n\nexport function applyReplaceRules(\n code = '',\n replaceRules: ReplaceRule[] = [],\n): string {\n let result = code;\n for (const rule of replaceRules) {\n result = result.replace(rule.search, rule.replace);\n }\n return result;\n}\n","import { join } from 'path';\nimport { UserConfig } from '@rspress/shared';\nimport { FactoryContext, RuntimeModuleID } from '.';\n\nconst DEFAULT_I18N_SOURCE = join(process.cwd(), 'i18n.json');\n\nexport function getI18nData(docConfig: UserConfig) {\n const { i18nSourcePath = DEFAULT_I18N_SOURCE } = docConfig;\n try {\n // eslint-disable-next-line import/no-dynamic-require\n const i18nSource = require(i18nSourcePath);\n return i18nSource;\n } catch (e) {\n return {};\n }\n}\n\nexport function i18nVMPlugin(context: FactoryContext) {\n const { config } = context;\n const i18nData = getI18nData(config);\n return {\n [RuntimeModuleID.I18nText]: `export default ${JSON.stringify(i18nData)}`,\n };\n}\n","import path from 'path';\nimport {\n PageIndexInfo,\n ReplaceRule,\n Header,\n MDX_REGEXP,\n} from '@rspress/shared';\nimport { htmlToText } from 'html-to-text';\nimport fs from '@rspress/shared/fs-extra';\nimport { compile } from '@rspress/mdx-rs';\nimport { loadFrontMatter } from '@rspress/shared/node-utils';\nimport { flattenMdxContent } from '@/node/utils';\nimport { RouteService } from '@/node/route/RouteService';\nimport { applyReplaceRules } from '@/node/utils/applyReplaceRules';\nimport { importStatementRegex } from '@/node/constants';\n\nexport async function extractPageData(\n replaceRules: ReplaceRule[],\n alias: Record<string, string | string[]>,\n domain: string,\n root: string,\n routeService: RouteService,\n): Promise<(PageIndexInfo | null)[]> {\n return Promise.all(\n routeService\n .getRoutes()\n .filter(route => MDX_REGEXP.test(route.absolutePath))\n .map(async (route, index) => {\n let content: string = await fs.readFile(route.absolutePath, 'utf8');\n const { frontmatter, content: strippedFrontMatter } = loadFrontMatter(\n content,\n route.absolutePath,\n root,\n );\n\n // 1. Replace rules for frontmatter & content\n Object.keys(frontmatter).forEach(key => {\n if (typeof frontmatter[key] === 'string') {\n frontmatter[key] = applyReplaceRules(\n frontmatter[key],\n replaceRules,\n );\n }\n });\n\n // TODO: we will find a more efficient way to do this\n const flattenContent = await flattenMdxContent(\n applyReplaceRules(strippedFrontMatter, replaceRules),\n route.absolutePath,\n alias,\n );\n\n content = flattenContent.replace(importStatementRegex, '');\n\n const {\n html,\n title,\n toc: rawToc,\n } = await compile({\n value: content,\n filepath: route.absolutePath,\n development: process.env.NODE_ENV !== 'production',\n root,\n });\n\n if (!title?.length && !frontmatter && !frontmatter.title?.length) {\n return null;\n }\n content = htmlToText(String(html), {\n wordwrap: 80,\n selectors: [\n {\n selector: 'a',\n options: {\n ignoreHref: true,\n },\n },\n {\n selector: 'img',\n format: 'skip',\n },\n {\n // Skip code blocks\n selector: 'pre > code',\n format: 'skip',\n },\n ...['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].map(tag => ({\n selector: tag,\n options: {\n uppercase: false,\n },\n })),\n ],\n tables: true,\n longWordSplit: {\n forceWrapOnLimit: true,\n },\n });\n if (content.startsWith(title)) {\n // Remove the title from the content\n content = content.slice(title.length);\n }\n\n const toc: Header[] = rawToc.map(item => {\n // If the item.id ends with '-number', we take the number\n const match = item.id.match(/-(\\d+)$/);\n let position = -1;\n if (match) {\n for (let i = 0; i < Number(match[1]); i++) {\n position = content.indexOf(`\\n${item.text}#\\n\\n`, position + 1);\n }\n }\n return {\n ...item,\n charIndex: content.indexOf(`\\n${item.text}#\\n\\n`, position + 1),\n };\n });\n\n return {\n id: index,\n title: frontmatter.title || title,\n routePath: route.routePath,\n lang: route.lang,\n toc,\n domain,\n // Stripped frontmatter content\n content,\n frontmatter: {\n ...frontmatter,\n __content: undefined,\n },\n version: route.version,\n _filepath: route.absolutePath,\n _relativePath: path.relative(root, route.absolutePath),\n };\n }),\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 { removeLeadingSlash } from '@rspress/shared';\n\nexport function getPageKey(route: string) {\n const cleanRoute = removeLeadingSlash(route);\n return cleanRoute.replace(/\\//g, '_').replace(/\\.[^.]+$/, '') || 'index';\n}\n","import { createHash as createHashFunc } from 'crypto';\n\nexport function createHash(str: string) {\n return createHashFunc('sha256').update(str).digest('hex').slice(0, 8);\n}\n","import path from 'path';\nimport fs from '@rspress/shared/fs-extra';\nimport { logger } from '@rspress/shared/logger';\nimport enhancedResolve from 'enhanced-resolve';\nimport { PACKAGE_ROOT } from '../constants';\n\nconst { CachedInputFileSystem, ResolverFactory } = enhancedResolve;\n\nconst DEFAULT_REACT_VERSION = 18;\n\nexport async function detectReactVersion(): Promise<number> {\n // Detect react version from current cwd\n // return the major version of react\n // if not found, return 18\n const cwd = process.cwd();\n const reactPath = path.join(cwd, 'node_modules', 'react');\n if (await fs.pathExists(reactPath)) {\n const reactPkg = await fs.readJson(path.join(reactPath, 'package.json'));\n const version = Number(reactPkg.version.split('.')[0]);\n return version;\n } else {\n return DEFAULT_REACT_VERSION;\n }\n}\n\nexport async function resolveReactAlias(reactVersion: number) {\n const basedir =\n reactVersion === DEFAULT_REACT_VERSION ? PACKAGE_ROOT : process.cwd();\n const libPaths = [\n 'react',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n 'react-dom',\n 'react-dom/server',\n ];\n if (reactVersion === DEFAULT_REACT_VERSION) {\n libPaths.push('react-dom/client');\n }\n const alias: Record<string, string> = {};\n const resolver = ResolverFactory.createResolver({\n fileSystem: new CachedInputFileSystem(fs),\n extensions: ['.js'],\n alias,\n });\n await Promise.all(\n libPaths.map(async lib => {\n try {\n alias[lib] = await new Promise<string>((resolve, reject) => {\n resolver.resolve(\n { importer: basedir },\n basedir,\n lib,\n {},\n (err, filePath) => {\n if (err || filePath === false) {\n return reject(err);\n }\n return resolve(filePath);\n },\n );\n });\n } catch (e) {\n console.log(e);\n logger.warn(`${lib} not found`);\n }\n }),\n );\n return alias;\n}\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';\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 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 result = result.replace((node as { value: string }).value, '');\n return (node.data?.estree as { body: ImportNode[] })?.body || [];\n })\n .flat()\n .filter(node => node.type === 'ImportDeclaration');\n\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 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","import { FactoryContext, RuntimeModuleID } from '.';\n\nexport async function globalUIComponentsVMPlugin(context: FactoryContext) {\n const { config, pluginDriver } = context;\n let index = 0;\n\n const globalUIComponentsByPlugins = pluginDriver.globalUIComponents();\n const globalComponents = [\n ...(config?.globalUIComponents || []),\n ...globalUIComponentsByPlugins,\n ];\n const moduleContent = globalComponents\n .map(source => {\n const name = `Comp_${index}`;\n if (Array.isArray(source)) {\n return `import ${name} from ${JSON.stringify(source[0])};\nconst Props_${index++} = ${JSON.stringify(source[1])};\\n`;\n } else {\n index++;\n return `import ${name} from ${JSON.stringify(source)};\\n`;\n }\n })\n .concat(\n `export default [${Array.from({ length: index }, (_, i) => {\n if (Array.isArray(globalComponents[i])) {\n return `[${`Comp_${i}`}, Props_${i}]`;\n } else {\n return `Comp_${i}`;\n }\n }).join(', ')}];`,\n )\n .join('');\n\n return {\n [RuntimeModuleID.GlobalComponents]: moduleContent,\n };\n}\n","import fs from '@rspress/shared/fs-extra';\nimport { FactoryContext, RuntimeModuleID } from '.';\n\nexport async function globalStylesVMPlugin(context: FactoryContext) {\n const { config, pluginDriver } = context;\n const globalStylesByPlugins = pluginDriver.globalStyles();\n\n if (config.globalStyles) {\n // Only patch user config global styles\n const source = config.globalStyles;\n const styleContent = await fs.readFile(source, 'utf-8');\n\n // Patch --modern-xxx, .modern-xxx global name\n const patchedStyleContent = styleContent\n .replace(/--modern-/g, '--rp-')\n .replace(/\\.modern-doc/g, '.rspress')\n .replace(/\\.modern-/g, '.rspress-');\n\n await fs.writeFile(source, patchedStyleContent, 'utf-8');\n }\n\n const moduleContent = (\n await Promise.all(\n [config?.globalStyles || '', ...globalStylesByPlugins]\n .filter(source => source.length > 0)\n .map(async source => {\n return `import ${JSON.stringify(source)};`;\n }),\n )\n ).join('');\n\n return {\n [RuntimeModuleID.GlobalStyles]: moduleContent,\n };\n}\n","import path from 'path';\nimport { FactoryContext, RuntimeModuleID } from '.';\n\nexport async function searchHookVMPlugin(context: FactoryContext) {\n const { config } = context;\n let content = 'export const onSearch = () => {};';\n let extname = '';\n if (\n typeof config.search === 'object' &&\n typeof config.search.searchHooks === 'string'\n ) {\n content = `export * from '${config.search.searchHooks}'`;\n extname = path.extname(config.search.searchHooks);\n }\n\n return {\n [`${RuntimeModuleID.SearchHooks}${extname}`]: content,\n };\n}\n","import { uniqBy } from 'lodash-es';\nimport { DEFAULT_HIGHLIGHT_LANGUAGES } from '@rspress/shared';\nimport { FactoryContext, RuntimeModuleID } from '.';\n\nexport async function prismLanguageVMPlugin(context: FactoryContext) {\n const { config } = context;\n const { highlightLanguages = [] } = config.markdown || {};\n const languageMeta = uniqBy(\n [...DEFAULT_HIGHLIGHT_LANGUAGES, ...highlightLanguages].map(language => {\n const [alias, name] = Array.isArray(language)\n ? language\n : [language, language];\n return { alias, name };\n }),\n 'alias',\n );\n\n const importStatement = languageMeta.map(language => {\n const { alias, name } = language;\n return `import ${alias} from 'react-syntax-highlighter/dist/esm/languages/prism/${name}'`;\n });\n\n const moduleContent = `\n${importStatement.join('\\n')}\n\nexport default {\n ${languageMeta.map(({ alias }) => `\"${alias}\": ${alias}`)}\n};\n`;\n return {\n [RuntimeModuleID.PrismLanguages]: moduleContent,\n };\n}\n","import path, { join } from 'path';\nimport fs from '@rspress/shared/fs-extra';\nimport chalk from '@rspress/shared/chalk';\nimport { RequestHandler } from '@modern-js/types';\nimport fetch from 'node-fetch';\nimport { UserConfig, isSCM, SEARCH_INDEX_NAME } from '@rspress/shared';\nimport { logger } from '@rspress/shared/logger';\nimport { isProduction, OUTPUT_DIR, TEMP_DIR } from './constants';\n\nexport async function writeSearchIndex(config: UserConfig) {\n if (config?.search === false) {\n return;\n }\n const cwd = process.cwd();\n // get all search index files, format is `${SEARCH_INDEX_NAME}.xxx.${hash}.json`\n const searchIndexFiles = await fs.readdir(TEMP_DIR);\n const outDir = config?.outDir ?? join(cwd, OUTPUT_DIR);\n\n // For performance, we only stitch the string of search index data instead of big JavaScript object in memory\n let searchIndexData = '[]';\n let scaning = false;\n for (const searchIndexFile of searchIndexFiles) {\n if (\n !searchIndexFile.includes(SEARCH_INDEX_NAME) ||\n !searchIndexFile.endsWith('.json')\n ) {\n continue;\n }\n const source = join(TEMP_DIR, searchIndexFile);\n const target = join(outDir, 'static', searchIndexFile);\n const searchIndex = await fs.readFile(\n join(TEMP_DIR, searchIndexFile),\n 'utf-8',\n );\n searchIndexData = `${searchIndexData.slice(0, -1)}${\n scaning ? ',' : ''\n }${searchIndex.slice(1)}`;\n await fs.move(source, target, { overwrite: true });\n scaning = true;\n }\n\n if (isProduction() && isSCM() && config?.search?.mode === 'remote') {\n const { apiUrl, indexName } = config.search;\n try {\n await fetch(`${apiUrl}?index=${indexName}`, {\n method: 'PUT',\n body: searchIndexData,\n headers: { 'Content-Type': 'application/json' },\n });\n\n logger.info(\n chalk.green(\n `[doc-tools] Search index uploaded to ${apiUrl}, indexName: ${indexName}`,\n ),\n );\n } catch (e) {\n logger.info(\n chalk.red(\n `[doc-tools] Upload search index \\`${indexName}\\` failed:\\n ${e}`,\n ),\n );\n }\n }\n}\n\nexport function serveSearchIndexMiddleware(config: UserConfig): RequestHandler {\n return (req, res, next) => {\n const searchIndexRequestMatch = `/${SEARCH_INDEX_NAME}.`;\n if (req.url?.includes(searchIndexRequestMatch)) {\n res.setHeader('Content-Type', 'application/json');\n // Get search index name from request url\n const searchIndexFile = req.url?.split('/').pop();\n const searchIndex = fs.readFileSync(\n path.join(\n process.cwd(),\n config?.outDir || OUTPUT_DIR,\n 'static',\n searchIndexFile,\n ),\n 'utf-8',\n );\n res.end(searchIndex);\n } else {\n next?.();\n }\n };\n}\n","import path from 'path';\nimport type { ComponentType } from 'react';\nimport fs from '@rspress/shared/fs-extra';\nimport { PageModule, UserConfig, RouteMeta, withBase } from '@rspress/shared';\nimport { getPageKey, normalizePath } from '../utils';\nimport { PluginDriver } from '../PluginDriver';\n\nexport const DEFAULT_PAGE_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'];\n\nexport interface Route {\n path: string;\n element: React.ReactElement;\n filePath: string;\n preload: () => Promise<PageModule<ComponentType<unknown>>>;\n lang: string;\n}\n\nexport interface RouteOptions {\n extensions?: string[];\n include?: string[];\n exclude?: string[];\n}\n\nexport const addLeadingSlash = (str: string) => {\n return str.startsWith('/') ? str : `/${str}`;\n};\n\nexport const normalizeRoutePath = (\n routePath: string,\n base: string,\n lang: string,\n version: string,\n langs: string[],\n versions: string[],\n): { routePath: string; lang: string; version: string } => {\n const hasTrailSlash = routePath.endsWith('/');\n let versionPart = '';\n let langPart = '';\n let purePathPart = '';\n const parts: string[] = routePath.split('/').filter(Boolean);\n\n if (version) {\n const versionToMatch = parts[0];\n if (versions.includes(versionToMatch)) {\n if (versionToMatch !== version) {\n versionPart = versionToMatch;\n }\n parts.shift();\n }\n }\n\n if (lang) {\n const langToMatch = parts[0];\n if (langs.includes(langToMatch)) {\n if (langToMatch !== lang) {\n langPart = langToMatch;\n }\n parts.shift();\n }\n }\n purePathPart = parts.join('/');\n\n let normalizedRoutePath = addLeadingSlash(\n [versionPart, langPart, purePathPart].filter(Boolean).join('/'),\n )\n // remove the extension\n .replace(/\\.[^.]+$/, '')\n .replace(/\\/index$/, '/');\n\n // restore the trail slash\n if (hasTrailSlash && !normalizedRoutePath.endsWith('/')) {\n normalizedRoutePath = `${normalizedRoutePath}/`;\n }\n\n return {\n routePath: withBase(normalizedRoutePath, base),\n lang: langPart || lang,\n version: versionPart || version,\n };\n};\n\nexport class RouteService {\n routeData: Map<string, RouteMeta> = new Map();\n\n #scanDir: string;\n\n #defaultLang: string;\n\n #defaultVersion: string = '';\n\n #extensions: string[] = [];\n\n #langs: string[] = [];\n\n #versions: string[] = [];\n\n #include: string[] = [];\n\n #exclude: string[] = [];\n\n #base: string = '';\n\n #tempDir: string = '';\n\n #pluginDriver: PluginDriver;\n\n constructor(\n scanDir: string,\n userConfig: UserConfig,\n tempDir: string,\n pluginDriver: PluginDriver,\n ) {\n const routeOptions = userConfig?.route || {};\n this.#scanDir = scanDir;\n this.#extensions = routeOptions.extensions || DEFAULT_PAGE_EXTENSIONS;\n this.#include = routeOptions.include || [];\n this.#exclude = routeOptions.exclude || [];\n this.#defaultLang = userConfig?.lang || '';\n this.#langs = (\n userConfig?.locales ??\n userConfig?.themeConfig?.locales ??\n []\n ).map(item => item.lang);\n this.#base = userConfig?.base || '';\n this.#tempDir = tempDir;\n this.#pluginDriver = pluginDriver;\n\n if (userConfig.multiVersion) {\n this.#defaultVersion = userConfig.multiVersion.default || '';\n this.#versions = userConfig.multiVersion.versions || [];\n }\n }\n\n async init() {\n const globby = (\n await import(\n // @ts-expect-error\n // eslint-disable-next-line node/file-extension-in-import\n '../compiled/globby/index.js'\n )\n ).default as typeof import('../../../compiled/globby');\n // 1. internal pages\n const files = globby\n .sync([`**/*.{${this.#extensions.join(',')}}`, ...this.#include], {\n cwd: this.#scanDir,\n absolute: true,\n ignore: [\n ...this.#exclude,\n '**/node_modules/**',\n '**/.eslintrc.js',\n '**/.nx-cache/**',\n ],\n })\n .sort();\n files.forEach(filePath => {\n const fileRelativePath = normalizePath(\n path.relative(this.#scanDir, filePath),\n );\n const { routePath, lang, version } = normalizeRoutePath(\n fileRelativePath,\n this.#base,\n this.#defaultLang,\n this.#defaultVersion,\n this.#langs,\n this.#versions,\n );\n const absolutePath = path.join(this.#scanDir, fileRelativePath);\n\n const routeInfo = {\n routePath,\n absolutePath: normalizePath(absolutePath),\n relativePath: fileRelativePath,\n pageName: getPageKey(fileRelativePath),\n lang,\n version,\n };\n this.addRoute(routeInfo);\n });\n // 2. external pages added by plugins\n const externalPages = await this.#pluginDriver.addPages();\n\n await Promise.all(\n externalPages.map(async (route, index) => {\n const { routePath, content, filepath } = route;\n // case1: specify the filepath\n if (filepath) {\n const routeInfo = this.#generateRouteInfo(routePath, filepath);\n this.addRoute(routeInfo);\n return;\n }\n // case2: specify the content\n if (content) {\n const filepath = await this.#writeTempFile(index, content);\n const routeInfo = this.#generateRouteInfo(routePath, filepath);\n this.addRoute(routeInfo);\n }\n }),\n );\n\n await this.#pluginDriver.routeGenerated(this.getRoutes());\n }\n\n addRoute(routeInfo: RouteMeta) {\n const { routePath, absolutePath } = routeInfo;\n if (this.routeData.has(routePath)) {\n // apply the one with the extension listed first in the array and skip the rest.\n const preRouteExtIndex = this.#extensions.indexOf(\n path.extname(this.routeData.get(routePath)!.absolutePath).slice(1),\n );\n const currRouteExtIndex = this.#extensions.indexOf(\n path.extname(absolutePath).slice(1),\n );\n\n if (\n currRouteExtIndex !== -1 &&\n (currRouteExtIndex < preRouteExtIndex || preRouteExtIndex === -1)\n ) {\n this.routeData.set(routePath, routeInfo);\n }\n } else {\n this.routeData.set(routePath, routeInfo);\n }\n }\n\n removeRoute(filePath: string) {\n const fileRelativePath = path.relative(this.#scanDir, filePath);\n const { routePath } = this.#normalizeRoutePath(fileRelativePath);\n this.routeData.delete(routePath);\n }\n\n getRoutes() {\n return Array.from(this.routeData.values());\n }\n\n isExistRoute(routePath: string) {\n const { routePath: normalizedRoute } = this.#normalizeRoutePath(routePath);\n return this.routeData.get(normalizedRoute);\n }\n\n isEmpty() {\n return this.routeData.size === 0;\n }\n\n generateRoutesCode(isStaticImport = false) {\n return this.generateRoutesCodeByRouteMeta(this.getRoutes(), isStaticImport);\n }\n\n generateRoutesCodeByRouteMeta(\n routeMeta: RouteMeta[],\n isStaticImport: boolean,\n ) {\n // TODO: webpackChunkName need fix https://github.com/web-infra-dev/rspack/issues/4664\n\n return `\nimport React from 'react';\nimport { lazyWithPreload } from \"react-lazy-with-preload\";\n${routeMeta\n .map((route, index) => {\n return isStaticImport\n ? `import * as Route${index} from '${route.absolutePath}';`\n : `const Route${index} = lazyWithPreload(() => import('${route.absolutePath}'))`;\n })\n .join('\\n')}\nexport const routes = [\n${routeMeta\n .map((route, index) => {\n // In ssr, we don't need to import component dynamically.\n const preload = isStaticImport\n ? `() => Route${index}`\n : `async () => {\n await Route${index}.preload();\n return import(\"${route.absolutePath}\");\n }`;\n const component = isStaticImport\n ? `Route${index}.default`\n : `Route${index}`;\n /**\n * For SSR, example:\n * {\n * route: '/',\n * element: jsx(Route0),\n * preload: Route0.preload,\n * filePath: '/Users/xxx/xxx/index.md'\n * }\n *\n * For client render, example:\n * {\n * route: '/',\n * element: jsx(Route0.default),\n * preload: Route0.preload,\n * filePath: '/Users/xxx/xxx/index.md'\n * }\n */\n return `{ path: '${route.routePath}', element: React.createElement(${component}), filePath: '${route.relativePath}', preload: ${preload}, lang: '${route.lang}', version: '${route.version}' }`;\n })\n .join(',\\n')}\n];\n`;\n }\n\n async #writeTempFile(index: number, content: string) {\n const tempFilePath = path.join(this.#tempDir, `temp-${index}.mdx`);\n await fs.writeFile(tempFilePath, content);\n return tempFilePath;\n }\n\n #generateRouteInfo(routePath: string, filepath: string): RouteMeta {\n const {\n routePath: normalizedPath,\n lang,\n version,\n } = this.#normalizeRoutePath(routePath);\n return {\n routePath: normalizedPath,\n absolutePath: normalizePath(filepath),\n relativePath: normalizePath(path.relative(this.#scanDir, filepath)),\n pageName: getPageKey(routePath),\n lang,\n version,\n };\n }\n\n #normalizeRoutePath(routePath: string) {\n return normalizeRoutePath(\n routePath,\n this.#base,\n this.#defaultLang,\n this.#defaultVersion,\n this.#langs,\n this.#versions,\n );\n }\n}\n","import { UserConfig } from '@rspress/shared';\nimport { PluginDriver } from '../PluginDriver';\nimport { RouteService } from './RouteService';\n\ninterface InitOptions {\n scanDir: string;\n config: UserConfig;\n runtimeTempDir: string;\n pluginDriver: PluginDriver;\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let routeService: RouteService | null = null;\n\n// The factory to create route serveice instance\nexport async function initRouteService(options: InitOptions) {\n const { scanDir, config, runtimeTempDir, pluginDriver } = options;\n routeService = new RouteService(\n scanDir,\n config,\n runtimeTempDir,\n pluginDriver,\n );\n await routeService.init();\n return routeService;\n}\n","import type {\n UserConfig,\n PageIndexInfo,\n RspressPlugin,\n RouteMeta,\n} from '@rspress/shared';\nimport { pluginContainerSyntax } from '@rspress/plugin-container-syntax';\n\nexport class PluginDriver {\n #config: UserConfig;\n\n #plugins: RspressPlugin[];\n\n #isProd: boolean;\n\n constructor(config: UserConfig, isProd: boolean) {\n this.#config = config;\n this.#isProd = isProd;\n this.#plugins = [];\n }\n\n // The init function is used to initialize the doc plugins and will execute before the build process.\n async init() {\n // Clear RspressPlugins first, for the watch mode\n this.clearPlugins();\n const config = this.#config;\n const themeConfig = config?.themeConfig || {};\n const enableLastUpdated =\n themeConfig?.lastUpdated ||\n themeConfig?.locales?.some(locale => locale.lastUpdated);\n const mediumZoomConfig = config?.mediumZoom ?? true;\n const haveNavSidebarConfig =\n themeConfig.nav ||\n themeConfig.sidebar ||\n themeConfig.locales?.[0].nav ||\n themeConfig.locales?.[0].sidebar;\n if (enableLastUpdated) {\n const { pluginLastUpdated } = await import(\n '@rspress/plugin-last-updated'\n );\n this.addPlugin(pluginLastUpdated());\n }\n if (mediumZoomConfig) {\n const { pluginMediumZoom } = await import('@rspress/plugin-medium-zoom');\n this.addPlugin(\n pluginMediumZoom(\n typeof mediumZoomConfig === 'object' ? mediumZoomConfig : undefined,\n ),\n );\n }\n if (!haveNavSidebarConfig) {\n const { pluginAutoNavSidebar } = await import(\n '@rspress/plugin-auto-nav-sidebar'\n );\n this.addPlugin(pluginAutoNavSidebar());\n }\n\n // Support the container syntax in markdown/mdx, such as :::tip\n this.addPlugin(pluginContainerSyntax());\n\n (config.plugins || []).forEach(plugin => {\n this.addPlugin(plugin);\n });\n }\n\n addPlugin(plugin: RspressPlugin) {\n const exsitedIndex = this.#plugins.findIndex(\n item => item.name === plugin.name,\n );\n // Avoid the duplicated plugin\n if (exsitedIndex !== -1) {\n throw new Error(`The plugin \"${plugin.name}\" has been registered`);\n } else {\n this.#plugins.push(plugin);\n }\n }\n\n getPlugins() {\n return this.#plugins;\n }\n\n clearPlugins() {\n this.#plugins = [];\n }\n\n removePlugin(pluginName: string) {\n const index = this.#plugins.findIndex(item => item.name === pluginName);\n if (index !== -1) {\n this.#plugins.splice(index, 1);\n }\n }\n\n async modifyConfig() {\n let config = this.#config;\n\n for (const plugin of this.#plugins) {\n if (typeof plugin.config === 'function') {\n config = await plugin.config(\n config || {},\n {\n addPlugin: this.addPlugin.bind(this),\n removePlugin: this.removePlugin.bind(this),\n },\n this.#isProd,\n );\n }\n }\n this.#config = config;\n return this.#config;\n }\n\n async beforeBuild() {\n return this._runParallelAsyncHook(\n 'beforeBuild',\n this.#config || {},\n this.#isProd,\n );\n }\n\n async afterBuild() {\n return this._runParallelAsyncHook(\n 'afterBuild',\n this.#config || {},\n this.#isProd,\n );\n }\n\n async modifySearchIndexData(\n pages: PageIndexInfo[],\n ): Promise<PageIndexInfo[]> {\n return this._runParallelAsyncHook(\n 'modifySearchIndexData',\n pages,\n this.#isProd,\n );\n }\n\n async extendPageData(pageData: PageIndexInfo) {\n return this._runParallelAsyncHook('extendPageData', pageData, this.#isProd);\n }\n\n async addPages() {\n // addPages hooks\n const result = await this._runParallelAsyncHook(\n 'addPages',\n this.#config || {},\n this.#isProd,\n );\n return result.flat();\n }\n\n async routeGenerated(routes: RouteMeta[]) {\n return this._runParallelAsyncHook('routeGenerated', routes);\n }\n\n async addRuntimeModules() {\n const result: Record<string, string>[] = await this._runParallelAsyncHook(\n 'addRuntimeModules',\n this.#config || {},\n this.#isProd,\n );\n\n return result.reduce((prev, current) => {\n return {\n ...prev,\n ...current,\n };\n }, {});\n }\n\n async addSSGRoutes() {\n const result = await this._runParallelAsyncHook(\n 'addSSGRoutes',\n this.#config || {},\n this.#isProd,\n );\n\n return result.flat();\n }\n\n globalUIComponents(): (string | [string, object])[] {\n const result = this.#plugins.map(plugin => {\n return plugin.globalUIComponents || [];\n });\n\n return result.flat();\n }\n\n globalStyles(): string[] {\n return this.#plugins\n .filter(plugin => typeof plugin.globalStyles === 'string')\n .map(plugin => {\n return plugin.globalStyles;\n });\n }\n\n _runParallelAsyncHook(hookName: string, ...args: unknown[]) {\n return Promise.all(\n this.#plugins\n .filter(plugin => typeof plugin[hookName] === 'function')\n .map(plugin => {\n return plugin[hookName](...args);\n }),\n );\n }\n\n _runSerialAysncHook(hookName: string, ...args: unknown[]) {\n return this.#plugins.reduce(async (prev, plugin) => {\n if (typeof plugin[hookName] === 'function') {\n await prev;\n return plugin[hookName](...args);\n }\n return prev;\n }, Promise.resolve());\n }\n}\n","import { dirname, join } from 'path';\nimport { pathToFileURL } from 'url';\nimport { HelmetData } from 'react-helmet-async';\nimport chalk from '@rspress/shared/chalk';\nimport fs from '@rspress/shared/fs-extra';\nimport {\n PageData,\n UserConfig,\n APPEARANCE_KEY,\n normalizeSlash,\n withBase,\n isDebugMode,\n} from '@rspress/shared';\nimport { logger } from '@rspress/shared/logger';\nimport {\n OUTPUT_DIR,\n APP_HTML_MARKER,\n HEAD_MARKER,\n HTML_START_TAG,\n BODY_START_TAG,\n PUBLIC_DIR,\n TEMP_DIR,\n} from './constants';\nimport { initRsbuild } from './initRsbuild';\nimport { writeSearchIndex } from './searchIndex';\nimport { PluginDriver } from './PluginDriver';\nimport type { Route } from '@/node/route/RouteService';\nimport { routeService } from '@/node/route/init';\n\n// In the first render, the theme will be set according to the user's system theme\nconst CHECK_DARK_LIGHT_SCRIPT = `\n<script id=\"check-dark-light\">\n;(() => {\n const saved = localStorage.getItem('${APPEARANCE_KEY}')\n const prefereDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n if (!saved || saved === 'auto' ? prefereDark : saved === 'dark') {\n document.documentElement.classList.add('dark')\n }\n})()\n</script>\n`;\n\ninterface BuildOptions {\n appDirectory: string;\n docDirectory: string;\n config: UserConfig;\n}\n\nexport async function bundle(\n docDirectory: string,\n config: UserConfig,\n pluginDriver: PluginDriver,\n enableSSG: boolean,\n) {\n try {\n const outputDir = config?.outDir ?? OUTPUT_DIR;\n if (enableSSG) {\n const [clientBuilder, ssrBuilder] = await Promise.all([\n initRsbuild(docDirectory, config, pluginDriver, false),\n initRsbuild(docDirectory, config, pluginDriver, true, {\n output: {\n distPath: {\n root: `${outputDir}/ssr`,\n },\n disableMinimize: true,\n },\n tools: {\n rspack(options) {\n options.output.filename = 'main.cjs';\n },\n },\n }),\n ]);\n await Promise.all([clientBuilder.build(), ssrBuilder.build()]);\n } else {\n // Only build client bundle\n const clientBuilder = await initRsbuild(\n docDirectory,\n config,\n pluginDriver,\n false,\n );\n await clientBuilder.build();\n }\n // Copy public dir to output folder\n const publicDir = join(docDirectory, PUBLIC_DIR);\n if (await fs.pathExists(publicDir)) {\n await fs.copy(publicDir, outputDir);\n }\n } finally {\n await writeSearchIndex(config);\n }\n}\n\nexport interface SSRBundleExports {\n render: (\n url: string,\n helmetContext: object,\n ) => Promise<{ appHtml: string; pageData: PageData }>;\n routes: Route[];\n}\n\nexport async function renderPages(\n appDirectory: string,\n config: UserConfig,\n pluginDriver: PluginDriver,\n enableSSG: boolean,\n) {\n logger.info('Rendering pages...');\n const startTime = Date.now();\n const outputPath = config?.outDir ?? join(appDirectory, OUTPUT_DIR);\n const ssrBundlePath = join(outputPath, 'ssr', 'main.cjs');\n try {\n const { default: fs } = await import('@rspress/shared/fs-extra');\n // There are two cases where we will fallback to CSR:\n // 1. ssr bundle load failed\n // 2. ssr bundle render failed\n // 3. ssg is disabled\n let render = null;\n if (enableSSG) {\n try {\n const { default: ssrExports } = await import(\n pathToFileURL(ssrBundlePath).toString()\n );\n ({ render } = ssrExports as SSRBundleExports);\n } catch (e) {\n logger.error(e);\n logger.warn(\n `Failed to load SSR bundle: ${ssrBundlePath}, fallback to CSR.`,\n );\n // fallback to csr\n }\n }\n\n const routes = routeService.getRoutes();\n const base = config?.base ?? '';\n\n // Get the html generated by builder, as the default ssr template\n const htmlTemplatePath = join(outputPath, 'index.html');\n const htmlTemplate = await fs.readFile(htmlTemplatePath, 'utf-8');\n const additionalRoutes = (await pluginDriver.addSSGRoutes()).map(route => ({\n routePath: withBase(route.path, base),\n }));\n await Promise.all(\n [...routes, ...additionalRoutes]\n .filter(route => {\n // filter the route including dynamic params\n return !route.routePath.includes(':');\n })\n .map(async route => {\n const helmetContext: HelmetData = {\n context: {},\n } as HelmetData;\n const { routePath } = route;\n let appHtml = '';\n if (render) {\n try {\n ({ appHtml } = await render(routePath, helmetContext.context));\n } catch (e) {\n logger.warn(\n `page \"${routePath}\" render error: ${e.message}, fallback to CSR.`,\n );\n // fallback to csr\n }\n }\n\n const { helmet } = helmetContext.context;\n let html = htmlTemplate\n // Don't use `string` as second param\n // To avoid some special characters transformed to the marker, such as `$&`, etc.\n .replace(APP_HTML_MARKER, () => appHtml)\n .replace(\n HEAD_MARKER,\n (config?.head || [])\n .concat([\n helmet?.title?.toString(),\n helmet?.meta?.toString(),\n helmet?.link?.toString(),\n helmet?.style?.toString(),\n helmet?.script?.toString(),\n config.themeConfig?.darkMode !== false\n ? CHECK_DARK_LIGHT_SCRIPT\n : '',\n ])\n .join(''),\n );\n if (helmet?.htmlAttributes) {\n html = html.replace(\n HTML_START_TAG,\n `${HTML_START_TAG} ${helmet?.htmlAttributes?.toString()}`,\n );\n }\n\n if (helmet?.bodyAttributes) {\n html = html.replace(\n BODY_START_TAG,\n `${BODY_START_TAG} ${helmet?.bodyAttributes?.toString()}`,\n );\n }\n\n const normalizeHtmlFilePath = (path: string) => {\n const normalizedBase = normalizeSlash(config?.base || '/');\n\n if (path.endsWith('/')) {\n return `${path}index.html`.replace(normalizedBase, '');\n }\n\n return `${path}.html`.replace(normalizedBase, '');\n };\n const fileName = normalizeHtmlFilePath(routePath);\n await fs.ensureDir(join(outputPath, dirname(fileName)));\n await fs.writeFile(join(outputPath, fileName), html);\n }),\n );\n // Remove ssr bundle\n if (!isDebugMode()) {\n await fs.remove(join(outputPath, 'ssr'));\n }\n await fs.remove(join(outputPath, 'html'));\n\n const totalTime = Date.now() - startTime;\n logger.success(`Pages rendered in ${chalk.yellow(totalTime)} ms.`);\n } catch (e) {\n logger.error(`Pages render error: ${e.stack}`);\n throw e;\n }\n}\n\nexport async function build(options: BuildOptions) {\n const { docDirectory, appDirectory, config } = options;\n const pluginDriver = new PluginDriver(config, true);\n const enableSSG = config.ssg ?? true;\n await pluginDriver.init();\n const modifiedConfig = await pluginDriver.modifyConfig();\n await pluginDriver.beforeBuild();\n\n // empty temp dir before build\n await fs.emptyDir(TEMP_DIR);\n\n await bundle(docDirectory, modifiedConfig, pluginDriver, enableSSG);\n await renderPages(appDirectory, modifiedConfig, pluginDriver, enableSSG);\n await pluginDriver.afterBuild();\n}\n","import sirv from 'sirv';\nimport compression from 'compression';\nimport polka from 'polka';\nimport type { UserConfig } from '@rspress/shared';\nimport { OUTPUT_DIR } from './constants';\n\nexport interface CLIServeOption {\n base?: string;\n rootDir?: string;\n port?: number;\n host?: string;\n}\n\ninterface ServeOptions {\n config: UserConfig;\n port?: number;\n host?: string;\n}\n\n// Serve ssg site in production\nexport async function serve(options: ServeOptions) {\n const { config, port: userPort, host: userHost } = options;\n const envPort = process.env.PORT;\n const envHost = process.env.HOST;\n const port = envPort || userPort || 4173;\n const host = envHost || userHost || 'localhost';\n const base = config?.base?.replace(/^\\//, '').replace(/\\/$/, '') || '';\n const compress = compression();\n const serve = sirv(config?.outDir || OUTPUT_DIR, {\n etag: true,\n maxAge: 31536000,\n immutable: true,\n });\n\n if (base) {\n polka()\n .use(base, compress, serve)\n .listen(port, host, (err: Error) => {\n if (err) {\n throw err;\n }\n console.log(\n `Preview server running at http://${host}:${port}/${base}/\\n`,\n );\n });\n } else {\n polka()\n .use(compress, serve)\n .listen(port, host, (err: Error) => {\n if (err) {\n throw err;\n }\n console.log(`Preview server running at http://${host}:${port}/\\n`);\n });\n }\n}\n","export * from './node';\nexport * from '@rspress/shared';\n"]}
1
+ {"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,MACE,MAAQ;AAAA,MACR,SAAW;AAAA,MACX,aAAe;AAAA,MACf,MAAQ;AAAA,MACR,YAAc;AAAA,QACZ,MAAQ;AAAA,QACR,KAAO;AAAA,QACP,WAAa;AAAA,MACf;AAAA,MACA,SAAW;AAAA,MACX,MAAQ;AAAA,MACR,iBAAiB;AAAA,MACjB,OAAS;AAAA,MACT,MAAQ;AAAA,MACR,QAAU;AAAA,MACV,SAAW;AAAA,QACT,KAAK;AAAA,UACH,OAAS;AAAA,UACT,QAAU;AAAA,QACZ;AAAA,QACA,YAAY;AAAA,QACZ,kBAAkB;AAAA,QAClB,WAAW;AAAA,UACT,SAAW;AAAA,QACb;AAAA,QACA,aAAa;AAAA,UACX,SAAW;AAAA,QACb;AAAA,MACF;AAAA,MACA,SAAW;AAAA,QACT,KAAO;AAAA,QACP,OAAS;AAAA,QACT,OAAS;AAAA,QACT,MAAQ;AAAA,QACR,QAAU;AAAA,QACV,MAAQ;AAAA,QACR,KAAO;AAAA,QACP,iBAAiB;AAAA,QACjB,oBAAoB;AAAA,QACpB,SAAW;AAAA,QACX,KAAO;AAAA,QACP,MAAQ;AAAA,QACR,SAAW;AAAA,MACb;AAAA,MACA,SAAW;AAAA,QACT,MAAQ;AAAA,MACV;AAAA,MACA,cAAgB;AAAA,QACd;AAAA,QACA;AAA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AAM,uBAAuB,EAAE,KAAK,EAAE;AAC7C,UAAM;AAAA,EACR;AACF;AAEA,eAAsB,MAAM,SAAuB;AACjD,QAAM,EAAE,cAAc,cAAc,OAAO,IAAI;AAC/C,QAAM,eAAe,IAAI,aAAa,QAAQ,IAAI;AAClD,QAAM,YAAY,OAAO,OAAO;AAChC,QAAM,aAAa,KAAK;AACxB,QAAM,iBAAiB,MAAM,aAAa,aAAa;AACvD,QAAM,aAAa,YAAY;AAG/B,QAAMb,IAAG,SAAS,QAAQ;AAE1B,QAAM,OAAO,cAAc,gBAAgB,cAAc,SAAS;AAClE,QAAM,YAAY,cAAc,gBAAgB,cAAc,SAAS;AACvE,QAAM,aAAa,WAAW;AAChC;;;ACjPA,SAAS,0BAA0B;AAWnC,eAAsB,MAAM,SAAuB;AACjD,QAAM,EAAE,QAAQ,MAAM,UAAU,MAAM,SAAS,IAAI;AACnD,QAAM,UAAU,QAAQ,IAAI;AAC5B,QAAM,UAAU,QAAQ,IAAI;AAC5B,QAAM,EAAE,cAAc,IAAI;AAC1B,QAAM,OAAO;AAAA,IACX,WAAW,YAAY,eAAe,QAAQ,QAAQ;AAAA,EACxD;AACA,QAAM,OACJ,WAAW,YAAY,eAAe,QAAQ,QAAQ;AAExD,SAAO,gBAAgB,mBAAmB,eAAe;AAAA,IACvD,QAAQ;AAAA,MACN;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AAED,QAAM,eAAe,IAAI,aAAa,QAAQ,IAAI;AAClD,QAAM,aAAa,KAAK;AAExB,QAAM,iBAAiB,MAAM,aAAa,aAAa;AAEvD,QAAM,UAAU,MAAM;AAAA,IACpB,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,QAAQ,QAAQ;AACxB;;;AC1CA,cAAc","names":["path","removeLeadingSlash","MDX_REGEXP","RSPRESS_TEMP_DIR","fs","routeService","addLeadingSlash","page","normalizeSidebar","sidebar","resolver","enhancedResolve","CachedInputFileSystem","ResolverFactory","domain","join","SEARCH_INDEX_NAME","logger","withBase","filepath","config","mergeRsbuildConfig","dirname","chalk","isDebugMode"],"sources":["../package.json","../src/node/initRsbuild.ts","../tailwind.config.ts","../src/node/constants.ts","../src/node/runtimeModule/index.ts","../src/node/runtimeModule/routeData.ts","../src/node/runtimeModule/siteData/index.ts","../src/node/runtimeModule/siteData/normalizeThemeConfig.ts","../src/node/utils/applyReplaceRules.ts","../src/node/runtimeModule/i18n.ts","../src/node/runtimeModule/siteData/extractPageData.ts","../src/node/utils/normalizePath.ts","../src/node/utils/getPageKey.ts","../src/node/utils/createHash.ts","../src/node/utils/detectReactVersion.ts","../src/node/utils/flattenMdxContent.ts","../src/node/runtimeModule/globalUIComponents.ts","../src/node/runtimeModule/globalStyles.ts","../src/node/runtimeModule/searchHooks.ts","../src/node/runtimeModule/prismLanguages.ts","../src/node/searchIndex.ts","../src/node/route/RouteService.ts","../src/node/route/init.ts","../src/node/PluginDriver.ts","../src/node/dev.ts","../src/node/build.ts","../src/node/serve.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@rspress/core\",\n \"version\": \"1.10.0\",\n \"description\": \"The Rspress Documentation Framework\",\n \"bugs\": \"https://github.com/web-infra-dev/rspress/issues\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/web-infra-dev/rspress\",\n \"directory\": \"packages/cli/core\"\n },\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"jsnext:source\": \"./src/index.ts\",\n \"types\": \"./dist/index.d.ts\",\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/node/index.js\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./dist/*\": \"./dist/*\",\n \"./package.json\": \"./package.json\",\n \"./theme\": {\n \"default\": \"./theme.ts\"\n },\n \"./runtime\": {\n \"default\": \"./runtime.ts\"\n }\n },\n \"scripts\": {\n \"dev\": \"modern build -w\",\n \"build\": \"modern build\",\n \"reset\": \"rimraf ./**/node_modules\",\n \"lint\": \"modern lint\",\n \"change\": \"modern change\",\n \"bump\": \"modern bump\",\n \"pre\": \"modern pre\",\n \"change-status\": \"modern change-status\",\n \"gen-release-note\": \"modern gen-release-note\",\n \"release\": \"modern release\",\n \"new\": \"modern new\",\n \"test\": \"vitest run --passWithNoTests\",\n \"upgrade\": \"modern upgrade\"\n },\n \"engines\": {\n \"node\": \">=14.17.6\"\n },\n \"eslintIgnore\": [\n \"node_modules/\",\n \"dist/\"\n ],\n \"dependencies\": {\n \"@loadable/component\": \"5.15.2\",\n \"@mdx-js/loader\": \"2.2.1\",\n \"@mdx-js/mdx\": \"2.2.1\",\n \"@mdx-js/react\": \"2.2.1\",\n \"@modern-js/utils\": \"2.46.0\",\n \"@rsbuild/core\": \"0.3.1\",\n \"@rsbuild/plugin-react\": \"0.3.1\",\n \"@rsbuild/plugin-svgr\": \"0.3.1\",\n \"@rspress/theme-default\": \"workspace:*\",\n \"@rspress/runtime\": \"workspace:*\",\n \"@rspress/plugin-medium-zoom\": \"workspace:*\",\n \"@rspress/plugin-last-updated\": \"workspace:*\",\n \"@rspress/plugin-auto-nav-sidebar\": \"workspace:*\",\n \"@rspress/mdx-rs\": \"0.4.3\",\n \"@rspress/plugin-container-syntax\": \"workspace:*\",\n \"@rspress/shared\": \"workspace:*\",\n \"body-scroll-lock\": \"4.0.0-beta.0\",\n \"copy-to-clipboard\": \"^3.3.3\",\n \"enhanced-resolve\": \"5.12.0\",\n \"flexsearch\": \"0.6.32\",\n \"fs-extra\": \"10.1.0\",\n \"github-slugger\": \"^2.0.0\",\n \"hast-util-from-html\": \"^1.0.0\",\n \"hast-util-heading-rank\": \"^3.0.0\",\n \"html-to-text\": \"^9.0.3\",\n \"htmr\": \"^1.0.2\",\n \"is-html\": \"^3.0.0\",\n \"lodash-es\": \"^4.17.21\",\n \"mdast-util-mdxjs-esm\": \"^1.3.0\",\n \"node-fetch\": \"3.3.0\",\n \"nprogress\": \"^0.2.0\",\n \"postcss\": \"8.4.21\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"react-helmet-async\": \"^1.3.0\",\n \"react-lazy-with-preload\": \"^2.2.1\",\n \"react-syntax-highlighter\": \"^15.5.0\",\n \"rehype-external-links\": \"^2.0.1\",\n \"rehype-stringify\": \"^9.0.3\",\n \"remark\": \"^14.0.2\",\n \"remark-gfm\": \"3.0.1\",\n \"remark-html\": \"^15.0.1\",\n \"remark-parse\": \"^10.0.1\",\n \"remark-rehype\": \"^10.1.0\",\n \"rspack-plugin-virtual-module\": \"0.1.12\",\n \"source-map\": \"0.7.4\",\n \"string-replace-loader\": \"^3.1.0\",\n \"unified\": \"^10.1.2\",\n \"unist-util-visit\": \"^4.1.1\",\n \"unist-util-visit-children\": \"^2.0.1\",\n \"yaml-front-matter\": \"^4.1.1\"\n },\n \"devDependencies\": {\n \"tailwindcss\": \"^3.2.7\",\n \"@modern-js/plugin-tailwindcss\": \"2.46.0\",\n \"@modern-js/tsconfig\": \"2.46.0\",\n \"@modern-js/types\": \"2.46.0\",\n \"@types/body-scroll-lock\": \"^3.1.0\",\n \"@types/fs-extra\": \"^9.0.13\",\n \"@types/hast\": \"^2.3.4\",\n \"@types/html-to-text\": \"^8.1.1\",\n \"@types/jest\": \"^26.0.9\",\n \"@types/lodash-es\": \"^4.17.6\",\n \"@types/mdast\": \"^3.0.10\",\n \"@types/node\": \"^14\",\n \"@types/nprogress\": \"^0.2.0\",\n \"@types/react\": \"^18\",\n \"@types/react-dom\": \"^18\",\n \"@types/yaml-front-matter\": \"^4.1.0\",\n \"husky\": \"^8\",\n \"lint-staged\": \"~13.1.0\",\n \"@biomejs/biome\": \"1.5.2\",\n \"rimraf\": \"^3.0.2\",\n \"typescript\": \"^5\",\n \"vite\": \"^4.0.5\",\n \"vitest\": \"0.33.0\",\n \"webpack\": \"^5.88.1\"\n },\n \"sideEffects\": [\n \"*.css\",\n \"*.less\",\n \"*.sass\",\n \"*.scss\",\n \"**/virtual-global-styles.js\",\n \"virtual-global-styles\",\n \"./src/theme-default/styles/index.ts\"\n ],\n \"files\": [\n \"bin\",\n \"dist\",\n \"src/runtime\",\n \"src/theme-default\",\n \"src/shared\",\n \"index.html\",\n \"runtime.ts\",\n \"theme.ts\",\n \"loader.cjs\",\n \"compiled\"\n ],\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true,\n \"registry\": \"https://registry.npmjs.org/\"\n }\n}\n","import path from 'path';\nimport {\n type UserConfig,\n removeLeadingSlash,\n MDX_REGEXP,\n RSPRESS_TEMP_DIR,\n isDebugMode,\n removeTrailingSlash,\n} from '@rspress/shared';\nimport fs from '@rspress/shared/fs-extra';\nimport type { RsbuildInstance, RsbuildConfig } from '@rsbuild/core';\nimport { tailwindConfig } from '../../tailwind.config';\nimport {\n CLIENT_ENTRY,\n SSR_ENTRY,\n PACKAGE_ROOT,\n OUTPUT_DIR,\n isProduction,\n PUBLIC_DIR,\n} from './constants';\nimport { rsbuildPluginDocVM } from './runtimeModule';\nimport { serveSearchIndexMiddleware } from './searchIndex';\nimport { detectReactVersion, resolveReactAlias } from './utils';\nimport { initRouteService } from './route/init';\nimport { PluginDriver } from './PluginDriver';\nimport { RouteService } from './route/RouteService';\n\nexport interface MdxRsLoaderCallbackContext {\n resourcePath: string;\n links: string[];\n root: string;\n base: string;\n}\n\nasync function createInternalBuildConfig(\n userDocRoot: string,\n config: UserConfig,\n isSSR: boolean,\n routeService: RouteService,\n pluginDriver: PluginDriver,\n): Promise<RsbuildConfig> {\n const cwd = process.cwd();\n const { default: fs } = await import('@rspress/shared/fs-extra');\n const CUSTOM_THEME_DIR =\n config?.themeDir ?? path.join(process.cwd(), 'theme');\n const outDir = config?.outDir ?? OUTPUT_DIR;\n const DEFAULT_THEME = require.resolve('@rspress/theme-default');\n const themeDir = (await fs.pathExists(CUSTOM_THEME_DIR))\n ? CUSTOM_THEME_DIR\n : DEFAULT_THEME;\n const checkDeadLinks = (config?.markdown?.checkDeadLinks && !isSSR) ?? false;\n const base = config?.base ?? '';\n\n // In production, we need to add assetPrefix in asset path\n const assetPrefix = isProduction()\n ? removeTrailingSlash(config?.builderConfig?.output?.assetPrefix ?? base)\n : '';\n const reactVersion = await detectReactVersion();\n\n const normalizeIcon = (icon: string | undefined) => {\n if (!icon) {\n return undefined;\n }\n\n if (path.isAbsolute(icon)) {\n return path.join(userDocRoot, PUBLIC_DIR, icon);\n }\n\n return icon;\n };\n\n // Using latest browserslist in development to improve build performance\n const browserslist = {\n web: isProduction()\n ? ['chrome >= 87', 'edge >= 88', 'firefox >= 78', 'safari >= 14']\n : [\n 'last 1 chrome version',\n 'last 1 firefox version',\n 'last 1 safari version',\n ],\n node: ['node >= 14'],\n };\n\n return {\n server: {\n port:\n !isProduction() && process.env.PORT\n ? Number(process.env.PORT)\n : undefined,\n printUrls: ({ urls }) => {\n return urls.map(url => `${url}/${removeLeadingSlash(base)}`);\n },\n publicDir: {\n name: path.join(userDocRoot, PUBLIC_DIR),\n },\n },\n dev: {\n progressBar: false,\n // Serve static files\n setupMiddlewares: [\n middlewares => {\n middlewares.unshift(serveSearchIndexMiddleware(config));\n },\n ],\n },\n html: {\n title: config?.title,\n favicon: normalizeIcon(config?.icon),\n template: path.join(PACKAGE_ROOT, 'index.html'),\n },\n output: {\n targets: isSSR ? ['node'] : ['web'],\n distPath: {\n // `root` must be a relative path in Rsbuild\n root: path.isAbsolute(outDir) ? path.relative(cwd, outDir) : outDir,\n },\n overrideBrowserslist: browserslist,\n assetPrefix,\n },\n source: {\n entry: {\n index: isSSR ? SSR_ENTRY : CLIENT_ENTRY,\n },\n alias: {\n '@mdx-js/react': require.resolve('@mdx-js/react'),\n '@theme': themeDir,\n '@/theme-default': DEFAULT_THEME,\n '@rspress/core': PACKAGE_ROOT,\n 'react-lazy-with-preload': require.resolve('react-lazy-with-preload'),\n 'react-syntax-highlighter': path.dirname(\n require.resolve('react-syntax-highlighter/package.json'),\n ),\n ...(await resolveReactAlias(reactVersion)),\n },\n include: [PACKAGE_ROOT, path.join(cwd, 'node_modules', RSPRESS_TEMP_DIR)],\n define: {\n 'process.env.__ASSET_PREFIX__': JSON.stringify(assetPrefix),\n 'process.env.__SSR__': JSON.stringify(isSSR),\n 'process.env.__IS_REACT_18__': JSON.stringify(reactVersion === 18),\n 'process.env.TEST': JSON.stringify(process.env.TEST),\n },\n },\n performance: {\n // No need to print the server bundles size\n printFileSize: !isSSR,\n },\n tools: {\n postcss(config) {\n // In debug mode, we should use tailwindcss to build the theme source code\n if (isDebugMode()) {\n try {\n config.postcssOptions.plugins.push(\n require('tailwindcss')({\n config: {\n ...tailwindConfig,\n content: [\n path.join(PACKAGE_ROOT, 'src', 'theme-default', '**/*'),\n ],\n },\n }),\n );\n } catch (e) {\n // if require tailwindcss failed, skip\n }\n }\n },\n bundlerChain(chain, { CHAIN_ID }) {\n const swcLoaderOptions = chain.module\n .rule(CHAIN_ID.RULE.JS)\n .use(CHAIN_ID.USE.SWC)\n .get('options');\n\n chain.module\n .rule('MDX')\n .type('javascript/auto')\n .test(MDX_REGEXP)\n .oneOf('MDXCompile')\n .use('builtin:swc-loader')\n .loader('builtin:swc-loader')\n .options(swcLoaderOptions)\n .end()\n .use('mdx-loader')\n .loader(require.resolve('../loader.cjs'))\n .options({\n config,\n docDirectory: userDocRoot,\n checkDeadLinks,\n routeService,\n pluginDriver,\n })\n .end()\n .use('string-replace-loader')\n .loader(require.resolve('string-replace-loader'))\n .options({\n multiple: config?.replaceRules || [],\n });\n\n if (chain.plugins.has(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH)) {\n chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).tap(options => {\n options[0] ??= {};\n options[0].include = [/\\.([cm]js|[jt]sx?|flow)$/i, MDX_REGEXP];\n return options;\n });\n }\n\n chain.resolve.extensions.prepend('.md').prepend('.mdx').prepend('.mjs');\n },\n },\n };\n}\n\nexport async function initRsbuild(\n rootDir: string,\n config: UserConfig,\n pluginDriver: PluginDriver,\n isSSR = false,\n extraRsbuildConfig?: RsbuildConfig,\n): Promise<RsbuildInstance> {\n const cwd = process.cwd();\n const userDocRoot = path.resolve(rootDir || config?.root || cwd);\n const builderPlugins = config?.builderPlugins ?? [];\n // We use a temp dir to store runtime files, so we can separate client and server build\n // and we should empty temp dir before build\n const runtimeTempDir = path.join(RSPRESS_TEMP_DIR, 'runtime');\n const runtimeAbsTempDir = path.join(cwd, 'node_modules', runtimeTempDir);\n await fs.ensureDir(runtimeAbsTempDir);\n\n const routeService = await initRouteService({\n config,\n runtimeTempDir: runtimeAbsTempDir,\n scanDir: userDocRoot,\n pluginDriver,\n });\n const {\n default: { createRsbuild, mergeRsbuildConfig },\n } = await import('@rsbuild/core');\n const { pluginReact } = await import('@rsbuild/plugin-react');\n const { pluginSvgr } = await import('@rsbuild/plugin-svgr');\n\n const internalRsbuildConfig = await createInternalBuildConfig(\n userDocRoot,\n config,\n isSSR,\n routeService,\n pluginDriver,\n );\n\n const rsbuild = await createRsbuild({\n rsbuildConfig: mergeRsbuildConfig(\n internalRsbuildConfig,\n ...(config?.plugins?.map(plugin => plugin.builderConfig ?? {}) || []),\n config?.builderConfig || {},\n extraRsbuildConfig || {},\n ),\n });\n\n rsbuild.addPlugins([\n rsbuildPluginDocVM({\n userDocRoot,\n config,\n isSSR,\n runtimeTempDir,\n routeService,\n pluginDriver,\n }),\n pluginReact(),\n pluginSvgr({\n svgDefaultExport: 'component',\n }),\n ...builderPlugins,\n ]);\n\n return rsbuild;\n}\n","import { Config } from 'tailwindcss';\n\nexport const tailwindConfig: Config = {\n content: [],\n darkMode: 'class',\n theme: {\n backgroundColor: ctx => ({\n ...ctx.theme('colors'),\n white: 'var(--rp-c-bg)',\n soft: 'var(--rp-c-bg-soft)',\n mute: 'var(--rp-c-bg-mute)',\n }),\n extend: {\n borderRadius: {\n '4xl': '2rem',\n },\n breakpoints: {\n xs: '640px',\n sm: '768px',\n md: '960px',\n lg: '1280px',\n },\n maxWidth: {\n '60': '15rem',\n },\n maxHeight: {\n '60': '15rem',\n },\n colors: {\n brand: {\n DEFAULT: 'var(--rp-c-brand)',\n light: 'var(--rp-c-brand-light)',\n dark: 'var(--rp-c-brand-dark)',\n lighter: 'var(--rp-c-brand-lighter)',\n darker: 'var(--rp-c-brand-darker)',\n },\n text: {\n 1: 'var(--rp-c-text-1)',\n 2: 'var(--rp-c-text-2)',\n 3: 'var(--rp-c-text-3)',\n 4: 'var(--rp-c-text-4)',\n },\n divider: {\n DEFAULT: 'var(--rp-c-divider)',\n light: 'var(--rp-c-divider-light)',\n dark: 'var(--rp-c-divider-dark)',\n },\n gray: {\n light: {\n 1: 'var(--rp-c-gray-light-1)',\n 2: 'var(--rp-c-gray-light-2)',\n 3: 'var(--rp-c-gray-light-3)',\n 4: 'var(--rp-c-gray-light-4)',\n 5: 'var(--rp-c-gray-light-5)',\n },\n },\n dark: {\n light: {\n 1: 'var(--rp-c-dark-light-1)',\n 2: 'var(--rp-c-dark-light-2)',\n 3: 'var(--rp-c-dark-light-3)',\n 4: 'var(--rp-c-dark-light-4)',\n 5: 'var(--rp-c-dark-light-5)',\n },\n },\n },\n },\n },\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 { UserConfig } from '@rspress/shared';\nimport type { RsbuildPlugin } from '@rsbuild/core';\nimport { RspackVirtualModulePlugin } from 'rspack-plugin-virtual-module';\nimport { RouteService } from '../route/RouteService';\nimport { PluginDriver } from '../PluginDriver';\nimport { routeVMPlugin } from './routeData';\nimport { siteDataVMPlugin } from './siteData/index';\nimport { i18nVMPlugin } from './i18n';\nimport { globalUIComponentsVMPlugin } from './globalUIComponents';\nimport { globalStylesVMPlugin } from './globalStyles';\nimport { searchHookVMPlugin } from './searchHooks';\nimport { prismLanguageVMPlugin } from './prismLanguages';\n\nexport interface FactoryContext {\n userDocRoot: string;\n config: UserConfig;\n isSSR: boolean;\n runtimeTempDir: string;\n alias: Record<string, string | string[]>;\n routeService: RouteService;\n pluginDriver: PluginDriver;\n}\n\ntype RuntimeModuleFactory = (\n context: FactoryContext,\n) => Record<string, string> | Promise<Record<string, string>>;\n\nexport const runtimeModuleFactory: RuntimeModuleFactory[] = [\n /**\n * Generate route data for client and server runtime\n */\n routeVMPlugin,\n /**\n * Generate search index and site data for client runtime\n */\n siteDataVMPlugin,\n /**\n * Generate global components from config and plugins\n */\n globalUIComponentsVMPlugin,\n /**\n * Generate global styles from config and plugins\n */\n globalStylesVMPlugin,\n /**\n * Generate i18n text for client runtime\n */\n i18nVMPlugin,\n /**\n * Generate search hook module\n */\n searchHookVMPlugin,\n /**\n * Generate prism languages module\n */\n prismLanguageVMPlugin,\n];\n\n// We will use this plugin to generate runtime module in browser, which is important to ensure the client have access to some compile-time data\n// TODO: We can separate the compile-time data generation and runtime module generation logic instead of putting them together(such as `siteDataVMPlugin` plugin, it does too much thing) to make it more clear\nexport function rsbuildPluginDocVM(\n factoryContext: Omit<FactoryContext, 'alias'>,\n): RsbuildPlugin {\n const { pluginDriver } = factoryContext;\n return {\n name: 'rsbuild-plugin-doc-vm',\n setup(api) {\n api.modifyBundlerChain(async bundlerChain => {\n // The order should be sync\n const alias = bundlerChain.resolve.alias.entries();\n const runtimeModule: Record<string, string> = {};\n // Add internal runtime module\n for (const factory of runtimeModuleFactory) {\n const moduleResult = await factory({\n ...factoryContext,\n alias,\n });\n Object.assign(runtimeModule, moduleResult);\n }\n // Add runtime module from outer plugins\n const modulesByPlugin = await pluginDriver.addRuntimeModules();\n Object.keys(modulesByPlugin).forEach(key => {\n if (runtimeModule[key]) {\n throw new Error(\n `The runtime module ${key} is duplicated, please check your plugin`,\n );\n }\n runtimeModule[key] = modulesByPlugin[key];\n });\n bundlerChain\n .plugin(`rspress-runtime-module`)\n .use(\n new RspackVirtualModulePlugin(\n runtimeModule,\n factoryContext.runtimeTempDir,\n ),\n );\n });\n },\n };\n}\n\nexport enum RuntimeModuleID {\n GlobalStyles = 'virtual-global-styles',\n GlobalComponents = 'virtual-global-components',\n RouteForClient = 'virtual-routes',\n RouteForSSR = 'virtual-routes-ssr',\n SiteData = 'virtual-site-data',\n SearchIndexHash = 'virtual-search-index-hash',\n I18nText = 'virtual-i18n-text',\n SearchHooks = 'virtual-search-hooks',\n PrismLanguages = 'virtual-prism-languages',\n}\n\nexport const runtimeModuleIDs = [\n RuntimeModuleID.GlobalStyles,\n RuntimeModuleID.GlobalComponents,\n RuntimeModuleID.RouteForClient,\n RuntimeModuleID.RouteForSSR,\n RuntimeModuleID.SiteData,\n RuntimeModuleID.SearchIndexHash,\n RuntimeModuleID.I18nText,\n RuntimeModuleID.SearchHooks,\n RuntimeModuleID.PrismLanguages,\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 { PageIndexInfo, SEARCH_INDEX_NAME } from '@rspress/shared';\nimport fs from '@rspress/shared/fs-extra';\nimport { FactoryContext, RuntimeModuleID } from '..';\nimport { normalizeThemeConfig } from './normalizeThemeConfig';\nimport { extractPageData } from './extractPageData';\nimport { createHash } from '@/node/utils';\nimport { TEMP_DIR } from '@/node/constants';\n\n// How can we let the client runtime access the `indexHash`?\n// We can only do something after the Rspack build process becuase the index hash is generated within Rspack build process.There are two ways to do this:\n// 1. insert window.__INDEX_HASH__ = 'xxx' into the html template manually\n// 2. replace the `__INDEX_HASH__` placeholder in the html template with the real index hash after Rspack build\nexport const indexHash = '';\n\nfunction deletePriviteKey<T>(obj: T): T {\n if (typeof obj !== 'object' || obj === null) {\n return obj;\n }\n const newObj = { ...obj };\n Object.keys(newObj).forEach(key => {\n if (key.startsWith('_')) {\n delete newObj[key];\n }\n });\n return newObj;\n}\n\nexport async function siteDataVMPlugin(context: FactoryContext) {\n const { config, alias, userDocRoot, routeService, pluginDriver } = context;\n const userConfig = config;\n const replaceRules = userConfig?.replaceRules || [];\n // If the dev server restart when config file, we will reuse the siteData instead of extracting the siteData from source files again.\n const domain =\n userConfig?.search && userConfig?.search?.mode === 'remote'\n ? userConfig?.search.domain ?? ''\n : '';\n const pages = (\n await extractPageData(\n replaceRules,\n alias,\n domain,\n userDocRoot,\n routeService,\n )\n ).filter(Boolean);\n // modify page index by plugins\n await pluginDriver.modifySearchIndexData(pages);\n\n // Categorize pages, sorted by language, and write search index to file\n const pagesByLang = pages.reduce((acc, page) => {\n if (!acc[page.lang]) {\n acc[page.lang] = [];\n }\n if (page.frontmatter?.pageType === 'home') {\n return acc;\n }\n acc[page.lang].push(page);\n return acc;\n }, {} as Record<string, PageIndexInfo[]>);\n\n const indexHashByLang = {} as Record<string, string>;\n\n // Generate search index by different languages, file name is {SEARCH_INDEX_NAME}.{lang}.{hash}.json\n await Promise.all(\n Object.keys(pagesByLang).map(async lang => {\n // Avoid writing filepath in compile-time\n const stringfiedIndex = JSON.stringify(\n pagesByLang[lang].map(deletePriviteKey),\n );\n const indexHash = createHash(stringfiedIndex);\n indexHashByLang[lang] = indexHash;\n await fs.ensureDir(TEMP_DIR);\n await fs.writeFile(\n path.join(\n TEMP_DIR,\n `${SEARCH_INDEX_NAME}${lang ? `.${lang}` : ''}.${indexHash}.json`,\n ),\n stringfiedIndex,\n );\n }),\n );\n\n // Run extendPageData hook in plugins\n await Promise.all(\n pages.map(async pageData => pluginDriver.extendPageData(pageData)),\n );\n\n const siteData = {\n title: userConfig?.title || '',\n description: userConfig?.description || '',\n icon: userConfig?.icon || '',\n route: userConfig?.route,\n themeConfig: normalizeThemeConfig(userConfig, pages),\n base: userConfig?.base || '/',\n lang: userConfig?.lang || '',\n locales: userConfig?.locales || userConfig.themeConfig?.locales || [],\n logo: userConfig?.logo || '',\n ssg: userConfig?.ssg ?? true,\n multiVersion: {\n default: userConfig?.multiVersion?.default || '',\n versions: userConfig?.multiVersion?.versions || [],\n },\n search: userConfig?.search ?? { mode: 'local' },\n pages: pages.map(page => {\n const { content, id, domain, _filepath, ...rest } = page;\n return rest;\n }),\n markdown: {\n showLineNumbers: userConfig?.markdown?.showLineNumbers ?? false,\n defaultWrapCode: userConfig?.markdown?.defaultWrapCode ?? false,\n codeHighlighter: userConfig?.markdown?.codeHighlighter || 'prism',\n },\n };\n\n return {\n [`${RuntimeModuleID.SiteData}.mjs`]: `export default ${JSON.stringify(\n siteData,\n )}`,\n [RuntimeModuleID.SearchIndexHash]: `export default ${JSON.stringify(\n indexHashByLang,\n )}`,\n };\n}\n","import {\n UserConfig,\n DefaultThemeConfig,\n NormalizedDefaultThemeConfig,\n SidebarItem,\n SidebarGroup,\n NormalizedSidebarGroup,\n PageIndexInfo,\n NavItemWithLink,\n withBase,\n addLeadingSlash,\n isExternalUrl,\n withoutBase,\n NavItem,\n Sidebar,\n SidebarDivider,\n} from '@rspress/shared';\nimport { applyReplaceRules } from '../../utils/applyReplaceRules';\nimport { getI18nData } from '../i18n';\n\nexport function normalizeThemeConfig(\n docConfig: UserConfig,\n pages: PageIndexInfo[] = [],\n): NormalizedDefaultThemeConfig {\n const {\n locales: siteLocales,\n base = '',\n lang,\n replaceRules = [],\n multiVersion,\n } = docConfig;\n const { versions = [] } = multiVersion || {};\n const hasMultiVersion = versions.length > 0;\n docConfig.themeConfig = docConfig.themeConfig || {};\n const { themeConfig } = docConfig;\n const locales = siteLocales ?? (themeConfig?.locales || []);\n const i18nTextData = getI18nData(docConfig);\n // In following code, we will normalize the theme config reference to the pages data extracted from mdx files\n const normalizeLinkPrefix = (link = '', currentLang = '') => {\n if (\n !currentLang ||\n !link ||\n withoutBase(link, base).startsWith(`/${currentLang}`) ||\n isExternalUrl(link) ||\n // In multi version case, we have got the complete link prefix in `plugin-auto-nav-sidebar` and does not need to add the lang prefix\n hasMultiVersion\n ) {\n return link;\n }\n // if lang exists, we should add the lang prefix to the link\n // such /guide -> /en/guide\n return lang === currentLang\n ? link\n : `/${currentLang}${addLeadingSlash(link)}`;\n };\n\n const getI18nText = (key = '', currentLang = '') => {\n const text = i18nTextData[key]?.[currentLang];\n return text || key;\n };\n // Normalize sidebar\n const normalizeSidebar = (\n sidebar?: DefaultThemeConfig['sidebar'],\n currentLang = '',\n ): NormalizedDefaultThemeConfig['sidebar'] => {\n const normalizedSidebar: NormalizedDefaultThemeConfig['sidebar'] = {};\n if (!sidebar) {\n return {};\n }\n const normalizeSidebarItem = (\n item: SidebarGroup | SidebarItem | SidebarDivider | string,\n ): NormalizedSidebarGroup | SidebarItem | SidebarDivider => {\n if (typeof item === 'object' && 'items' in item) {\n return {\n text: applyReplaceRules(\n getI18nText(item.text, currentLang),\n replaceRules,\n ),\n link: normalizeLinkPrefix(item.link),\n collapsed: item.collapsed ?? false,\n collapsible: item.collapsible ?? true,\n tag: item.tag,\n items: item.items.map(subItem => {\n return normalizeSidebarItem(subItem);\n }),\n };\n }\n\n if (typeof item === 'object' && 'dividerType' in item) {\n return item;\n }\n\n if (typeof item === 'string') {\n const normalizedItem = normalizeLinkPrefix(item, currentLang);\n const page = pages.find(\n page => page.routePath === withBase(normalizedItem, base),\n );\n return {\n text: applyReplaceRules(page?.title || '', replaceRules),\n link: normalizedItem,\n };\n }\n\n return {\n text: applyReplaceRules(\n getI18nText(item.text, currentLang),\n replaceRules,\n ),\n link: normalizeLinkPrefix(item.link),\n tag: item.tag,\n };\n };\n\n const normalizeSidebar = (sidebar: Sidebar) => {\n Object.keys(sidebar).forEach(key => {\n const value = sidebar[key];\n normalizedSidebar[key] = value.map(normalizeSidebarItem);\n });\n };\n\n normalizeSidebar(sidebar);\n\n return normalizedSidebar;\n };\n\n const normalizeNav = (\n nav?: DefaultThemeConfig['nav'],\n currentLang?: string,\n ) => {\n if (!nav) {\n return [];\n }\n const transformNavItem = (navItem: NavItem) => {\n const text = applyReplaceRules(\n getI18nText(navItem.text, currentLang),\n replaceRules,\n );\n if ('link' in navItem) {\n return {\n ...navItem,\n text,\n link: normalizeLinkPrefix(navItem.link, currentLang),\n };\n }\n\n if ('items' in navItem) {\n return {\n ...navItem,\n text,\n items: navItem.items.map((item: NavItemWithLink) => {\n return {\n ...item,\n text: applyReplaceRules(\n getI18nText(item.text, currentLang),\n replaceRules,\n ),\n link: normalizeLinkPrefix(item.link, currentLang),\n };\n }),\n };\n }\n\n return navItem;\n };\n\n if (Array.isArray(nav)) {\n return nav.map(transformNavItem);\n }\n\n // Multi version case\n return Object.entries(nav).reduce((acc, [key, value]) => {\n acc[key] = value.map(transformNavItem);\n return acc;\n }, {});\n };\n\n /**\n * There are two place the user will define the locales:\n * 1. in the `doc.locales` (the site config)\n * 2. in the `doc.themeConfig.locales`\n * The locales in the theme config will override the locales in the site config.\n *\n * For nav and sidebar, we prefer the locales in the `themeConfig.nav` and `themeConfig.sidebar` if it exists. And the frameowork will generate complete nav and sidebar for each locale and place them in the `themeConfig.locales` field.\n */\n if (locales.length) {\n themeConfig.locales = locales.map(({ lang: currentLang, label }) => {\n const localeInThemeConfig = themeConfig.locales?.find(\n locale => locale.lang === currentLang,\n );\n return {\n lang: currentLang,\n label,\n ...(localeInThemeConfig || {}),\n sidebar: normalizeSidebar(\n localeInThemeConfig?.sidebar ?? themeConfig.sidebar,\n currentLang,\n ),\n nav: normalizeNav(\n localeInThemeConfig?.nav ?? themeConfig.nav,\n currentLang,\n ),\n };\n });\n } else {\n themeConfig.sidebar = normalizeSidebar(themeConfig?.sidebar);\n themeConfig.nav = normalizeNav(themeConfig?.nav);\n }\n return themeConfig as NormalizedDefaultThemeConfig;\n}\n","import { ReplaceRule } from '@rspress/shared';\n\nexport function applyReplaceRules(\n code = '',\n replaceRules: ReplaceRule[] = [],\n): string {\n let result = code;\n for (const rule of replaceRules) {\n result = result.replace(rule.search, rule.replace);\n }\n return result;\n}\n","import { join } from 'path';\nimport { UserConfig } from '@rspress/shared';\nimport { FactoryContext, RuntimeModuleID } from '.';\n\nconst DEFAULT_I18N_SOURCE = join(process.cwd(), 'i18n.json');\n\nexport function getI18nData(docConfig: UserConfig) {\n const { i18nSourcePath = DEFAULT_I18N_SOURCE } = docConfig;\n try {\n // eslint-disable-next-line import/no-dynamic-require\n const i18nSource = require(i18nSourcePath);\n return i18nSource;\n } catch (e) {\n return {};\n }\n}\n\nexport function i18nVMPlugin(context: FactoryContext) {\n const { config } = context;\n const i18nData = getI18nData(config);\n return {\n [RuntimeModuleID.I18nText]: `export default ${JSON.stringify(i18nData)}`,\n };\n}\n","import path from 'path';\nimport {\n PageIndexInfo,\n ReplaceRule,\n Header,\n MDX_REGEXP,\n} from '@rspress/shared';\nimport { htmlToText } from 'html-to-text';\nimport fs from '@rspress/shared/fs-extra';\nimport { compile } from '@rspress/mdx-rs';\nimport { loadFrontMatter } from '@rspress/shared/node-utils';\nimport { flattenMdxContent } from '@/node/utils';\nimport { RouteService } from '@/node/route/RouteService';\nimport { applyReplaceRules } from '@/node/utils/applyReplaceRules';\nimport { importStatementRegex } from '@/node/constants';\n\nexport async function extractPageData(\n replaceRules: ReplaceRule[],\n alias: Record<string, string | string[]>,\n domain: string,\n root: string,\n routeService: RouteService,\n): Promise<(PageIndexInfo | null)[]> {\n return Promise.all(\n routeService.getRoutes().map(async (route, index) => {\n const defaultIndexInfo: PageIndexInfo = {\n id: index,\n title: '',\n content: '',\n routePath: route.routePath,\n lang: route.lang,\n toc: [],\n domain,\n frontmatter: {},\n version: route.version,\n _filepath: route.absolutePath,\n _relativePath: path.relative(root, route.absolutePath),\n };\n if (!MDX_REGEXP.test(route.absolutePath)) {\n return defaultIndexInfo;\n }\n let content: string = await fs.readFile(route.absolutePath, 'utf8');\n const { frontmatter, content: strippedFrontMatter } = loadFrontMatter(\n content,\n route.absolutePath,\n root,\n );\n\n // 1. Replace rules for frontmatter & content\n Object.keys(frontmatter).forEach(key => {\n if (typeof frontmatter[key] === 'string') {\n frontmatter[key] = applyReplaceRules(frontmatter[key], replaceRules);\n }\n });\n\n // TODO: we will find a more efficient way to do this\n const flattenContent = await flattenMdxContent(\n applyReplaceRules(strippedFrontMatter, replaceRules),\n route.absolutePath,\n alias,\n );\n\n content = flattenContent.replace(importStatementRegex, '');\n\n const {\n html,\n title,\n toc: rawToc,\n } = await compile({\n value: content,\n filepath: route.absolutePath,\n development: process.env.NODE_ENV !== 'production',\n root,\n });\n\n if (!title?.length && !frontmatter && !frontmatter.title?.length) {\n return null;\n }\n content = htmlToText(String(html), {\n wordwrap: 80,\n selectors: [\n {\n selector: 'a',\n options: {\n ignoreHref: true,\n },\n },\n {\n selector: 'img',\n format: 'skip',\n },\n {\n // Skip code blocks\n selector: 'pre > code',\n format: 'skip',\n },\n ...['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].map(tag => ({\n selector: tag,\n options: {\n uppercase: false,\n },\n })),\n ],\n tables: true,\n longWordSplit: {\n forceWrapOnLimit: true,\n },\n });\n if (content.startsWith(title)) {\n // Remove the title from the content\n content = content.slice(title.length);\n }\n\n const toc: Header[] = rawToc.map(item => {\n // If the item.id ends with '-number', we take the number\n const match = item.id.match(/-(\\d+)$/);\n let position = -1;\n if (match) {\n for (let i = 0; i < Number(match[1]); i++) {\n position = content.indexOf(`\\n${item.text}#\\n\\n`, position + 1);\n }\n }\n return {\n ...item,\n charIndex: content.indexOf(`\\n${item.text}#\\n\\n`, position + 1),\n };\n });\n\n return {\n ...defaultIndexInfo,\n title: frontmatter.title || title,\n toc,\n // Stripped frontmatter content\n content,\n frontmatter: {\n ...frontmatter,\n __content: undefined,\n },\n };\n }),\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 { removeLeadingSlash } from '@rspress/shared';\n\nexport function getPageKey(route: string) {\n const cleanRoute = removeLeadingSlash(route);\n return cleanRoute.replace(/\\//g, '_').replace(/\\.[^.]+$/, '') || 'index';\n}\n","import { createHash as createHashFunc } from 'crypto';\n\nexport function createHash(str: string) {\n return createHashFunc('sha256').update(str).digest('hex').slice(0, 8);\n}\n","import path from 'path';\nimport fs from '@rspress/shared/fs-extra';\nimport { logger } from '@rspress/shared/logger';\nimport enhancedResolve from 'enhanced-resolve';\nimport { PACKAGE_ROOT } from '../constants';\n\nconst { CachedInputFileSystem, ResolverFactory } = enhancedResolve;\n\nconst DEFAULT_REACT_VERSION = 18;\n\nexport async function detectReactVersion(): Promise<number> {\n // Detect react version from current cwd\n // return the major version of react\n // if not found, return 18\n const cwd = process.cwd();\n const reactPath = path.join(cwd, 'node_modules', 'react');\n if (await fs.pathExists(reactPath)) {\n const reactPkg = await fs.readJson(path.join(reactPath, 'package.json'));\n const version = Number(reactPkg.version.split('.')[0]);\n return version;\n } else {\n return DEFAULT_REACT_VERSION;\n }\n}\n\nexport async function resolveReactAlias(reactVersion: number) {\n const basedir =\n reactVersion === DEFAULT_REACT_VERSION ? PACKAGE_ROOT : process.cwd();\n const libPaths = [\n 'react',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n 'react-dom',\n 'react-dom/server',\n ];\n if (reactVersion === DEFAULT_REACT_VERSION) {\n libPaths.push('react-dom/client');\n }\n const alias: Record<string, string> = {};\n const resolver = ResolverFactory.createResolver({\n fileSystem: new CachedInputFileSystem(fs),\n extensions: ['.js'],\n alias,\n });\n await Promise.all(\n libPaths.map(async lib => {\n try {\n alias[lib] = await new Promise<string>((resolve, reject) => {\n resolver.resolve(\n { importer: basedir },\n basedir,\n lib,\n {},\n (err, filePath) => {\n if (err || filePath === false) {\n return reject(err);\n }\n return resolve(filePath);\n },\n );\n });\n } catch (e) {\n console.log(e);\n logger.warn(`${lib} not found`);\n }\n }),\n );\n return alias;\n}\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';\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 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 result = result.replace((node as { value: string }).value, '');\n return (node.data?.estree as { body: ImportNode[] })?.body || [];\n })\n .flat()\n .filter(node => node.type === 'ImportDeclaration');\n\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 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","import { FactoryContext, RuntimeModuleID } from '.';\n\nexport async function globalUIComponentsVMPlugin(context: FactoryContext) {\n const { config, pluginDriver } = context;\n let index = 0;\n\n const globalUIComponentsByPlugins = pluginDriver.globalUIComponents();\n const globalComponents = [\n ...(config?.globalUIComponents || []),\n ...globalUIComponentsByPlugins,\n ];\n const moduleContent = globalComponents\n .map(source => {\n const name = `Comp_${index}`;\n if (Array.isArray(source)) {\n return `import ${name} from ${JSON.stringify(source[0])};\nconst Props_${index++} = ${JSON.stringify(source[1])};\\n`;\n } else {\n index++;\n return `import ${name} from ${JSON.stringify(source)};\\n`;\n }\n })\n .concat(\n `export default [${Array.from({ length: index }, (_, i) => {\n if (Array.isArray(globalComponents[i])) {\n return `[${`Comp_${i}`}, Props_${i}]`;\n } else {\n return `Comp_${i}`;\n }\n }).join(', ')}];`,\n )\n .join('');\n\n return {\n [RuntimeModuleID.GlobalComponents]: moduleContent,\n };\n}\n","import fs from '@rspress/shared/fs-extra';\nimport { FactoryContext, RuntimeModuleID } from '.';\n\nexport async function globalStylesVMPlugin(context: FactoryContext) {\n const { config, pluginDriver } = context;\n const globalStylesByPlugins = pluginDriver.globalStyles();\n\n if (config.globalStyles) {\n // Only patch user config global styles\n const source = config.globalStyles;\n const styleContent = await fs.readFile(source, 'utf-8');\n\n // Patch --modern-xxx, .modern-xxx global name\n const patchedStyleContent = styleContent\n .replace(/--modern-/g, '--rp-')\n .replace(/\\.modern-doc/g, '.rspress')\n .replace(/\\.modern-/g, '.rspress-');\n\n await fs.writeFile(source, patchedStyleContent, 'utf-8');\n }\n\n const moduleContent = (\n await Promise.all(\n [config?.globalStyles || '', ...globalStylesByPlugins]\n .filter(source => source.length > 0)\n .map(async source => {\n return `import ${JSON.stringify(source)};`;\n }),\n )\n ).join('');\n\n return {\n [RuntimeModuleID.GlobalStyles]: moduleContent,\n };\n}\n","import path from 'path';\nimport { FactoryContext, RuntimeModuleID } from '.';\n\nexport async function searchHookVMPlugin(context: FactoryContext) {\n const { config } = context;\n let content = 'export const onSearch = () => {};';\n let extname = '';\n if (\n typeof config.search === 'object' &&\n typeof config.search.searchHooks === 'string'\n ) {\n content = `export * from '${config.search.searchHooks}'`;\n extname = path.extname(config.search.searchHooks);\n }\n\n return {\n [`${RuntimeModuleID.SearchHooks}${extname}`]: content,\n };\n}\n","import { uniqBy } from 'lodash-es';\nimport { DEFAULT_HIGHLIGHT_LANGUAGES } from '@rspress/shared';\nimport { FactoryContext, RuntimeModuleID } from '.';\n\nexport async function prismLanguageVMPlugin(context: FactoryContext) {\n const { config } = context;\n const { highlightLanguages = [] } = config.markdown || {};\n const languageMeta = uniqBy(\n [...DEFAULT_HIGHLIGHT_LANGUAGES, ...highlightLanguages].map(language => {\n const [alias, name] = Array.isArray(language)\n ? language\n : [language, language];\n return { alias, name };\n }),\n 'alias',\n );\n\n const importStatement = languageMeta.map(language => {\n const { alias, name } = language;\n return `import ${alias} from 'react-syntax-highlighter/dist/esm/languages/prism/${name}'`;\n });\n\n const moduleContent = `\n${importStatement.join('\\n')}\n\nexport default {\n ${languageMeta.map(({ alias }) => `\"${alias}\": ${alias}`)}\n};\n`;\n return {\n [RuntimeModuleID.PrismLanguages]: moduleContent,\n };\n}\n","import path, { join } from 'path';\nimport fs from '@rspress/shared/fs-extra';\nimport chalk from '@rspress/shared/chalk';\nimport { RequestHandler } from '@modern-js/types';\nimport fetch from 'node-fetch';\nimport { UserConfig, isSCM, SEARCH_INDEX_NAME } from '@rspress/shared';\nimport { logger } from '@rspress/shared/logger';\nimport { isProduction, OUTPUT_DIR, TEMP_DIR } from './constants';\n\nexport async function writeSearchIndex(config: UserConfig) {\n if (config?.search === false) {\n return;\n }\n const cwd = process.cwd();\n // get all search index files, format is `${SEARCH_INDEX_NAME}.xxx.${hash}.json`\n const searchIndexFiles = await fs.readdir(TEMP_DIR);\n const outDir = config?.outDir ?? join(cwd, OUTPUT_DIR);\n\n // For performance, we only stitch the string of search index data instead of big JavaScript object in memory\n let searchIndexData = '[]';\n let scaning = false;\n for (const searchIndexFile of searchIndexFiles) {\n if (\n !searchIndexFile.includes(SEARCH_INDEX_NAME) ||\n !searchIndexFile.endsWith('.json')\n ) {\n continue;\n }\n const source = join(TEMP_DIR, searchIndexFile);\n const target = join(outDir, 'static', searchIndexFile);\n const searchIndex = await fs.readFile(\n join(TEMP_DIR, searchIndexFile),\n 'utf-8',\n );\n searchIndexData = `${searchIndexData.slice(0, -1)}${\n scaning ? ',' : ''\n }${searchIndex.slice(1)}`;\n await fs.move(source, target, { overwrite: true });\n scaning = true;\n }\n\n if (isProduction() && isSCM() && config?.search?.mode === 'remote') {\n const { apiUrl, indexName } = config.search;\n try {\n await fetch(`${apiUrl}?index=${indexName}`, {\n method: 'PUT',\n body: searchIndexData,\n headers: { 'Content-Type': 'application/json' },\n });\n\n logger.info(\n chalk.green(\n `[doc-tools] Search index uploaded to ${apiUrl}, indexName: ${indexName}`,\n ),\n );\n } catch (e) {\n logger.info(\n chalk.red(\n `[doc-tools] Upload search index \\`${indexName}\\` failed:\\n ${e}`,\n ),\n );\n }\n }\n}\n\nexport function serveSearchIndexMiddleware(config: UserConfig): RequestHandler {\n return (req, res, next) => {\n const searchIndexRequestMatch = `/${SEARCH_INDEX_NAME}.`;\n if (req.url?.includes(searchIndexRequestMatch)) {\n res.setHeader('Content-Type', 'application/json');\n // Get search index name from request url\n const searchIndexFile = req.url?.split('/').pop();\n const searchIndex = fs.readFileSync(\n path.join(\n process.cwd(),\n config?.outDir || OUTPUT_DIR,\n 'static',\n searchIndexFile,\n ),\n 'utf-8',\n );\n res.end(searchIndex);\n } else {\n next?.();\n }\n };\n}\n","import path from 'path';\nimport type { ComponentType } from 'react';\nimport fs from '@rspress/shared/fs-extra';\nimport { PageModule, UserConfig, RouteMeta, withBase } from '@rspress/shared';\nimport { getPageKey, normalizePath } from '../utils';\nimport { PluginDriver } from '../PluginDriver';\n\nexport const DEFAULT_PAGE_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'];\n\nexport interface Route {\n path: string;\n element: React.ReactElement;\n filePath: string;\n preload: () => Promise<PageModule<ComponentType<unknown>>>;\n lang: string;\n}\n\nexport interface RouteOptions {\n extensions?: string[];\n include?: string[];\n exclude?: string[];\n}\n\nexport const addLeadingSlash = (str: string) => {\n return str.startsWith('/') ? str : `/${str}`;\n};\n\nexport const normalizeRoutePath = (\n routePath: string,\n base: string,\n lang: string,\n version: string,\n langs: string[],\n versions: string[],\n): { routePath: string; lang: string; version: string } => {\n const hasTrailSlash = routePath.endsWith('/');\n let versionPart = '';\n let langPart = '';\n let purePathPart = '';\n const parts: string[] = routePath.split('/').filter(Boolean);\n\n if (version) {\n const versionToMatch = parts[0];\n if (versions.includes(versionToMatch)) {\n if (versionToMatch !== version) {\n versionPart = versionToMatch;\n }\n parts.shift();\n }\n }\n\n if (lang) {\n const langToMatch = parts[0];\n if (langs.includes(langToMatch)) {\n if (langToMatch !== lang) {\n langPart = langToMatch;\n }\n parts.shift();\n }\n }\n purePathPart = parts.join('/');\n\n let normalizedRoutePath = addLeadingSlash(\n [versionPart, langPart, purePathPart].filter(Boolean).join('/'),\n )\n // remove the extension\n .replace(/\\.[^.]+$/, '')\n .replace(/\\/index$/, '/');\n\n // restore the trail slash\n if (hasTrailSlash && !normalizedRoutePath.endsWith('/')) {\n normalizedRoutePath = `${normalizedRoutePath}/`;\n }\n\n return {\n routePath: withBase(normalizedRoutePath, base),\n lang: langPart || lang,\n version: versionPart || version,\n };\n};\n\nexport class RouteService {\n routeData: Map<string, RouteMeta> = new Map();\n\n #scanDir: string;\n\n #defaultLang: string;\n\n #defaultVersion: string = '';\n\n #extensions: string[] = [];\n\n #langs: string[] = [];\n\n #versions: string[] = [];\n\n #include: string[] = [];\n\n #exclude: string[] = [];\n\n #base: string = '';\n\n #tempDir: string = '';\n\n #pluginDriver: PluginDriver;\n\n constructor(\n scanDir: string,\n userConfig: UserConfig,\n tempDir: string,\n pluginDriver: PluginDriver,\n ) {\n const routeOptions = userConfig?.route || {};\n this.#scanDir = scanDir;\n this.#extensions = routeOptions.extensions || DEFAULT_PAGE_EXTENSIONS;\n this.#include = routeOptions.include || [];\n this.#exclude = routeOptions.exclude || [];\n this.#defaultLang = userConfig?.lang || '';\n this.#langs = (\n userConfig?.locales ??\n userConfig?.themeConfig?.locales ??\n []\n ).map(item => item.lang);\n this.#base = userConfig?.base || '';\n this.#tempDir = tempDir;\n this.#pluginDriver = pluginDriver;\n\n if (userConfig.multiVersion) {\n this.#defaultVersion = userConfig.multiVersion.default || '';\n this.#versions = userConfig.multiVersion.versions || [];\n }\n }\n\n async init() {\n const globby = (\n await import(\n // @ts-expect-error\n // eslint-disable-next-line node/file-extension-in-import\n '../compiled/globby/index.js'\n )\n ).default as typeof import('../../../compiled/globby');\n // 1. internal pages\n const files = globby\n .sync([`**/*.{${this.#extensions.join(',')}}`, ...this.#include], {\n cwd: this.#scanDir,\n absolute: true,\n ignore: [\n ...this.#exclude,\n '**/node_modules/**',\n '**/.eslintrc.js',\n '**/.nx-cache/**',\n ],\n })\n .sort();\n files.forEach(filePath => {\n const fileRelativePath = normalizePath(\n path.relative(this.#scanDir, filePath),\n );\n const { routePath, lang, version } = normalizeRoutePath(\n fileRelativePath,\n this.#base,\n this.#defaultLang,\n this.#defaultVersion,\n this.#langs,\n this.#versions,\n );\n const absolutePath = path.join(this.#scanDir, fileRelativePath);\n\n const routeInfo = {\n routePath,\n absolutePath: normalizePath(absolutePath),\n relativePath: fileRelativePath,\n pageName: getPageKey(fileRelativePath),\n lang,\n version,\n };\n this.addRoute(routeInfo);\n });\n // 2. external pages added by plugins\n const externalPages = await this.#pluginDriver.addPages();\n\n await Promise.all(\n externalPages.map(async (route, index) => {\n const { routePath, content, filepath } = route;\n // case1: specify the filepath\n if (filepath) {\n const routeInfo = this.#generateRouteInfo(routePath, filepath);\n this.addRoute(routeInfo);\n return;\n }\n // case2: specify the content\n if (content) {\n const filepath = await this.#writeTempFile(index, content);\n const routeInfo = this.#generateRouteInfo(routePath, filepath);\n this.addRoute(routeInfo);\n }\n }),\n );\n\n await this.#pluginDriver.routeGenerated(this.getRoutes());\n }\n\n addRoute(routeInfo: RouteMeta) {\n const { routePath, absolutePath } = routeInfo;\n if (this.routeData.has(routePath)) {\n // apply the one with the extension listed first in the array and skip the rest.\n const preRouteExtIndex = this.#extensions.indexOf(\n path.extname(this.routeData.get(routePath)!.absolutePath).slice(1),\n );\n const currRouteExtIndex = this.#extensions.indexOf(\n path.extname(absolutePath).slice(1),\n );\n\n if (\n currRouteExtIndex !== -1 &&\n (currRouteExtIndex < preRouteExtIndex || preRouteExtIndex === -1)\n ) {\n this.routeData.set(routePath, routeInfo);\n }\n } else {\n this.routeData.set(routePath, routeInfo);\n }\n }\n\n removeRoute(filePath: string) {\n const fileRelativePath = path.relative(this.#scanDir, filePath);\n const { routePath } = this.#normalizeRoutePath(fileRelativePath);\n this.routeData.delete(routePath);\n }\n\n getRoutes() {\n return Array.from(this.routeData.values());\n }\n\n isExistRoute(routePath: string) {\n const { routePath: normalizedRoute } = this.#normalizeRoutePath(routePath);\n return this.routeData.get(normalizedRoute);\n }\n\n isEmpty() {\n return this.routeData.size === 0;\n }\n\n generateRoutesCode(isStaticImport = false) {\n return this.generateRoutesCodeByRouteMeta(this.getRoutes(), isStaticImport);\n }\n\n generateRoutesCodeByRouteMeta(\n routeMeta: RouteMeta[],\n isStaticImport: boolean,\n ) {\n // TODO: webpackChunkName need fix https://github.com/web-infra-dev/rspack/issues/4664\n\n return `\nimport React from 'react';\nimport { lazyWithPreload } from \"react-lazy-with-preload\";\n${routeMeta\n .map((route, index) => {\n return isStaticImport\n ? `import * as Route${index} from '${route.absolutePath}';`\n : `const Route${index} = lazyWithPreload(() => import('${route.absolutePath}'))`;\n })\n .join('\\n')}\nexport const routes = [\n${routeMeta\n .map((route, index) => {\n // In ssr, we don't need to import component dynamically.\n const preload = isStaticImport\n ? `() => Route${index}`\n : `async () => {\n await Route${index}.preload();\n return import(\"${route.absolutePath}\");\n }`;\n const component = isStaticImport\n ? `Route${index}.default`\n : `Route${index}`;\n /**\n * For SSR, example:\n * {\n * route: '/',\n * element: jsx(Route0),\n * preload: Route0.preload,\n * filePath: '/Users/xxx/xxx/index.md'\n * }\n *\n * For client render, example:\n * {\n * route: '/',\n * element: jsx(Route0.default),\n * preload: Route0.preload,\n * filePath: '/Users/xxx/xxx/index.md'\n * }\n */\n return `{ path: '${route.routePath}', element: React.createElement(${component}), filePath: '${route.relativePath}', preload: ${preload}, lang: '${route.lang}', version: '${route.version}' }`;\n })\n .join(',\\n')}\n];\n`;\n }\n\n async #writeTempFile(index: number, content: string) {\n const tempFilePath = path.join(this.#tempDir, `temp-${index}.mdx`);\n await fs.writeFile(tempFilePath, content);\n return tempFilePath;\n }\n\n #generateRouteInfo(routePath: string, filepath: string): RouteMeta {\n const {\n routePath: normalizedPath,\n lang,\n version,\n } = this.#normalizeRoutePath(routePath);\n return {\n routePath: normalizedPath,\n absolutePath: normalizePath(filepath),\n relativePath: normalizePath(path.relative(this.#scanDir, filepath)),\n pageName: getPageKey(routePath),\n lang,\n version,\n };\n }\n\n #normalizeRoutePath(routePath: string) {\n return normalizeRoutePath(\n routePath,\n this.#base,\n this.#defaultLang,\n this.#defaultVersion,\n this.#langs,\n this.#versions,\n );\n }\n}\n","import { UserConfig } from '@rspress/shared';\nimport { PluginDriver } from '../PluginDriver';\nimport { RouteService } from './RouteService';\n\ninterface InitOptions {\n scanDir: string;\n config: UserConfig;\n runtimeTempDir: string;\n pluginDriver: PluginDriver;\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let routeService: RouteService | null = null;\n\n// The factory to create route serveice instance\nexport async function initRouteService(options: InitOptions) {\n const { scanDir, config, runtimeTempDir, pluginDriver } = options;\n routeService = new RouteService(\n scanDir,\n config,\n runtimeTempDir,\n pluginDriver,\n );\n await routeService.init();\n return routeService;\n}\n","import type {\n UserConfig,\n PageIndexInfo,\n RspressPlugin,\n RouteMeta,\n} from '@rspress/shared';\nimport { pluginContainerSyntax } from '@rspress/plugin-container-syntax';\n\nexport class PluginDriver {\n #config: UserConfig;\n\n #plugins: RspressPlugin[];\n\n #isProd: boolean;\n\n constructor(config: UserConfig, isProd: boolean) {\n this.#config = config;\n this.#isProd = isProd;\n this.#plugins = [];\n }\n\n // The init function is used to initialize the doc plugins and will execute before the build process.\n async init() {\n // Clear RspressPlugins first, for the watch mode\n this.clearPlugins();\n const config = this.#config;\n const themeConfig = config?.themeConfig || {};\n const enableLastUpdated =\n themeConfig?.lastUpdated ||\n themeConfig?.locales?.some(locale => locale.lastUpdated);\n const mediumZoomConfig = config?.mediumZoom ?? true;\n const haveNavSidebarConfig =\n themeConfig.nav ||\n themeConfig.sidebar ||\n themeConfig.locales?.[0].nav ||\n themeConfig.locales?.[0].sidebar;\n if (enableLastUpdated) {\n const { pluginLastUpdated } = await import(\n '@rspress/plugin-last-updated'\n );\n this.addPlugin(pluginLastUpdated());\n }\n if (mediumZoomConfig) {\n const { pluginMediumZoom } = await import('@rspress/plugin-medium-zoom');\n this.addPlugin(\n pluginMediumZoom(\n typeof mediumZoomConfig === 'object' ? mediumZoomConfig : undefined,\n ),\n );\n }\n if (!haveNavSidebarConfig) {\n const { pluginAutoNavSidebar } = await import(\n '@rspress/plugin-auto-nav-sidebar'\n );\n this.addPlugin(pluginAutoNavSidebar());\n }\n\n // Support the container syntax in markdown/mdx, such as :::tip\n this.addPlugin(pluginContainerSyntax());\n\n (config.plugins || []).forEach(plugin => {\n this.addPlugin(plugin);\n });\n }\n\n addPlugin(plugin: RspressPlugin) {\n const exsitedIndex = this.#plugins.findIndex(\n item => item.name === plugin.name,\n );\n // Avoid the duplicated plugin\n if (exsitedIndex !== -1) {\n throw new Error(`The plugin \"${plugin.name}\" has been registered`);\n } else {\n this.#plugins.push(plugin);\n }\n }\n\n getPlugins() {\n return this.#plugins;\n }\n\n clearPlugins() {\n this.#plugins = [];\n }\n\n removePlugin(pluginName: string) {\n const index = this.#plugins.findIndex(item => item.name === pluginName);\n if (index !== -1) {\n this.#plugins.splice(index, 1);\n }\n }\n\n async modifyConfig() {\n let config = this.#config;\n\n for (const plugin of this.#plugins) {\n if (typeof plugin.config === 'function') {\n config = await plugin.config(\n config || {},\n {\n addPlugin: this.addPlugin.bind(this),\n removePlugin: this.removePlugin.bind(this),\n },\n this.#isProd,\n );\n }\n }\n this.#config = config;\n return this.#config;\n }\n\n async beforeBuild() {\n return this._runParallelAsyncHook(\n 'beforeBuild',\n this.#config || {},\n this.#isProd,\n );\n }\n\n async afterBuild() {\n return this._runParallelAsyncHook(\n 'afterBuild',\n this.#config || {},\n this.#isProd,\n );\n }\n\n async modifySearchIndexData(\n pages: PageIndexInfo[],\n ): Promise<PageIndexInfo[]> {\n return this._runParallelAsyncHook(\n 'modifySearchIndexData',\n pages,\n this.#isProd,\n );\n }\n\n async extendPageData(pageData: PageIndexInfo) {\n return this._runParallelAsyncHook('extendPageData', pageData, this.#isProd);\n }\n\n async addPages() {\n // addPages hooks\n const result = await this._runParallelAsyncHook(\n 'addPages',\n this.#config || {},\n this.#isProd,\n );\n return result.flat();\n }\n\n async routeGenerated(routes: RouteMeta[]) {\n return this._runParallelAsyncHook('routeGenerated', routes);\n }\n\n async addRuntimeModules() {\n const result: Record<string, string>[] = await this._runParallelAsyncHook(\n 'addRuntimeModules',\n this.#config || {},\n this.#isProd,\n );\n\n return result.reduce((prev, current) => {\n return {\n ...prev,\n ...current,\n };\n }, {});\n }\n\n async addSSGRoutes() {\n const result = await this._runParallelAsyncHook(\n 'addSSGRoutes',\n this.#config || {},\n this.#isProd,\n );\n\n return result.flat();\n }\n\n globalUIComponents(): (string | [string, object])[] {\n const result = this.#plugins.map(plugin => {\n return plugin.globalUIComponents || [];\n });\n\n return result.flat();\n }\n\n globalStyles(): string[] {\n return this.#plugins\n .filter(plugin => typeof plugin.globalStyles === 'string')\n .map(plugin => {\n return plugin.globalStyles;\n });\n }\n\n _runParallelAsyncHook(hookName: string, ...args: unknown[]) {\n return Promise.all(\n this.#plugins\n .filter(plugin => typeof plugin[hookName] === 'function')\n .map(plugin => {\n return plugin[hookName](...args);\n }),\n );\n }\n\n _runSerialAysncHook(hookName: string, ...args: unknown[]) {\n return this.#plugins.reduce(async (prev, plugin) => {\n if (typeof plugin[hookName] === 'function') {\n await prev;\n return plugin[hookName](...args);\n }\n return prev;\n }, Promise.resolve());\n }\n}\n","import { UserConfig } from '@rspress/shared';\nimport { type RsbuildConfig } from '@rsbuild/core';\nimport { initRsbuild } from './initRsbuild';\nimport { writeSearchIndex } from './searchIndex';\nimport { PluginDriver } from './PluginDriver';\n\ninterface ServerInstance {\n close: () => Promise<void>;\n}\n\ninterface DevOptions {\n appDirectory: string;\n docDirectory: string;\n config: UserConfig;\n extraBuilderConfig?: RsbuildConfig;\n}\n\nexport async function dev(options: DevOptions): Promise<ServerInstance> {\n const { docDirectory, config, extraBuilderConfig } = options;\n const isProd = false;\n const pluginDriver = new PluginDriver(config, isProd);\n await pluginDriver.init();\n\n try {\n const modifiedConfig = await pluginDriver.modifyConfig();\n await pluginDriver.beforeBuild();\n\n // empty temp dir before build\n // await fs.emptyDir( TEMP_DIR);\n const builder = await initRsbuild(\n docDirectory,\n modifiedConfig,\n pluginDriver,\n false,\n extraBuilderConfig,\n );\n const { server } = await builder.startDevServer({\n // We will support the following options in the future\n getPortSilently: true,\n });\n\n await pluginDriver.afterBuild();\n return server;\n } finally {\n await writeSearchIndex(config);\n }\n}\n","import { dirname, join } from 'path';\nimport { pathToFileURL } from 'url';\nimport { HelmetData } from 'react-helmet-async';\nimport chalk from '@rspress/shared/chalk';\nimport fs from '@rspress/shared/fs-extra';\nimport {\n PageData,\n UserConfig,\n APPEARANCE_KEY,\n normalizeSlash,\n withBase,\n isDebugMode,\n} from '@rspress/shared';\nimport { logger } from '@rspress/shared/logger';\nimport {\n OUTPUT_DIR,\n APP_HTML_MARKER,\n HEAD_MARKER,\n META_GENERATOR,\n HTML_START_TAG,\n BODY_START_TAG,\n TEMP_DIR,\n} from './constants';\nimport { initRsbuild } from './initRsbuild';\nimport { writeSearchIndex } from './searchIndex';\nimport { PluginDriver } from './PluginDriver';\nimport type { Route } from '@/node/route/RouteService';\nimport { routeService } from '@/node/route/init';\n\n// In the first render, the theme will be set according to the user's system theme\nconst CHECK_DARK_LIGHT_SCRIPT = `\n<script id=\"check-dark-light\">\n;(() => {\n const saved = localStorage.getItem('${APPEARANCE_KEY}')\n const prefereDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n if (!saved || saved === 'auto' ? prefereDark : saved === 'dark') {\n document.documentElement.classList.add('dark')\n }\n})()\n</script>\n`;\n\ninterface BuildOptions {\n appDirectory: string;\n docDirectory: string;\n config: UserConfig;\n}\n\nexport async function bundle(\n docDirectory: string,\n config: UserConfig,\n pluginDriver: PluginDriver,\n enableSSG: boolean,\n) {\n try {\n const outputDir = config?.outDir ?? OUTPUT_DIR;\n if (enableSSG) {\n const [clientBuilder, ssrBuilder] = await Promise.all([\n initRsbuild(docDirectory, config, pluginDriver, false),\n initRsbuild(docDirectory, config, pluginDriver, true, {\n output: {\n distPath: {\n root: `${outputDir}/ssr`,\n },\n disableMinimize: true,\n },\n tools: {\n rspack(options) {\n options.output.filename = 'main.cjs';\n },\n },\n }),\n ]);\n await Promise.all([clientBuilder.build(), ssrBuilder.build()]);\n } else {\n // Only build client bundle\n const clientBuilder = await initRsbuild(\n docDirectory,\n config,\n pluginDriver,\n false,\n );\n await clientBuilder.build();\n }\n } finally {\n await writeSearchIndex(config);\n }\n}\n\nexport interface SSRBundleExports {\n render: (\n url: string,\n helmetContext: object,\n ) => Promise<{ appHtml: string; pageData: PageData }>;\n routes: Route[];\n}\n\nexport async function renderPages(\n appDirectory: string,\n config: UserConfig,\n pluginDriver: PluginDriver,\n enableSSG: boolean,\n) {\n logger.info('Rendering pages...');\n const startTime = Date.now();\n const outputPath = config?.outDir ?? join(appDirectory, OUTPUT_DIR);\n const ssrBundlePath = join(outputPath, 'ssr', 'main.cjs');\n try {\n const { default: fs } = await import('@rspress/shared/fs-extra');\n const { version } = await import('../../package.json');\n // There are two cases where we will fallback to CSR:\n // 1. ssr bundle load failed\n // 2. ssr bundle render failed\n // 3. ssg is disabled\n let render = null;\n if (enableSSG) {\n try {\n const { default: ssrExports } = await import(\n pathToFileURL(ssrBundlePath).toString()\n );\n ({ render } = ssrExports as SSRBundleExports);\n } catch (e) {\n logger.error(e);\n logger.warn(\n `Failed to load SSR bundle: ${ssrBundlePath}, fallback to CSR.`,\n );\n // fallback to csr\n }\n }\n\n const routes = routeService.getRoutes();\n const base = config?.base ?? '';\n\n // Get the html generated by builder, as the default ssr template\n const htmlTemplatePath = join(outputPath, 'index.html');\n const htmlTemplate = await fs.readFile(htmlTemplatePath, 'utf-8');\n const additionalRoutes = (await pluginDriver.addSSGRoutes()).map(route => ({\n routePath: withBase(route.path, base),\n }));\n await Promise.all(\n [...routes, ...additionalRoutes]\n .filter(route => {\n // filter the route including dynamic params\n return !route.routePath.includes(':');\n })\n .map(async route => {\n const helmetContext: HelmetData = {\n context: {},\n } as HelmetData;\n const { routePath } = route;\n let appHtml = '';\n if (render) {\n try {\n ({ appHtml } = await render(routePath, helmetContext.context));\n } catch (e) {\n logger.warn(\n `page \"${routePath}\" render error: ${e.message}, fallback to CSR.`,\n );\n // fallback to csr\n }\n }\n\n const { helmet } = helmetContext.context;\n let html = htmlTemplate\n // Don't use `string` as second param\n // To avoid some special characters transformed to the marker, such as `$&`, etc.\n .replace(APP_HTML_MARKER, () => appHtml)\n .replace(\n META_GENERATOR,\n () => `<meta name=\"generator\" content=\"Rspress v${version}\">`,\n )\n .replace(\n HEAD_MARKER,\n (config?.head || [])\n .concat([\n helmet?.title?.toString(),\n helmet?.meta?.toString(),\n helmet?.link?.toString(),\n helmet?.style?.toString(),\n helmet?.script?.toString(),\n config.themeConfig?.darkMode !== false\n ? CHECK_DARK_LIGHT_SCRIPT\n : '',\n ])\n .join(''),\n );\n if (helmet?.htmlAttributes) {\n html = html.replace(\n HTML_START_TAG,\n `${HTML_START_TAG} ${helmet?.htmlAttributes?.toString()}`,\n );\n }\n\n if (helmet?.bodyAttributes) {\n html = html.replace(\n BODY_START_TAG,\n `${BODY_START_TAG} ${helmet?.bodyAttributes?.toString()}`,\n );\n }\n\n const normalizeHtmlFilePath = (path: string) => {\n const normalizedBase = normalizeSlash(config?.base || '/');\n\n if (path.endsWith('/')) {\n return `${path}index.html`.replace(normalizedBase, '');\n }\n\n return `${path}.html`.replace(normalizedBase, '');\n };\n const fileName = normalizeHtmlFilePath(routePath);\n await fs.ensureDir(join(outputPath, dirname(fileName)));\n await fs.writeFile(join(outputPath, fileName), html);\n }),\n );\n // Remove ssr bundle\n if (!isDebugMode()) {\n await fs.remove(join(outputPath, 'ssr'));\n }\n await fs.remove(join(outputPath, 'html'));\n\n const totalTime = Date.now() - startTime;\n logger.success(`Pages rendered in ${chalk.yellow(totalTime)} ms.`);\n } catch (e) {\n logger.error(`Pages render error: ${e.stack}`);\n throw e;\n }\n}\n\nexport async function build(options: BuildOptions) {\n const { docDirectory, appDirectory, config } = options;\n const pluginDriver = new PluginDriver(config, true);\n const enableSSG = config.ssg ?? true;\n await pluginDriver.init();\n const modifiedConfig = await pluginDriver.modifyConfig();\n await pluginDriver.beforeBuild();\n\n // empty temp dir before build\n await fs.emptyDir(TEMP_DIR);\n\n await bundle(docDirectory, modifiedConfig, pluginDriver, enableSSG);\n await renderPages(appDirectory, modifiedConfig, pluginDriver, enableSSG);\n await pluginDriver.afterBuild();\n}\n","import type { UserConfig } from '@rspress/shared';\nimport { mergeRsbuildConfig } from '@rsbuild/core';\nimport { initRsbuild } from './initRsbuild';\nimport { PluginDriver } from './PluginDriver';\n\ninterface ServeOptions {\n config: UserConfig;\n port?: number;\n host?: string;\n}\n\n// Serve ssg site in production\nexport async function serve(options: ServeOptions) {\n const { config, port: userPort, host: userHost } = options;\n const envPort = process.env.PORT;\n const envHost = process.env.HOST;\n const { builderConfig } = config;\n const port = Number(\n envPort || userPort || builderConfig?.server?.port || 4173,\n );\n const host =\n envHost || userHost || builderConfig?.server?.host || 'localhost';\n\n config.builderConfig = mergeRsbuildConfig(builderConfig, {\n server: {\n port,\n host,\n },\n });\n\n const pluginDriver = new PluginDriver(config, true);\n await pluginDriver.init();\n\n const modifiedConfig = await pluginDriver.modifyConfig();\n\n const builder = await initRsbuild(\n config.root,\n modifiedConfig,\n pluginDriver,\n false,\n );\n\n await builder.preview();\n}\n","export * from './node';\nexport * from '@rspress/shared';\n"]}
package/dist/loader.d.ts CHANGED
@@ -59,4 +59,4 @@ interface PageMeta {
59
59
  }
60
60
  declare function mdxLoader(context: Rspack.LoaderContext<LoaderOptions>, source: string, callback: Rspack.LoaderContext['callback']): Promise<void>;
61
61
 
62
- export { PageMeta, mdxLoader as default };
62
+ export { type PageMeta, mdxLoader as default };
package/index.html CHANGED
@@ -5,6 +5,7 @@
5
5
  <meta charset="UTF-8">
6
6
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
+ <!--<?- GENERATOR ?>-->
8
9
  <!--<?- HEAD ?>-->
9
10
  </head>
10
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "1.9.3",
3
+ "version": "1.10.0",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -40,15 +40,12 @@
40
40
  "@mdx-js/loader": "2.2.1",
41
41
  "@mdx-js/mdx": "2.2.1",
42
42
  "@mdx-js/react": "2.2.1",
43
- "@modern-js/utils": "2.45.0",
44
- "@rsbuild/core": "0.2.1",
45
- "@rsbuild/plugin-react": "0.2.1",
46
- "@rsbuild/plugin-svgr": "0.2.1",
43
+ "@modern-js/utils": "2.46.0",
44
+ "@rsbuild/core": "0.3.1",
45
+ "@rsbuild/plugin-react": "0.3.1",
46
+ "@rsbuild/plugin-svgr": "0.3.1",
47
47
  "@rspress/mdx-rs": "0.4.3",
48
- "@types/compression": "^1.7.2",
49
- "@types/polka": "^0.5.4",
50
48
  "body-scroll-lock": "4.0.0-beta.0",
51
- "compression": "^1.7.4",
52
49
  "copy-to-clipboard": "^3.3.3",
53
50
  "enhanced-resolve": "5.12.0",
54
51
  "flexsearch": "0.6.32",
@@ -63,7 +60,6 @@
63
60
  "mdast-util-mdxjs-esm": "^1.3.0",
64
61
  "node-fetch": "3.3.0",
65
62
  "nprogress": "^0.2.0",
66
- "polka": "^0.5.2",
67
63
  "postcss": "8.4.21",
68
64
  "react": "^18.2.0",
69
65
  "react-dom": "^18.2.0",
@@ -78,26 +74,25 @@
78
74
  "remark-parse": "^10.0.1",
79
75
  "remark-rehype": "^10.1.0",
80
76
  "rspack-plugin-virtual-module": "0.1.12",
81
- "sirv": "^2.0.2",
82
77
  "source-map": "0.7.4",
83
78
  "string-replace-loader": "^3.1.0",
84
79
  "unified": "^10.1.2",
85
80
  "unist-util-visit": "^4.1.1",
86
81
  "unist-util-visit-children": "^2.0.1",
87
82
  "yaml-front-matter": "^4.1.1",
88
- "@rspress/theme-default": "1.9.3",
89
- "@rspress/runtime": "1.9.3",
90
- "@rspress/plugin-medium-zoom": "1.9.3",
91
- "@rspress/plugin-last-updated": "1.9.3",
92
- "@rspress/plugin-auto-nav-sidebar": "1.9.3",
93
- "@rspress/shared": "1.9.3",
94
- "@rspress/plugin-container-syntax": "1.9.3"
83
+ "@rspress/runtime": "1.10.0",
84
+ "@rspress/plugin-medium-zoom": "1.10.0",
85
+ "@rspress/plugin-last-updated": "1.10.0",
86
+ "@rspress/plugin-auto-nav-sidebar": "1.10.0",
87
+ "@rspress/theme-default": "1.10.0",
88
+ "@rspress/plugin-container-syntax": "1.10.0",
89
+ "@rspress/shared": "1.10.0"
95
90
  },
96
91
  "devDependencies": {
97
92
  "tailwindcss": "^3.2.7",
98
- "@modern-js/plugin-tailwindcss": "2.45.0",
99
- "@modern-js/tsconfig": "2.45.0",
100
- "@modern-js/types": "2.45.0",
93
+ "@modern-js/plugin-tailwindcss": "2.46.0",
94
+ "@modern-js/tsconfig": "2.46.0",
95
+ "@modern-js/types": "2.46.0",
101
96
  "@types/body-scroll-lock": "^3.1.0",
102
97
  "@types/fs-extra": "^9.0.13",
103
98
  "@types/hast": "^2.3.4",
@@ -112,7 +107,7 @@
112
107
  "@types/yaml-front-matter": "^4.1.0",
113
108
  "husky": "^8",
114
109
  "lint-staged": "~13.1.0",
115
- "prettier": "^2.6.2",
110
+ "@biomejs/biome": "1.5.2",
116
111
  "rimraf": "^3.0.2",
117
112
  "typescript": "^5",
118
113
  "vite": "^4.0.5",