@rspress/core 2.0.0-beta.0 → 2.0.0-beta.2

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
@@ -23,48 +23,24 @@ import * as __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__ from "enhanced
23
23
  import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
24
24
  import * as __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__ from "react-helmet-async";
25
25
  import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
26
+ import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__ from "unist-util-visit";
26
27
  export * from "@rspress/shared";
27
- function _check_private_redeclaration(obj, privateCollection) {
28
- if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
29
- }
30
- function _class_apply_descriptor_get(receiver, descriptor) {
31
- if (descriptor.get) return descriptor.get.call(receiver);
32
- return descriptor.value;
33
- }
34
- function _class_apply_descriptor_set(receiver, descriptor, value) {
35
- if (descriptor.set) descriptor.set.call(receiver, value);
36
- else {
37
- if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
38
- descriptor.value = value;
39
- }
40
- }
41
- function _class_extract_field_descriptor(receiver, privateMap, action) {
42
- if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
43
- return privateMap.get(receiver);
44
- }
45
- function _class_private_field_get(receiver, privateMap) {
46
- var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
47
- return _class_apply_descriptor_get(receiver, descriptor);
48
- }
49
- function _class_private_field_init(obj, privateMap, value) {
50
- _check_private_redeclaration(obj, privateMap);
51
- privateMap.set(obj, value);
52
- }
53
- function _class_private_field_set(receiver, privateMap, value) {
54
- var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
55
- _class_apply_descriptor_set(receiver, descriptor, value);
56
- return value;
57
- }
58
- var _config = /*#__PURE__*/ new WeakMap(), _plugins = /*#__PURE__*/ new WeakMap(), _isProd = /*#__PURE__*/ new WeakMap();
59
28
  class PluginDriver {
29
+ #config;
30
+ #plugins;
31
+ #isProd;
32
+ constructor(config, isProd){
33
+ this.#config = config;
34
+ this.#isProd = isProd;
35
+ this.#plugins = [];
36
+ }
60
37
  async init() {
61
- var _themeConfig_locales, _themeConfig_locales_, _themeConfig_locales1, _themeConfig_locales_1, _themeConfig_locales2;
62
38
  this.clearPlugins();
63
- const config = _class_private_field_get(this, _config);
64
- const themeConfig = (null == config ? void 0 : config.themeConfig) || {};
65
- const enableLastUpdated = (null == themeConfig ? void 0 : themeConfig.lastUpdated) || (null == themeConfig ? void 0 : null == (_themeConfig_locales = themeConfig.locales) ? void 0 : _themeConfig_locales.some((locale)=>locale.lastUpdated));
66
- const mediumZoomConfig = (null == config ? void 0 : config.mediumZoom) ?? true;
67
- const haveNavSidebarConfig = themeConfig.nav || themeConfig.sidebar || (null == (_themeConfig_locales1 = themeConfig.locales) ? void 0 : null == (_themeConfig_locales_ = _themeConfig_locales1[0]) ? void 0 : _themeConfig_locales_.nav) || (null == (_themeConfig_locales2 = themeConfig.locales) ? void 0 : null == (_themeConfig_locales_1 = _themeConfig_locales2[0]) ? void 0 : _themeConfig_locales_1.sidebar);
39
+ const config = this.#config;
40
+ const themeConfig = config?.themeConfig || {};
41
+ const enableLastUpdated = themeConfig?.lastUpdated || themeConfig?.locales?.some((locale)=>locale.lastUpdated);
42
+ const mediumZoomConfig = config?.mediumZoom ?? true;
43
+ const haveNavSidebarConfig = themeConfig.nav || themeConfig.sidebar || themeConfig.locales?.[0]?.nav || themeConfig.locales?.[0]?.sidebar;
68
44
  if (enableLastUpdated) {
69
45
  const { pluginLastUpdated } = await import("@rspress/plugin-last-updated");
70
46
  this.addPlugin(pluginLastUpdated());
@@ -87,78 +63,81 @@ class PluginDriver {
87
63
  }
88
64
  }
89
65
  addPlugin(plugin) {
90
- const existedIndex = _class_private_field_get(this, _plugins).findIndex((item)=>item.name === plugin.name);
66
+ const existedIndex = this.#plugins.findIndex((item)=>item.name === plugin.name);
91
67
  if (-1 !== existedIndex) throw new Error(`The plugin "${plugin.name}" has been registered`);
92
- _class_private_field_get(this, _plugins).push(plugin);
68
+ this.#plugins.push(plugin);
93
69
  }
94
70
  getPlugins() {
95
- return _class_private_field_get(this, _plugins);
71
+ return this.#plugins;
96
72
  }
97
73
  clearPlugins() {
98
- _class_private_field_set(this, _plugins, []);
74
+ this.#plugins = [];
99
75
  }
100
76
  removePlugin(pluginName) {
101
- const index = _class_private_field_get(this, _plugins).findIndex((item)=>item.name === pluginName);
102
- if (-1 !== index) _class_private_field_get(this, _plugins).splice(index, 1);
77
+ const index = this.#plugins.findIndex((item)=>item.name === pluginName);
78
+ if (-1 !== index) this.#plugins.splice(index, 1);
103
79
  }
104
80
  async modifyConfig() {
105
- let config = _class_private_field_get(this, _config);
106
- for(let i = 0; i < _class_private_field_get(this, _plugins).length; i++){
107
- const plugin = _class_private_field_get(this, _plugins)[i];
81
+ let config = this.#config;
82
+ for(let i = 0; i < this.#plugins.length; i++){
83
+ const plugin = this.#plugins[i];
108
84
  if ('function' == typeof plugin.config) config = await plugin.config(config || {}, {
109
85
  addPlugin: this.addPlugin.bind(this),
110
86
  removePlugin: (pluginName)=>{
111
- const index = _class_private_field_get(this, _plugins).findIndex((item)=>item.name === pluginName);
87
+ const index = this.#plugins.findIndex((item)=>item.name === pluginName);
112
88
  this.removePlugin(pluginName);
113
89
  if (index <= i && index > 0) i--;
114
90
  }
115
- }, _class_private_field_get(this, _isProd));
91
+ }, this.#isProd);
116
92
  }
117
- _class_private_field_set(this, _config, config);
118
- return _class_private_field_get(this, _config);
93
+ this.#config = config;
94
+ return this.#config;
119
95
  }
120
96
  async beforeBuild() {
121
- return this._runParallelAsyncHook('beforeBuild', _class_private_field_get(this, _config) || {}, _class_private_field_get(this, _isProd));
97
+ return this._runParallelAsyncHook('beforeBuild', this.#config || {}, this.#isProd);
122
98
  }
123
99
  async afterBuild() {
124
- return this._runParallelAsyncHook('afterBuild', _class_private_field_get(this, _config) || {}, _class_private_field_get(this, _isProd));
100
+ return this._runParallelAsyncHook('afterBuild', this.#config || {}, this.#isProd);
125
101
  }
126
102
  async modifySearchIndexData(pages) {
127
- return this._runParallelAsyncHook('modifySearchIndexData', pages, _class_private_field_get(this, _isProd));
103
+ return this._runParallelAsyncHook('modifySearchIndexData', pages, this.#isProd);
128
104
  }
129
105
  async extendPageData(pageData) {
130
- return this._runParallelAsyncHook('extendPageData', pageData, _class_private_field_get(this, _isProd));
106
+ return this._runParallelAsyncHook('extendPageData', pageData, this.#isProd);
131
107
  }
132
108
  async addPages() {
133
- const result = await this._runParallelAsyncHook('addPages', _class_private_field_get(this, _config) || {}, _class_private_field_get(this, _isProd));
109
+ const result = await this._runParallelAsyncHook('addPages', this.#config || {}, this.#isProd);
134
110
  return result.flat();
135
111
  }
136
112
  async routeGenerated(routes) {
137
- return this._runParallelAsyncHook('routeGenerated', routes, _class_private_field_get(this, _isProd));
113
+ return this._runParallelAsyncHook('routeGenerated', routes, this.#isProd);
114
+ }
115
+ async routeServiceGenerated(routeService) {
116
+ return this._runParallelAsyncHook('routeServiceGenerated', routeService, this.#isProd);
138
117
  }
139
118
  async addRuntimeModules() {
140
- const result = await this._runParallelAsyncHook('addRuntimeModules', _class_private_field_get(this, _config) || {}, _class_private_field_get(this, _isProd));
119
+ const result = await this._runParallelAsyncHook('addRuntimeModules', this.#config || {}, this.#isProd);
141
120
  return result.reduce((prev, current)=>({
142
121
  ...prev,
143
122
  ...current
144
123
  }), {});
145
124
  }
146
125
  async addSSGRoutes() {
147
- const result = await this._runParallelAsyncHook('addSSGRoutes', _class_private_field_get(this, _config) || {}, _class_private_field_get(this, _isProd));
126
+ const result = await this._runParallelAsyncHook('addSSGRoutes', this.#config || {}, this.#isProd);
148
127
  return result.flat();
149
128
  }
150
129
  globalUIComponents() {
151
- const result = _class_private_field_get(this, _plugins).map((plugin)=>plugin.globalUIComponents || []);
130
+ const result = this.#plugins.map((plugin)=>plugin.globalUIComponents || []);
152
131
  return result.flat();
153
132
  }
154
133
  globalStyles() {
155
- return _class_private_field_get(this, _plugins).filter((plugin)=>'string' == typeof plugin.globalStyles).map((plugin)=>plugin.globalStyles);
134
+ return this.#plugins.filter((plugin)=>'string' == typeof plugin.globalStyles).map((plugin)=>plugin.globalStyles);
156
135
  }
157
136
  _runParallelAsyncHook(hookName, ...args) {
158
- return Promise.all(_class_private_field_get(this, _plugins).filter((plugin)=>'function' == typeof plugin[hookName]).map((plugin)=>plugin[hookName](...args)));
137
+ return Promise.all(this.#plugins.filter((plugin)=>'function' == typeof plugin[hookName]).map((plugin)=>plugin[hookName](...args)));
159
138
  }
160
139
  _runSerialAsyncHook(hookName, ...args) {
161
- return _class_private_field_get(this, _plugins).reduce(async (prev, plugin)=>{
140
+ return this.#plugins.reduce(async (prev, plugin)=>{
162
141
  if ('function' == typeof plugin[hookName]) {
163
142
  await prev;
164
143
  return plugin[hookName](...args);
@@ -166,23 +145,6 @@ class PluginDriver {
166
145
  return prev;
167
146
  }, Promise.resolve());
168
147
  }
169
- constructor(config, isProd){
170
- _class_private_field_init(this, _config, {
171
- writable: true,
172
- value: void 0
173
- });
174
- _class_private_field_init(this, _plugins, {
175
- writable: true,
176
- value: void 0
177
- });
178
- _class_private_field_init(this, _isProd, {
179
- writable: true,
180
- value: void 0
181
- });
182
- _class_private_field_set(this, _config, config);
183
- _class_private_field_set(this, _isProd, isProd);
184
- _class_private_field_set(this, _plugins, []);
185
- }
186
148
  }
187
149
  const PLUGIN_VIRTUAL_MODULE_NAME = 'rsbuild:virtual-module';
188
150
  const pluginVirtualModule = (pluginOptions = {})=>({
@@ -215,7 +177,7 @@ const pluginVirtualModule = (pluginOptions = {})=>({
215
177
  }
216
178
  }
217
179
  });
218
- var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.0"}');
180
+ var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.2"}');
219
181
  const RSPRESS_VERSION = package_namespaceObject.i8;
220
182
  const isProduction = ()=>'production' === process.env.NODE_ENV;
221
183
  const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
@@ -346,71 +308,49 @@ const normalizeRoutePath = (routePath, base, lang, version, langs, versions, ext
346
308
  version: versionPart || version
347
309
  };
348
310
  };
349
- function RouteService_check_private_redeclaration(obj, privateCollection) {
350
- if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
351
- }
352
- function RouteService_class_apply_descriptor_get(receiver, descriptor) {
353
- if (descriptor.get) return descriptor.get.call(receiver);
354
- return descriptor.value;
355
- }
356
- function RouteService_class_apply_descriptor_set(receiver, descriptor, value) {
357
- if (descriptor.set) descriptor.set.call(receiver, value);
358
- else {
359
- if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
360
- descriptor.value = value;
361
- }
362
- }
363
- function RouteService_class_extract_field_descriptor(receiver, privateMap, action) {
364
- if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
365
- return privateMap.get(receiver);
366
- }
367
- function RouteService_class_private_field_get(receiver, privateMap) {
368
- var descriptor = RouteService_class_extract_field_descriptor(receiver, privateMap, "get");
369
- return RouteService_class_apply_descriptor_get(receiver, descriptor);
370
- }
371
- function RouteService_class_private_field_init(obj, privateMap, value) {
372
- RouteService_check_private_redeclaration(obj, privateMap);
373
- privateMap.set(obj, value);
374
- }
375
- function RouteService_class_private_field_set(receiver, privateMap, value) {
376
- var descriptor = RouteService_class_extract_field_descriptor(receiver, privateMap, "set");
377
- RouteService_class_apply_descriptor_set(receiver, descriptor, value);
378
- return value;
379
- }
380
- function _class_private_method_get(receiver, privateSet, fn) {
381
- if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
382
- return fn;
383
- }
384
- function _class_private_method_init(obj, privateSet) {
385
- RouteService_check_private_redeclaration(obj, privateSet);
386
- privateSet.add(obj);
387
- }
388
- function _define_property(obj, key, value) {
389
- if (key in obj) Object.defineProperty(obj, key, {
390
- value: value,
391
- enumerable: true,
392
- configurable: true,
393
- writable: true
394
- });
395
- else obj[key] = value;
396
- return obj;
397
- }
398
- var _scanDir = /*#__PURE__*/ new WeakMap(), _defaultLang = /*#__PURE__*/ new WeakMap(), _defaultVersion = /*#__PURE__*/ new WeakMap(), _extensions = /*#__PURE__*/ new WeakMap(), _langs = /*#__PURE__*/ new WeakMap(), _versions = /*#__PURE__*/ new WeakMap(), _include = /*#__PURE__*/ new WeakMap(), _exclude = /*#__PURE__*/ new WeakMap(), _base = /*#__PURE__*/ new WeakMap(), _tempDir = /*#__PURE__*/ new WeakMap(), _pluginDriver = /*#__PURE__*/ new WeakMap(), _writeTempFile = /*#__PURE__*/ new WeakSet(), _generateRouteInfo = /*#__PURE__*/ new WeakSet();
399
311
  class RouteService {
312
+ routeData = new Map();
313
+ #scanDir;
314
+ #defaultLang;
315
+ #defaultVersion = '';
316
+ #extensions = [];
317
+ #langs = [];
318
+ #versions = [];
319
+ #include = [];
320
+ #exclude = [];
321
+ #base = '';
322
+ #tempDir = '';
323
+ #pluginDriver;
324
+ constructor(scanDir, userConfig, tempDir, pluginDriver){
325
+ const routeOptions = userConfig?.route || {};
326
+ this.#scanDir = scanDir;
327
+ this.#extensions = routeOptions.extensions || __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__.DEFAULT_PAGE_EXTENSIONS;
328
+ this.#include = routeOptions.include || [];
329
+ this.#exclude = routeOptions.exclude || [];
330
+ this.#defaultLang = userConfig?.lang || '';
331
+ this.#langs = (userConfig?.locales ?? userConfig?.themeConfig?.locales ?? []).map((item)=>item.lang);
332
+ this.#base = userConfig?.base || '';
333
+ this.#tempDir = tempDir;
334
+ this.#pluginDriver = pluginDriver;
335
+ if (userConfig.multiVersion) {
336
+ this.#defaultVersion = userConfig.multiVersion.default || '';
337
+ this.#versions = userConfig.multiVersion.versions || [];
338
+ }
339
+ }
400
340
  get extensions() {
401
- return RouteService_class_private_field_get(this, _extensions);
341
+ return this.#extensions;
402
342
  }
403
343
  async init() {
404
- const extensions = RouteService_class_private_field_get(this, _extensions).map((i)=>i.slice(1));
344
+ const extensions = this.#extensions.map((i)=>i.slice(1));
405
345
  const files = (await (0, __WEBPACK_EXTERNAL_MODULE_tinyglobby__.glob)([
406
346
  `**/*.{${extensions.join(',')}}`,
407
- ...RouteService_class_private_field_get(this, _include)
347
+ ...this.#include
408
348
  ], {
409
- cwd: RouteService_class_private_field_get(this, _scanDir),
349
+ cwd: this.#scanDir,
410
350
  absolute: true,
411
351
  onlyFiles: true,
412
352
  ignore: [
413
- ...RouteService_class_private_field_get(this, _exclude),
353
+ ...this.#exclude,
414
354
  '**/node_modules/**',
415
355
  '**/.eslintrc.js',
416
356
  '**/.nx/**',
@@ -418,9 +358,9 @@ class RouteService {
418
358
  ]
419
359
  })).sort();
420
360
  files.forEach((filePath)=>{
421
- const fileRelativePath = normalizePath(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(RouteService_class_private_field_get(this, _scanDir), filePath));
361
+ const fileRelativePath = normalizePath(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(this.#scanDir, filePath));
422
362
  const { routePath, lang, version } = this.normalizeRoutePath(fileRelativePath);
423
- const absolutePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(RouteService_class_private_field_get(this, _scanDir), fileRelativePath);
363
+ const absolutePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(this.#scanDir, fileRelativePath);
424
364
  const routeInfo = {
425
365
  routePath,
426
366
  absolutePath: normalizePath(absolutePath),
@@ -431,32 +371,32 @@ class RouteService {
431
371
  };
432
372
  this.addRoute(routeInfo);
433
373
  });
434
- const externalPages = await RouteService_class_private_field_get(this, _pluginDriver).addPages();
374
+ const externalPages = await this.#pluginDriver.addPages();
435
375
  await Promise.all(externalPages.map(async (route, index)=>{
436
376
  const { routePath, content, filepath } = route;
437
377
  if (filepath) {
438
- const routeInfo = _class_private_method_get(this, _generateRouteInfo, generateRouteInfo).call(this, routePath, filepath);
378
+ const routeInfo = this.#generateRouteInfo(routePath, filepath);
439
379
  this.addRoute(routeInfo);
440
380
  return;
441
381
  }
442
382
  if (content) {
443
- const filepath = await _class_private_method_get(this, _writeTempFile, writeTempFile).call(this, index, content);
444
- const routeInfo = _class_private_method_get(this, _generateRouteInfo, generateRouteInfo).call(this, routePath, filepath);
383
+ const filepath = await this.#writeTempFile(index, content);
384
+ const routeInfo = this.#generateRouteInfo(routePath, filepath);
445
385
  this.addRoute(routeInfo);
446
386
  }
447
387
  }));
448
- await RouteService_class_private_field_get(this, _pluginDriver).routeGenerated(this.getRoutes());
388
+ await this.#pluginDriver.routeGenerated(this.getRoutes());
449
389
  }
450
390
  addRoute(routeInfo) {
451
391
  const { routePath, absolutePath } = routeInfo;
452
392
  if (this.routeData.has(routePath)) {
453
- const preRouteExtIndex = RouteService_class_private_field_get(this, _extensions).indexOf(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(this.routeData.get(routePath).absolutePath));
454
- const currRouteExtIndex = RouteService_class_private_field_get(this, _extensions).indexOf(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(absolutePath));
393
+ const preRouteExtIndex = this.#extensions.indexOf(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(this.routeData.get(routePath).absolutePath));
394
+ const currRouteExtIndex = this.#extensions.indexOf(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(absolutePath));
455
395
  if (-1 !== currRouteExtIndex && (currRouteExtIndex < preRouteExtIndex || -1 === preRouteExtIndex)) this.routeData.set(routePath, routeInfo);
456
396
  } else this.routeData.set(routePath, routeInfo);
457
397
  }
458
398
  removeRoute(filePath) {
459
- const fileRelativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(RouteService_class_private_field_get(this, _scanDir), filePath);
399
+ const fileRelativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(this.#scanDir, filePath);
460
400
  const { routePath } = this.normalizeRoutePath(fileRelativePath);
461
401
  this.routeData.delete(routePath);
462
402
  }
@@ -491,97 +431,34 @@ ${routeMeta.map((route, index)=>{
491
431
  `;
492
432
  }
493
433
  getRoutePathParts(routePath) {
494
- return getRoutePathParts(routePath, RouteService_class_private_field_get(this, _defaultLang), RouteService_class_private_field_get(this, _defaultVersion), RouteService_class_private_field_get(this, _langs), RouteService_class_private_field_get(this, _versions));
434
+ return getRoutePathParts(routePath, this.#defaultLang, this.#defaultVersion, this.#langs, this.#versions);
495
435
  }
496
436
  normalizeRoutePath(routePath) {
497
- return normalizeRoutePath(routePath, RouteService_class_private_field_get(this, _base), RouteService_class_private_field_get(this, _defaultLang), RouteService_class_private_field_get(this, _defaultVersion), RouteService_class_private_field_get(this, _langs), RouteService_class_private_field_get(this, _versions), RouteService_class_private_field_get(this, _extensions));
437
+ return normalizeRoutePath(routePath, this.#base, this.#defaultLang, this.#defaultVersion, this.#langs, this.#versions, this.#extensions);
498
438
  }
499
- constructor(scanDir, userConfig, tempDir, pluginDriver){
500
- var _userConfig_themeConfig;
501
- _class_private_method_init(this, _writeTempFile);
502
- _class_private_method_init(this, _generateRouteInfo);
503
- _define_property(this, "routeData", new Map());
504
- RouteService_class_private_field_init(this, _scanDir, {
505
- writable: true,
506
- value: void 0
507
- });
508
- RouteService_class_private_field_init(this, _defaultLang, {
509
- writable: true,
510
- value: void 0
511
- });
512
- RouteService_class_private_field_init(this, _defaultVersion, {
513
- writable: true,
514
- value: ''
515
- });
516
- RouteService_class_private_field_init(this, _extensions, {
517
- writable: true,
518
- value: []
519
- });
520
- RouteService_class_private_field_init(this, _langs, {
521
- writable: true,
522
- value: []
523
- });
524
- RouteService_class_private_field_init(this, _versions, {
525
- writable: true,
526
- value: []
527
- });
528
- RouteService_class_private_field_init(this, _include, {
529
- writable: true,
530
- value: []
531
- });
532
- RouteService_class_private_field_init(this, _exclude, {
533
- writable: true,
534
- value: []
535
- });
536
- RouteService_class_private_field_init(this, _base, {
537
- writable: true,
538
- value: ''
539
- });
540
- RouteService_class_private_field_init(this, _tempDir, {
541
- writable: true,
542
- value: ''
543
- });
544
- RouteService_class_private_field_init(this, _pluginDriver, {
545
- writable: true,
546
- value: void 0
547
- });
548
- const routeOptions = (null == userConfig ? void 0 : userConfig.route) || {};
549
- RouteService_class_private_field_set(this, _scanDir, scanDir);
550
- RouteService_class_private_field_set(this, _extensions, routeOptions.extensions || __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__.DEFAULT_PAGE_EXTENSIONS);
551
- RouteService_class_private_field_set(this, _include, routeOptions.include || []);
552
- RouteService_class_private_field_set(this, _exclude, routeOptions.exclude || []);
553
- RouteService_class_private_field_set(this, _defaultLang, (null == userConfig ? void 0 : userConfig.lang) || '');
554
- RouteService_class_private_field_set(this, _langs, ((null == userConfig ? void 0 : userConfig.locales) ?? (null == userConfig ? void 0 : null == (_userConfig_themeConfig = userConfig.themeConfig) ? void 0 : _userConfig_themeConfig.locales) ?? []).map((item)=>item.lang));
555
- RouteService_class_private_field_set(this, _base, (null == userConfig ? void 0 : userConfig.base) || '');
556
- RouteService_class_private_field_set(this, _tempDir, tempDir);
557
- RouteService_class_private_field_set(this, _pluginDriver, pluginDriver);
558
- if (userConfig.multiVersion) {
559
- RouteService_class_private_field_set(this, _defaultVersion, userConfig.multiVersion.default || '');
560
- RouteService_class_private_field_set(this, _versions, userConfig.multiVersion.versions || []);
561
- }
439
+ async #writeTempFile(index, content) {
440
+ const tempFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(this.#tempDir, `temp-${index}.mdx`);
441
+ await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile(tempFilePath, content);
442
+ return tempFilePath;
443
+ }
444
+ #generateRouteInfo(routePath, filepath) {
445
+ const { routePath: normalizedPath, lang, version } = this.normalizeRoutePath(routePath);
446
+ return {
447
+ routePath: normalizedPath,
448
+ absolutePath: normalizePath(filepath),
449
+ relativePath: normalizePath(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(this.#scanDir, filepath)),
450
+ pageName: getPageKey(routePath),
451
+ lang,
452
+ version
453
+ };
562
454
  }
563
- }
564
- async function writeTempFile(index, content) {
565
- const tempFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(RouteService_class_private_field_get(this, _tempDir), `temp-${index}.mdx`);
566
- await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile(tempFilePath, content);
567
- return tempFilePath;
568
- }
569
- function generateRouteInfo(routePath, filepath) {
570
- const { routePath: normalizedPath, lang, version } = this.normalizeRoutePath(routePath);
571
- return {
572
- routePath: normalizedPath,
573
- absolutePath: normalizePath(filepath),
574
- relativePath: normalizePath(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(RouteService_class_private_field_get(this, _scanDir), filepath)),
575
- pageName: getPageKey(routePath),
576
- lang,
577
- version
578
- };
579
455
  }
580
456
  let init_routeService = null;
581
457
  async function initRouteService(options) {
582
458
  const { scanDir, config, runtimeTempDir, pluginDriver } = options;
583
459
  init_routeService = new RouteService(scanDir, config, runtimeTempDir, pluginDriver);
584
460
  await init_routeService.init();
461
+ await pluginDriver.routeServiceGenerated(init_routeService);
585
462
  return init_routeService;
586
463
  }
587
464
  var types_RuntimeModuleID = /*#__PURE__*/ function(RuntimeModuleID) {
@@ -665,10 +542,7 @@ async function flattenMdxContent(content, basePath, alias) {
665
542
  deps
666
543
  };
667
544
  }
668
- const importNodes = ast.children.filter((node)=>'mdxjsEsm' === node.type).flatMap((node)=>{
669
- var _node_data_estree, _node_data;
670
- return (null == (_node_data = node.data) ? void 0 : null == (_node_data_estree = _node_data.estree) ? void 0 : _node_data_estree.body) || [];
671
- }).filter((node)=>'ImportDeclaration' === node.type);
545
+ const importNodes = ast.children.filter((node)=>'mdxjsEsm' === node.type).flatMap((node)=>node.data?.estree?.body || []).filter((node)=>'ImportDeclaration' === node.type);
672
546
  for (const importNode of importNodes){
673
547
  const id = importNode.specifiers[0].local.name;
674
548
  const importPath = importNode.source.value;
@@ -706,6 +580,7 @@ async function extractPageData(replaceRules, alias, domain, root, routeService,
706
580
  id: index,
707
581
  title: '',
708
582
  content: '',
583
+ _flattenContent: '',
709
584
  _html: '',
710
585
  routePath: route.routePath,
711
586
  lang: route.lang,
@@ -718,9 +593,9 @@ async function extractPageData(replaceRules, alias, domain, root, routeService,
718
593
  };
719
594
  if (!__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(route.absolutePath)) return defaultIndexInfo;
720
595
  let content = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(route.absolutePath, 'utf8');
721
- const { frontmatter, content: strippedFrontMatter } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.loadFrontMatter)(content, route.absolutePath, root);
596
+ const { frontmatter, content: contentWithoutFrontMatter } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.loadFrontMatter)(content, route.absolutePath, root);
722
597
  applyReplaceRulesToNestedObject(frontmatter, replaceRules);
723
- const { flattenContent } = await flattenMdxContent(applyReplaceRules(strippedFrontMatter, replaceRules), route.absolutePath, alias);
598
+ const { flattenContent } = await flattenMdxContent(applyReplaceRules(contentWithoutFrontMatter, replaceRules), route.absolutePath, alias);
724
599
  content = flattenContent.replace(importStatementRegex, '');
725
600
  const { html: rawHtml, title, toc: rawToc, languages } = await (0, __WEBPACK_EXTERNAL_MODULE__rspress_mdx_rs_d2f3021f__.compile)({
726
601
  value: content,
@@ -789,6 +664,7 @@ async function extractPageData(replaceRules, alias, domain, root, routeService,
789
664
  title: frontmatter.title || title,
790
665
  toc,
791
666
  content,
667
+ _flattenContent: flattenContent,
792
668
  _html: html,
793
669
  frontmatter: {
794
670
  ...frontmatter,
@@ -866,7 +742,7 @@ function normalizeThemeConfig(docConfig, pages = []) {
866
742
  const hasMultiVersion = versions.length > 0;
867
743
  docConfig.themeConfig = docConfig.themeConfig || {};
868
744
  const { themeConfig } = docConfig;
869
- const locales = siteLocales ?? ((null == themeConfig ? void 0 : themeConfig.locales) || []);
745
+ const locales = siteLocales ?? (themeConfig?.locales || []);
870
746
  const i18nTextData = getI18nData(docConfig);
871
747
  const normalizeLinkPrefix = (link = '', currentLang = '')=>{
872
748
  const normalizedLink = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.slash)(link);
@@ -874,8 +750,7 @@ function normalizeThemeConfig(docConfig, pages = []) {
874
750
  return lang === currentLang ? normalizedLink : `/${currentLang}${(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.addLeadingSlash)(normalizedLink)}`;
875
751
  };
876
752
  const getI18nText = (key = '', currentLang = '')=>{
877
- var _i18nTextData_key;
878
- const text = null == (_i18nTextData_key = i18nTextData[key]) ? void 0 : _i18nTextData_key[currentLang];
753
+ const text = i18nTextData[key]?.[currentLang];
879
754
  return text || key;
880
755
  };
881
756
  const normalizeSidebar = (sidebar, currentLang = '')=>{
@@ -900,9 +775,9 @@ function normalizeThemeConfig(docConfig, pages = []) {
900
775
  const normalizedItem = normalizeLinkPrefix(item, currentLang);
901
776
  const page = pages.find((page)=>page.routePath === (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.withBase)(normalizedItem, base));
902
777
  return {
903
- text: applyReplaceRules((null == page ? void 0 : page.title) || '', replaceRules),
778
+ text: applyReplaceRules(page?.title || '', replaceRules),
904
779
  link: normalizedItem,
905
- _fileKey: null == page ? void 0 : page._relativePath.replace(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(page._relativePath), '')
780
+ _fileKey: page?._relativePath.replace(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(page._relativePath), '')
906
781
  };
907
782
  }
908
783
  return {
@@ -948,19 +823,18 @@ function normalizeThemeConfig(docConfig, pages = []) {
948
823
  }, {});
949
824
  };
950
825
  if (locales.length) themeConfig.locales = locales.map(({ lang: currentLang, label })=>{
951
- var _themeConfig_locales;
952
- const localeInThemeConfig = null == (_themeConfig_locales = themeConfig.locales) ? void 0 : _themeConfig_locales.find((locale)=>locale.lang === currentLang);
826
+ const localeInThemeConfig = themeConfig.locales?.find((locale)=>locale.lang === currentLang);
953
827
  return {
954
828
  lang: currentLang,
955
829
  label,
956
830
  ...localeInThemeConfig || {},
957
- sidebar: normalizeSidebar((null == localeInThemeConfig ? void 0 : localeInThemeConfig.sidebar) ?? themeConfig.sidebar, currentLang),
958
- nav: normalizeNav((null == localeInThemeConfig ? void 0 : localeInThemeConfig.nav) ?? themeConfig.nav, currentLang)
831
+ sidebar: normalizeSidebar(localeInThemeConfig?.sidebar ?? themeConfig.sidebar, currentLang),
832
+ nav: normalizeNav(localeInThemeConfig?.nav ?? themeConfig.nav, currentLang)
959
833
  };
960
834
  });
961
835
  else {
962
- themeConfig.sidebar = normalizeSidebar(null == themeConfig ? void 0 : themeConfig.sidebar);
963
- themeConfig.nav = normalizeNav(null == themeConfig ? void 0 : themeConfig.nav);
836
+ themeConfig.sidebar = normalizeSidebar(themeConfig?.sidebar);
837
+ themeConfig.nav = normalizeNav(themeConfig?.nav);
964
838
  }
965
839
  return themeConfig;
966
840
  }
@@ -973,22 +847,20 @@ function deletePrivateField(obj) {
973
847
  return newObj;
974
848
  }
975
849
  async function siteDataVMPlugin(context) {
976
- var _userConfig_themeConfig, _userConfig_multiVersion, _userConfig_multiVersion1, _userConfig_markdown, _userConfig_markdown1, _userConfig_markdown2, _siteData_pages_;
977
850
  const { config, alias, userDocRoot, routeService, pluginDriver } = context;
978
851
  const userConfig = config;
979
852
  const tempSearchObj = Object.assign({}, userConfig.search);
980
853
  if (tempSearchObj) tempSearchObj.searchHooks = void 0;
981
854
  const highlightLanguages = new Set();
982
- const replaceRules = (null == userConfig ? void 0 : userConfig.replaceRules) || [];
983
- const searchConfig = (null == userConfig ? void 0 : userConfig.search) || {};
984
- const domain = (null == searchConfig ? void 0 : searchConfig.mode) === 'remote' ? searchConfig.domain ?? '' : '';
855
+ const replaceRules = userConfig?.replaceRules || [];
856
+ const searchConfig = userConfig?.search || {};
857
+ const domain = searchConfig?.mode === 'remote' ? searchConfig.domain ?? '' : '';
985
858
  const searchCodeBlocks = 'codeBlocks' in searchConfig ? Boolean(searchConfig.codeBlocks) : true;
986
859
  const pages = await extractPageData(replaceRules, alias, domain, userDocRoot, routeService, highlightLanguages, searchCodeBlocks);
987
860
  await pluginDriver.modifySearchIndexData(pages);
988
861
  const versioned = userConfig.search && 'remote' !== userConfig.search.mode && userConfig.search.versioned;
989
862
  const groupedPages = (0, __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__.groupBy)(pages, (page)=>{
990
- var _page_frontmatter;
991
- if ((null == (_page_frontmatter = page.frontmatter) ? void 0 : _page_frontmatter.pageType) === 'home') return 'noindex';
863
+ if (page.frontmatter?.pageType === 'home') return 'noindex';
992
864
  const version = versioned ? page.version : '';
993
865
  const lang = page.lang || '';
994
866
  return `${version}###${lang}`;
@@ -1009,39 +881,39 @@ async function siteDataVMPlugin(context) {
1009
881
  }));
1010
882
  await Promise.all(pages.map(async (pageData)=>pluginDriver.extendPageData(pageData)));
1011
883
  const siteData = {
1012
- title: (null == userConfig ? void 0 : userConfig.title) || '',
1013
- description: (null == userConfig ? void 0 : userConfig.description) || '',
1014
- icon: (null == userConfig ? void 0 : userConfig.icon) || '',
1015
- route: (null == userConfig ? void 0 : userConfig.route) || {},
884
+ title: userConfig?.title || '',
885
+ description: userConfig?.description || '',
886
+ icon: userConfig?.icon || '',
887
+ route: userConfig?.route || {},
1016
888
  themeConfig: normalizeThemeConfig(userConfig, pages),
1017
- base: (null == userConfig ? void 0 : userConfig.base) || '/',
1018
- lang: (null == userConfig ? void 0 : userConfig.lang) || '',
1019
- locales: (null == userConfig ? void 0 : userConfig.locales) || (null == (_userConfig_themeConfig = userConfig.themeConfig) ? void 0 : _userConfig_themeConfig.locales) || [],
1020
- logo: (null == userConfig ? void 0 : userConfig.logo) || '',
1021
- logoText: (null == userConfig ? void 0 : userConfig.logoText) || '',
1022
- ssg: Boolean((null == userConfig ? void 0 : userConfig.ssg) ?? true),
889
+ base: userConfig?.base || '/',
890
+ lang: userConfig?.lang || '',
891
+ locales: userConfig?.locales || userConfig.themeConfig?.locales || [],
892
+ logo: userConfig?.logo || '',
893
+ logoText: userConfig?.logoText || '',
894
+ ssg: Boolean(userConfig?.ssg ?? true),
1023
895
  multiVersion: {
1024
- default: (null == userConfig ? void 0 : null == (_userConfig_multiVersion = userConfig.multiVersion) ? void 0 : _userConfig_multiVersion.default) || '',
1025
- versions: (null == userConfig ? void 0 : null == (_userConfig_multiVersion1 = userConfig.multiVersion) ? void 0 : _userConfig_multiVersion1.versions) || []
896
+ default: userConfig?.multiVersion?.default || '',
897
+ versions: userConfig?.multiVersion?.versions || []
1026
898
  },
1027
899
  search: tempSearchObj ?? {
1028
900
  mode: 'local'
1029
901
  },
1030
902
  pages: pages.map((page)=>{
1031
- const { content, id, domain, _filepath, _html, ...rest } = page;
903
+ const { content, id, domain, _filepath, _html, _flattenContent, ...rest } = page;
1032
904
  return isProduction() ? rest : {
1033
905
  ...rest,
1034
906
  _filepath
1035
907
  };
1036
908
  }),
1037
909
  markdown: {
1038
- showLineNumbers: (null == userConfig ? void 0 : null == (_userConfig_markdown = userConfig.markdown) ? void 0 : _userConfig_markdown.showLineNumbers) ?? false,
1039
- defaultWrapCode: (null == userConfig ? void 0 : null == (_userConfig_markdown1 = userConfig.markdown) ? void 0 : _userConfig_markdown1.defaultWrapCode) ?? false,
1040
- codeHighlighter: (null == userConfig ? void 0 : null == (_userConfig_markdown2 = userConfig.markdown) ? void 0 : _userConfig_markdown2.codeHighlighter) || 'prism'
910
+ showLineNumbers: userConfig?.markdown?.showLineNumbers ?? false,
911
+ defaultWrapCode: userConfig?.markdown?.defaultWrapCode ?? false,
912
+ codeHighlighter: userConfig?.markdown?.codeHighlighter || 'prism'
1041
913
  }
1042
914
  };
1043
915
  const { highlightLanguages: defaultLanguages = [] } = config.markdown || {};
1044
- if (Array.isArray(null == (_siteData_pages_ = siteData.pages[0]) ? void 0 : _siteData_pages_.extraHighlightLanguages)) siteData.pages[0].extraHighlightLanguages.forEach((lang)=>highlightLanguages.add(lang));
916
+ if (Array.isArray(siteData.pages[0]?.extraHighlightLanguages)) siteData.pages[0].extraHighlightLanguages.forEach((lang)=>highlightLanguages.add(lang));
1045
917
  const aliases = handleHighlightLanguages(highlightLanguages, defaultLanguages);
1046
918
  const sortedAliases = Object.fromEntries(Object.entries(aliases).sort());
1047
919
  const sortedHighlightLanguages = Array.from(highlightLanguages).sort();
@@ -1092,7 +964,7 @@ const globalStylesVMPlugin = (context)=>({
1092
964
  const { config, pluginDriver } = context;
1093
965
  const globalStylesByPlugins = pluginDriver.globalStyles();
1094
966
  const moduleContent = [
1095
- null == config ? void 0 : config.globalStyles,
967
+ config?.globalStyles,
1096
968
  ...globalStylesByPlugins
1097
969
  ].filter(Boolean).map((source)=>`import ${JSON.stringify(source)};`).join('');
1098
970
  return moduleContent;
@@ -1104,7 +976,7 @@ const globalUIComponentsVMPlugin = (context)=>({
1104
976
  let index = 0;
1105
977
  const globalUIComponentsByPlugins = pluginDriver.globalUIComponents();
1106
978
  const globalComponents = [
1107
- ...(null == config ? void 0 : config.globalUIComponents) || [],
979
+ ...config?.globalUIComponents || [],
1108
980
  ...globalUIComponentsByPlugins
1109
981
  ];
1110
982
  const moduleContent = globalComponents.map((source)=>{
@@ -1131,11 +1003,10 @@ const searchHookVMPlugin = (context)=>({
1131
1003
  }
1132
1004
  });
1133
1005
  async function writeSearchIndex(config) {
1134
- var _config_search;
1135
- if ((null == config ? void 0 : config.search) === false) return;
1006
+ if (config?.search === false) return;
1136
1007
  const cwd = process.cwd();
1137
1008
  const searchIndexFiles = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readdir(constants_TEMP_DIR);
1138
- const outDir = (null == config ? void 0 : config.outDir) ?? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(cwd, OUTPUT_DIR);
1009
+ const outDir = config?.outDir ?? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(cwd, OUTPUT_DIR);
1139
1010
  const targetDir = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outDir, 'static');
1140
1011
  await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].mkdir(targetDir, {
1141
1012
  recursive: true
@@ -1151,7 +1022,7 @@ async function writeSearchIndex(config) {
1151
1022
  await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].rename(source, target);
1152
1023
  scanning = true;
1153
1024
  }
1154
- if (isProduction() && (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isSCM)() && (null == config ? void 0 : null == (_config_search = config.search) ? void 0 : _config_search.mode) === 'remote') {
1025
+ if (isProduction() && (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isSCM)() && config?.search?.mode === 'remote') {
1155
1026
  const { apiUrl, indexName } = config.search;
1156
1027
  try {
1157
1028
  await fetch(`${apiUrl}?index=${indexName}`, {
@@ -1169,16 +1040,15 @@ async function writeSearchIndex(config) {
1169
1040
  }
1170
1041
  function serveSearchIndexMiddleware(config) {
1171
1042
  return (req, res, next)=>{
1172
- var _req_url;
1173
1043
  const searchIndexRequestMatch = `/${__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.SEARCH_INDEX_NAME}.`;
1174
- if (null == (_req_url = req.url) ? void 0 : _req_url.includes(searchIndexRequestMatch)) {
1044
+ if (req.url?.includes(searchIndexRequestMatch)) {
1175
1045
  res.setHeader('Content-Type', 'application/json');
1176
- const outDir = (null == config ? void 0 : config.outDir) ?? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(process.cwd(), OUTPUT_DIR);
1046
+ const outDir = config?.outDir ?? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(process.cwd(), OUTPUT_DIR);
1177
1047
  const searchIndexFile = req.url.split('/').pop();
1178
1048
  (0, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.createReadStream)((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outDir, 'static', searchIndexFile), 'utf-8').pipe(res, {
1179
1049
  end: true
1180
1050
  });
1181
- } else null == next || next();
1051
+ } else next?.();
1182
1052
  };
1183
1053
  }
1184
1054
  async function renderFrontmatterHead(route) {
@@ -1231,7 +1101,7 @@ async function renderPages(routeService, config, pluginDriver, ssrBundlePath, ht
1231
1101
  }
1232
1102
  try {
1233
1103
  const routes = routeService.getRoutes();
1234
- const base = (null == config ? void 0 : config.base) ?? '';
1104
+ const base = config?.base ?? '';
1235
1105
  const additionalRoutes = (await pluginDriver.addSSGRoutes()).map((route)=>({
1236
1106
  routePath: (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.withBase)(route.path, base)
1237
1107
  }));
@@ -1264,16 +1134,10 @@ async function renderPages(routeService, config, pluginDriver, ssrBundlePath, ht
1264
1134
  helmet.script.toString(),
1265
1135
  await renderFrontmatterHead(route)
1266
1136
  ].join(''));
1267
- if (helmet.htmlAttributes) {
1268
- var _helmet_htmlAttributes;
1269
- html = html.replace(HTML_START_TAG, `${HTML_START_TAG} ${null == (_helmet_htmlAttributes = helmet.htmlAttributes) ? void 0 : _helmet_htmlAttributes.toString()}`);
1270
- }
1271
- if (helmet.bodyAttributes) {
1272
- var _helmet_bodyAttributes;
1273
- html = html.replace(BODY_START_TAG, `${BODY_START_TAG} ${null == (_helmet_bodyAttributes = helmet.bodyAttributes) ? void 0 : _helmet_bodyAttributes.toString()}`);
1274
- }
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()}`);
1275
1139
  const normalizeHtmlFilePath = (path)=>{
1276
- const normalizedBase = `${(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeSlash)((null == config ? void 0 : config.base) || '/')}/`;
1140
+ const normalizedBase = `${(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeSlash)(config?.base || '/')}/`;
1277
1141
  if (path.endsWith('/')) return `${path}index.html`.replace(normalizedBase, '');
1278
1142
  return `${path}.html`.replace(normalizedBase, '');
1279
1143
  };
@@ -1346,17 +1210,49 @@ const rsbuildPluginSSG = ({ routeService, config, pluginDriver })=>({
1346
1210
  }
1347
1211
  });
1348
1212
  const { CachedInputFileSystem: detectReactVersion_CachedInputFileSystem, ResolverFactory: detectReactVersion_ResolverFactory } = __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__["default"];
1349
- const DEFAULT_REACT_VERSION = 18;
1350
- async function detectReactVersion() {
1213
+ async function detectPackageMajorVersion(name) {
1351
1214
  const cwd = process.cwd();
1352
- const reactPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(cwd, 'node_modules', 'react');
1353
- if (await pathExists(reactPath)) {
1354
- var _reactPkg_version;
1355
- const reactPkg = await readJson(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(reactPath, 'package.json'));
1356
- const version = Number(null == (_reactPkg_version = reactPkg.version) ? void 0 : _reactPkg_version.split('.')[0]);
1215
+ const pkgPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(cwd, 'node_modules', name);
1216
+ if (await pathExists(pkgPath)) {
1217
+ const pkgJson = await readJson(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(pkgPath, 'package.json'));
1218
+ const version = Number(pkgJson.version?.split('.')[0]);
1357
1219
  return version;
1358
1220
  }
1359
- return DEFAULT_REACT_VERSION;
1221
+ }
1222
+ const DEFAULT_REACT_VERSION = 19;
1223
+ async function detectReactVersion() {
1224
+ return await detectPackageMajorVersion('react') ?? DEFAULT_REACT_VERSION;
1225
+ }
1226
+ async function resolveReactRouterDomAlias() {
1227
+ const alias = {};
1228
+ const resolver = detectReactVersion_ResolverFactory.createResolver({
1229
+ fileSystem: new detectReactVersion_CachedInputFileSystem(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"], 0),
1230
+ mainFields: [
1231
+ 'browser',
1232
+ 'module',
1233
+ 'main'
1234
+ ],
1235
+ extensions: [
1236
+ '.js'
1237
+ ],
1238
+ alias
1239
+ });
1240
+ try {
1241
+ const pkgPath = await new Promise((resolve, reject)=>{
1242
+ resolver.resolve({
1243
+ importer: PACKAGE_ROOT
1244
+ }, PACKAGE_ROOT, 'react-router-dom', {}, (err, filePath)=>{
1245
+ if (err || !filePath) return reject(err);
1246
+ return resolve(filePath);
1247
+ });
1248
+ });
1249
+ return {
1250
+ 'react-router-dom': pkgPath
1251
+ };
1252
+ } catch (e) {
1253
+ __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.warn('react-router-dom not found: \n', e);
1254
+ }
1255
+ return {};
1360
1256
  }
1361
1257
  async function resolveReactAlias(reactVersion, isSSR) {
1362
1258
  const basedir = reactVersion === DEFAULT_REACT_VERSION ? PACKAGE_ROOT : process.cwd();
@@ -1367,7 +1263,7 @@ async function resolveReactAlias(reactVersion, isSSR) {
1367
1263
  'react-dom',
1368
1264
  'react-dom/server'
1369
1265
  ];
1370
- if (reactVersion >= DEFAULT_REACT_VERSION) libPaths.push('react-dom/client');
1266
+ if (reactVersion >= 18) libPaths.push('react-dom/client');
1371
1267
  const alias = {};
1372
1268
  const resolver = detectReactVersion_ResolverFactory.createResolver({
1373
1269
  fileSystem: new detectReactVersion_CachedInputFileSystem(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"], 0),
@@ -1441,17 +1337,15 @@ function getSocialIcons(socialLinks = []) {
1441
1337
  return icons;
1442
1338
  }
1443
1339
  function isPluginIncluded(config, pluginName) {
1444
- var _config_builderPlugins, _config_builderConfig_plugins, _config_builderConfig;
1445
- return Boolean((null == (_config_builderPlugins = config.builderPlugins) ? void 0 : _config_builderPlugins.some((plugin)=>plugin.name === pluginName)) || (null == (_config_builderConfig = config.builderConfig) ? void 0 : null == (_config_builderConfig_plugins = _config_builderConfig.plugins) ? void 0 : _config_builderConfig_plugins.some((plugin)=>plugin && plugin.name === pluginName)));
1340
+ return Boolean(config.builderPlugins?.some((plugin)=>plugin.name === pluginName) || config.builderConfig?.plugins?.some((plugin)=>plugin && plugin.name === pluginName));
1446
1341
  }
1447
1342
  async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, runtimeTempDir) {
1448
- var _config_builderConfig_output, _config_builderConfig, _config_themeConfig, _config_themeConfig1;
1449
1343
  const cwd = process.cwd();
1450
- const CUSTOM_THEME_DIR = (null == config ? void 0 : config.themeDir) ?? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), 'theme');
1451
- const outDir = (null == config ? void 0 : config.outDir) ?? OUTPUT_DIR;
1344
+ const CUSTOM_THEME_DIR = config?.themeDir ?? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), 'theme');
1345
+ const outDir = config?.outDir ?? OUTPUT_DIR;
1452
1346
  const DEFAULT_THEME = require.resolve('@rspress/theme-default');
1453
- const base = (null == config ? void 0 : config.base) ?? '';
1454
- const assetPrefix = isProduction() ? (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.removeTrailingSlash)((null == config ? void 0 : null == (_config_builderConfig = config.builderConfig) ? void 0 : null == (_config_builderConfig_output = _config_builderConfig.output) ? void 0 : _config_builderConfig_output.assetPrefix) ?? base) : '';
1347
+ const base = config?.base ?? '';
1348
+ const assetPrefix = isProduction() ? (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.removeTrailingSlash)(config?.builderConfig?.output?.assetPrefix ?? base) : '';
1455
1349
  const reactVersion = await detectReactVersion();
1456
1350
  const normalizeIcon = (icon)=>{
1457
1351
  if (!icon) return;
@@ -1459,10 +1353,11 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1459
1353
  return icon;
1460
1354
  };
1461
1355
  await hintThemeBreakingChange(CUSTOM_THEME_DIR);
1462
- const [detectCustomIconAlias, reactCSRAlias, reactSSRAlias] = await Promise.all([
1356
+ const [detectCustomIconAlias, reactCSRAlias, reactSSRAlias, reactRouterDomAlias] = await Promise.all([
1463
1357
  detectCustomIcon(CUSTOM_THEME_DIR),
1464
1358
  resolveReactAlias(reactVersion, false),
1465
- enableSSG ? resolveReactAlias(reactVersion, true) : Promise.resolve({})
1359
+ enableSSG ? resolveReactAlias(reactVersion, true) : Promise.resolve({}),
1360
+ resolveReactRouterDomAlias()
1466
1361
  ]);
1467
1362
  const context = {
1468
1363
  userDocRoot,
@@ -1512,11 +1407,11 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1512
1407
  }
1513
1408
  },
1514
1409
  html: {
1515
- title: (null == config ? void 0 : config.title) ?? DEFAULT_TITLE,
1516
- favicon: normalizeIcon(null == config ? void 0 : config.icon),
1410
+ title: config?.title ?? DEFAULT_TITLE,
1411
+ favicon: normalizeIcon(config?.icon),
1517
1412
  template: TEMPLATE_PATH,
1518
1413
  tags: [
1519
- (null == (_config_themeConfig = config.themeConfig) ? void 0 : _config_themeConfig.darkMode) !== false ? {
1414
+ config.themeConfig?.darkMode !== false ? {
1520
1415
  tag: "script",
1521
1416
  children: inlineThemeScript,
1522
1417
  append: false
@@ -1551,7 +1446,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1551
1446
  define: {
1552
1447
  'process.env.__REACT_GTE_18__': JSON.stringify(reactVersion >= 18),
1553
1448
  'process.env.TEST': JSON.stringify(process.env.TEST),
1554
- 'process.env.RSPRESS_SOCIAL_ICONS': JSON.stringify(getSocialIcons(null == (_config_themeConfig1 = config.themeConfig) ? void 0 : _config_themeConfig1.socialLinks))
1449
+ 'process.env.RSPRESS_SOCIAL_ICONS': JSON.stringify(getSocialIcons(config.themeConfig?.socialLinks))
1555
1450
  }
1556
1451
  },
1557
1452
  performance: {
@@ -1571,11 +1466,10 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1571
1466
  },
1572
1467
  tools: {
1573
1468
  bundlerChain (chain, { CHAIN_ID, target }) {
1574
- var _config_markdown;
1575
1469
  const isServer = 'node' === target;
1576
1470
  const jsModuleRule = chain.module.rule(CHAIN_ID.RULE.JS);
1577
1471
  const swcLoaderOptions = jsModuleRule.use(CHAIN_ID.USE.SWC).get('options');
1578
- const checkDeadLinks = ((null == config ? void 0 : null == (_config_markdown = config.markdown) ? void 0 : _config_markdown.checkDeadLinks) && !isServer) ?? false;
1472
+ const checkDeadLinks = (config?.markdown?.checkDeadLinks && !isServer) ?? false;
1579
1473
  chain.module.rule('MDX').type("javascript/auto").test(__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP).resolve.merge({
1580
1474
  conditionNames: jsModuleRule.resolve.conditionNames.values(),
1581
1475
  mainFields: jsModuleRule.resolve.mainFields.values()
@@ -1612,6 +1506,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1612
1506
  resolve: {
1613
1507
  alias: {
1614
1508
  ...reactCSRAlias,
1509
+ ...reactRouterDomAlias,
1615
1510
  __VIRTUAL_ROUTES__: 'virtual-routes'
1616
1511
  }
1617
1512
  },
@@ -1635,6 +1530,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1635
1530
  resolve: {
1636
1531
  alias: {
1637
1532
  ...reactSSRAlias,
1533
+ ...reactRouterDomAlias,
1638
1534
  __VIRTUAL_ROUTES__: 'virtual-routes-ssr'
1639
1535
  }
1640
1536
  },
@@ -1669,10 +1565,9 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1669
1565
  };
1670
1566
  }
1671
1567
  async function initRsbuild(rootDir, config, pluginDriver, enableSSG, extraRsbuildConfig) {
1672
- var _pluginDriver_getPlugins;
1673
1568
  const cwd = process.cwd();
1674
- const userDocRoot = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(rootDir || (null == config ? void 0 : config.root) || cwd);
1675
- const builderPlugins = (null == config ? void 0 : config.builderPlugins) ?? [];
1569
+ const userDocRoot = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(rootDir || config?.root || cwd);
1570
+ const builderPlugins = config?.builderPlugins ?? [];
1676
1571
  const runtimeTempDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.RSPRESS_TEMP_DIR, 'runtime');
1677
1572
  const runtimeAbsTempDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(cwd, 'node_modules', runtimeTempDir);
1678
1573
  await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].mkdir(runtimeAbsTempDir, {
@@ -1687,7 +1582,7 @@ async function initRsbuild(rootDir, config, pluginDriver, enableSSG, extraRsbuil
1687
1582
  const { createRsbuild, mergeRsbuildConfig } = await import("@rsbuild/core");
1688
1583
  const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, runtimeTempDir);
1689
1584
  const rsbuild = await createRsbuild({
1690
- rsbuildConfig: mergeRsbuildConfig(internalRsbuildConfig, ...(null == (_pluginDriver_getPlugins = pluginDriver.getPlugins()) ? void 0 : _pluginDriver_getPlugins.map((plugin)=>plugin.builderConfig ?? {})) || [], (null == config ? void 0 : config.builderConfig) || {}, extraRsbuildConfig || {})
1585
+ rsbuildConfig: mergeRsbuildConfig(internalRsbuildConfig, ...pluginDriver.getPlugins()?.map((plugin)=>plugin.builderConfig ?? {}) || [], config?.builderConfig || {}, extraRsbuildConfig || {})
1691
1586
  });
1692
1587
  rsbuild.addPlugins(builderPlugins);
1693
1588
  return rsbuild;
@@ -1736,15 +1631,14 @@ async function collectModuleFiles(contentPath, lang, includedDir, excludedDirs,
1736
1631
  return fileLangMap;
1737
1632
  }
1738
1633
  async function checkLanguageParity(config) {
1739
- var _config_languageParity_include, _this, _config_themeConfig;
1740
- if (!(null == config ? void 0 : config.languageParity) || false === config.languageParity.enabled) return;
1634
+ if (!config?.languageParity || false === config.languageParity.enabled) return;
1741
1635
  __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info('Checking language parity...');
1742
1636
  const contentPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(config.root);
1743
- const includedDirs = (null == (_config_languageParity_include = config.languageParity.include) ? void 0 : _config_languageParity_include.length) ? config.languageParity.include : [
1637
+ const includedDirs = config.languageParity.include?.length ? config.languageParity.include : [
1744
1638
  ''
1745
1639
  ];
1746
1640
  const excludedDirs = config.languageParity.exclude ?? [];
1747
- const supportedLanguages = (null == (_this = config.locales ?? (null == (_config_themeConfig = config.themeConfig) ? void 0 : _config_themeConfig.locales)) ? void 0 : _this.map((locale)=>locale.lang)) || [];
1641
+ const supportedLanguages = (config.locales ?? config.themeConfig?.locales)?.map((locale)=>locale.lang) || [];
1748
1642
  if (!supportedLanguages.length) return void __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error('No supported languages found in the configuration.');
1749
1643
  const missingLanguagesFile = [];
1750
1644
  try {
@@ -1816,13 +1710,12 @@ async function build(options) {
1816
1710
  await pluginDriver.afterBuild();
1817
1711
  }
1818
1712
  async function serve(options) {
1819
- var _builderConfig_server, _builderConfig_server1;
1820
1713
  const { config, port: userPort, host: userHost } = options;
1821
1714
  const envPort = process.env.PORT;
1822
1715
  const envHost = process.env.HOST;
1823
1716
  const { builderConfig } = config;
1824
- const port = Number(envPort || userPort || (null == builderConfig ? void 0 : null == (_builderConfig_server = builderConfig.server) ? void 0 : _builderConfig_server.port) || 4173);
1825
- const host = envHost || userHost || (null == builderConfig ? void 0 : null == (_builderConfig_server1 = builderConfig.server) ? void 0 : _builderConfig_server1.host) || 'localhost';
1717
+ const port = Number(envPort || userPort || builderConfig?.server?.port || 4173);
1718
+ const host = envHost || userHost || builderConfig?.server?.host || 'localhost';
1826
1719
  config.builderConfig = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(builderConfig, {
1827
1720
  server: {
1828
1721
  port,
@@ -1835,5 +1728,124 @@ async function serve(options) {
1835
1728
  const rsbuild = await initRsbuild(config.root, modifiedConfig, pluginDriver, false);
1836
1729
  return rsbuild.preview();
1837
1730
  }
1731
+ const getASTNodeImport = (name, from)=>({
1732
+ type: 'mdxjsEsm',
1733
+ value: `import ${name} from ${JSON.stringify(from)}`,
1734
+ data: {
1735
+ estree: {
1736
+ type: 'Program',
1737
+ sourceType: 'module',
1738
+ body: [
1739
+ {
1740
+ type: 'ImportDeclaration',
1741
+ specifiers: [
1742
+ {
1743
+ type: 'ImportDefaultSpecifier',
1744
+ local: {
1745
+ type: 'Identifier',
1746
+ name
1747
+ }
1748
+ }
1749
+ ],
1750
+ source: {
1751
+ type: 'Literal',
1752
+ value: from,
1753
+ raw: `${JSON.stringify(from)}`
1754
+ }
1755
+ }
1756
+ ]
1757
+ }
1758
+ }
1759
+ });
1760
+ function normalizeLink(nodeUrl, routeService, relativePath, cleanUrls) {
1761
+ if (!nodeUrl) return '';
1762
+ if (nodeUrl.startsWith('#')) return `#${nodeUrl.slice(1)}`;
1763
+ let { url, hash } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.parseUrl)(nodeUrl);
1764
+ if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isExternalUrl)(url)) return url + (hash ? `#${hash}` : '');
1765
+ const extname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(url);
1766
+ if ((routeService?.extensions ?? __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__.DEFAULT_PAGE_EXTENSIONS).includes(extname)) url = url.replace(new RegExp(`\\${extname}$`), '');
1767
+ if (url.startsWith('.')) url = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.join((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.slash)(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(relativePath)), url);
1768
+ else if (routeService) {
1769
+ const [pathVersion, pathLang] = routeService.getRoutePathParts((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.slash)(relativePath));
1770
+ const [urlVersion, urlLang, urlPath] = routeService.getRoutePathParts(url);
1771
+ url = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.addLeadingSlash)(urlPath);
1772
+ if (pathLang && urlLang !== pathLang) url = `/${pathLang}${url}`;
1773
+ if (pathVersion && urlVersion !== pathVersion) url = `/${pathVersion}${url}`;
1774
+ }
1775
+ if ('boolean' == typeof cleanUrls) url = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeHref)(url, cleanUrls);
1776
+ else {
1777
+ url = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeHref)(url, false);
1778
+ url = url.replace(/\.html$/, cleanUrls);
1779
+ }
1780
+ if (hash) url += `#${hash}`;
1781
+ return url;
1782
+ }
1783
+ const normalizeImageUrl = (imageUrl)=>{
1784
+ if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isExternalUrl)(imageUrl) || imageUrl.startsWith('/')) return '';
1785
+ return imageUrl;
1786
+ };
1787
+ const remarkPluginNormalizeLink = ({ root, cleanUrls, routeService })=>(tree, file)=>{
1788
+ const images = [];
1789
+ (0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'link', (node)=>{
1790
+ const { url: nodeUrl } = node;
1791
+ const relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, file.path);
1792
+ node.url = normalizeLink(nodeUrl, routeService, relativePath, cleanUrls);
1793
+ });
1794
+ const getMdxSrcAttribute = (tempVar)=>({
1795
+ type: 'mdxJsxAttribute',
1796
+ name: 'src',
1797
+ value: {
1798
+ type: 'mdxJsxAttributeValueExpression',
1799
+ value: tempVar,
1800
+ data: {
1801
+ estree: {
1802
+ type: 'Program',
1803
+ sourceType: 'module',
1804
+ body: [
1805
+ {
1806
+ type: 'ExpressionStatement',
1807
+ expression: {
1808
+ type: 'Identifier',
1809
+ name: tempVar
1810
+ }
1811
+ }
1812
+ ]
1813
+ }
1814
+ }
1815
+ }
1816
+ });
1817
+ (0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'image', (node)=>{
1818
+ const { alt, url } = node;
1819
+ if (!url) return;
1820
+ const imagePath = normalizeImageUrl(url);
1821
+ if (!imagePath) return;
1822
+ const tempVariableName = `image${images.length}`;
1823
+ Object.assign(node, {
1824
+ type: 'mdxJsxFlowElement',
1825
+ name: 'img',
1826
+ children: [],
1827
+ attributes: [
1828
+ alt && {
1829
+ type: 'mdxJsxAttribute',
1830
+ name: 'alt',
1831
+ value: alt
1832
+ },
1833
+ getMdxSrcAttribute(tempVariableName)
1834
+ ].filter(Boolean)
1835
+ });
1836
+ images.push(getASTNodeImport(tempVariableName, imagePath));
1837
+ });
1838
+ (0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, (node)=>{
1839
+ if ('mdxJsxFlowElement' !== node.type && 'mdxJsxTextElement' !== node.type || 'img' !== node.name) return;
1840
+ const srcAttr = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.getNodeAttribute)(node, 'src', true);
1841
+ if ('string' != typeof srcAttr?.value) return;
1842
+ const imagePath = normalizeImageUrl(srcAttr.value);
1843
+ if (!imagePath) return;
1844
+ const tempVariableName = `image${images.length}`;
1845
+ Object.assign(srcAttr, getMdxSrcAttribute(tempVariableName));
1846
+ images.push(getASTNodeImport(tempVariableName, imagePath));
1847
+ });
1848
+ tree.children.unshift(...images);
1849
+ };
1838
1850
  var __webpack_exports__mergeDocConfig = __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.mergeDocConfig;
1839
- export { build, dev, serve, __webpack_exports__mergeDocConfig as mergeDocConfig };
1851
+ export { build, dev, remarkPluginNormalizeLink, serve, __webpack_exports__mergeDocConfig as mergeDocConfig };