@rspress/core 2.0.0-alpha.10 → 2.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +32 -35
- package/dist/loader.js +14 -14
- package/dist/runtime/ClientApp.d.ts +4 -1
- package/dist/runtime/ClientApp.js +15 -24
- package/dist/runtime/clientEntry.js +14 -4
- package/dist/runtime/initPageData.js +2 -2
- package/dist/runtime/tsconfig.js +3 -3
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -62,9 +62,9 @@ class PluginDriver {
|
|
|
62
62
|
this.clearPlugins();
|
|
63
63
|
const config = _class_private_field_get(this, _config);
|
|
64
64
|
const themeConfig = (null == config ? void 0 : config.themeConfig) || {};
|
|
65
|
-
const enableLastUpdated = (null == themeConfig ? void 0 : themeConfig.lastUpdated) || (null == themeConfig ? void 0 : null
|
|
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
66
|
const mediumZoomConfig = (null == config ? void 0 : config.mediumZoom) ?? true;
|
|
67
|
-
const haveNavSidebarConfig = themeConfig.nav || themeConfig.sidebar || (null
|
|
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);
|
|
68
68
|
if (enableLastUpdated) {
|
|
69
69
|
const { pluginLastUpdated } = await import("@rspress/plugin-last-updated");
|
|
70
70
|
this.addPlugin(pluginLastUpdated());
|
|
@@ -547,7 +547,7 @@ ${routeMeta.map((route, index)=>{
|
|
|
547
547
|
RouteService_class_private_field_set(this, _include, routeOptions.include || []);
|
|
548
548
|
RouteService_class_private_field_set(this, _exclude, routeOptions.exclude || []);
|
|
549
549
|
RouteService_class_private_field_set(this, _defaultLang, (null == userConfig ? void 0 : userConfig.lang) || '');
|
|
550
|
-
RouteService_class_private_field_set(this, _langs, ((null == userConfig ? void 0 : userConfig.locales) ?? (null == userConfig ? void 0 : null
|
|
550
|
+
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));
|
|
551
551
|
RouteService_class_private_field_set(this, _base, (null == userConfig ? void 0 : userConfig.base) || '');
|
|
552
552
|
RouteService_class_private_field_set(this, _tempDir, tempDir);
|
|
553
553
|
RouteService_class_private_field_set(this, _pluginDriver, pluginDriver);
|
|
@@ -698,7 +698,7 @@ async function flattenMdxContent(content, basePath, alias) {
|
|
|
698
698
|
}
|
|
699
699
|
const importNodes = ast.children.filter((node)=>'mdxjsEsm' === node.type).flatMap((node)=>{
|
|
700
700
|
var _node_data_estree, _node_data;
|
|
701
|
-
return (null
|
|
701
|
+
return (null == (_node_data = node.data) ? void 0 : null == (_node_data_estree = _node_data.estree) ? void 0 : _node_data_estree.body) || [];
|
|
702
702
|
}).filter((node)=>'ImportDeclaration' === node.type);
|
|
703
703
|
for (const importNode of importNodes){
|
|
704
704
|
const id = importNode.specifiers[0].local.name;
|
|
@@ -906,7 +906,7 @@ function normalizeThemeConfig(docConfig, pages = []) {
|
|
|
906
906
|
};
|
|
907
907
|
const getI18nText = (key = '', currentLang = '')=>{
|
|
908
908
|
var _i18nTextData_key;
|
|
909
|
-
const text = null
|
|
909
|
+
const text = null == (_i18nTextData_key = i18nTextData[key]) ? void 0 : _i18nTextData_key[currentLang];
|
|
910
910
|
return text || key;
|
|
911
911
|
};
|
|
912
912
|
const normalizeSidebar = (sidebar, currentLang = '')=>{
|
|
@@ -980,7 +980,7 @@ function normalizeThemeConfig(docConfig, pages = []) {
|
|
|
980
980
|
};
|
|
981
981
|
if (locales.length) themeConfig.locales = locales.map(({ lang: currentLang, label })=>{
|
|
982
982
|
var _themeConfig_locales;
|
|
983
|
-
const localeInThemeConfig = null
|
|
983
|
+
const localeInThemeConfig = null == (_themeConfig_locales = themeConfig.locales) ? void 0 : _themeConfig_locales.find((locale)=>locale.lang === currentLang);
|
|
984
984
|
return {
|
|
985
985
|
lang: currentLang,
|
|
986
986
|
label,
|
|
@@ -1019,7 +1019,7 @@ async function siteDataVMPlugin(context) {
|
|
|
1019
1019
|
const versioned = userConfig.search && 'remote' !== userConfig.search.mode && userConfig.search.versioned;
|
|
1020
1020
|
const groupedPages = (0, __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__.groupBy)(pages, (page)=>{
|
|
1021
1021
|
var _page_frontmatter;
|
|
1022
|
-
if ((null
|
|
1022
|
+
if ((null == (_page_frontmatter = page.frontmatter) ? void 0 : _page_frontmatter.pageType) === 'home') return 'noindex';
|
|
1023
1023
|
const version = versioned ? page.version : '';
|
|
1024
1024
|
const lang = page.lang || '';
|
|
1025
1025
|
return `${version}###${lang}`;
|
|
@@ -1047,13 +1047,13 @@ async function siteDataVMPlugin(context) {
|
|
|
1047
1047
|
themeConfig: normalizeThemeConfig(userConfig, pages),
|
|
1048
1048
|
base: (null == userConfig ? void 0 : userConfig.base) || '/',
|
|
1049
1049
|
lang: (null == userConfig ? void 0 : userConfig.lang) || '',
|
|
1050
|
-
locales: (null == userConfig ? void 0 : userConfig.locales) || (null
|
|
1050
|
+
locales: (null == userConfig ? void 0 : userConfig.locales) || (null == (_userConfig_themeConfig = userConfig.themeConfig) ? void 0 : _userConfig_themeConfig.locales) || [],
|
|
1051
1051
|
logo: (null == userConfig ? void 0 : userConfig.logo) || '',
|
|
1052
1052
|
logoText: (null == userConfig ? void 0 : userConfig.logoText) || '',
|
|
1053
|
-
ssg: Boolean(null == userConfig ? void 0 : userConfig.ssg) ?? true,
|
|
1053
|
+
ssg: Boolean((null == userConfig ? void 0 : userConfig.ssg) ?? true),
|
|
1054
1054
|
multiVersion: {
|
|
1055
|
-
default: (null == userConfig ? void 0 : null
|
|
1056
|
-
versions: (null == userConfig ? void 0 : null
|
|
1055
|
+
default: (null == userConfig ? void 0 : null == (_userConfig_multiVersion = userConfig.multiVersion) ? void 0 : _userConfig_multiVersion.default) || '',
|
|
1056
|
+
versions: (null == userConfig ? void 0 : null == (_userConfig_multiVersion1 = userConfig.multiVersion) ? void 0 : _userConfig_multiVersion1.versions) || []
|
|
1057
1057
|
},
|
|
1058
1058
|
search: tempSearchObj ?? {
|
|
1059
1059
|
mode: 'local'
|
|
@@ -1066,13 +1066,13 @@ async function siteDataVMPlugin(context) {
|
|
|
1066
1066
|
};
|
|
1067
1067
|
}),
|
|
1068
1068
|
markdown: {
|
|
1069
|
-
showLineNumbers: (null == userConfig ? void 0 : null
|
|
1070
|
-
defaultWrapCode: (null == userConfig ? void 0 : null
|
|
1071
|
-
codeHighlighter: (null == userConfig ? void 0 : null
|
|
1069
|
+
showLineNumbers: (null == userConfig ? void 0 : null == (_userConfig_markdown = userConfig.markdown) ? void 0 : _userConfig_markdown.showLineNumbers) ?? false,
|
|
1070
|
+
defaultWrapCode: (null == userConfig ? void 0 : null == (_userConfig_markdown1 = userConfig.markdown) ? void 0 : _userConfig_markdown1.defaultWrapCode) ?? false,
|
|
1071
|
+
codeHighlighter: (null == userConfig ? void 0 : null == (_userConfig_markdown2 = userConfig.markdown) ? void 0 : _userConfig_markdown2.codeHighlighter) || 'prism'
|
|
1072
1072
|
}
|
|
1073
1073
|
};
|
|
1074
1074
|
const { highlightLanguages: defaultLanguages = [] } = config.markdown || {};
|
|
1075
|
-
if (Array.isArray(null
|
|
1075
|
+
if (Array.isArray(null == (_siteData_pages_ = siteData.pages[0]) ? void 0 : _siteData_pages_.extraHighlightLanguages)) siteData.pages[0].extraHighlightLanguages.forEach((lang)=>highlightLanguages.add(lang));
|
|
1076
1076
|
const aliases = handleHighlightLanguages(highlightLanguages, defaultLanguages);
|
|
1077
1077
|
const sortedAliases = Object.fromEntries(Object.entries(aliases).sort());
|
|
1078
1078
|
const sortedHighlightLanguages = Array.from(highlightLanguages).sort();
|
|
@@ -1154,7 +1154,7 @@ async function writeSearchIndex(config) {
|
|
|
1154
1154
|
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].rename(source, target);
|
|
1155
1155
|
scanning = true;
|
|
1156
1156
|
}
|
|
1157
|
-
if (isProduction() && (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isSCM)() && (null == config ? void 0 : null
|
|
1157
|
+
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') {
|
|
1158
1158
|
const { apiUrl, indexName } = config.search;
|
|
1159
1159
|
try {
|
|
1160
1160
|
await fetch(`${apiUrl}?index=${indexName}`, {
|
|
@@ -1174,7 +1174,7 @@ function serveSearchIndexMiddleware(config) {
|
|
|
1174
1174
|
return (req, res, next)=>{
|
|
1175
1175
|
var _req_url;
|
|
1176
1176
|
const searchIndexRequestMatch = `/${__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.SEARCH_INDEX_NAME}.`;
|
|
1177
|
-
if (null
|
|
1177
|
+
if (null == (_req_url = req.url) ? void 0 : _req_url.includes(searchIndexRequestMatch)) {
|
|
1178
1178
|
res.setHeader('Content-Type', 'application/json');
|
|
1179
1179
|
const outDir = (null == config ? void 0 : config.outDir) ?? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(process.cwd(), OUTPUT_DIR);
|
|
1180
1180
|
const searchIndexFile = req.url.split('/').pop();
|
|
@@ -1192,7 +1192,7 @@ async function detectReactVersion() {
|
|
|
1192
1192
|
if (await pathExists(reactPath)) {
|
|
1193
1193
|
var _reactPkg_version;
|
|
1194
1194
|
const reactPkg = await readJson(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(reactPath, 'package.json'));
|
|
1195
|
-
const version = Number(null
|
|
1195
|
+
const version = Number(null == (_reactPkg_version = reactPkg.version) ? void 0 : _reactPkg_version.split('.')[0]);
|
|
1196
1196
|
return version;
|
|
1197
1197
|
}
|
|
1198
1198
|
return DEFAULT_REACT_VERSION;
|
|
@@ -1281,7 +1281,7 @@ function getSocialIcons(socialLinks = []) {
|
|
|
1281
1281
|
}
|
|
1282
1282
|
function isPluginIncluded(config, pluginName) {
|
|
1283
1283
|
var _config_builderPlugins, _config_builderConfig_plugins, _config_builderConfig;
|
|
1284
|
-
return Boolean((null
|
|
1284
|
+
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)));
|
|
1285
1285
|
}
|
|
1286
1286
|
async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, runtimeTempDir) {
|
|
1287
1287
|
var _config_builderConfig_output, _config_builderConfig, _config_themeConfig, _config_themeConfig1;
|
|
@@ -1292,7 +1292,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1292
1292
|
const ssrOutDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(baseOutDir, 'ssr');
|
|
1293
1293
|
const DEFAULT_THEME = require.resolve('@rspress/theme-default');
|
|
1294
1294
|
const base = (null == config ? void 0 : config.base) ?? '';
|
|
1295
|
-
const assetPrefix = isProduction() ? (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.removeTrailingSlash)((null == config ? void 0 : null
|
|
1295
|
+
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) : '';
|
|
1296
1296
|
const reactVersion = await detectReactVersion();
|
|
1297
1297
|
const normalizeIcon = (icon)=>{
|
|
1298
1298
|
if (!icon) return;
|
|
@@ -1347,7 +1347,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1347
1347
|
favicon: normalizeIcon(null == config ? void 0 : config.icon),
|
|
1348
1348
|
template: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'index.html'),
|
|
1349
1349
|
tags: [
|
|
1350
|
-
(null
|
|
1350
|
+
(null == (_config_themeConfig = config.themeConfig) ? void 0 : _config_themeConfig.darkMode) !== false ? {
|
|
1351
1351
|
tag: "script",
|
|
1352
1352
|
children: inlineThemeScript,
|
|
1353
1353
|
append: false
|
|
@@ -1382,7 +1382,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1382
1382
|
define: {
|
|
1383
1383
|
'process.env.__REACT_GTE_18__': JSON.stringify(reactVersion >= 18),
|
|
1384
1384
|
'process.env.TEST': JSON.stringify(process.env.TEST),
|
|
1385
|
-
'process.env.RSPRESS_SOCIAL_ICONS': JSON.stringify(getSocialIcons(null
|
|
1385
|
+
'process.env.RSPRESS_SOCIAL_ICONS': JSON.stringify(getSocialIcons(null == (_config_themeConfig1 = config.themeConfig) ? void 0 : _config_themeConfig1.socialLinks))
|
|
1386
1386
|
}
|
|
1387
1387
|
},
|
|
1388
1388
|
performance: {
|
|
@@ -1406,7 +1406,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1406
1406
|
const isServer = 'node' === target;
|
|
1407
1407
|
const jsModuleRule = chain.module.rule(CHAIN_ID.RULE.JS);
|
|
1408
1408
|
const swcLoaderOptions = jsModuleRule.use(CHAIN_ID.USE.SWC).get('options');
|
|
1409
|
-
const checkDeadLinks = ((null == config ? void 0 : null
|
|
1409
|
+
const checkDeadLinks = ((null == config ? void 0 : null == (_config_markdown = config.markdown) ? void 0 : _config_markdown.checkDeadLinks) && !isServer) ?? false;
|
|
1410
1410
|
chain.module.rule('MDX').type("javascript/auto").test(__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP).resolve.merge({
|
|
1411
1411
|
conditionNames: jsModuleRule.resolve.conditionNames.values(),
|
|
1412
1412
|
mainFields: jsModuleRule.resolve.mainFields.values()
|
|
@@ -1512,7 +1512,7 @@ async function initRsbuild(rootDir, config, pluginDriver, enableSSG, extraRsbuil
|
|
|
1512
1512
|
const { createRsbuild, mergeRsbuildConfig } = await import("@rsbuild/core");
|
|
1513
1513
|
const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, runtimeTempDir);
|
|
1514
1514
|
const rsbuild = await createRsbuild({
|
|
1515
|
-
rsbuildConfig: mergeRsbuildConfig(internalRsbuildConfig, ...(null
|
|
1515
|
+
rsbuildConfig: mergeRsbuildConfig(internalRsbuildConfig, ...(null == (_pluginDriver_getPlugins = pluginDriver.getPlugins()) ? void 0 : _pluginDriver_getPlugins.map((plugin)=>plugin.builderConfig ?? {})) || [], (null == config ? void 0 : config.builderConfig) || {}, extraRsbuildConfig || {})
|
|
1516
1516
|
});
|
|
1517
1517
|
rsbuild.addPlugins(builderPlugins);
|
|
1518
1518
|
return rsbuild;
|
|
@@ -1565,15 +1565,12 @@ async function checkLanguageParity(config) {
|
|
|
1565
1565
|
if (!(null == config ? void 0 : config.languageParity) || false === config.languageParity.enabled) return;
|
|
1566
1566
|
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info('Checking language parity...');
|
|
1567
1567
|
const contentPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(config.root);
|
|
1568
|
-
const includedDirs = (null
|
|
1568
|
+
const includedDirs = (null == (_config_languageParity_include = config.languageParity.include) ? void 0 : _config_languageParity_include.length) ? config.languageParity.include : [
|
|
1569
1569
|
''
|
|
1570
1570
|
];
|
|
1571
1571
|
const excludedDirs = config.languageParity.exclude ?? [];
|
|
1572
|
-
const supportedLanguages = (null
|
|
1573
|
-
if (!supportedLanguages.length)
|
|
1574
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error('No supported languages found in the configuration.');
|
|
1575
|
-
return;
|
|
1576
|
-
}
|
|
1572
|
+
const supportedLanguages = (null == (_this = config.locales ?? (null == (_config_themeConfig = config.themeConfig) ? void 0 : _config_themeConfig.locales)) ? void 0 : _this.map((locale)=>locale.lang)) || [];
|
|
1573
|
+
if (!supportedLanguages.length) return void __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error('No supported languages found in the configuration.');
|
|
1577
1574
|
const missingLanguagesFile = [];
|
|
1578
1575
|
try {
|
|
1579
1576
|
for (const includedDir of includedDirs){
|
|
@@ -1616,7 +1613,7 @@ async function dev(options) {
|
|
|
1616
1613
|
await checkLanguageParity(modifiedConfig);
|
|
1617
1614
|
}
|
|
1618
1615
|
}
|
|
1619
|
-
var package_namespaceObject = JSON.parse('{"i8":"2.0.0-alpha.
|
|
1616
|
+
var package_namespaceObject = JSON.parse('{"i8":"2.0.0-alpha.11"}');
|
|
1620
1617
|
async function renderFrontmatterHead(route) {
|
|
1621
1618
|
if (!isRouteMeta(route)) return '';
|
|
1622
1619
|
const content = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(route.absolutePath, {
|
|
@@ -1719,11 +1716,11 @@ async function renderPages(appDirectory, config, pluginDriver) {
|
|
|
1719
1716
|
].join(''));
|
|
1720
1717
|
if (helmet.htmlAttributes) {
|
|
1721
1718
|
var _helmet_htmlAttributes;
|
|
1722
|
-
html = html.replace(HTML_START_TAG, `${HTML_START_TAG} ${null
|
|
1719
|
+
html = html.replace(HTML_START_TAG, `${HTML_START_TAG} ${null == (_helmet_htmlAttributes = helmet.htmlAttributes) ? void 0 : _helmet_htmlAttributes.toString()}`);
|
|
1723
1720
|
}
|
|
1724
1721
|
if (helmet.bodyAttributes) {
|
|
1725
1722
|
var _helmet_bodyAttributes;
|
|
1726
|
-
html = html.replace(BODY_START_TAG, `${BODY_START_TAG} ${null
|
|
1723
|
+
html = html.replace(BODY_START_TAG, `${BODY_START_TAG} ${null == (_helmet_bodyAttributes = helmet.bodyAttributes) ? void 0 : _helmet_bodyAttributes.toString()}`);
|
|
1727
1724
|
}
|
|
1728
1725
|
const normalizeHtmlFilePath = (path)=>{
|
|
1729
1726
|
const normalizedBase = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeSlash)((null == config ? void 0 : config.base) || '/');
|
|
@@ -1767,8 +1764,8 @@ async function serve(options) {
|
|
|
1767
1764
|
const envPort = process.env.PORT;
|
|
1768
1765
|
const envHost = process.env.HOST;
|
|
1769
1766
|
const { builderConfig } = config;
|
|
1770
|
-
const port = Number(envPort || userPort || (null == builderConfig ? void 0 : null
|
|
1771
|
-
const host = envHost || userHost || (null == builderConfig ? void 0 : null
|
|
1767
|
+
const port = Number(envPort || userPort || (null == builderConfig ? void 0 : null == (_builderConfig_server = builderConfig.server) ? void 0 : _builderConfig_server.port) || 4173);
|
|
1768
|
+
const host = envHost || userHost || (null == builderConfig ? void 0 : null == (_builderConfig_server1 = builderConfig.server) ? void 0 : _builderConfig_server1.host) || 'localhost';
|
|
1772
1769
|
config.builderConfig = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(builderConfig, {
|
|
1773
1770
|
server: {
|
|
1774
1771
|
port,
|
package/dist/loader.js
CHANGED
|
@@ -101,7 +101,7 @@ async function flattenMdxContent(content, basePath, alias) {
|
|
|
101
101
|
}
|
|
102
102
|
const importNodes = ast.children.filter((node)=>'mdxjsEsm' === node.type).flatMap((node)=>{
|
|
103
103
|
var _node_data_estree, _node_data;
|
|
104
|
-
return (null
|
|
104
|
+
return (null == (_node_data = node.data) ? void 0 : null == (_node_data_estree = _node_data.estree) ? void 0 : _node_data_estree.body) || [];
|
|
105
105
|
}).filter((node)=>'ImportDeclaration' === node.type);
|
|
106
106
|
for (const importNode of importNodes){
|
|
107
107
|
const id = importNode.specifiers[0].local.name;
|
|
@@ -143,11 +143,11 @@ function normalizePath(id) {
|
|
|
143
143
|
const rehypePluginCodeMeta = ()=>(tree)=>{
|
|
144
144
|
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'element', (node)=>{
|
|
145
145
|
var _node_children_;
|
|
146
|
-
if ('pre' === node.tagName && (null
|
|
146
|
+
if ('pre' === node.tagName && (null == (_node_children_ = node.children[0]) ? void 0 : _node_children_.type) === 'element' && 'code' === node.children[0].tagName) {
|
|
147
147
|
var _codeNode_data;
|
|
148
148
|
const codeNode = node.children[0];
|
|
149
149
|
codeNode.properties ??= {};
|
|
150
|
-
codeNode.properties.meta = null
|
|
150
|
+
codeNode.properties.meta = null == (_codeNode_data = codeNode.data) ? void 0 : _codeNode_data.meta;
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
153
|
};
|
|
@@ -157,7 +157,7 @@ const rehypeHeaderAnchor = ()=>{
|
|
|
157
157
|
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'element', (node)=>{
|
|
158
158
|
var _node_properties;
|
|
159
159
|
if (!(0, __WEBPACK_EXTERNAL_MODULE_hast_util_heading_rank_cff646ba__.headingRank)(node)) return;
|
|
160
|
-
if (!(null
|
|
160
|
+
if (!(null == (_node_properties = node.properties) ? void 0 : _node_properties.id)) {
|
|
161
161
|
const [text, customId] = collectHeaderText(node);
|
|
162
162
|
node.properties ??= {};
|
|
163
163
|
node.properties.id = customId || slugger.slug(text);
|
|
@@ -261,7 +261,7 @@ const remarkCheckDeadLinks = (checkLink)=>{
|
|
|
261
261
|
if (internalLinks.has(url)) return;
|
|
262
262
|
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
|
263
263
|
var _url_split_join;
|
|
264
|
-
const { routePath: normalizeUrl } = routeService.normalizeRoutePath(null
|
|
264
|
+
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
265
|
internalLinks.add(normalizeUrl);
|
|
266
266
|
}
|
|
267
267
|
});
|
|
@@ -367,19 +367,19 @@ const parseToc = (tree)=>{
|
|
|
367
367
|
const text = node.children.map((child)=>{
|
|
368
368
|
if ('link' === child.type) {
|
|
369
369
|
var _child_children;
|
|
370
|
-
return null
|
|
370
|
+
return null == (_child_children = child.children) ? void 0 : _child_children.map((item)=>item.value).join('');
|
|
371
371
|
}
|
|
372
372
|
if ('strong' === child.type) {
|
|
373
373
|
var _child_children1;
|
|
374
|
-
return `**${null
|
|
374
|
+
return `**${null == (_child_children1 = child.children) ? void 0 : _child_children1.map((item)=>item.value).join('')}**`;
|
|
375
375
|
}
|
|
376
376
|
if ('emphasis' === child.type) {
|
|
377
377
|
var _child_children2;
|
|
378
|
-
return `*${null
|
|
378
|
+
return `*${null == (_child_children2 = child.children) ? void 0 : _child_children2.map((item)=>item.value).join('')}*`;
|
|
379
379
|
}
|
|
380
380
|
if ('delete' === child.type) {
|
|
381
381
|
var _child_children3;
|
|
382
|
-
return `~~${null
|
|
382
|
+
return `~~${null == (_child_children3 = child.children) ? void 0 : _child_children3.map((item)=>item.value).join('')}~~`;
|
|
383
383
|
}
|
|
384
384
|
if ('text' === child.type) {
|
|
385
385
|
const [textPart, idPart] = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.extractTextAndId)(child.value);
|
|
@@ -417,21 +417,21 @@ const remarkPluginToc = function() {
|
|
|
417
417
|
};
|
|
418
418
|
async function createMDXOptions(docDirectory, config, checkDeadLinks, routeService, filepath, pluginDriver) {
|
|
419
419
|
var _config_route;
|
|
420
|
-
const cleanUrls = (null == config ? void 0 : null
|
|
420
|
+
const cleanUrls = (null == config ? void 0 : null == (_config_route = config.route) ? void 0 : _config_route.cleanUrls) ?? false;
|
|
421
421
|
const { remarkPlugins: remarkPluginsFromConfig = [], rehypePlugins: rehypePluginsFromConfig = [], globalComponents: globalComponentsFromConfig = [] } = (null == config ? void 0 : config.markdown) || {};
|
|
422
422
|
const rspressPlugins = pluginDriver.getPlugins();
|
|
423
423
|
const remarkPluginsFromPlugins = rspressPlugins.flatMap((plugin)=>{
|
|
424
424
|
var _plugin_markdown;
|
|
425
|
-
return (null
|
|
425
|
+
return (null == (_plugin_markdown = plugin.markdown) ? void 0 : _plugin_markdown.remarkPlugins) || [];
|
|
426
426
|
});
|
|
427
427
|
const rehypePluginsFromPlugins = rspressPlugins.flatMap((plugin)=>{
|
|
428
428
|
var _plugin_markdown;
|
|
429
|
-
return (null
|
|
429
|
+
return (null == (_plugin_markdown = plugin.markdown) ? void 0 : _plugin_markdown.rehypePlugins) || [];
|
|
430
430
|
});
|
|
431
431
|
const globalComponents = [
|
|
432
432
|
...rspressPlugins.flatMap((plugin)=>{
|
|
433
433
|
var _plugin_markdown;
|
|
434
|
-
return (null
|
|
434
|
+
return (null == (_plugin_markdown = plugin.markdown) ? void 0 : _plugin_markdown.globalComponents) || [];
|
|
435
435
|
}),
|
|
436
436
|
...globalComponentsFromConfig
|
|
437
437
|
];
|
|
@@ -521,7 +521,7 @@ async function mdxLoader(source) {
|
|
|
521
521
|
const replacedContent = applyReplaceRules(flattenContent, config.replaceRules);
|
|
522
522
|
const preprocessedContent = escapeMarkdownHeadingIds(replacedContent);
|
|
523
523
|
let enableMdxRs;
|
|
524
|
-
const mdxRs = (null == config ? void 0 : null
|
|
524
|
+
const mdxRs = (null == config ? void 0 : null == (_config_markdown = config.markdown) ? void 0 : _config_markdown.mdxRs) ?? true;
|
|
525
525
|
enableMdxRs = 'object' == typeof mdxRs ? 'function' == typeof (null == mdxRs ? void 0 : mdxRs.include) ? mdxRs.include(filepath) : true : mdxRs;
|
|
526
526
|
try {
|
|
527
527
|
let compileResult;
|
|
@@ -3,34 +3,25 @@ import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress
|
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE__theme_75e53063__ from "@theme";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__ from "./App.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const [data, setData] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(null);
|
|
6
|
+
function ClientApp({ initialPageData }) {
|
|
7
|
+
const [data, setData] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(initialPageData);
|
|
9
8
|
const [theme, setTheme] = (0, __WEBPACK_EXTERNAL_MODULE__theme_75e53063__.useThemeState)();
|
|
10
|
-
(0,
|
|
11
|
-
(0,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const themeValue = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
9
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.ThemeContext.Provider, {
|
|
10
|
+
value: (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
11
|
+
theme,
|
|
12
|
+
setTheme
|
|
13
|
+
}), [
|
|
16
14
|
theme,
|
|
17
15
|
setTheme
|
|
18
|
-
|
|
19
|
-
theme,
|
|
20
|
-
setTheme
|
|
21
|
-
]);
|
|
22
|
-
const dataValue = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
23
|
-
data,
|
|
24
|
-
setData
|
|
25
|
-
}), [
|
|
26
|
-
data,
|
|
27
|
-
setData
|
|
28
|
-
]);
|
|
29
|
-
if (!data) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {});
|
|
30
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.ThemeContext.Provider, {
|
|
31
|
-
value: themeValue,
|
|
16
|
+
]),
|
|
32
17
|
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.DataContext.Provider, {
|
|
33
|
-
value:
|
|
18
|
+
value: (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
19
|
+
data,
|
|
20
|
+
setData
|
|
21
|
+
}), [
|
|
22
|
+
data,
|
|
23
|
+
setData
|
|
24
|
+
]),
|
|
34
25
|
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.BrowserRouter, {
|
|
35
26
|
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.App, {})
|
|
36
27
|
})
|
|
@@ -2,17 +2,27 @@ import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/j
|
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__ from "virtual-site-data";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__ from "./ClientApp.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__ from "./initPageData.js";
|
|
5
6
|
const enableSSG = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].ssg;
|
|
6
7
|
async function renderInBrowser() {
|
|
7
8
|
const container = document.getElementById('root');
|
|
9
|
+
const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__.initPageData)(window.location.pathname);
|
|
8
10
|
if (process.env.__REACT_GTE_18__) {
|
|
9
11
|
const { createRoot, hydrateRoot } = await import("react-dom/client");
|
|
10
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)() && enableSSG) hydrateRoot(container, /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
|
|
11
|
-
|
|
12
|
+
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)() && enableSSG) hydrateRoot(container, /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
|
|
13
|
+
initialPageData: initialPageData
|
|
14
|
+
}));
|
|
15
|
+
else createRoot(container).render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
|
|
16
|
+
initialPageData: initialPageData
|
|
17
|
+
}));
|
|
12
18
|
} else {
|
|
13
19
|
const ReactDOM = await import("react-dom");
|
|
14
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)()) ReactDOM.hydrate(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
|
|
15
|
-
|
|
20
|
+
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)()) ReactDOM.hydrate(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
|
|
21
|
+
initialPageData: initialPageData
|
|
22
|
+
}), container);
|
|
23
|
+
else ReactDOM.render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
|
|
24
|
+
initialPageData: initialPageData
|
|
25
|
+
}), container);
|
|
16
26
|
}
|
|
17
27
|
}
|
|
18
28
|
renderInBrowser();
|
|
@@ -12,7 +12,7 @@ async function initPageData(routePath) {
|
|
|
12
12
|
const normalize = (p)=>p.replace(/\/$/, '').toLowerCase();
|
|
13
13
|
const extractPageInfo = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].pages.find((page)=>(0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.isEqualPath)(normalize(page.routePath), normalize(matchedRoute.path)));
|
|
14
14
|
const encodedPagePath = encodeURIComponent(pagePath);
|
|
15
|
-
const meta = (null
|
|
15
|
+
const meta = (null == (_mod_default___RSPRESS_PAGE_META = mod.default.__RSPRESS_PAGE_META) ? void 0 : _mod_default___RSPRESS_PAGE_META[encodedPagePath]) || {};
|
|
16
16
|
const { toc = [], title = '', frontmatter = {}, ...rest } = __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(matchedRoute.filePath) ? meta : mod;
|
|
17
17
|
return {
|
|
18
18
|
siteData: __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"],
|
|
@@ -28,7 +28,7 @@ async function initPageData(routePath) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
let lang = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang || '';
|
|
31
|
-
let version = (null
|
|
31
|
+
let version = (null == (_siteData_multiVersion = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion) ? void 0 : _siteData_multiVersion.default) || '';
|
|
32
32
|
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang && 'undefined' != typeof window) {
|
|
33
33
|
const path = location.pathname.replace(__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].base, '').split('/').slice(0, 2);
|
|
34
34
|
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].locales.length) {
|
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": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.11",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@mdx-js/loader": "^3.1.0",
|
|
46
46
|
"@mdx-js/mdx": "^3.1.0",
|
|
47
47
|
"@mdx-js/react": "^3.1.0",
|
|
48
|
-
"@rsbuild/core": "1.3.
|
|
48
|
+
"@rsbuild/core": "1.3.6",
|
|
49
49
|
"@rsbuild/plugin-react": "~1.1.1",
|
|
50
50
|
"@rspress/mdx-rs": "0.6.6",
|
|
51
51
|
"enhanced-resolve": "5.18.1",
|
|
@@ -70,17 +70,17 @@
|
|
|
70
70
|
"unified": "^11.0.5",
|
|
71
71
|
"unist-util-visit": "^5.0.0",
|
|
72
72
|
"unist-util-visit-children": "^3.0.0",
|
|
73
|
-
"@rspress/plugin-auto-nav-sidebar": "2.0.0-alpha.
|
|
74
|
-
"@rspress/plugin-container-syntax": "2.0.0-alpha.
|
|
75
|
-
"@rspress/plugin-last-updated": "2.0.0-alpha.
|
|
76
|
-
"@rspress/plugin-medium-zoom": "2.0.0-alpha.
|
|
77
|
-
"@rspress/
|
|
78
|
-
"@rspress/
|
|
79
|
-
"@rspress/
|
|
73
|
+
"@rspress/plugin-auto-nav-sidebar": "2.0.0-alpha.11",
|
|
74
|
+
"@rspress/plugin-container-syntax": "2.0.0-alpha.11",
|
|
75
|
+
"@rspress/plugin-last-updated": "2.0.0-alpha.11",
|
|
76
|
+
"@rspress/plugin-medium-zoom": "2.0.0-alpha.11",
|
|
77
|
+
"@rspress/shared": "2.0.0-alpha.11",
|
|
78
|
+
"@rspress/theme-default": "2.0.0-alpha.11",
|
|
79
|
+
"@rspress/runtime": "2.0.0-alpha.11"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@microsoft/api-extractor": "^7.52.3",
|
|
83
|
-
"@rslib/core": "0.6.
|
|
83
|
+
"@rslib/core": "0.6.3",
|
|
84
84
|
"@rspress-dev/plugin-preview": "link:../plugin-preview",
|
|
85
85
|
"@types/hast": "^3.0.4",
|
|
86
86
|
"@types/html-to-text": "^9.0.4",
|