@rspress/core 2.0.0-beta.1 → 2.0.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # @rspress/core
2
2
 
3
- The core package for [Rspress](https://rspress.dev).
3
+ The core package for [Rspress](https://rspress.rs).
package/dist/index.d.ts CHANGED
@@ -162,8 +162,8 @@ export declare class RouteService {
162
162
  getRoutes(): RouteMeta[];
163
163
  isExistRoute(routePath: string): boolean;
164
164
  isEmpty(): boolean;
165
- generateRoutesCode(isStaticImport?: boolean): string;
166
- generateRoutesCodeByRouteMeta(routeMeta: RouteMeta[], isStaticImport: boolean): string;
165
+ generateRoutesCode(): string;
166
+ generateRoutesCodeByRouteMeta(routeMeta: RouteMeta[]): string;
167
167
  getRoutePathParts(routePath: string): readonly [string, string, string];
168
168
  normalizeRoutePath(routePath: string): {
169
169
  routePath: string;
package/dist/index.js CHANGED
@@ -1,27 +1,26 @@
1
1
  import __rslib_shim_module__ from 'module';
2
2
  const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
3
3
  import * as __WEBPACK_EXTERNAL_MODULE__rspress_plugin_container_syntax_12d3c700__ from "@rspress/plugin-container-syntax";
4
- import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
5
4
  import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
6
5
  import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
7
- import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__ from "@rsbuild/plugin-react";
8
6
  import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
7
+ import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__ from "@rsbuild/plugin-react";
8
+ import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
9
9
  import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__ from "@rspress/shared/logger";
10
10
  import * as __WEBPACK_EXTERNAL_MODULE_picocolors__ from "picocolors";
11
11
  import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__ from "@rspress/shared/constants";
12
12
  import * as __WEBPACK_EXTERNAL_MODULE_tinyglobby__ from "tinyglobby";
13
13
  import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
14
14
  import * as __WEBPACK_EXTERNAL_MODULE_rspack_plugin_virtual_module_609978fd__ from "rspack-plugin-virtual-module";
15
+ import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__ from "@rspress/shared/node-utils";
15
16
  import * as __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__ from "lodash-es";
16
17
  import * as __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__ from "node:crypto";
17
18
  import * as __WEBPACK_EXTERNAL_MODULE__rspress_mdx_rs_d2f3021f__ from "@rspress/mdx-rs";
18
- import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__ from "@rspress/shared/node-utils";
19
19
  import * as __WEBPACK_EXTERNAL_MODULE_html_to_text_2c51ed38__ from "html-to-text";
20
20
  import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
21
21
  import * as __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__ from "@mdx-js/mdx";
22
22
  import * as __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__ from "enhanced-resolve";
23
- import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
24
- import * as __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__ from "react-helmet-async";
23
+ import * as __WEBPACK_EXTERNAL_MODULE__unhead_react_server_7e85c952__ from "@unhead/react/server";
25
24
  import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
26
25
  import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__ from "unist-util-visit";
27
26
  export * from "@rspress/shared";
@@ -37,6 +36,7 @@ class PluginDriver {
37
36
  async init() {
38
37
  this.clearPlugins();
39
38
  const config = this.#config;
39
+ const markdownConfig = config.markdown || {};
40
40
  const themeConfig = config?.themeConfig || {};
41
41
  const enableLastUpdated = themeConfig?.lastUpdated || themeConfig?.locales?.some((locale)=>locale.lastUpdated);
42
42
  const mediumZoomConfig = config?.mediumZoom ?? true;
@@ -50,13 +50,11 @@ class PluginDriver {
50
50
  this.addPlugin(pluginMediumZoom('object' == typeof mediumZoomConfig ? mediumZoomConfig : void 0));
51
51
  }
52
52
  this.addPlugin((0, __WEBPACK_EXTERNAL_MODULE__rspress_plugin_container_syntax_12d3c700__.pluginContainerSyntax)());
53
- if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isDevDebugMode)()) {
54
- const SourceBuildPlugin = await import("@rspress/theme-default/node/source-build-plugin.js").then((r)=>r.SourceBuildPlugin, ()=>null);
55
- if (SourceBuildPlugin) this.addPlugin(SourceBuildPlugin());
56
- }
53
+ const { pluginShiki } = await import("@rspress/plugin-shiki");
57
54
  (config.plugins || []).forEach((plugin)=>{
58
55
  this.addPlugin(plugin);
59
56
  });
57
+ this.addPlugin(pluginShiki(markdownConfig.shiki));
60
58
  if (!haveNavSidebarConfig) {
61
59
  const { pluginAutoNavSidebar } = await import("@rspress/plugin-auto-nav-sidebar");
62
60
  this.addPlugin(pluginAutoNavSidebar());
@@ -150,8 +148,8 @@ const PLUGIN_VIRTUAL_MODULE_NAME = 'rsbuild:virtual-module';
150
148
  const pluginVirtualModule = (pluginOptions = {})=>({
151
149
  name: PLUGIN_VIRTUAL_MODULE_NAME,
152
150
  async setup (api) {
153
- const TEMP_DIR = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(process.cwd(), 'node_modules/.rsbuild-virtual-module');
154
- const { virtualModules = {} } = pluginOptions;
151
+ const { virtualModules = {}, tempDir: virtualFolderName = '.rsbuild-virtual-module' } = pluginOptions;
152
+ const TEMP_DIR = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(api.context.rootPath, 'node_modules', virtualFolderName);
155
153
  const virtualFileAbsolutePaths = Object.keys(virtualModules).map((i)=>{
156
154
  let absolutePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(TEMP_DIR, i);
157
155
  if (!(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(absolutePath)) absolutePath = `${absolutePath}.js`;
@@ -160,6 +158,13 @@ const pluginVirtualModule = (pluginOptions = {})=>({
160
158
  absolutePath
161
159
  ];
162
160
  });
161
+ api.modifyRsbuildConfig((config)=>{
162
+ if (!config.source) config.source = {};
163
+ config.source.include = [
164
+ ...config.source.include || [],
165
+ TEMP_DIR
166
+ ];
167
+ });
163
168
  api.onBeforeCreateCompiler(async ()=>{
164
169
  await (0, __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__.mkdir)(TEMP_DIR, {
165
170
  recursive: true
@@ -177,7 +182,7 @@ const pluginVirtualModule = (pluginOptions = {})=>({
177
182
  }
178
183
  }
179
184
  });
180
- var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.1"}');
185
+ var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.11"}');
181
186
  const RSPRESS_VERSION = package_namespaceObject.i8;
182
187
  const isProduction = ()=>'production' === process.env.NODE_ENV;
183
188
  const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
@@ -199,8 +204,6 @@ const OUTPUT_DIR = 'doc_build';
199
204
  const APP_HTML_MARKER = '<!--<?- DOC_CONTENT ?>-->';
200
205
  const HEAD_MARKER = '<!--<?- HEAD ?>-->';
201
206
  const META_GENERATOR = '<!--<?- GENERATOR ?>-->';
202
- const HTML_START_TAG = '<html';
203
- const BODY_START_TAG = '<body';
204
207
  const DEFAULT_TITLE = 'Rspress';
205
208
  const PUBLIC_DIR = 'public';
206
209
  const constants_TEMP_DIR = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), 'node_modules', __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.RSPRESS_TEMP_DIR);
@@ -256,6 +259,9 @@ function hintSSGFailed() {
256
259
  function hintSSGFalse() {
257
260
  __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info('`ssg: false` detected, SSG will be disabled.');
258
261
  }
262
+ function hintReactVersion() {
263
+ __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info('[Rspress v2] Rspress support React 18 and 19, please confirm that both react and react-dom are installed in package.json with the same version. ');
264
+ }
259
265
  const isWindows = 'win32' === __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__["default"].platform();
260
266
  function slash(p) {
261
267
  return p.replace(/\\/g, '/');
@@ -410,21 +416,21 @@ class RouteService {
410
416
  isEmpty() {
411
417
  return 0 === this.routeData.size;
412
418
  }
413
- generateRoutesCode(isStaticImport = false) {
414
- return this.generateRoutesCodeByRouteMeta(this.getRoutes(), isStaticImport);
419
+ generateRoutesCode() {
420
+ return this.generateRoutesCodeByRouteMeta(this.getRoutes());
415
421
  }
416
- generateRoutesCodeByRouteMeta(routeMeta, isStaticImport) {
422
+ generateRoutesCodeByRouteMeta(routeMeta) {
417
423
  return `
418
424
  import React from 'react';
419
425
  import { lazyWithPreload } from "react-lazy-with-preload";
420
- ${routeMeta.map((route, index)=>isStaticImport ? `import * as Route${index} from '${route.absolutePath}';` : `const Route${index} = lazyWithPreload(() => import('${route.absolutePath}'))`).join('\n')}
426
+ ${routeMeta.map((route, index)=>`const Route${index} = lazyWithPreload(() => import('${route.absolutePath}'))`).join('\n')}
421
427
  export const routes = [
422
428
  ${routeMeta.map((route, index)=>{
423
- const preload = isStaticImport ? `() => Route${index}` : `async () => {
429
+ const preload = `async () => {
424
430
  await Route${index}.preload();
425
431
  return import("${route.absolutePath}");
426
432
  }`;
427
- const component = isStaticImport ? `Route${index}.default` : `Route${index}`;
433
+ const component = `Route${index}`;
428
434
  return `{ path: '${route.routePath}', element: React.createElement(${component}), filePath: '${route.relativePath}', preload: ${preload}, lang: '${route.lang}', version: '${route.version}' }`;
429
435
  }).join(',\n')}
430
436
  ];
@@ -461,32 +467,19 @@ async function initRouteService(options) {
461
467
  await pluginDriver.routeServiceGenerated(init_routeService);
462
468
  return init_routeService;
463
469
  }
470
+ function createHash(str) {
471
+ return (0, __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.createHash)('sha256').update(str).digest('hex').slice(0, 8);
472
+ }
464
473
  var types_RuntimeModuleID = /*#__PURE__*/ function(RuntimeModuleID) {
465
474
  RuntimeModuleID["GlobalStyles"] = "virtual-global-styles";
466
475
  RuntimeModuleID["GlobalComponents"] = "virtual-global-components";
467
- RuntimeModuleID["RouteForClient"] = "virtual-routes";
468
- RuntimeModuleID["RouteForSSR"] = "virtual-routes-ssr";
476
+ RuntimeModuleID["Routes"] = "virtual-routes";
469
477
  RuntimeModuleID["SiteData"] = "virtual-site-data";
470
478
  RuntimeModuleID["SearchIndexHash"] = "virtual-search-index-hash";
471
479
  RuntimeModuleID["I18nText"] = "virtual-i18n-text";
472
480
  RuntimeModuleID["SearchHooks"] = "virtual-search-hooks";
473
- RuntimeModuleID["PrismLanguages"] = "virtual-prism-languages";
474
481
  return RuntimeModuleID;
475
482
  }({});
476
- async function routeVMPlugin(context) {
477
- const { routeService, isSSR } = context;
478
- if (!isSSR) return {
479
- [types_RuntimeModuleID.RouteForClient]: routeService.generateRoutesCode(false),
480
- [types_RuntimeModuleID.RouteForSSR]: ''
481
- };
482
- return {
483
- [types_RuntimeModuleID.RouteForClient]: routeService.generateRoutesCode(false),
484
- [types_RuntimeModuleID.RouteForSSR]: routeService.generateRoutesCode(true)
485
- };
486
- }
487
- function createHash(str) {
488
- return (0, __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.createHash)('sha256').update(str).digest('hex').slice(0, 8);
489
- }
490
483
  let flattenMdxContent_resolver;
491
484
  let startFlatten = false;
492
485
  const processor = (0, __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__.createProcessor)();
@@ -674,45 +667,6 @@ async function extractPageData(replaceRules, alias, domain, root, routeService,
674
667
  }));
675
668
  return pageData.filter(Boolean);
676
669
  }
677
- const highlightLanguages_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
678
- let highlightLanguages_supportedLanguages;
679
- function handleHighlightLanguages(highlightLanguages, defaultLanguages) {
680
- const aliases = {};
681
- if (highlightLanguages.size) {
682
- if (!highlightLanguages_supportedLanguages) {
683
- const langs = highlightLanguages_require('react-syntax-highlighter/dist/cjs/languages/prism/supported-languages').default;
684
- highlightLanguages_supportedLanguages = new Set(langs);
685
- }
686
- let useDeprecatedTypeWarning = true;
687
- const names = {};
688
- [
689
- ...__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.DEFAULT_HIGHLIGHT_LANGUAGES,
690
- ...defaultLanguages
691
- ].forEach((lang)=>{
692
- if (Array.isArray(lang)) {
693
- const [alias, name] = lang;
694
- names[alias] = name;
695
- } else if (useDeprecatedTypeWarning) {
696
- console.log(`${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellowBright('warning')} Automatic import is supported. \`highlightLanguages\` is now used only as alias, and string types will be ignored. \n`);
697
- useDeprecatedTypeWarning = false;
698
- }
699
- });
700
- [
701
- ...highlightLanguages.values()
702
- ].forEach((lang)=>{
703
- const name = names[lang];
704
- if (name && highlightLanguages_supportedLanguages.has(name)) {
705
- const temp = aliases[name] || (aliases[name] = []);
706
- if (!temp.includes(lang)) temp.push(lang);
707
- highlightLanguages.delete(lang);
708
- highlightLanguages.add(name);
709
- return;
710
- }
711
- if (!highlightLanguages_supportedLanguages.has(lang)) highlightLanguages.delete(lang);
712
- });
713
- }
714
- return aliases;
715
- }
716
670
  const DEFAULT_I18N_SOURCE = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(process.cwd(), 'i18n.json');
717
671
  function getI18nData(docConfig) {
718
672
  const { i18nSourcePath = DEFAULT_I18N_SOURCE } = docConfig;
@@ -883,7 +837,7 @@ async function siteDataVMPlugin(context) {
883
837
  const siteData = {
884
838
  title: userConfig?.title || '',
885
839
  description: userConfig?.description || '',
886
- icon: userConfig?.icon || '',
840
+ icon: (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.getIconUrlPath)(userConfig?.icon) || '',
887
841
  route: userConfig?.route || {},
888
842
  themeConfig: normalizeThemeConfig(userConfig, pages),
889
843
  base: userConfig?.base || '/',
@@ -909,27 +863,16 @@ async function siteDataVMPlugin(context) {
909
863
  markdown: {
910
864
  showLineNumbers: userConfig?.markdown?.showLineNumbers ?? false,
911
865
  defaultWrapCode: userConfig?.markdown?.defaultWrapCode ?? false,
912
- codeHighlighter: userConfig?.markdown?.codeHighlighter || 'prism'
866
+ shiki: {}
913
867
  }
914
868
  };
915
- const { highlightLanguages: defaultLanguages = [] } = config.markdown || {};
916
869
  if (Array.isArray(siteData.pages[0]?.extraHighlightLanguages)) siteData.pages[0].extraHighlightLanguages.forEach((lang)=>highlightLanguages.add(lang));
917
- const aliases = handleHighlightLanguages(highlightLanguages, defaultLanguages);
918
- const sortedAliases = Object.fromEntries(Object.entries(aliases).sort());
919
- const sortedHighlightLanguages = Array.from(highlightLanguages).sort();
920
870
  return {
921
871
  [`${types_RuntimeModuleID.SiteData}.mjs`]: `export default ${JSON.stringify(siteData, null, 2)}`,
922
- [types_RuntimeModuleID.SearchIndexHash]: `export default ${JSON.stringify(indexHashByGroup, null, 2)}`,
923
- [types_RuntimeModuleID.PrismLanguages]: `export const aliases = ${JSON.stringify(sortedAliases, null, 2)};
924
- export const languages = {
925
- ${sortedHighlightLanguages.map((lang)=>`"${lang}": require(
926
- "react-syntax-highlighter/dist/cjs/languages/prism/${lang}"
927
- ).default`)}
928
- }`
872
+ [types_RuntimeModuleID.SearchIndexHash]: `export default ${JSON.stringify(indexHashByGroup, null, 2)}`
929
873
  };
930
874
  }
931
875
  const runtimeModuleFactory = [
932
- routeVMPlugin,
933
876
  siteDataVMPlugin
934
877
  ];
935
878
  function rsbuildPluginDocVM(factoryContext) {
@@ -937,14 +880,12 @@ function rsbuildPluginDocVM(factoryContext) {
937
880
  return {
938
881
  name: 'rsbuild-plugin-doc-vm',
939
882
  setup (api) {
940
- api.modifyBundlerChain(async (bundlerChain, { target })=>{
941
- const isServer = 'node' === target;
883
+ api.modifyBundlerChain(async (bundlerChain)=>{
942
884
  const alias = bundlerChain.resolve.alias.entries();
943
885
  const runtimeModule = {};
944
886
  for (const factory of runtimeModuleFactory){
945
887
  const moduleResult = await factory({
946
888
  ...factoryContext,
947
- isSSR: isServer,
948
889
  alias: alias
949
890
  });
950
891
  Object.assign(runtimeModule, moduleResult);
@@ -954,7 +895,7 @@ function rsbuildPluginDocVM(factoryContext) {
954
895
  if (runtimeModule[key]) throw new Error(`The runtime module ${key} is duplicated, please check your plugin`);
955
896
  runtimeModule[key] = modulesByPlugin[key];
956
897
  });
957
- bundlerChain.plugin('rspress-runtime-module').use(new __WEBPACK_EXTERNAL_MODULE_rspack_plugin_virtual_module_609978fd__.RspackVirtualModulePlugin(runtimeModule, factoryContext.runtimeTempDir));
898
+ bundlerChain.plugin('rspress-runtime-module').use(new __WEBPACK_EXTERNAL_MODULE_rspack_plugin_virtual_module_609978fd__.RspackVirtualModulePlugin(runtimeModule));
958
899
  });
959
900
  }
960
901
  };
@@ -994,6 +935,12 @@ const Props_${index++} = ${JSON.stringify(source[1])};\n`;
994
935
  return moduleContent;
995
936
  }
996
937
  });
938
+ const routeListVMPlugin = (context)=>{
939
+ const { routeService } = context;
940
+ return {
941
+ [types_RuntimeModuleID.Routes]: ()=>routeService.generateRoutesCode()
942
+ };
943
+ };
997
944
  const searchHookVMPlugin = (context)=>({
998
945
  [`${types_RuntimeModuleID.SearchHooks}`]: ()=>{
999
946
  const { config } = context;
@@ -1051,6 +998,97 @@ function serveSearchIndexMiddleware(config) {
1051
998
  } else next?.();
1052
999
  };
1053
1000
  }
1001
+ async function pMap(iterable, mapper, { concurrency = Number.POSITIVE_INFINITY, stopOnError = true, signal } = {}) {
1002
+ return new Promise((resolve_, reject_)=>{
1003
+ if (void 0 === iterable[Symbol.iterator] && void 0 === iterable[Symbol.asyncIterator]) throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
1004
+ if ('function' != typeof mapper) throw new TypeError('Mapper function is required');
1005
+ if (!(Number.isSafeInteger(concurrency) && concurrency >= 1 || concurrency === Number.POSITIVE_INFINITY)) throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
1006
+ const result = [];
1007
+ const errors = [];
1008
+ const skippedIndexesMap = new Map();
1009
+ let isRejected = false;
1010
+ let isResolved = false;
1011
+ let isIterableDone = false;
1012
+ let resolvingCount = 0;
1013
+ let currentIndex = 0;
1014
+ const iterator = void 0 === iterable[Symbol.iterator] ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
1015
+ const signalListener = ()=>{
1016
+ reject(signal.reason);
1017
+ };
1018
+ const cleanup = ()=>{
1019
+ signal?.removeEventListener('abort', signalListener);
1020
+ };
1021
+ const resolve = (value)=>{
1022
+ resolve_(value);
1023
+ cleanup();
1024
+ };
1025
+ const reject = (reason)=>{
1026
+ isRejected = true;
1027
+ isResolved = true;
1028
+ reject_(reason);
1029
+ cleanup();
1030
+ };
1031
+ if (signal) {
1032
+ if (signal.aborted) reject(signal.reason);
1033
+ signal.addEventListener('abort', signalListener, {
1034
+ once: true
1035
+ });
1036
+ }
1037
+ const next = async ()=>{
1038
+ if (isResolved) return;
1039
+ const nextItem = await iterator.next();
1040
+ const index = currentIndex;
1041
+ currentIndex++;
1042
+ if (nextItem.done) {
1043
+ isIterableDone = true;
1044
+ if (0 === resolvingCount && !isResolved) {
1045
+ if (!stopOnError && errors.length > 0) return void reject(new AggregateError(errors));
1046
+ isResolved = true;
1047
+ if (0 === skippedIndexesMap.size) return void resolve(result);
1048
+ const pureResult = [];
1049
+ for (const [index, value] of result.entries())if (skippedIndexesMap.get(index) !== pMapSkip) pureResult.push(value);
1050
+ resolve(pureResult);
1051
+ }
1052
+ return;
1053
+ }
1054
+ resolvingCount++;
1055
+ (async ()=>{
1056
+ try {
1057
+ const element = await nextItem.value;
1058
+ if (isResolved) return;
1059
+ const value = await mapper(element, index);
1060
+ if (value === pMapSkip) skippedIndexesMap.set(index, value);
1061
+ result[index] = value;
1062
+ resolvingCount--;
1063
+ await next();
1064
+ } catch (error) {
1065
+ if (stopOnError) reject(error);
1066
+ else {
1067
+ errors.push(error);
1068
+ resolvingCount--;
1069
+ try {
1070
+ await next();
1071
+ } catch (error) {
1072
+ reject(error);
1073
+ }
1074
+ }
1075
+ }
1076
+ })();
1077
+ };
1078
+ (async ()=>{
1079
+ for(let index = 0; index < concurrency; index++){
1080
+ try {
1081
+ await next();
1082
+ } catch (error) {
1083
+ reject(error);
1084
+ break;
1085
+ }
1086
+ if (isIterableDone || isRejected) break;
1087
+ }
1088
+ })();
1089
+ });
1090
+ }
1091
+ const pMapSkip = Symbol('skip');
1054
1092
  async function renderFrontmatterHead(route) {
1055
1093
  if (!isRouteMeta(route)) return '';
1056
1094
  const content = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(route.absolutePath, {
@@ -1113,29 +1151,24 @@ async function renderPages(routeService, config, pluginDriver, ssrBundlePath, ht
1113
1151
  if (!is404RouteInRoutes) allRoutes.push({
1114
1152
  routePath: '/404'
1115
1153
  });
1116
- await Promise.all(allRoutes.filter((route)=>!route.routePath.includes(':')).map(async (route)=>{
1117
- const helmetContext = new __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__["default"].HelmetData({});
1154
+ const filteredRoutes = allRoutes.filter((route)=>!route.routePath.includes(':'));
1155
+ await pMap(filteredRoutes, async (route)=>{
1156
+ const head = (0, __WEBPACK_EXTERNAL_MODULE__unhead_react_server_7e85c952__.createHead)();
1118
1157
  const { routePath } = route;
1119
1158
  let appHtml = '';
1120
1159
  if (render) try {
1121
- ({ appHtml } = await render(routePath, helmetContext.context));
1160
+ ({ appHtml } = await render(routePath, head));
1122
1161
  } catch (e) {
1123
- __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Page "${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(routePath)}" SSG rendering failed.`);
1124
- __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.debug(e);
1125
- throw e;
1162
+ if (e instanceof Error) {
1163
+ __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Page "${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(routePath)}" SSG rendering failed.\n ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].gray(e.toString())}`);
1164
+ throw e;
1165
+ }
1126
1166
  }
1127
- const { helmet } = helmetContext.context;
1128
- let html = htmlTemplate.replace(/<title>(.*?)<\/title>/gi, '').replace(APP_HTML_MARKER, ()=>appHtml).replace(META_GENERATOR, ()=>`<meta name="generator" content="Rspress v${RSPRESS_VERSION}">`).replace(HEAD_MARKER, [
1167
+ const replacedHtmlTemplate = htmlTemplate.replace(/<title>(.*?)<\/title>/gi, '').replace(APP_HTML_MARKER, ()=>appHtml).replace(META_GENERATOR, ()=>`<meta name="generator" content="Rspress v${RSPRESS_VERSION}">`).replace(HEAD_MARKER, [
1129
1168
  await renderConfigHead(config, route),
1130
- helmet.title.toString(),
1131
- helmet.meta.toString(),
1132
- helmet.link.toString(),
1133
- helmet.style.toString(),
1134
- helmet.script.toString(),
1135
1169
  await renderFrontmatterHead(route)
1136
1170
  ].join(''));
1137
- if (helmet.htmlAttributes) html = html.replace(HTML_START_TAG, `${HTML_START_TAG} ${helmet.htmlAttributes?.toString()}`);
1138
- if (helmet.bodyAttributes) html = html.replace(BODY_START_TAG, `${BODY_START_TAG} ${helmet.bodyAttributes?.toString()}`);
1171
+ const html = await (0, __WEBPACK_EXTERNAL_MODULE__unhead_react_server_7e85c952__.transformHtmlTemplate)(head, replacedHtmlTemplate);
1139
1172
  const normalizeHtmlFilePath = (path)=>{
1140
1173
  const normalizedBase = `${(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeSlash)(config?.base || '/')}/`;
1141
1174
  if (path.endsWith('/')) return `${path}index.html`.replace(normalizedBase, '');
@@ -1143,7 +1176,9 @@ async function renderPages(routeService, config, pluginDriver, ssrBundlePath, ht
1143
1176
  };
1144
1177
  const fileName = normalizeHtmlFilePath(routePath);
1145
1178
  emitAsset(fileName, html);
1146
- }));
1179
+ }, {
1180
+ concurrency: process.env.RSPRESS_SSG_CONCURRENCY ? Number.parseInt(process.env.RSPRESS_SSG_CONCURRENCY, 10) : 32
1181
+ });
1147
1182
  const totalTime = Date.now() - startTime;
1148
1183
  __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.success(`Pages rendered in ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(totalTime)} ms.`);
1149
1184
  } catch (e) {
@@ -1261,9 +1296,9 @@ async function resolveReactAlias(reactVersion, isSSR) {
1261
1296
  'react/jsx-runtime',
1262
1297
  'react/jsx-dev-runtime',
1263
1298
  'react-dom',
1299
+ 'react-dom/client',
1264
1300
  'react-dom/server'
1265
1301
  ];
1266
- if (reactVersion >= 18) libPaths.push('react-dom/client');
1267
1302
  const alias = {};
1268
1303
  const resolver = detectReactVersion_ResolverFactory.createResolver({
1269
1304
  fileSystem: new detectReactVersion_CachedInputFileSystem(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"], 0),
@@ -1289,7 +1324,10 @@ async function resolveReactAlias(reactVersion, isSSR) {
1289
1324
  });
1290
1325
  });
1291
1326
  } catch (e) {
1292
- __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.warn(`${lib} not found: \n`, e);
1327
+ if (e instanceof Error) {
1328
+ __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.warn(`${lib} not found: \n ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].gray(e.toString())}`);
1329
+ hintReactVersion();
1330
+ }
1293
1331
  }
1294
1332
  }));
1295
1333
  return alias;
@@ -1339,7 +1377,7 @@ function getSocialIcons(socialLinks = []) {
1339
1377
  function isPluginIncluded(config, pluginName) {
1340
1378
  return Boolean(config.builderPlugins?.some((plugin)=>plugin.name === pluginName) || config.builderConfig?.plugins?.some((plugin)=>plugin && plugin.name === pluginName));
1341
1379
  }
1342
- async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, runtimeTempDir) {
1380
+ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver) {
1343
1381
  const cwd = process.cwd();
1344
1382
  const CUSTOM_THEME_DIR = config?.themeDir ?? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), 'theme');
1345
1383
  const outDir = config?.outDir ?? OUTPUT_DIR;
@@ -1349,7 +1387,9 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1349
1387
  const reactVersion = await detectReactVersion();
1350
1388
  const normalizeIcon = (icon)=>{
1351
1389
  if (!icon) return;
1352
- if (__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(icon)) return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(userDocRoot, PUBLIC_DIR, icon);
1390
+ icon = icon.toString();
1391
+ if (icon.startsWith('file://')) icon = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(icon);
1392
+ else if (__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(icon)) return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(userDocRoot, PUBLIC_DIR, icon);
1353
1393
  return icon;
1354
1394
  };
1355
1395
  await hintThemeBreakingChange(CUSTOM_THEME_DIR);
@@ -1362,7 +1402,6 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1362
1402
  const context = {
1363
1403
  userDocRoot,
1364
1404
  config,
1365
- runtimeTempDir,
1366
1405
  routeService,
1367
1406
  pluginDriver
1368
1407
  };
@@ -1373,11 +1412,13 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1373
1412
  ],
1374
1413
  rsbuildPluginDocVM(context),
1375
1414
  pluginVirtualModule({
1415
+ tempDir: '.rspress/runtime',
1376
1416
  virtualModules: {
1377
1417
  ...i18nVMPlugin(context),
1378
1418
  ...globalUIComponentsVMPlugin(context),
1379
1419
  ...globalStylesVMPlugin(context),
1380
- ...searchHookVMPlugin(context)
1420
+ ...searchHookVMPlugin(context),
1421
+ ...routeListVMPlugin(context)
1381
1422
  }
1382
1423
  }),
1383
1424
  ...enableSSG ? [
@@ -1396,6 +1437,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1396
1437
  }
1397
1438
  },
1398
1439
  dev: {
1440
+ lazyCompilation: 'false' !== process.env.RSPRESS_LAZY_COMPILATION,
1399
1441
  progressBar: false,
1400
1442
  setupMiddlewares: [
1401
1443
  (middlewares)=>{
@@ -1434,8 +1476,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1434
1476
  ],
1435
1477
  '@theme-assets': __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(DEFAULT_THEME, '../assets'),
1436
1478
  '@rspress/core': PACKAGE_ROOT,
1437
- 'react-lazy-with-preload': require.resolve('react-lazy-with-preload'),
1438
- 'react-syntax-highlighter': __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(require.resolve('react-syntax-highlighter/package.json'))
1479
+ 'react-lazy-with-preload': require.resolve('react-lazy-with-preload')
1439
1480
  }
1440
1481
  },
1441
1482
  source: {
@@ -1444,7 +1485,6 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1444
1485
  __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(cwd, 'node_modules', __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.RSPRESS_TEMP_DIR)
1445
1486
  ],
1446
1487
  define: {
1447
- 'process.env.__REACT_GTE_18__': JSON.stringify(reactVersion >= 18),
1448
1488
  'process.env.TEST': JSON.stringify(process.env.TEST),
1449
1489
  'process.env.RSPRESS_SOCIAL_ICONS': JSON.stringify(getSocialIcons(config.themeConfig?.socialLinks))
1450
1490
  }
@@ -1493,12 +1533,6 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1493
1533
  sideEffects: true
1494
1534
  });
1495
1535
  if (isServer) chain.output.filename(NODE_SSR_BUNDLE_NAME);
1496
- const enableIncremental = !isProduction() && !process.env.DISABLE_RSPACK_INCREMENTAL;
1497
- if (enableIncremental) chain.merge({
1498
- experiments: {
1499
- incremental: true
1500
- }
1501
- });
1502
1536
  }
1503
1537
  },
1504
1538
  environments: {
@@ -1506,14 +1540,17 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1506
1540
  resolve: {
1507
1541
  alias: {
1508
1542
  ...reactCSRAlias,
1509
- ...reactRouterDomAlias,
1510
- __VIRTUAL_ROUTES__: 'virtual-routes'
1543
+ ...reactRouterDomAlias
1511
1544
  }
1512
1545
  },
1513
1546
  source: {
1514
1547
  entry: {
1515
1548
  index: enableSSG && isProduction() ? SSR_CLIENT_ENTRY : CSR_CLIENT_ENTRY
1516
1549
  },
1550
+ preEntry: [
1551
+ __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(DEFAULT_THEME, '../styles/index.js'),
1552
+ 'virtual-global-styles'
1553
+ ],
1517
1554
  define: {
1518
1555
  'process.env.__SSR__': JSON.stringify(false)
1519
1556
  }
@@ -1530,8 +1567,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1530
1567
  resolve: {
1531
1568
  alias: {
1532
1569
  ...reactSSRAlias,
1533
- ...reactRouterDomAlias,
1534
- __VIRTUAL_ROUTES__: 'virtual-routes-ssr'
1570
+ ...reactRouterDomAlias
1535
1571
  }
1536
1572
  },
1537
1573
  tools: {
@@ -1580,8 +1616,9 @@ async function initRsbuild(rootDir, config, pluginDriver, enableSSG, extraRsbuil
1580
1616
  pluginDriver
1581
1617
  });
1582
1618
  const { createRsbuild, mergeRsbuildConfig } = await import("@rsbuild/core");
1583
- const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, runtimeTempDir);
1619
+ const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver);
1584
1620
  const rsbuild = await createRsbuild({
1621
+ callerName: 'rspress',
1585
1622
  rsbuildConfig: mergeRsbuildConfig(internalRsbuildConfig, ...pluginDriver.getPlugins()?.map((plugin)=>plugin.builderConfig ?? {}) || [], config?.builderConfig || {}, extraRsbuildConfig || {})
1586
1623
  });
1587
1624
  rsbuild.addPlugins(builderPlugins);
@@ -1791,6 +1828,11 @@ const remarkPluginNormalizeLink = ({ root, cleanUrls, routeService })=>(tree, fi
1791
1828
  const relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, file.path);
1792
1829
  node.url = normalizeLink(nodeUrl, routeService, relativePath, cleanUrls);
1793
1830
  });
1831
+ (0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'definition', (node)=>{
1832
+ const { url: nodeUrl } = node;
1833
+ const relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, file.path);
1834
+ node.url = normalizeLink(nodeUrl, routeService, relativePath, cleanUrls);
1835
+ });
1794
1836
  const getMdxSrcAttribute = (tempVar)=>({
1795
1837
  type: 'mdxJsxAttribute',
1796
1838
  name: 'src',
package/dist/loader.d.ts CHANGED
@@ -7,8 +7,6 @@ import type { Rspack as Rspack_2 } from '@rsbuild/core';
7
7
  import type { RspressPlugin } from '@rspress/shared';
8
8
  import type { UserConfig } from '@rspress/shared';
9
9
 
10
- export declare function createCheckPageMetaUpdateFn(): (modulePath: string, pageMeta: PageMeta) => void;
11
-
12
10
  declare interface LoaderOptions {
13
11
  config: UserConfig;
14
12
  docDirectory: string;
@@ -66,8 +64,8 @@ declare class RouteService {
66
64
  getRoutes(): RouteMeta[];
67
65
  isExistRoute(routePath: string): boolean;
68
66
  isEmpty(): boolean;
69
- generateRoutesCode(isStaticImport?: boolean): string;
70
- generateRoutesCodeByRouteMeta(routeMeta: RouteMeta[], isStaticImport: boolean): string;
67
+ generateRoutesCode(): string;
68
+ generateRoutesCodeByRouteMeta(routeMeta: RouteMeta[]): string;
71
69
  getRoutePathParts(routePath: string): readonly [string, string, string];
72
70
  normalizeRoutePath(routePath: string): {
73
71
  routePath: string;
@@ -84,6 +82,4 @@ declare interface TocItem {
84
82
  depth: number;
85
83
  }
86
84
 
87
- export declare function updateSiteDataRuntimeModule(modulePath: string, pageMeta: PageMeta): Promise<void>;
88
-
89
85
  export { }
package/dist/loader.js CHANGED
@@ -1,127 +1,19 @@
1
1
  import __rslib_shim_module__ from 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
4
3
  import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
5
- import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
6
4
  import * as __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__ from "@mdx-js/mdx";
7
- import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
8
5
  import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__ from "@rspress/shared/logger";
9
6
  import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__ from "@rspress/shared/node-utils";
10
- import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
11
- import * as __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__ from "enhanced-resolve";
12
7
  import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
13
8
  import * as __WEBPACK_EXTERNAL_MODULE_rehype_external_links_09bed11a__ from "rehype-external-links";
9
+ import * as __WEBPACK_EXTERNAL_MODULE_rehype_raw_434f4cf9__ from "rehype-raw";
14
10
  import * as __WEBPACK_EXTERNAL_MODULE_remark_gfm_073acf21__ from "remark-gfm";
15
- import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__ from "unist-util-visit";
16
11
  import * as __WEBPACK_EXTERNAL_MODULE_github_slugger_8e9a17cb__ from "github-slugger";
17
12
  import * as __WEBPACK_EXTERNAL_MODULE_hast_util_heading_rank_cff646ba__ from "hast-util-heading-rank";
13
+ import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__ from "unist-util-visit";
14
+ import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
18
15
  import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__ from "@rspress/shared/constants";
19
16
  import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_children_71921007__ from "unist-util-visit-children";
20
- const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
21
- `{
22
- const saved = localStorage.getItem('${__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.APPEARANCE_KEY}')
23
- const preferDark = window.matchMedia('(prefers-color-scheme: dark)').matches
24
- const isDark = !saved || saved === 'auto' ? preferDark : saved === 'dark'
25
- document.documentElement.classList.toggle('dark', isDark)
26
- document.documentElement.classList.toggle('rp-dark', isDark)
27
- document.documentElement.style.colorScheme = isDark ? 'dark' : 'light'
28
- }`.replace(/\n/g, ';').replace(/\s{2,}/g, '');
29
- const dirname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(new URL(import.meta.url)));
30
- const PACKAGE_ROOT = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dirname, '..');
31
- __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'index.html');
32
- __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'csrClientEntry.js');
33
- __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrClientEntry.js');
34
- __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrServerEntry.js');
35
- const TEMP_DIR = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), 'node_modules', __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.RSPRESS_TEMP_DIR);
36
- var types_RuntimeModuleID = /*#__PURE__*/ function(RuntimeModuleID) {
37
- RuntimeModuleID["GlobalStyles"] = "virtual-global-styles";
38
- RuntimeModuleID["GlobalComponents"] = "virtual-global-components";
39
- RuntimeModuleID["RouteForClient"] = "virtual-routes";
40
- RuntimeModuleID["RouteForSSR"] = "virtual-routes-ssr";
41
- RuntimeModuleID["SiteData"] = "virtual-site-data";
42
- RuntimeModuleID["SearchIndexHash"] = "virtual-search-index-hash";
43
- RuntimeModuleID["I18nText"] = "virtual-i18n-text";
44
- RuntimeModuleID["SearchHooks"] = "virtual-search-hooks";
45
- RuntimeModuleID["PrismLanguages"] = "virtual-prism-languages";
46
- return RuntimeModuleID;
47
- }({});
48
- let resolver;
49
- let startFlatten = false;
50
- const processor = (0, __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__.createProcessor)();
51
- const { CachedInputFileSystem, ResolverFactory } = __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__["default"];
52
- const fileSystem = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"];
53
- async function resolveDepPath(importPath, importer, alias) {
54
- if (!resolver) resolver = ResolverFactory.createResolver({
55
- fileSystem: new CachedInputFileSystem(fileSystem, 0),
56
- extensions: [
57
- '.mdx',
58
- '.md'
59
- ],
60
- alias
61
- });
62
- const resolveResult = await new Promise((resolve, reject)=>{
63
- resolver.resolve({
64
- importer
65
- }, importer, importPath, {}, (err, filePath)=>{
66
- if (err) return reject(err);
67
- if (!filePath) return reject(new Error(`Empty result when resolving ${importPath} from ${importer}`));
68
- return resolve(filePath);
69
- });
70
- });
71
- return resolveResult;
72
- }
73
- async function flattenMdxContent(content, basePath, alias) {
74
- const deps = [];
75
- const regex = new RegExp(importStatementRegex);
76
- if (!regex.test(content)) return {
77
- flattenContent: content,
78
- deps
79
- };
80
- if (!startFlatten) {
81
- resolver = ResolverFactory.createResolver({
82
- fileSystem: new CachedInputFileSystem(fileSystem, 0),
83
- extensions: [
84
- '.mdx',
85
- '.md',
86
- '.js'
87
- ],
88
- alias
89
- });
90
- startFlatten = true;
91
- }
92
- let ast;
93
- let result = content;
94
- try {
95
- ast = processor.parse(content);
96
- } catch (e) {
97
- __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.debug('flattenMdxContent parse failed: \n', e);
98
- return {
99
- flattenContent: content,
100
- deps
101
- };
102
- }
103
- const importNodes = ast.children.filter((node)=>'mdxjsEsm' === node.type).flatMap((node)=>node.data?.estree?.body || []).filter((node)=>'ImportDeclaration' === node.type);
104
- for (const importNode of importNodes){
105
- const id = importNode.specifiers[0].local.name;
106
- const importPath = importNode.source.value;
107
- let absoluteImportPath;
108
- try {
109
- absoluteImportPath = await resolveDepPath(importPath, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(basePath), alias);
110
- } catch (_e) {
111
- continue;
112
- }
113
- if (__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(absoluteImportPath)) {
114
- const importedContent = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(absoluteImportPath, 'utf-8');
115
- const { flattenContent: replacedValue, deps: subDeps } = await flattenMdxContent(importedContent, absoluteImportPath, alias);
116
- result = result.replace(new RegExp(`import\\s+${id}\\s+from\\s+['"](${importPath})['"];?`), '').replace(new RegExp(`<${id}\\s*/>`, 'g'), ()=>replacedValue);
117
- deps.push(...subDeps, absoluteImportPath);
118
- }
119
- }
120
- return {
121
- flattenContent: result,
122
- deps
123
- };
124
- }
125
17
  function applyReplaceRules(code = '', replaceRules = []) {
126
18
  let result = code;
127
19
  for (const rule of replaceRules)result = result.replace(rule.search, rule.replace);
@@ -138,15 +30,6 @@ function slash(p) {
138
30
  function normalizePath(id) {
139
31
  return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.normalize(isWindows ? slash(id) : id);
140
32
  }
141
- const rehypePluginCodeMeta = ()=>(tree)=>{
142
- (0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'element', (node)=>{
143
- if ('pre' === node.tagName && node.children[0]?.type === 'element' && 'code' === node.children[0].tagName) {
144
- const codeNode = node.children[0];
145
- codeNode.properties ??= {};
146
- codeNode.properties.meta = codeNode.data?.meta;
147
- }
148
- });
149
- };
150
33
  const rehypeHeaderAnchor = ()=>{
151
34
  const slugger = new __WEBPACK_EXTERNAL_MODULE_github_slugger_8e9a17cb__["default"]();
152
35
  return (tree)=>{
@@ -296,6 +179,11 @@ const remarkPluginNormalizeLink = ({ root, cleanUrls, routeService })=>(tree, fi
296
179
  const relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, file.path);
297
180
  node.url = normalizeLink(nodeUrl, routeService, relativePath, cleanUrls);
298
181
  });
182
+ (0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'definition', (node)=>{
183
+ const { url: nodeUrl } = node;
184
+ const relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, file.path);
185
+ node.url = normalizeLink(nodeUrl, routeService, relativePath, cleanUrls);
186
+ });
299
187
  const getMdxSrcAttribute = (tempVar)=>({
300
188
  type: 'mdxJsxAttribute',
301
189
  name: 'src',
@@ -399,7 +287,16 @@ const remarkPluginToc = function() {
399
287
  if (title) data.pageMeta.title = title;
400
288
  };
401
289
  };
290
+ const rehypeCodeMeta = ()=>(tree)=>{
291
+ (0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'element', (node)=>{
292
+ if ('pre' === node.tagName && node.children[0]?.type === 'element' && 'code' === node.children[0].tagName) {
293
+ const codeNode = node.children[0];
294
+ codeNode.properties.metastring = codeNode.data?.meta;
295
+ }
296
+ });
297
+ };
402
298
  async function createMDXOptions(docDirectory, config, checkDeadLinks, routeService, filepath, pluginDriver) {
299
+ const format = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(filepath).slice(1);
403
300
  const cleanUrls = config?.route?.cleanUrls ?? false;
404
301
  const { remarkPlugins: remarkPluginsFromConfig = [], rehypePlugins: rehypePluginsFromConfig = [], globalComponents: globalComponentsFromConfig = [] } = config?.markdown || {};
405
302
  const rspressPlugins = pluginDriver.getPlugins();
@@ -411,7 +308,7 @@ async function createMDXOptions(docDirectory, config, checkDeadLinks, routeServi
411
308
  ];
412
309
  return {
413
310
  providerImportSource: '@mdx-js/react',
414
- format: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(filepath).slice(1),
311
+ format,
415
312
  remarkPlugins: [
416
313
  __WEBPACK_EXTERNAL_MODULE_remark_gfm_073acf21__["default"],
417
314
  remarkPluginToc,
@@ -442,7 +339,15 @@ async function createMDXOptions(docDirectory, config, checkDeadLinks, routeServi
442
339
  ].filter(Boolean),
443
340
  rehypePlugins: [
444
341
  rehypeHeaderAnchor,
445
- rehypePluginCodeMeta,
342
+ ...'md' === format ? [
343
+ rehypeCodeMeta,
344
+ [
345
+ __WEBPACK_EXTERNAL_MODULE_rehype_raw_434f4cf9__["default"],
346
+ {
347
+ passThrough: __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__.nodeTypes
348
+ }
349
+ ]
350
+ ] : [],
446
351
  [
447
352
  __WEBPACK_EXTERNAL_MODULE_rehype_external_links_09bed11a__["default"],
448
353
  {
@@ -455,44 +360,15 @@ async function createMDXOptions(docDirectory, config, checkDeadLinks, routeServi
455
360
  ]
456
361
  };
457
362
  }
458
- async function updateSiteDataRuntimeModule(modulePath, pageMeta) {
459
- const siteDataModulePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(TEMP_DIR, 'runtime', `${types_RuntimeModuleID.SiteData}.mjs`);
460
- const { default: siteData } = await import((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(siteDataModulePath).href);
461
- await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile(siteDataModulePath, `export default ${JSON.stringify({
462
- ...siteData,
463
- timestamp: Date.now().toString(),
464
- pages: siteData.pages.map((page)=>page._filepath === modulePath ? {
465
- ...page,
466
- ...pageMeta
467
- } : page)
468
- }, null, 2)}`);
469
- }
470
- function createCheckPageMetaUpdateFn() {
471
- const pageMetaMap = new Map();
472
- return (modulePath, pageMeta)=>{
473
- const prevMeta = pageMetaMap.get(modulePath);
474
- const deserializedMeta = JSON.stringify(pageMeta);
475
- pageMetaMap.set(modulePath, deserializedMeta);
476
- if (!prevMeta) return;
477
- if (prevMeta !== deserializedMeta) setTimeout(async ()=>{
478
- __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info('Page metadata changed, page reloading...');
479
- await updateSiteDataRuntimeModule(modulePath, pageMeta);
480
- });
481
- };
482
- }
483
- const checkPageMetaUpdate = createCheckPageMetaUpdateFn();
484
363
  async function mdxLoader(source) {
485
364
  this.cacheable(true);
486
365
  const callback = this.async();
487
366
  const options = this.getOptions();
488
367
  const filepath = this.resourcePath;
489
- const { alias } = this._compiler.options.resolve;
490
368
  const { config, docDirectory, checkDeadLinks, routeService, pluginDriver } = options;
491
- const { frontmatter, content } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.loadFrontMatter)(source, filepath, docDirectory, true);
492
- const { flattenContent, deps } = await flattenMdxContent(content, filepath, alias);
493
- deps.forEach((dep)=>this.addDependency(dep));
494
- const replacedContent = applyReplaceRules(flattenContent, config.replaceRules);
495
- const preprocessedContent = escapeMarkdownHeadingIds(replacedContent);
369
+ const { frontmatter, emptyLinesSource } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.loadFrontMatter)(source, filepath, docDirectory, true);
370
+ const replacedSource = applyReplaceRules(emptyLinesSource, config.replaceRules);
371
+ const preprocessedContent = escapeMarkdownHeadingIds(replacedSource);
496
372
  try {
497
373
  let pageMeta = {
498
374
  title: '',
@@ -519,7 +395,6 @@ async function mdxLoader(source) {
519
395
  headingTitle,
520
396
  frontmatter
521
397
  };
522
- if (!(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)()) checkPageMetaUpdate(filepath, pageMeta);
523
398
  const result = `const frontmatter = ${JSON.stringify(frontmatter)};
524
399
  ${compileResult}
525
400
  MDXContent.__RSPRESS_PAGE_META = {};
@@ -538,4 +413,4 @@ MDXContent.__RSPRESS_PAGE_META["${encodeURIComponent(normalizePath(__WEBPACK_EXT
538
413
  }
539
414
  }
540
415
  }
541
- export { createCheckPageMetaUpdateFn, mdxLoader as default, updateSiteDataRuntimeModule };
416
+ export { mdxLoader as default };
@@ -1,4 +1 @@
1
- import 'virtual-global-styles';
2
- export declare function App({ helmetContext }: {
3
- helmetContext?: object;
4
- }): import("react/jsx-runtime").JSX.Element;
1
+ export declare function App(): import("react/jsx-runtime").JSX.Element;
@@ -2,11 +2,9 @@ import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/j
2
2
  import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
3
3
  import * as __WEBPACK_EXTERNAL_MODULE__theme_75e53063__ from "@theme";
4
4
  import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
5
- import * as __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__ from "react-helmet-async";
6
5
  import * as __WEBPACK_EXTERNAL_MODULE_virtual_global_components_43dbb356__ from "virtual-global-components";
7
- import "virtual-global-styles";
8
6
  import * as __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__ from "./initPageData.js";
9
- function App({ helmetContext }) {
7
+ function App() {
10
8
  const { setData: setPageData, data } = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.DataContext);
11
9
  const { pathname, search } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLocation)();
12
10
  (0, __WEBPACK_EXTERNAL_MODULE_react__.useLayoutEffect)(()=>{
@@ -28,8 +26,7 @@ function App({ helmetContext }) {
28
26
  const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
29
27
  const query = new URLSearchParams(search);
30
28
  const hideGlobalUIComponents = false === frontmatter[GLOBAL_COMPONENTS_KEY] || "0" === query.get(GLOBAL_COMPONENTS_KEY);
31
- return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__.HelmetProvider, {
32
- context: helmetContext,
29
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
33
30
  children: [
34
31
  /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__.Layout, {}),
35
32
  !hideGlobalUIComponents && __WEBPACK_EXTERNAL_MODULE_virtual_global_components_43dbb356__["default"].map((componentInfo, index)=>{
@@ -1,8 +1,10 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
2
2
  import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
3
3
  import * as __WEBPACK_EXTERNAL_MODULE__theme_75e53063__ from "@theme";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__unhead_react_client_2b506c0d__ from "@unhead/react/client";
4
5
  import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
5
6
  import * as __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__ from "./App.js";
7
+ const head = (0, __WEBPACK_EXTERNAL_MODULE__unhead_react_client_2b506c0d__.createHead)();
6
8
  function ClientApp({ initialPageData = null }) {
7
9
  const [data, setData] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(initialPageData);
8
10
  const [theme, setTheme] = (0, __WEBPACK_EXTERNAL_MODULE__theme_75e53063__.useThemeState)();
@@ -23,7 +25,10 @@ function ClientApp({ initialPageData = null }) {
23
25
  setData
24
26
  ]),
25
27
  children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.BrowserRouter, {
26
- children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.App, {})
28
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__unhead_react_client_2b506c0d__.UnheadProvider, {
29
+ head: head,
30
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.App, {})
31
+ })
27
32
  })
28
33
  })
29
34
  });
@@ -1,13 +1,5 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_react_dom_client_76b1397c__ from "react-dom/client";
2
3
  import * as __WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__ from "./ClientApp.js";
3
- async function renderInBrowser() {
4
- const container = document.getElementById('root');
5
- if (process.env.__REACT_GTE_18__) {
6
- const { createRoot } = await import("react-dom/client");
7
- createRoot(container).render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}));
8
- } else {
9
- const ReactDOM = await import("react-dom");
10
- ReactDOM.render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}), container);
11
- }
12
- }
13
- renderInBrowser();
4
+ const container = document.getElementById('root');
5
+ (0, __WEBPACK_EXTERNAL_MODULE_react_dom_client_76b1397c__.createRoot)(container).render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}));
@@ -1,3 +1,2 @@
1
1
  import { type PageData } from '@rspress/shared';
2
- import 'virtual-global-styles';
3
2
  export declare function initPageData(routePath: string): Promise<PageData>;
@@ -1,6 +1,5 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
2
2
  import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
3
- import "virtual-global-styles";
4
3
  import * as __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__ from "virtual-site-data";
5
4
  async function initPageData(routePath) {
6
5
  const matchedRoute = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.pathnameToRouteService)(routePath);
@@ -1,19 +1,19 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_react_dom_client_76b1397c__ from "react-dom/client";
2
4
  import * as __WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__ from "./ClientApp.js";
3
5
  import * as __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__ from "./initPageData.js";
4
6
  async function renderInBrowser() {
5
7
  const container = document.getElementById('root');
6
8
  const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__.initPageData)(window.location.pathname);
7
- if (process.env.__REACT_GTE_18__) {
8
- const { hydrateRoot } = await import("react-dom/client");
9
- hydrateRoot(container, /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
9
+ (0, __WEBPACK_EXTERNAL_MODULE_react__.startTransition)(()=>{
10
+ (0, __WEBPACK_EXTERNAL_MODULE_react_dom_client_76b1397c__.hydrateRoot)(container, /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
10
11
  initialPageData: initialPageData
11
- }));
12
- } else {
13
- const ReactDOM = await import("react-dom");
14
- ReactDOM.hydrate(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
15
- initialPageData: initialPageData
16
- }), container);
17
- }
12
+ }), {
13
+ onRecoverableError (error, errorInfo) {
14
+ if (error instanceof Error) console.warn('hydrateRoot recoverable error:', error, errorInfo);
15
+ }
16
+ });
17
+ });
18
18
  }
19
19
  renderInBrowser();
@@ -1,6 +1,7 @@
1
1
  import type { PageData } from '@rspress/shared';
2
- export declare function render(pagePath: string, helmetContext: object): Promise<{
2
+ import { type Unhead } from '@unhead/react/server';
3
+ export declare function render(pagePath: string, head: Unhead): Promise<{
3
4
  appHtml: string;
4
5
  pageData: PageData;
5
6
  }>;
6
- export { routes } from 'virtual-routes-ssr';
7
+ export { routes } from 'virtual-routes';
@@ -1,14 +1,36 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
2
2
  import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
3
3
  import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_server_673c713a__ from "@rspress/runtime/server";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__unhead_react_server_7e85c952__ from "@unhead/react/server";
4
5
  import * as __WEBPACK_EXTERNAL_MODULE_react_dom_server_98c38d5c__ from "react-dom/server";
6
+ import * as __WEBPACK_EXTERNAL_MODULE_node_stream_444d1c2b__ from "node:stream";
7
+ import * as __WEBPACK_EXTERNAL_MODULE_node_stream_consumers_9c152648__ from "node:stream/consumers";
5
8
  import * as __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__ from "./App.js";
6
9
  import * as __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__ from "./initPageData.js";
7
- import * as __WEBPACK_EXTERNAL_MODULE_virtual_routes_ssr_f802e6e5__ from "virtual-routes-ssr";
10
+ import * as __WEBPACK_EXTERNAL_MODULE_virtual_routes_98776429__ from "virtual-routes";
8
11
  const DEFAULT_THEME = 'light';
9
- async function render(pagePath, helmetContext) {
12
+ async function preloadRoute(pathname) {
13
+ const route = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.pathnameToRouteService)(pathname);
14
+ await route?.preload();
15
+ }
16
+ function renderToHtml(app) {
17
+ return new Promise((resolve, reject)=>{
18
+ const passThrough = new __WEBPACK_EXTERNAL_MODULE_node_stream_444d1c2b__.PassThrough();
19
+ const { pipe } = (0, __WEBPACK_EXTERNAL_MODULE_react_dom_server_98c38d5c__.renderToPipeableStream)(app, {
20
+ onError (error) {
21
+ reject(error);
22
+ },
23
+ onAllReady () {
24
+ pipe(passThrough);
25
+ (0, __WEBPACK_EXTERNAL_MODULE_node_stream_consumers_9c152648__.text)(passThrough).then(resolve, reject);
26
+ }
27
+ });
28
+ });
29
+ }
30
+ async function render(pagePath, head) {
10
31
  const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__.initPageData)(pagePath);
11
- const appHtml = (0, __WEBPACK_EXTERNAL_MODULE_react_dom_server_98c38d5c__.renderToString)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.ThemeContext.Provider, {
32
+ await preloadRoute(pagePath);
33
+ const appHtml = await renderToHtml(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.ThemeContext.Provider, {
12
34
  value: {
13
35
  theme: DEFAULT_THEME
14
36
  },
@@ -18,8 +40,9 @@ async function render(pagePath, helmetContext) {
18
40
  },
19
41
  children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_server_673c713a__.StaticRouter, {
20
42
  location: pagePath,
21
- children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.App, {
22
- helmetContext: helmetContext
43
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__unhead_react_server_7e85c952__.UnheadProvider, {
44
+ value: head,
45
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.App, {})
23
46
  })
24
47
  })
25
48
  })
@@ -29,5 +52,5 @@ async function render(pagePath, helmetContext) {
29
52
  pageData: initialPageData
30
53
  };
31
54
  }
32
- var __webpack_exports__routes = __WEBPACK_EXTERNAL_MODULE_virtual_routes_ssr_f802e6e5__.routes;
55
+ var __webpack_exports__routes = __WEBPACK_EXTERNAL_MODULE_virtual_routes_98776429__.routes;
33
56
  export { render, __webpack_exports__routes as routes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.11",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -45,9 +45,11 @@
45
45
  "@mdx-js/loader": "^3.1.0",
46
46
  "@mdx-js/mdx": "^3.1.0",
47
47
  "@mdx-js/react": "^3.1.0",
48
- "@rsbuild/core": "1.3.9",
49
- "@rsbuild/plugin-react": "~1.1.1",
48
+ "@rsbuild/core": "~1.3.21",
49
+ "@rsbuild/plugin-react": "~1.3.1",
50
50
  "@rspress/mdx-rs": "0.6.6",
51
+ "@types/unist": "^3.0.3",
52
+ "@unhead/react": "^2.0.10",
51
53
  "enhanced-resolve": "5.18.1",
52
54
  "github-slugger": "^2.0.0",
53
55
  "hast-util-from-html": "^2.0.3",
@@ -58,39 +60,40 @@
58
60
  "picocolors": "^1.1.1",
59
61
  "react": "^19.1.0",
60
62
  "react-dom": "^19.1.0",
61
- "react-helmet-async": "^2.0.5",
62
63
  "react-lazy-with-preload": "^2.2.1",
63
64
  "react-router-dom": "^6.29.0",
64
- "react-syntax-highlighter": "^15.6.1",
65
65
  "rehype-external-links": "^3.0.0",
66
+ "rehype-raw": "^7.0.0",
66
67
  "remark": "^15.0.1",
67
68
  "remark-gfm": "^4.0.1",
68
- "rspack-plugin-virtual-module": "0.1.13",
69
- "tinyglobby": "^0.2.13",
69
+ "rspack-plugin-virtual-module": "1.0.1",
70
+ "tinyglobby": "^0.2.14",
70
71
  "unified": "^11.0.5",
71
72
  "unist-util-visit": "^5.0.0",
72
73
  "unist-util-visit-children": "^3.0.0",
73
- "@rspress/plugin-auto-nav-sidebar": "2.0.0-beta.1",
74
- "@rspress/plugin-container-syntax": "2.0.0-beta.1",
75
- "@rspress/plugin-last-updated": "2.0.0-beta.1",
76
- "@rspress/plugin-medium-zoom": "2.0.0-beta.1",
77
- "@rspress/theme-default": "2.0.0-beta.1",
78
- "@rspress/shared": "2.0.0-beta.1",
79
- "@rspress/runtime": "2.0.0-beta.1"
74
+ "@rspress/plugin-container-syntax": "2.0.0-beta.11",
75
+ "@rspress/plugin-auto-nav-sidebar": "2.0.0-beta.11",
76
+ "@rspress/plugin-last-updated": "2.0.0-beta.11",
77
+ "@rspress/plugin-medium-zoom": "2.0.0-beta.11",
78
+ "@rspress/plugin-shiki": "2.0.0-beta.11",
79
+ "@rspress/runtime": "2.0.0-beta.11",
80
+ "@rspress/theme-default": "2.0.0-beta.11",
81
+ "@rspress/shared": "2.0.0-beta.11"
80
82
  },
81
83
  "devDependencies": {
82
- "@microsoft/api-extractor": "^7.52.4",
83
- "@rslib/core": "0.6.5",
84
+ "@microsoft/api-extractor": "^7.52.8",
85
+ "@rslib/core": "0.8.0",
84
86
  "@rspress-dev/plugin-preview": "link:../plugin-preview",
85
87
  "@types/hast": "^3.0.4",
86
88
  "@types/html-to-text": "^9.0.4",
87
89
  "@types/jest": "~29.5.14",
88
90
  "@types/lodash-es": "^4.17.12",
89
91
  "@types/mdast": "^4.0.4",
90
- "@types/node": "^18.11.17",
91
- "@types/react": "^18.3.20",
92
- "@types/react-dom": "^18.3.6",
93
- "memfs": "^4.17.0",
92
+ "@types/node": "^22.8.1",
93
+ "@types/react": "^19.1.6",
94
+ "@types/react-dom": "^19.1.6",
95
+ "memfs": "^4.17.2",
96
+ "p-map": "^7.0.3",
94
97
  "postcss": "8.5.3",
95
98
  "rehype-stringify": "^10.0.1",
96
99
  "remark-mdx": "^3.1.0",
@@ -98,8 +101,8 @@
98
101
  "remark-rehype": "^11.1.2",
99
102
  "remark-stringify": "^11.0.0",
100
103
  "rimraf": "^6.0.1",
101
- "rsbuild-plugin-publint": "^0.3.0",
102
- "rsbuild-plugin-virtual-module": "0.1.1",
104
+ "rsbuild-plugin-publint": "^0.3.2",
105
+ "rsbuild-plugin-virtual-module": "0.2.0",
103
106
  "tailwindcss": "^3.4.17",
104
107
  "typescript": "^5.8.2",
105
108
  "vfile": "^6.0.3",
@@ -1,4 +0,0 @@
1
- var tsconfig_namespaceObject = JSON.parse('{"compilerOptions":{"rootDir":".","baseUrl":".","skipLibCheck":true,"jsx":"react-jsx","esModuleInterop":true},"include":["./**/*"]}');
2
- var __webpack_exports__compilerOptions = tsconfig_namespaceObject.compilerOptions;
3
- var __webpack_exports__include = tsconfig_namespaceObject.include;
4
- export { __webpack_exports__compilerOptions as compilerOptions, __webpack_exports__include as include };