@rspress/core 1.43.13 → 1.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +38 -38
- package/dist/loader.d.ts +0 -4
- package/dist/loader.js +18 -158
- package/dist/runtime/App.js +4 -4
- package/dist/runtime/tsconfig.js +3 -3
- package/package.json +15 -15
package/dist/index.js
CHANGED
|
@@ -4,19 +4,19 @@ import * as __WEBPACK_EXTERNAL_MODULE__rspress_plugin_container_syntax_12d3c700_
|
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
|
|
7
8
|
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_less_4c557a99__ from "@rsbuild/plugin-less";
|
|
8
9
|
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__ from "@rsbuild/plugin-react";
|
|
9
10
|
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_sass_b13a7d33__ from "@rsbuild/plugin-sass";
|
|
10
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
|
|
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
15
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__ from "@rspress/shared/logger";
|
|
16
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__ from "@rspress/shared/node-utils";
|
|
16
17
|
import * as __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__ from "lodash-es";
|
|
17
18
|
import * as __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__ from "node:crypto";
|
|
18
19
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_mdx_rs_d2f3021f__ from "@rspress/mdx-rs";
|
|
19
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__ from "@rspress/shared/node-utils";
|
|
20
20
|
import * as __WEBPACK_EXTERNAL_MODULE_html_to_text_2c51ed38__ from "html-to-text";
|
|
21
21
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
22
22
|
import * as __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__ from "@mdx-js/mdx";
|
|
@@ -64,9 +64,9 @@ class PluginDriver {
|
|
|
64
64
|
this.clearPlugins();
|
|
65
65
|
const config = _class_private_field_get(this, _config);
|
|
66
66
|
const themeConfig = (null == config ? void 0 : config.themeConfig) || {};
|
|
67
|
-
const enableLastUpdated = (null == themeConfig ? void 0 : themeConfig.lastUpdated) || (null == themeConfig ? void 0 : null
|
|
67
|
+
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));
|
|
68
68
|
const mediumZoomConfig = (null == config ? void 0 : config.mediumZoom) ?? true;
|
|
69
|
-
const haveNavSidebarConfig = themeConfig.nav || themeConfig.sidebar || (null
|
|
69
|
+
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);
|
|
70
70
|
if (enableLastUpdated) {
|
|
71
71
|
const { pluginLastUpdated } = await import("@rspress/plugin-last-updated");
|
|
72
72
|
this.addPlugin(pluginLastUpdated());
|
|
@@ -465,7 +465,7 @@ ${routeMeta.map((route, index)=>{
|
|
|
465
465
|
RouteService_class_private_field_set(this, _include, routeOptions.include || []);
|
|
466
466
|
RouteService_class_private_field_set(this, _exclude, routeOptions.exclude || []);
|
|
467
467
|
RouteService_class_private_field_set(this, _defaultLang, (null == userConfig ? void 0 : userConfig.lang) || '');
|
|
468
|
-
RouteService_class_private_field_set(this, _langs, ((null == userConfig ? void 0 : userConfig.locales) ?? (null == userConfig ? void 0 : null
|
|
468
|
+
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));
|
|
469
469
|
RouteService_class_private_field_set(this, _base, (null == userConfig ? void 0 : userConfig.base) || '');
|
|
470
470
|
RouteService_class_private_field_set(this, _tempDir, tempDir);
|
|
471
471
|
RouteService_class_private_field_set(this, _pluginDriver, pluginDriver);
|
|
@@ -641,7 +641,7 @@ async function flattenMdxContent(content, basePath, alias) {
|
|
|
641
641
|
}
|
|
642
642
|
const importNodes = ast.children.filter((node)=>'mdxjsEsm' === node.type).flatMap((node)=>{
|
|
643
643
|
var _node_data_estree, _node_data;
|
|
644
|
-
return (null
|
|
644
|
+
return (null == (_node_data = node.data) ? void 0 : null == (_node_data_estree = _node_data.estree) ? void 0 : _node_data_estree.body) || [];
|
|
645
645
|
}).filter((node)=>'ImportDeclaration' === node.type);
|
|
646
646
|
for (const importNode of importNodes){
|
|
647
647
|
const id = importNode.specifiers[0].local.name;
|
|
@@ -826,7 +826,7 @@ function normalizeThemeConfig(docConfig, pages = []) {
|
|
|
826
826
|
};
|
|
827
827
|
const getI18nText = (key = '', currentLang = '')=>{
|
|
828
828
|
var _i18nTextData_key;
|
|
829
|
-
const text = null
|
|
829
|
+
const text = null == (_i18nTextData_key = i18nTextData[key]) ? void 0 : _i18nTextData_key[currentLang];
|
|
830
830
|
return text || key;
|
|
831
831
|
};
|
|
832
832
|
const normalizeSidebar = (sidebar, currentLang = '')=>{
|
|
@@ -900,7 +900,7 @@ function normalizeThemeConfig(docConfig, pages = []) {
|
|
|
900
900
|
};
|
|
901
901
|
if (locales.length) themeConfig.locales = locales.map(({ lang: currentLang, label })=>{
|
|
902
902
|
var _themeConfig_locales;
|
|
903
|
-
const localeInThemeConfig = null
|
|
903
|
+
const localeInThemeConfig = null == (_themeConfig_locales = themeConfig.locales) ? void 0 : _themeConfig_locales.find((locale)=>locale.lang === currentLang);
|
|
904
904
|
return {
|
|
905
905
|
lang: currentLang,
|
|
906
906
|
label,
|
|
@@ -939,7 +939,7 @@ async function siteDataVMPlugin(context) {
|
|
|
939
939
|
const versioned = userConfig.search && 'remote' !== userConfig.search.mode && userConfig.search.versioned;
|
|
940
940
|
const groupedPages = (0, __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__.groupBy)(pages, (page)=>{
|
|
941
941
|
var _page_frontmatter;
|
|
942
|
-
if ((null
|
|
942
|
+
if ((null == (_page_frontmatter = page.frontmatter) ? void 0 : _page_frontmatter.pageType) === 'home') return 'noindex';
|
|
943
943
|
const version = versioned ? page.version : '';
|
|
944
944
|
const lang = page.lang || '';
|
|
945
945
|
return `${version}###${lang}`;
|
|
@@ -962,18 +962,18 @@ async function siteDataVMPlugin(context) {
|
|
|
962
962
|
const siteData = {
|
|
963
963
|
title: (null == userConfig ? void 0 : userConfig.title) || '',
|
|
964
964
|
description: (null == userConfig ? void 0 : userConfig.description) || '',
|
|
965
|
-
icon: (null == userConfig ? void 0 : userConfig.icon) || '',
|
|
965
|
+
icon: (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.getIconUrlPath)(null == userConfig ? void 0 : userConfig.icon) || '',
|
|
966
966
|
route: (null == userConfig ? void 0 : userConfig.route) || {},
|
|
967
967
|
themeConfig: normalizeThemeConfig(userConfig, pages),
|
|
968
968
|
base: (null == userConfig ? void 0 : userConfig.base) || '/',
|
|
969
969
|
lang: (null == userConfig ? void 0 : userConfig.lang) || '',
|
|
970
|
-
locales: (null == userConfig ? void 0 : userConfig.locales) || (null
|
|
970
|
+
locales: (null == userConfig ? void 0 : userConfig.locales) || (null == (_userConfig_themeConfig = userConfig.themeConfig) ? void 0 : _userConfig_themeConfig.locales) || [],
|
|
971
971
|
logo: (null == userConfig ? void 0 : userConfig.logo) || '',
|
|
972
972
|
logoText: (null == userConfig ? void 0 : userConfig.logoText) || '',
|
|
973
973
|
ssg: Boolean((null == userConfig ? void 0 : userConfig.ssg) ?? true),
|
|
974
974
|
multiVersion: {
|
|
975
|
-
default: (null == userConfig ? void 0 : null
|
|
976
|
-
versions: (null == userConfig ? void 0 : null
|
|
975
|
+
default: (null == userConfig ? void 0 : null == (_userConfig_multiVersion = userConfig.multiVersion) ? void 0 : _userConfig_multiVersion.default) || '',
|
|
976
|
+
versions: (null == userConfig ? void 0 : null == (_userConfig_multiVersion1 = userConfig.multiVersion) ? void 0 : _userConfig_multiVersion1.versions) || []
|
|
977
977
|
},
|
|
978
978
|
search: tempSearchObj ?? {
|
|
979
979
|
mode: 'local'
|
|
@@ -986,13 +986,13 @@ async function siteDataVMPlugin(context) {
|
|
|
986
986
|
};
|
|
987
987
|
}),
|
|
988
988
|
markdown: {
|
|
989
|
-
showLineNumbers: (null == userConfig ? void 0 : null
|
|
990
|
-
defaultWrapCode: (null == userConfig ? void 0 : null
|
|
991
|
-
codeHighlighter: (null == userConfig ? void 0 : null
|
|
989
|
+
showLineNumbers: (null == userConfig ? void 0 : null == (_userConfig_markdown = userConfig.markdown) ? void 0 : _userConfig_markdown.showLineNumbers) ?? false,
|
|
990
|
+
defaultWrapCode: (null == userConfig ? void 0 : null == (_userConfig_markdown1 = userConfig.markdown) ? void 0 : _userConfig_markdown1.defaultWrapCode) ?? false,
|
|
991
|
+
codeHighlighter: (null == userConfig ? void 0 : null == (_userConfig_markdown2 = userConfig.markdown) ? void 0 : _userConfig_markdown2.codeHighlighter) || 'prism'
|
|
992
992
|
}
|
|
993
993
|
};
|
|
994
994
|
const { highlightLanguages: defaultLanguages = [] } = config.markdown || {};
|
|
995
|
-
if (Array.isArray(null
|
|
995
|
+
if (Array.isArray(null == (_siteData_pages_ = siteData.pages[0]) ? void 0 : _siteData_pages_.extraHighlightLanguages)) siteData.pages[0].extraHighlightLanguages.forEach((lang)=>highlightLanguages.add(lang));
|
|
996
996
|
const aliases = handleHighlightLanguages(highlightLanguages, defaultLanguages);
|
|
997
997
|
const sortedAliases = Object.fromEntries(Object.entries(aliases).sort());
|
|
998
998
|
const sortedHighlightLanguages = Array.from(highlightLanguages).sort();
|
|
@@ -1075,7 +1075,7 @@ async function writeSearchIndex(config) {
|
|
|
1075
1075
|
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].rename(source, target);
|
|
1076
1076
|
scanning = true;
|
|
1077
1077
|
}
|
|
1078
|
-
if (isProduction() && (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isSCM)() && (null == config ? void 0 : null
|
|
1078
|
+
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') {
|
|
1079
1079
|
const { apiUrl, indexName } = config.search;
|
|
1080
1080
|
try {
|
|
1081
1081
|
await fetch(`${apiUrl}?index=${indexName}`, {
|
|
@@ -1095,7 +1095,7 @@ function serveSearchIndexMiddleware(config) {
|
|
|
1095
1095
|
return (req, res, next)=>{
|
|
1096
1096
|
var _req_url;
|
|
1097
1097
|
const searchIndexRequestMatch = `/${__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.SEARCH_INDEX_NAME}.`;
|
|
1098
|
-
if (null
|
|
1098
|
+
if (null == (_req_url = req.url) ? void 0 : _req_url.includes(searchIndexRequestMatch)) {
|
|
1099
1099
|
res.setHeader('Content-Type', 'application/json');
|
|
1100
1100
|
const outDir = (null == config ? void 0 : config.outDir) ?? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(process.cwd(), OUTPUT_DIR);
|
|
1101
1101
|
const searchIndexFile = req.url.split('/').pop();
|
|
@@ -1125,7 +1125,7 @@ async function detectReactVersion() {
|
|
|
1125
1125
|
if (await pathExists(reactPath)) {
|
|
1126
1126
|
var _reactPkg_version;
|
|
1127
1127
|
const reactPkg = await readJson(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(reactPath, 'package.json'));
|
|
1128
|
-
const version = Number(null
|
|
1128
|
+
const version = Number(null == (_reactPkg_version = reactPkg.version) ? void 0 : _reactPkg_version.split('.')[0]);
|
|
1129
1129
|
return version;
|
|
1130
1130
|
}
|
|
1131
1131
|
return DEFAULT_REACT_VERSION;
|
|
@@ -1214,7 +1214,7 @@ function getSocialIcons(socialLinks = []) {
|
|
|
1214
1214
|
}
|
|
1215
1215
|
function isPluginIncluded(config, pluginName) {
|
|
1216
1216
|
var _config_builderPlugins, _config_builderConfig_plugins, _config_builderConfig;
|
|
1217
|
-
return Boolean((null
|
|
1217
|
+
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)));
|
|
1218
1218
|
}
|
|
1219
1219
|
async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, runtimeTempDir) {
|
|
1220
1220
|
var _config_builderConfig_output, _config_builderConfig, _config_themeConfig, _config_themeConfig1;
|
|
@@ -1225,11 +1225,13 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1225
1225
|
const ssrOutDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(baseOutDir, 'ssr');
|
|
1226
1226
|
const DEFAULT_THEME = require.resolve('@rspress/theme-default');
|
|
1227
1227
|
const base = (null == config ? void 0 : config.base) ?? '';
|
|
1228
|
-
const assetPrefix = isProduction() ? (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.removeTrailingSlash)((null == config ? void 0 : null
|
|
1228
|
+
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) : '';
|
|
1229
1229
|
const reactVersion = await detectReactVersion();
|
|
1230
1230
|
const normalizeIcon = (icon)=>{
|
|
1231
1231
|
if (!icon) return;
|
|
1232
|
-
|
|
1232
|
+
icon = icon.toString();
|
|
1233
|
+
if (icon.startsWith('file://')) icon = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(icon);
|
|
1234
|
+
else if (__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(icon)) return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(userDocRoot, PUBLIC_DIR, icon);
|
|
1233
1235
|
return icon;
|
|
1234
1236
|
};
|
|
1235
1237
|
const [detectCustomIconAlias, reactCSRAlias, reactSSRAlias] = await Promise.all([
|
|
@@ -1279,7 +1281,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1279
1281
|
favicon: normalizeIcon(null == config ? void 0 : config.icon),
|
|
1280
1282
|
template: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'index.html'),
|
|
1281
1283
|
tags: [
|
|
1282
|
-
(null
|
|
1284
|
+
(null == (_config_themeConfig = config.themeConfig) ? void 0 : _config_themeConfig.darkMode) !== false ? {
|
|
1283
1285
|
tag: "script",
|
|
1284
1286
|
children: inlineThemeScript,
|
|
1285
1287
|
append: false
|
|
@@ -1314,7 +1316,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1314
1316
|
define: {
|
|
1315
1317
|
'process.env.__REACT_GTE_18__': JSON.stringify(reactVersion >= 18),
|
|
1316
1318
|
'process.env.TEST': JSON.stringify(process.env.TEST),
|
|
1317
|
-
'process.env.RSPRESS_SOCIAL_ICONS': JSON.stringify(getSocialIcons(null
|
|
1319
|
+
'process.env.RSPRESS_SOCIAL_ICONS': JSON.stringify(getSocialIcons(null == (_config_themeConfig1 = config.themeConfig) ? void 0 : _config_themeConfig1.socialLinks))
|
|
1318
1320
|
}
|
|
1319
1321
|
},
|
|
1320
1322
|
performance: {
|
|
@@ -1338,7 +1340,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1338
1340
|
const isServer = 'node' === target;
|
|
1339
1341
|
const jsModuleRule = chain.module.rule(CHAIN_ID.RULE.JS);
|
|
1340
1342
|
const swcLoaderOptions = jsModuleRule.use(CHAIN_ID.USE.SWC).get('options');
|
|
1341
|
-
const checkDeadLinks = ((null == config ? void 0 : null
|
|
1343
|
+
const checkDeadLinks = ((null == config ? void 0 : null == (_config_markdown = config.markdown) ? void 0 : _config_markdown.checkDeadLinks) && !isServer) ?? false;
|
|
1342
1344
|
chain.module.rule('MDX').type("javascript/auto").test(__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP).resolve.merge({
|
|
1343
1345
|
conditionNames: jsModuleRule.resolve.conditionNames.values(),
|
|
1344
1346
|
mainFields: jsModuleRule.resolve.mainFields.values()
|
|
@@ -1444,7 +1446,8 @@ async function initRsbuild(rootDir, config, pluginDriver, enableSSG, extraRsbuil
|
|
|
1444
1446
|
const { createRsbuild, mergeRsbuildConfig } = await import("@rsbuild/core");
|
|
1445
1447
|
const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, runtimeTempDir);
|
|
1446
1448
|
const rsbuild = await createRsbuild({
|
|
1447
|
-
|
|
1449
|
+
callerName: 'rspress',
|
|
1450
|
+
rsbuildConfig: mergeRsbuildConfig(internalRsbuildConfig, ...(null == (_pluginDriver_getPlugins = pluginDriver.getPlugins()) ? void 0 : _pluginDriver_getPlugins.map((plugin)=>plugin.builderConfig ?? {})) || [], (null == config ? void 0 : config.builderConfig) || {}, extraRsbuildConfig || {})
|
|
1448
1451
|
});
|
|
1449
1452
|
rsbuild.addPlugins(builderPlugins);
|
|
1450
1453
|
return rsbuild;
|
|
@@ -1497,15 +1500,12 @@ async function checkLanguageParity(config) {
|
|
|
1497
1500
|
if (!(null == config ? void 0 : config.languageParity) || false === config.languageParity.enabled) return;
|
|
1498
1501
|
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info('Checking language parity...');
|
|
1499
1502
|
const contentPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(config.root);
|
|
1500
|
-
const includedDirs = (null
|
|
1503
|
+
const includedDirs = (null == (_config_languageParity_include = config.languageParity.include) ? void 0 : _config_languageParity_include.length) ? config.languageParity.include : [
|
|
1501
1504
|
''
|
|
1502
1505
|
];
|
|
1503
1506
|
const excludedDirs = config.languageParity.exclude ?? [];
|
|
1504
|
-
const supportedLanguages = (null
|
|
1505
|
-
if (!supportedLanguages.length)
|
|
1506
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error('No supported languages found in the configuration.');
|
|
1507
|
-
return;
|
|
1508
|
-
}
|
|
1507
|
+
const supportedLanguages = (null == (_this = config.locales ?? (null == (_config_themeConfig = config.themeConfig) ? void 0 : _config_themeConfig.locales)) ? void 0 : _this.map((locale)=>locale.lang)) || [];
|
|
1508
|
+
if (!supportedLanguages.length) return void __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error('No supported languages found in the configuration.');
|
|
1509
1509
|
const missingLanguagesFile = [];
|
|
1510
1510
|
try {
|
|
1511
1511
|
for (const includedDir of includedDirs){
|
|
@@ -1549,7 +1549,7 @@ async function dev(options) {
|
|
|
1549
1549
|
}
|
|
1550
1550
|
}
|
|
1551
1551
|
var package_namespaceObject = {
|
|
1552
|
-
i8: "1.
|
|
1552
|
+
i8: "1.45.0"
|
|
1553
1553
|
};
|
|
1554
1554
|
async function renderFrontmatterHead(route) {
|
|
1555
1555
|
if (!isRouteMeta(route)) return '';
|
|
@@ -1657,11 +1657,11 @@ async function renderPages(appDirectory, config, pluginDriver, ssgConfig) {
|
|
|
1657
1657
|
].join(''));
|
|
1658
1658
|
if (helmet.htmlAttributes) {
|
|
1659
1659
|
var _helmet_htmlAttributes;
|
|
1660
|
-
html = html.replace(HTML_START_TAG, `${HTML_START_TAG} ${null
|
|
1660
|
+
html = html.replace(HTML_START_TAG, `${HTML_START_TAG} ${null == (_helmet_htmlAttributes = helmet.htmlAttributes) ? void 0 : _helmet_htmlAttributes.toString()}`);
|
|
1661
1661
|
}
|
|
1662
1662
|
if (helmet.bodyAttributes) {
|
|
1663
1663
|
var _helmet_bodyAttributes;
|
|
1664
|
-
html = html.replace(BODY_START_TAG, `${BODY_START_TAG} ${null
|
|
1664
|
+
html = html.replace(BODY_START_TAG, `${BODY_START_TAG} ${null == (_helmet_bodyAttributes = helmet.bodyAttributes) ? void 0 : _helmet_bodyAttributes.toString()}`);
|
|
1665
1665
|
}
|
|
1666
1666
|
const normalizeHtmlFilePath = (path)=>{
|
|
1667
1667
|
const normalizedBase = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeSlash)((null == config ? void 0 : config.base) || '/');
|
|
@@ -1701,8 +1701,8 @@ async function serve(options) {
|
|
|
1701
1701
|
const envPort = process.env.PORT;
|
|
1702
1702
|
const envHost = process.env.HOST;
|
|
1703
1703
|
const { builderConfig } = config;
|
|
1704
|
-
const port = Number(envPort || userPort || (null == builderConfig ? void 0 : null
|
|
1705
|
-
const host = envHost || userHost || (null == builderConfig ? void 0 : null
|
|
1704
|
+
const port = Number(envPort || userPort || (null == builderConfig ? void 0 : null == (_builderConfig_server = builderConfig.server) ? void 0 : _builderConfig_server.port) || 4173);
|
|
1705
|
+
const host = envHost || userHost || (null == builderConfig ? void 0 : null == (_builderConfig_server1 = builderConfig.server) ? void 0 : _builderConfig_server1.host) || 'localhost';
|
|
1706
1706
|
config.builderConfig = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(builderConfig, {
|
|
1707
1707
|
server: {
|
|
1708
1708
|
port,
|
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;
|
|
@@ -83,6 +81,4 @@ declare interface TocItem {
|
|
|
83
81
|
depth: number;
|
|
84
82
|
}
|
|
85
83
|
|
|
86
|
-
export declare function updateSiteDataRuntimeModule(modulePath: string, pageMeta: PageMeta): Promise<void>;
|
|
87
|
-
|
|
88
84
|
export { }
|
package/dist/loader.js
CHANGED
|
@@ -1,128 +1,18 @@
|
|
|
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 "rspack-plugin-virtual-module";
|
|
11
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
12
|
-
import * as __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__ from "enhanced-resolve";
|
|
13
7
|
import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
|
|
14
8
|
import * as __WEBPACK_EXTERNAL_MODULE_rehype_external_links_09bed11a__ from "rehype-external-links";
|
|
15
9
|
import * as __WEBPACK_EXTERNAL_MODULE_remark_gfm_073acf21__ from "remark-gfm";
|
|
16
10
|
import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__ from "unist-util-visit";
|
|
17
11
|
import * as __WEBPACK_EXTERNAL_MODULE_github_slugger_8e9a17cb__ from "github-slugger";
|
|
18
12
|
import * as __WEBPACK_EXTERNAL_MODULE_hast_util_heading_rank_cff646ba__ from "hast-util-heading-rank";
|
|
13
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
|
|
19
14
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__ from "@rspress/shared/constants";
|
|
20
15
|
import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_children_71921007__ from "unist-util-visit-children";
|
|
21
|
-
const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
|
|
22
|
-
`{
|
|
23
|
-
const saved = localStorage.getItem('${__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.APPEARANCE_KEY}')
|
|
24
|
-
const preferDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
25
|
-
const isDark = !saved || saved === 'auto' ? preferDark : saved === 'dark'
|
|
26
|
-
document.documentElement.classList.toggle('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, 'dist', 'runtime', 'clientEntry.js');
|
|
32
|
-
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrEntry.js');
|
|
33
|
-
const TEMP_DIR = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), 'node_modules', __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.RSPRESS_TEMP_DIR);
|
|
34
|
-
var runtimeModule_RuntimeModuleID = /*#__PURE__*/ function(RuntimeModuleID) {
|
|
35
|
-
RuntimeModuleID["GlobalStyles"] = "virtual-global-styles";
|
|
36
|
-
RuntimeModuleID["GlobalComponents"] = "virtual-global-components";
|
|
37
|
-
RuntimeModuleID["RouteForClient"] = "virtual-routes";
|
|
38
|
-
RuntimeModuleID["RouteForSSR"] = "virtual-routes-ssr";
|
|
39
|
-
RuntimeModuleID["SiteData"] = "virtual-site-data";
|
|
40
|
-
RuntimeModuleID["SearchIndexHash"] = "virtual-search-index-hash";
|
|
41
|
-
RuntimeModuleID["I18nText"] = "virtual-i18n-text";
|
|
42
|
-
RuntimeModuleID["SearchHooks"] = "virtual-search-hooks";
|
|
43
|
-
RuntimeModuleID["PrismLanguages"] = "virtual-prism-languages";
|
|
44
|
-
return RuntimeModuleID;
|
|
45
|
-
}({});
|
|
46
|
-
let resolver;
|
|
47
|
-
let startFlatten = false;
|
|
48
|
-
const processor = (0, __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__.createProcessor)();
|
|
49
|
-
const { CachedInputFileSystem, ResolverFactory } = __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__["default"];
|
|
50
|
-
const fileSystem = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"];
|
|
51
|
-
async function resolveDepPath(importPath, importer, alias) {
|
|
52
|
-
if (!resolver) resolver = ResolverFactory.createResolver({
|
|
53
|
-
fileSystem: new CachedInputFileSystem(fileSystem, 0),
|
|
54
|
-
extensions: [
|
|
55
|
-
'.mdx',
|
|
56
|
-
'.md'
|
|
57
|
-
],
|
|
58
|
-
alias
|
|
59
|
-
});
|
|
60
|
-
const resolveResult = await new Promise((resolve, reject)=>{
|
|
61
|
-
resolver.resolve({
|
|
62
|
-
importer
|
|
63
|
-
}, importer, importPath, {}, (err, filePath)=>{
|
|
64
|
-
if (err) return reject(err);
|
|
65
|
-
if (!filePath) return reject(new Error(`Empty result when resolving ${importPath} from ${importer}`));
|
|
66
|
-
return resolve(filePath);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
return resolveResult;
|
|
70
|
-
}
|
|
71
|
-
async function flattenMdxContent(content, basePath, alias) {
|
|
72
|
-
const deps = [];
|
|
73
|
-
const regex = new RegExp(importStatementRegex);
|
|
74
|
-
if (!regex.test(content)) return {
|
|
75
|
-
flattenContent: content,
|
|
76
|
-
deps
|
|
77
|
-
};
|
|
78
|
-
if (!startFlatten) {
|
|
79
|
-
resolver = ResolverFactory.createResolver({
|
|
80
|
-
fileSystem: new CachedInputFileSystem(fileSystem, 0),
|
|
81
|
-
extensions: [
|
|
82
|
-
'.mdx',
|
|
83
|
-
'.md',
|
|
84
|
-
'.js'
|
|
85
|
-
],
|
|
86
|
-
alias
|
|
87
|
-
});
|
|
88
|
-
startFlatten = true;
|
|
89
|
-
}
|
|
90
|
-
let ast;
|
|
91
|
-
let result = content;
|
|
92
|
-
try {
|
|
93
|
-
ast = processor.parse(content);
|
|
94
|
-
} catch (e) {
|
|
95
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.debug('flattenMdxContent parse failed: \n', e);
|
|
96
|
-
return {
|
|
97
|
-
flattenContent: content,
|
|
98
|
-
deps
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
const importNodes = ast.children.filter((node)=>'mdxjsEsm' === node.type).flatMap((node)=>{
|
|
102
|
-
var _node_data_estree, _node_data;
|
|
103
|
-
return (null === (_node_data = node.data) || void 0 === _node_data ? void 0 : null === (_node_data_estree = _node_data.estree) || void 0 === _node_data_estree ? void 0 : _node_data_estree.body) || [];
|
|
104
|
-
}).filter((node)=>'ImportDeclaration' === node.type);
|
|
105
|
-
for (const importNode of importNodes){
|
|
106
|
-
const id = importNode.specifiers[0].local.name;
|
|
107
|
-
const importPath = importNode.source.value;
|
|
108
|
-
let absoluteImportPath;
|
|
109
|
-
try {
|
|
110
|
-
absoluteImportPath = await resolveDepPath(importPath, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(basePath), alias);
|
|
111
|
-
} catch (_e) {
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
if (__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(absoluteImportPath)) {
|
|
115
|
-
const importedContent = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(absoluteImportPath, 'utf-8');
|
|
116
|
-
const { flattenContent: replacedValue, deps: subDeps } = await flattenMdxContent(importedContent, absoluteImportPath, alias);
|
|
117
|
-
result = result.replace(new RegExp(`import\\s+${id}\\s+from\\s+['"](${importPath})['"];?`), '').replace(new RegExp(`<${id}\\s*/>`, 'g'), ()=>replacedValue);
|
|
118
|
-
deps.push(...subDeps, absoluteImportPath);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
flattenContent: result,
|
|
123
|
-
deps
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
16
|
function applyReplaceRules(code = '', replaceRules = []) {
|
|
127
17
|
let result = code;
|
|
128
18
|
for (const rule of replaceRules)result = result.replace(rule.search, rule.replace);
|
|
@@ -142,11 +32,11 @@ function normalizePath(id) {
|
|
|
142
32
|
const rehypePluginCodeMeta = ()=>(tree)=>{
|
|
143
33
|
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'element', (node)=>{
|
|
144
34
|
var _node_children_;
|
|
145
|
-
if ('pre' === node.tagName && (null
|
|
35
|
+
if ('pre' === node.tagName && (null == (_node_children_ = node.children[0]) ? void 0 : _node_children_.type) === 'element' && 'code' === node.children[0].tagName) {
|
|
146
36
|
var _codeNode_data;
|
|
147
37
|
const codeNode = node.children[0];
|
|
148
38
|
codeNode.properties ??= {};
|
|
149
|
-
codeNode.properties.meta = null
|
|
39
|
+
codeNode.properties.meta = null == (_codeNode_data = codeNode.data) ? void 0 : _codeNode_data.meta;
|
|
150
40
|
}
|
|
151
41
|
});
|
|
152
42
|
};
|
|
@@ -156,7 +46,7 @@ const rehypeHeaderAnchor = ()=>{
|
|
|
156
46
|
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'element', (node)=>{
|
|
157
47
|
var _node_properties;
|
|
158
48
|
if (!(0, __WEBPACK_EXTERNAL_MODULE_hast_util_heading_rank_cff646ba__.headingRank)(node)) return;
|
|
159
|
-
if (!(null
|
|
49
|
+
if (!(null == (_node_properties = node.properties) ? void 0 : _node_properties.id)) {
|
|
160
50
|
const [text, customId] = collectHeaderText(node);
|
|
161
51
|
node.properties ??= {};
|
|
162
52
|
node.properties.id = customId || slugger.slug(text);
|
|
@@ -261,7 +151,7 @@ const remarkCheckDeadLinks = (checkLink)=>{
|
|
|
261
151
|
if (internalLinks.has(url)) return;
|
|
262
152
|
if (!url.startsWith('http') && !url.startsWith('https')) {
|
|
263
153
|
var _url_split_join;
|
|
264
|
-
const { routePath: normalizeUrl } = routeService.normalizeRoutePath(null
|
|
154
|
+
const { routePath: normalizeUrl } = routeService.normalizeRoutePath(null == (_url_split_join = url.split(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep).join('/')) ? void 0 : _url_split_join.split('#')[0]);
|
|
265
155
|
internalLinks.add(normalizeUrl);
|
|
266
156
|
}
|
|
267
157
|
});
|
|
@@ -367,19 +257,19 @@ const parseToc = (tree)=>{
|
|
|
367
257
|
const text = node.children.map((child)=>{
|
|
368
258
|
if ('link' === child.type) {
|
|
369
259
|
var _child_children;
|
|
370
|
-
return null
|
|
260
|
+
return null == (_child_children = child.children) ? void 0 : _child_children.map((item)=>item.value).join('');
|
|
371
261
|
}
|
|
372
262
|
if ('strong' === child.type) {
|
|
373
263
|
var _child_children1;
|
|
374
|
-
return `**${null
|
|
264
|
+
return `**${null == (_child_children1 = child.children) ? void 0 : _child_children1.map((item)=>item.value).join('')}**`;
|
|
375
265
|
}
|
|
376
266
|
if ('emphasis' === child.type) {
|
|
377
267
|
var _child_children2;
|
|
378
|
-
return `*${null
|
|
268
|
+
return `*${null == (_child_children2 = child.children) ? void 0 : _child_children2.map((item)=>item.value).join('')}*`;
|
|
379
269
|
}
|
|
380
270
|
if ('delete' === child.type) {
|
|
381
271
|
var _child_children3;
|
|
382
|
-
return `~~${null
|
|
272
|
+
return `~~${null == (_child_children3 = child.children) ? void 0 : _child_children3.map((item)=>item.value).join('')}~~`;
|
|
383
273
|
}
|
|
384
274
|
if ('text' === child.type) {
|
|
385
275
|
const [textPart, idPart] = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.extractTextAndId)(child.value);
|
|
@@ -417,21 +307,21 @@ const remarkPluginToc = function() {
|
|
|
417
307
|
};
|
|
418
308
|
async function createMDXOptions(docDirectory, config, checkDeadLinks, routeService, filepath, pluginDriver) {
|
|
419
309
|
var _config_route;
|
|
420
|
-
const cleanUrls = (null == config ? void 0 : null
|
|
310
|
+
const cleanUrls = (null == config ? void 0 : null == (_config_route = config.route) ? void 0 : _config_route.cleanUrls) ?? false;
|
|
421
311
|
const { remarkPlugins: remarkPluginsFromConfig = [], rehypePlugins: rehypePluginsFromConfig = [], globalComponents: globalComponentsFromConfig = [] } = (null == config ? void 0 : config.markdown) || {};
|
|
422
312
|
const rspressPlugins = pluginDriver.getPlugins();
|
|
423
313
|
const remarkPluginsFromPlugins = rspressPlugins.flatMap((plugin)=>{
|
|
424
314
|
var _plugin_markdown;
|
|
425
|
-
return (null
|
|
315
|
+
return (null == (_plugin_markdown = plugin.markdown) ? void 0 : _plugin_markdown.remarkPlugins) || [];
|
|
426
316
|
});
|
|
427
317
|
const rehypePluginsFromPlugins = rspressPlugins.flatMap((plugin)=>{
|
|
428
318
|
var _plugin_markdown;
|
|
429
|
-
return (null
|
|
319
|
+
return (null == (_plugin_markdown = plugin.markdown) ? void 0 : _plugin_markdown.rehypePlugins) || [];
|
|
430
320
|
});
|
|
431
321
|
const globalComponents = [
|
|
432
322
|
...rspressPlugins.flatMap((plugin)=>{
|
|
433
323
|
var _plugin_markdown;
|
|
434
|
-
return (null
|
|
324
|
+
return (null == (_plugin_markdown = plugin.markdown) ? void 0 : _plugin_markdown.globalComponents) || [];
|
|
435
325
|
}),
|
|
436
326
|
...globalComponentsFromConfig
|
|
437
327
|
];
|
|
@@ -481,47 +371,18 @@ async function createMDXOptions(docDirectory, config, checkDeadLinks, routeServi
|
|
|
481
371
|
]
|
|
482
372
|
};
|
|
483
373
|
}
|
|
484
|
-
async function updateSiteDataRuntimeModule(modulePath, pageMeta) {
|
|
485
|
-
const siteDataModulePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(TEMP_DIR, 'runtime', `${runtimeModule_RuntimeModuleID.SiteData}.mjs`);
|
|
486
|
-
const { default: siteData } = await import((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(siteDataModulePath).href);
|
|
487
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile(siteDataModulePath, `export default ${JSON.stringify({
|
|
488
|
-
...siteData,
|
|
489
|
-
timestamp: Date.now().toString(),
|
|
490
|
-
pages: siteData.pages.map((page)=>page._filepath === modulePath ? {
|
|
491
|
-
...page,
|
|
492
|
-
...pageMeta
|
|
493
|
-
} : page)
|
|
494
|
-
}, null, 2)}`);
|
|
495
|
-
}
|
|
496
|
-
function createCheckPageMetaUpdateFn() {
|
|
497
|
-
const pageMetaMap = new Map();
|
|
498
|
-
return (modulePath, pageMeta)=>{
|
|
499
|
-
const prevMeta = pageMetaMap.get(modulePath);
|
|
500
|
-
const deserializedMeta = JSON.stringify(pageMeta);
|
|
501
|
-
pageMetaMap.set(modulePath, deserializedMeta);
|
|
502
|
-
if (!prevMeta) return;
|
|
503
|
-
if (prevMeta !== deserializedMeta) setTimeout(async ()=>{
|
|
504
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info('Page metadata changed, page reloading...');
|
|
505
|
-
await updateSiteDataRuntimeModule(modulePath, pageMeta);
|
|
506
|
-
});
|
|
507
|
-
};
|
|
508
|
-
}
|
|
509
|
-
const checkPageMetaUpdate = createCheckPageMetaUpdateFn();
|
|
510
374
|
async function mdxLoader(source) {
|
|
511
375
|
var _config_markdown;
|
|
512
376
|
this.cacheable(true);
|
|
513
377
|
const callback = this.async();
|
|
514
378
|
const options = this.getOptions();
|
|
515
379
|
const filepath = this.resourcePath;
|
|
516
|
-
const { alias } = this._compiler.options.resolve;
|
|
517
380
|
const { config, docDirectory, checkDeadLinks, routeService, pluginDriver } = options;
|
|
518
|
-
const { frontmatter,
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
const replacedContent = applyReplaceRules(flattenContent, config.replaceRules);
|
|
522
|
-
const preprocessedContent = escapeMarkdownHeadingIds(replacedContent);
|
|
381
|
+
const { frontmatter, emptyLinesSource } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.loadFrontMatter)(source, filepath, docDirectory, true);
|
|
382
|
+
const replacedSource = applyReplaceRules(emptyLinesSource, config.replaceRules);
|
|
383
|
+
const preprocessedContent = escapeMarkdownHeadingIds(replacedSource);
|
|
523
384
|
let enableMdxRs;
|
|
524
|
-
const mdxRs = (null == config ? void 0 : null
|
|
385
|
+
const mdxRs = (null == config ? void 0 : null == (_config_markdown = config.markdown) ? void 0 : _config_markdown.mdxRs) ?? true;
|
|
525
386
|
enableMdxRs = 'object' == typeof mdxRs ? 'function' == typeof (null == mdxRs ? void 0 : mdxRs.include) ? mdxRs.include(filepath) : true : mdxRs;
|
|
526
387
|
try {
|
|
527
388
|
let compileResult;
|
|
@@ -569,7 +430,6 @@ async function mdxLoader(source) {
|
|
|
569
430
|
frontmatter
|
|
570
431
|
};
|
|
571
432
|
}
|
|
572
|
-
if (!(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)()) checkPageMetaUpdate(filepath, pageMeta);
|
|
573
433
|
const result = `const frontmatter = ${JSON.stringify(frontmatter)};
|
|
574
434
|
${compileResult}
|
|
575
435
|
MDXContent.__RSPRESS_PAGE_META = {};
|
|
@@ -588,4 +448,4 @@ MDXContent.__RSPRESS_PAGE_META["${encodeURIComponent(normalizePath(__WEBPACK_EXT
|
|
|
588
448
|
}
|
|
589
449
|
}
|
|
590
450
|
}
|
|
591
|
-
export {
|
|
451
|
+
export { mdxLoader as default };
|
package/dist/runtime/App.js
CHANGED
|
@@ -7,7 +7,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__ from "react-
|
|
|
7
7
|
import * as __WEBPACK_EXTERNAL_MODULE_virtual_global_components_43dbb356__ from "virtual-global-components";
|
|
8
8
|
import * as __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__ from "virtual-site-data";
|
|
9
9
|
import "virtual-global-styles";
|
|
10
|
-
var
|
|
10
|
+
var App_QueryStatus = /*#__PURE__*/ function(QueryStatus) {
|
|
11
11
|
QueryStatus["Show"] = "1";
|
|
12
12
|
QueryStatus["Hide"] = "0";
|
|
13
13
|
return QueryStatus;
|
|
@@ -24,7 +24,7 @@ async function initPageData(routePath) {
|
|
|
24
24
|
return (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.isEqualPath)(normalize(page.routePath), normalize(matchedRoute.path));
|
|
25
25
|
});
|
|
26
26
|
const encodedPagePath = encodeURIComponent(pagePath);
|
|
27
|
-
const meta = (null
|
|
27
|
+
const meta = (null == (_mod_default___RSPRESS_PAGE_META = mod.default.__RSPRESS_PAGE_META) ? void 0 : _mod_default___RSPRESS_PAGE_META[encodedPagePath]) || {};
|
|
28
28
|
const { toc = [], title = '', frontmatter = {}, ...rest } = __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(matchedRoute.filePath) ? meta : mod;
|
|
29
29
|
return {
|
|
30
30
|
siteData: __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"],
|
|
@@ -40,7 +40,7 @@ async function initPageData(routePath) {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
let lang = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang || '';
|
|
43
|
-
let version = (null
|
|
43
|
+
let version = (null == (_siteData_multiVersion = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion) ? void 0 : _siteData_multiVersion.default) || '';
|
|
44
44
|
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang && 'undefined' != typeof window) {
|
|
45
45
|
const path = location.pathname.replace(__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].base, '').split('/').slice(0, 2);
|
|
46
46
|
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].locales.length) {
|
|
@@ -108,4 +108,4 @@ function App({ helmetContext }) {
|
|
|
108
108
|
]
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
export { App,
|
|
111
|
+
export { App, App_QueryStatus as QueryStatus, initPageData };
|
package/dist/runtime/tsconfig.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
var __webpack_exports__compilerOptions =
|
|
3
|
-
var __webpack_exports__include =
|
|
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
4
|
export { __webpack_exports__compilerOptions as compilerOptions, __webpack_exports__include as include };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.45.0",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"theme.ts"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@mdx-js/loader": "2.3.0",
|
|
46
|
-
"@mdx-js/mdx": "2.3.0",
|
|
47
|
-
"@mdx-js/react": "2.3.0",
|
|
48
|
-
"@rsbuild/core": "1.3.
|
|
49
|
-
"@rsbuild/plugin-less": "~1.2.
|
|
50
|
-
"@rsbuild/plugin-react": "~1.3.
|
|
45
|
+
"@mdx-js/loader": "^2.3.0",
|
|
46
|
+
"@mdx-js/mdx": "^2.3.0",
|
|
47
|
+
"@mdx-js/react": "^2.3.0",
|
|
48
|
+
"@rsbuild/core": "~1.3.18",
|
|
49
|
+
"@rsbuild/plugin-less": "~1.2.4",
|
|
50
|
+
"@rsbuild/plugin-react": "~1.3.1",
|
|
51
51
|
"@rsbuild/plugin-sass": "~1.3.0",
|
|
52
52
|
"@rspress/mdx-rs": "0.6.6",
|
|
53
53
|
"enhanced-resolve": "5.18.0",
|
|
@@ -73,17 +73,17 @@
|
|
|
73
73
|
"unified": "^10.1.2",
|
|
74
74
|
"unist-util-visit": "^4.1.2",
|
|
75
75
|
"unist-util-visit-children": "^2.0.2",
|
|
76
|
-
"@rspress/plugin-
|
|
77
|
-
"@rspress/plugin-container-syntax": "1.
|
|
78
|
-
"@rspress/plugin-
|
|
79
|
-
"@rspress/
|
|
80
|
-
"@rspress/
|
|
81
|
-
"@rspress/
|
|
82
|
-
"@rspress/theme-default": "1.
|
|
76
|
+
"@rspress/plugin-last-updated": "1.45.0",
|
|
77
|
+
"@rspress/plugin-container-syntax": "1.45.0",
|
|
78
|
+
"@rspress/plugin-auto-nav-sidebar": "1.45.0",
|
|
79
|
+
"@rspress/plugin-medium-zoom": "1.45.0",
|
|
80
|
+
"@rspress/runtime": "1.45.0",
|
|
81
|
+
"@rspress/shared": "1.45.0",
|
|
82
|
+
"@rspress/theme-default": "1.45.0"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@microsoft/api-extractor": "^7.49.2",
|
|
86
|
-
"@rslib/core": "0.
|
|
86
|
+
"@rslib/core": "~0.6.9",
|
|
87
87
|
"@rspress-dev/plugin-preview": "link:../plugin-preview",
|
|
88
88
|
"@types/hast": "^2.3.10",
|
|
89
89
|
"@types/html-to-text": "^9.0.4",
|