@rspress/core 2.0.0-beta.4 → 2.0.0-beta.6
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 +20 -62
- package/dist/loader.d.ts +0 -4
- package/dist/loader.js +10 -61
- package/dist/runtime/csrClientEntry.js +3 -11
- package/dist/runtime/ssrClientEntry.js +4 -11
- package/package.json +16 -16
package/dist/index.js
CHANGED
|
@@ -4,23 +4,22 @@ 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__rsbuild_plugin_react_7b149ee4__ from "@rsbuild/plugin-react";
|
|
8
7
|
import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__ from "@rsbuild/plugin-react";
|
|
9
9
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__ from "@rspress/shared/logger";
|
|
10
10
|
import * as __WEBPACK_EXTERNAL_MODULE_picocolors__ from "picocolors";
|
|
11
11
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__ from "@rspress/shared/constants";
|
|
12
12
|
import * as __WEBPACK_EXTERNAL_MODULE_tinyglobby__ from "tinyglobby";
|
|
13
13
|
import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
|
|
14
14
|
import * as __WEBPACK_EXTERNAL_MODULE_rspack_plugin_virtual_module_609978fd__ from "rspack-plugin-virtual-module";
|
|
15
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__ from "@rspress/shared/node-utils";
|
|
15
16
|
import * as __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__ from "lodash-es";
|
|
16
17
|
import * as __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__ from "node:crypto";
|
|
17
18
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_mdx_rs_d2f3021f__ from "@rspress/mdx-rs";
|
|
18
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__ from "@rspress/shared/node-utils";
|
|
19
19
|
import * as __WEBPACK_EXTERNAL_MODULE_html_to_text_2c51ed38__ from "html-to-text";
|
|
20
20
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
21
21
|
import * as __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__ from "@mdx-js/mdx";
|
|
22
22
|
import * as __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__ from "enhanced-resolve";
|
|
23
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
|
|
24
23
|
import * as __WEBPACK_EXTERNAL_MODULE__unhead_react_server_7e85c952__ from "@unhead/react/server";
|
|
25
24
|
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
|
|
26
25
|
import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__ from "unist-util-visit";
|
|
@@ -37,6 +36,7 @@ class PluginDriver {
|
|
|
37
36
|
async init() {
|
|
38
37
|
this.clearPlugins();
|
|
39
38
|
const config = this.#config;
|
|
39
|
+
const markdownConfig = config.markdown || {};
|
|
40
40
|
const themeConfig = config?.themeConfig || {};
|
|
41
41
|
const enableLastUpdated = themeConfig?.lastUpdated || themeConfig?.locales?.some((locale)=>locale.lastUpdated);
|
|
42
42
|
const mediumZoomConfig = config?.mediumZoom ?? true;
|
|
@@ -54,9 +54,11 @@ class PluginDriver {
|
|
|
54
54
|
const SourceBuildPlugin = await import("@rspress/theme-default/node/source-build-plugin.js").then((r)=>r.SourceBuildPlugin, ()=>null);
|
|
55
55
|
if (SourceBuildPlugin) this.addPlugin(SourceBuildPlugin());
|
|
56
56
|
}
|
|
57
|
+
const { pluginShiki } = await import("@rspress/plugin-shiki");
|
|
57
58
|
(config.plugins || []).forEach((plugin)=>{
|
|
58
59
|
this.addPlugin(plugin);
|
|
59
60
|
});
|
|
61
|
+
this.addPlugin(pluginShiki(markdownConfig.shiki));
|
|
60
62
|
if (!haveNavSidebarConfig) {
|
|
61
63
|
const { pluginAutoNavSidebar } = await import("@rspress/plugin-auto-nav-sidebar");
|
|
62
64
|
this.addPlugin(pluginAutoNavSidebar());
|
|
@@ -177,7 +179,7 @@ const pluginVirtualModule = (pluginOptions = {})=>({
|
|
|
177
179
|
}
|
|
178
180
|
}
|
|
179
181
|
});
|
|
180
|
-
var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.
|
|
182
|
+
var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.6"}');
|
|
181
183
|
const RSPRESS_VERSION = package_namespaceObject.i8;
|
|
182
184
|
const isProduction = ()=>'production' === process.env.NODE_ENV;
|
|
183
185
|
const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
|
|
@@ -468,7 +470,6 @@ var types_RuntimeModuleID = /*#__PURE__*/ function(RuntimeModuleID) {
|
|
|
468
470
|
RuntimeModuleID["SearchIndexHash"] = "virtual-search-index-hash";
|
|
469
471
|
RuntimeModuleID["I18nText"] = "virtual-i18n-text";
|
|
470
472
|
RuntimeModuleID["SearchHooks"] = "virtual-search-hooks";
|
|
471
|
-
RuntimeModuleID["PrismLanguages"] = "virtual-prism-languages";
|
|
472
473
|
return RuntimeModuleID;
|
|
473
474
|
}({});
|
|
474
475
|
async function routeVMPlugin(context) {
|
|
@@ -672,45 +673,6 @@ async function extractPageData(replaceRules, alias, domain, root, routeService,
|
|
|
672
673
|
}));
|
|
673
674
|
return pageData.filter(Boolean);
|
|
674
675
|
}
|
|
675
|
-
const highlightLanguages_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
|
|
676
|
-
let highlightLanguages_supportedLanguages;
|
|
677
|
-
function handleHighlightLanguages(highlightLanguages, defaultLanguages) {
|
|
678
|
-
const aliases = {};
|
|
679
|
-
if (highlightLanguages.size) {
|
|
680
|
-
if (!highlightLanguages_supportedLanguages) {
|
|
681
|
-
const langs = highlightLanguages_require('react-syntax-highlighter/dist/cjs/languages/prism/supported-languages').default;
|
|
682
|
-
highlightLanguages_supportedLanguages = new Set(langs);
|
|
683
|
-
}
|
|
684
|
-
let useDeprecatedTypeWarning = true;
|
|
685
|
-
const names = {};
|
|
686
|
-
[
|
|
687
|
-
...__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.DEFAULT_HIGHLIGHT_LANGUAGES,
|
|
688
|
-
...defaultLanguages
|
|
689
|
-
].forEach((lang)=>{
|
|
690
|
-
if (Array.isArray(lang)) {
|
|
691
|
-
const [alias, name] = lang;
|
|
692
|
-
names[alias] = name;
|
|
693
|
-
} else if (useDeprecatedTypeWarning) {
|
|
694
|
-
console.log(`${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellowBright('warning')} Automatic import is supported. \`highlightLanguages\` is now used only as alias, and string types will be ignored. \n`);
|
|
695
|
-
useDeprecatedTypeWarning = false;
|
|
696
|
-
}
|
|
697
|
-
});
|
|
698
|
-
[
|
|
699
|
-
...highlightLanguages.values()
|
|
700
|
-
].forEach((lang)=>{
|
|
701
|
-
const name = names[lang];
|
|
702
|
-
if (name && highlightLanguages_supportedLanguages.has(name)) {
|
|
703
|
-
const temp = aliases[name] || (aliases[name] = []);
|
|
704
|
-
if (!temp.includes(lang)) temp.push(lang);
|
|
705
|
-
highlightLanguages.delete(lang);
|
|
706
|
-
highlightLanguages.add(name);
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
709
|
-
if (!highlightLanguages_supportedLanguages.has(lang)) highlightLanguages.delete(lang);
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
return aliases;
|
|
713
|
-
}
|
|
714
676
|
const DEFAULT_I18N_SOURCE = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(process.cwd(), 'i18n.json');
|
|
715
677
|
function getI18nData(docConfig) {
|
|
716
678
|
const { i18nSourcePath = DEFAULT_I18N_SOURCE } = docConfig;
|
|
@@ -881,7 +843,7 @@ async function siteDataVMPlugin(context) {
|
|
|
881
843
|
const siteData = {
|
|
882
844
|
title: userConfig?.title || '',
|
|
883
845
|
description: userConfig?.description || '',
|
|
884
|
-
icon: userConfig?.icon || '',
|
|
846
|
+
icon: (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.getIconUrlPath)(userConfig?.icon) || '',
|
|
885
847
|
route: userConfig?.route || {},
|
|
886
848
|
themeConfig: normalizeThemeConfig(userConfig, pages),
|
|
887
849
|
base: userConfig?.base || '/',
|
|
@@ -907,23 +869,13 @@ async function siteDataVMPlugin(context) {
|
|
|
907
869
|
markdown: {
|
|
908
870
|
showLineNumbers: userConfig?.markdown?.showLineNumbers ?? false,
|
|
909
871
|
defaultWrapCode: userConfig?.markdown?.defaultWrapCode ?? false,
|
|
910
|
-
|
|
872
|
+
shiki: {}
|
|
911
873
|
}
|
|
912
874
|
};
|
|
913
|
-
const { highlightLanguages: defaultLanguages = [] } = config.markdown || {};
|
|
914
875
|
if (Array.isArray(siteData.pages[0]?.extraHighlightLanguages)) siteData.pages[0].extraHighlightLanguages.forEach((lang)=>highlightLanguages.add(lang));
|
|
915
|
-
const aliases = handleHighlightLanguages(highlightLanguages, defaultLanguages);
|
|
916
|
-
const sortedAliases = Object.fromEntries(Object.entries(aliases).sort());
|
|
917
|
-
const sortedHighlightLanguages = Array.from(highlightLanguages).sort();
|
|
918
876
|
return {
|
|
919
877
|
[`${types_RuntimeModuleID.SiteData}.mjs`]: `export default ${JSON.stringify(siteData, null, 2)}`,
|
|
920
|
-
[types_RuntimeModuleID.SearchIndexHash]: `export default ${JSON.stringify(indexHashByGroup, null, 2)}
|
|
921
|
-
[types_RuntimeModuleID.PrismLanguages]: `export const aliases = ${JSON.stringify(sortedAliases, null, 2)};
|
|
922
|
-
export const languages = {
|
|
923
|
-
${sortedHighlightLanguages.map((lang)=>`"${lang}": require(
|
|
924
|
-
"react-syntax-highlighter/dist/cjs/languages/prism/${lang}"
|
|
925
|
-
).default`)}
|
|
926
|
-
}`
|
|
878
|
+
[types_RuntimeModuleID.SearchIndexHash]: `export default ${JSON.stringify(indexHashByGroup, null, 2)}`
|
|
927
879
|
};
|
|
928
880
|
}
|
|
929
881
|
const runtimeModuleFactory = [
|
|
@@ -1252,9 +1204,9 @@ async function resolveReactAlias(reactVersion, isSSR) {
|
|
|
1252
1204
|
'react/jsx-runtime',
|
|
1253
1205
|
'react/jsx-dev-runtime',
|
|
1254
1206
|
'react-dom',
|
|
1207
|
+
'react-dom/client',
|
|
1255
1208
|
'react-dom/server'
|
|
1256
1209
|
];
|
|
1257
|
-
if (reactVersion >= 18) libPaths.push('react-dom/client');
|
|
1258
1210
|
const alias = {};
|
|
1259
1211
|
const resolver = detectReactVersion_ResolverFactory.createResolver({
|
|
1260
1212
|
fileSystem: new detectReactVersion_CachedInputFileSystem(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"], 0),
|
|
@@ -1340,7 +1292,9 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1340
1292
|
const reactVersion = await detectReactVersion();
|
|
1341
1293
|
const normalizeIcon = (icon)=>{
|
|
1342
1294
|
if (!icon) return;
|
|
1343
|
-
|
|
1295
|
+
icon = icon.toString();
|
|
1296
|
+
if (icon.startsWith('file://')) icon = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(icon);
|
|
1297
|
+
else if (__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(icon)) return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(userDocRoot, PUBLIC_DIR, icon);
|
|
1344
1298
|
return icon;
|
|
1345
1299
|
};
|
|
1346
1300
|
await hintThemeBreakingChange(CUSTOM_THEME_DIR);
|
|
@@ -1426,8 +1380,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1426
1380
|
],
|
|
1427
1381
|
'@theme-assets': __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(DEFAULT_THEME, '../assets'),
|
|
1428
1382
|
'@rspress/core': PACKAGE_ROOT,
|
|
1429
|
-
'react-lazy-with-preload': require.resolve('react-lazy-with-preload')
|
|
1430
|
-
'react-syntax-highlighter': __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(require.resolve('react-syntax-highlighter/package.json'))
|
|
1383
|
+
'react-lazy-with-preload': require.resolve('react-lazy-with-preload')
|
|
1431
1384
|
}
|
|
1432
1385
|
},
|
|
1433
1386
|
source: {
|
|
@@ -1436,7 +1389,6 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1436
1389
|
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(cwd, 'node_modules', __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.RSPRESS_TEMP_DIR)
|
|
1437
1390
|
],
|
|
1438
1391
|
define: {
|
|
1439
|
-
'process.env.__REACT_GTE_18__': JSON.stringify(reactVersion >= 18),
|
|
1440
1392
|
'process.env.TEST': JSON.stringify(process.env.TEST),
|
|
1441
1393
|
'process.env.RSPRESS_SOCIAL_ICONS': JSON.stringify(getSocialIcons(config.themeConfig?.socialLinks))
|
|
1442
1394
|
}
|
|
@@ -1568,6 +1520,7 @@ async function initRsbuild(rootDir, config, pluginDriver, enableSSG, extraRsbuil
|
|
|
1568
1520
|
const { createRsbuild, mergeRsbuildConfig } = await import("@rsbuild/core");
|
|
1569
1521
|
const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, runtimeTempDir);
|
|
1570
1522
|
const rsbuild = await createRsbuild({
|
|
1523
|
+
callerName: 'rspress',
|
|
1571
1524
|
rsbuildConfig: mergeRsbuildConfig(internalRsbuildConfig, ...pluginDriver.getPlugins()?.map((plugin)=>plugin.builderConfig ?? {}) || [], config?.builderConfig || {}, extraRsbuildConfig || {})
|
|
1572
1525
|
});
|
|
1573
1526
|
rsbuild.addPlugins(builderPlugins);
|
|
@@ -1777,6 +1730,11 @@ const remarkPluginNormalizeLink = ({ root, cleanUrls, routeService })=>(tree, fi
|
|
|
1777
1730
|
const relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, file.path);
|
|
1778
1731
|
node.url = normalizeLink(nodeUrl, routeService, relativePath, cleanUrls);
|
|
1779
1732
|
});
|
|
1733
|
+
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'definition', (node)=>{
|
|
1734
|
+
const { url: nodeUrl } = node;
|
|
1735
|
+
const relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, file.path);
|
|
1736
|
+
node.url = normalizeLink(nodeUrl, routeService, relativePath, cleanUrls);
|
|
1737
|
+
});
|
|
1780
1738
|
const getMdxSrcAttribute = (tempVar)=>({
|
|
1781
1739
|
type: 'mdxJsxAttribute',
|
|
1782
1740
|
name: 'src',
|
package/dist/loader.d.ts
CHANGED
|
@@ -7,8 +7,6 @@ import type { Rspack as Rspack_2 } from '@rsbuild/core';
|
|
|
7
7
|
import type { RspressPlugin } from '@rspress/shared';
|
|
8
8
|
import type { UserConfig } from '@rspress/shared';
|
|
9
9
|
|
|
10
|
-
export declare function createCheckPageMetaUpdateFn(): (modulePath: string, pageMeta: PageMeta) => void;
|
|
11
|
-
|
|
12
10
|
declare interface LoaderOptions {
|
|
13
11
|
config: UserConfig;
|
|
14
12
|
docDirectory: string;
|
|
@@ -84,6 +82,4 @@ declare interface TocItem {
|
|
|
84
82
|
depth: number;
|
|
85
83
|
}
|
|
86
84
|
|
|
87
|
-
export declare function updateSiteDataRuntimeModule(modulePath: string, pageMeta: PageMeta): Promise<void>;
|
|
88
|
-
|
|
89
85
|
export { }
|
package/dist/loader.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
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
7
|
import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
|
|
@@ -13,35 +10,9 @@ import * as __WEBPACK_EXTERNAL_MODULE_remark_gfm_073acf21__ from "remark-gfm";
|
|
|
13
10
|
import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__ from "unist-util-visit";
|
|
14
11
|
import * as __WEBPACK_EXTERNAL_MODULE_github_slugger_8e9a17cb__ from "github-slugger";
|
|
15
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";
|
|
16
14
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__ from "@rspress/shared/constants";
|
|
17
15
|
import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_children_71921007__ from "unist-util-visit-children";
|
|
18
|
-
`{
|
|
19
|
-
const saved = localStorage.getItem('${__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.APPEARANCE_KEY}')
|
|
20
|
-
const preferDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
21
|
-
const isDark = !saved || saved === 'auto' ? preferDark : saved === 'dark'
|
|
22
|
-
document.documentElement.classList.toggle('dark', isDark)
|
|
23
|
-
document.documentElement.classList.toggle('rp-dark', isDark)
|
|
24
|
-
document.documentElement.style.colorScheme = isDark ? 'dark' : 'light'
|
|
25
|
-
}`.replace(/\n/g, ';').replace(/\s{2,}/g, '');
|
|
26
|
-
const dirname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(new URL(import.meta.url)));
|
|
27
|
-
const PACKAGE_ROOT = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dirname, '..');
|
|
28
|
-
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'index.html');
|
|
29
|
-
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'csrClientEntry.js');
|
|
30
|
-
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrClientEntry.js');
|
|
31
|
-
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrServerEntry.js');
|
|
32
|
-
const TEMP_DIR = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), 'node_modules', __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.RSPRESS_TEMP_DIR);
|
|
33
|
-
var types_RuntimeModuleID = /*#__PURE__*/ function(RuntimeModuleID) {
|
|
34
|
-
RuntimeModuleID["GlobalStyles"] = "virtual-global-styles";
|
|
35
|
-
RuntimeModuleID["GlobalComponents"] = "virtual-global-components";
|
|
36
|
-
RuntimeModuleID["RouteForClient"] = "virtual-routes";
|
|
37
|
-
RuntimeModuleID["RouteForSSR"] = "virtual-routes-ssr";
|
|
38
|
-
RuntimeModuleID["SiteData"] = "virtual-site-data";
|
|
39
|
-
RuntimeModuleID["SearchIndexHash"] = "virtual-search-index-hash";
|
|
40
|
-
RuntimeModuleID["I18nText"] = "virtual-i18n-text";
|
|
41
|
-
RuntimeModuleID["SearchHooks"] = "virtual-search-hooks";
|
|
42
|
-
RuntimeModuleID["PrismLanguages"] = "virtual-prism-languages";
|
|
43
|
-
return RuntimeModuleID;
|
|
44
|
-
}({});
|
|
45
16
|
function applyReplaceRules(code = '', replaceRules = []) {
|
|
46
17
|
let result = code;
|
|
47
18
|
for (const rule of replaceRules)result = result.replace(rule.search, rule.replace);
|
|
@@ -216,6 +187,11 @@ const remarkPluginNormalizeLink = ({ root, cleanUrls, routeService })=>(tree, fi
|
|
|
216
187
|
const relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, file.path);
|
|
217
188
|
node.url = normalizeLink(nodeUrl, routeService, relativePath, cleanUrls);
|
|
218
189
|
});
|
|
190
|
+
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'definition', (node)=>{
|
|
191
|
+
const { url: nodeUrl } = node;
|
|
192
|
+
const relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, file.path);
|
|
193
|
+
node.url = normalizeLink(nodeUrl, routeService, relativePath, cleanUrls);
|
|
194
|
+
});
|
|
219
195
|
const getMdxSrcAttribute = (tempVar)=>({
|
|
220
196
|
type: 'mdxJsxAttribute',
|
|
221
197
|
name: 'src',
|
|
@@ -375,41 +351,15 @@ async function createMDXOptions(docDirectory, config, checkDeadLinks, routeServi
|
|
|
375
351
|
]
|
|
376
352
|
};
|
|
377
353
|
}
|
|
378
|
-
async function updateSiteDataRuntimeModule(modulePath, pageMeta) {
|
|
379
|
-
const siteDataModulePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(TEMP_DIR, 'runtime', `${types_RuntimeModuleID.SiteData}.mjs`);
|
|
380
|
-
const { default: siteData } = await import((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(siteDataModulePath).href);
|
|
381
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile(siteDataModulePath, `export default ${JSON.stringify({
|
|
382
|
-
...siteData,
|
|
383
|
-
timestamp: Date.now().toString(),
|
|
384
|
-
pages: siteData.pages.map((page)=>page._filepath === modulePath ? {
|
|
385
|
-
...page,
|
|
386
|
-
...pageMeta
|
|
387
|
-
} : page)
|
|
388
|
-
}, null, 2)}`);
|
|
389
|
-
}
|
|
390
|
-
function createCheckPageMetaUpdateFn() {
|
|
391
|
-
const pageMetaMap = new Map();
|
|
392
|
-
return (modulePath, pageMeta)=>{
|
|
393
|
-
const prevMeta = pageMetaMap.get(modulePath);
|
|
394
|
-
const deserializedMeta = JSON.stringify(pageMeta);
|
|
395
|
-
pageMetaMap.set(modulePath, deserializedMeta);
|
|
396
|
-
if (!prevMeta) return;
|
|
397
|
-
if (prevMeta !== deserializedMeta) setTimeout(async ()=>{
|
|
398
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info('Page metadata changed, page reloading...');
|
|
399
|
-
await updateSiteDataRuntimeModule(modulePath, pageMeta);
|
|
400
|
-
});
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
const checkPageMetaUpdate = createCheckPageMetaUpdateFn();
|
|
404
354
|
async function mdxLoader(source) {
|
|
405
355
|
this.cacheable(true);
|
|
406
356
|
const callback = this.async();
|
|
407
357
|
const options = this.getOptions();
|
|
408
358
|
const filepath = this.resourcePath;
|
|
409
359
|
const { config, docDirectory, checkDeadLinks, routeService, pluginDriver } = options;
|
|
410
|
-
const { frontmatter,
|
|
411
|
-
const
|
|
412
|
-
const preprocessedContent = escapeMarkdownHeadingIds(
|
|
360
|
+
const { frontmatter, emptyLinesSource } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.loadFrontMatter)(source, filepath, docDirectory, true);
|
|
361
|
+
const replacedSource = applyReplaceRules(emptyLinesSource, config.replaceRules);
|
|
362
|
+
const preprocessedContent = escapeMarkdownHeadingIds(replacedSource);
|
|
413
363
|
try {
|
|
414
364
|
let pageMeta = {
|
|
415
365
|
title: '',
|
|
@@ -436,7 +386,6 @@ async function mdxLoader(source) {
|
|
|
436
386
|
headingTitle,
|
|
437
387
|
frontmatter
|
|
438
388
|
};
|
|
439
|
-
if (!(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)()) checkPageMetaUpdate(filepath, pageMeta);
|
|
440
389
|
const result = `const frontmatter = ${JSON.stringify(frontmatter)};
|
|
441
390
|
${compileResult}
|
|
442
391
|
MDXContent.__RSPRESS_PAGE_META = {};
|
|
@@ -455,4 +404,4 @@ MDXContent.__RSPRESS_PAGE_META["${encodeURIComponent(normalizePath(__WEBPACK_EXT
|
|
|
455
404
|
}
|
|
456
405
|
}
|
|
457
406
|
}
|
|
458
|
-
export {
|
|
407
|
+
export { mdxLoader as default };
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_dom_client_76b1397c__ from "react-dom/client";
|
|
2
3
|
import * as __WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__ from "./ClientApp.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (process.env.__REACT_GTE_18__) {
|
|
6
|
-
const { createRoot } = await import("react-dom/client");
|
|
7
|
-
createRoot(container).render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}));
|
|
8
|
-
} else {
|
|
9
|
-
const ReactDOM = await import("react-dom");
|
|
10
|
-
ReactDOM.render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}), container);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
renderInBrowser();
|
|
4
|
+
const container = document.getElementById('root');
|
|
5
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react_dom_client_76b1397c__.createRoot)(container).render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}));
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_dom_client_76b1397c__ from "react-dom/client";
|
|
2
3
|
import * as __WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__ from "./ClientApp.js";
|
|
3
4
|
import * as __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__ from "./initPageData.js";
|
|
4
5
|
async function renderInBrowser() {
|
|
5
6
|
const container = document.getElementById('root');
|
|
6
7
|
const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__.initPageData)(window.location.pathname);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
initialPageData: initialPageData
|
|
11
|
-
}));
|
|
12
|
-
} else {
|
|
13
|
-
const ReactDOM = await import("react-dom");
|
|
14
|
-
ReactDOM.hydrate(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
|
|
15
|
-
initialPageData: initialPageData
|
|
16
|
-
}), container);
|
|
17
|
-
}
|
|
8
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react_dom_client_76b1397c__.hydrateRoot)(container, /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
|
|
9
|
+
initialPageData: initialPageData
|
|
10
|
+
}));
|
|
18
11
|
}
|
|
19
12
|
renderInBrowser();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.6",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"@mdx-js/loader": "^3.1.0",
|
|
46
46
|
"@mdx-js/mdx": "^3.1.0",
|
|
47
47
|
"@mdx-js/react": "^3.1.0",
|
|
48
|
-
"@rsbuild/core": "1.3.
|
|
49
|
-
"@rsbuild/plugin-react": "~1.3.
|
|
48
|
+
"@rsbuild/core": "~1.3.18",
|
|
49
|
+
"@rsbuild/plugin-react": "~1.3.1",
|
|
50
50
|
"@rspress/mdx-rs": "0.6.6",
|
|
51
|
-
"@types/unist": "^3.0.
|
|
52
|
-
"@unhead/react": "^2.0.
|
|
51
|
+
"@types/unist": "^3.0.3",
|
|
52
|
+
"@unhead/react": "^2.0.8",
|
|
53
53
|
"enhanced-resolve": "5.18.1",
|
|
54
54
|
"github-slugger": "^2.0.0",
|
|
55
55
|
"hast-util-from-html": "^2.0.3",
|
|
@@ -62,26 +62,26 @@
|
|
|
62
62
|
"react-dom": "^19.1.0",
|
|
63
63
|
"react-lazy-with-preload": "^2.2.1",
|
|
64
64
|
"react-router-dom": "^6.29.0",
|
|
65
|
-
"react-syntax-highlighter": "^15.6.1",
|
|
66
65
|
"rehype-external-links": "^3.0.0",
|
|
67
66
|
"remark": "^15.0.1",
|
|
68
67
|
"remark-gfm": "^4.0.1",
|
|
69
|
-
"rspack-plugin-virtual-module": "0.
|
|
68
|
+
"rspack-plugin-virtual-module": "1.0.0",
|
|
70
69
|
"tinyglobby": "^0.2.13",
|
|
71
70
|
"unified": "^11.0.5",
|
|
72
71
|
"unist-util-visit": "^5.0.0",
|
|
73
72
|
"unist-util-visit-children": "^3.0.0",
|
|
74
|
-
"@rspress/plugin-
|
|
75
|
-
"@rspress/plugin-
|
|
76
|
-
"@rspress/plugin-
|
|
77
|
-
"@rspress/
|
|
78
|
-
"@rspress/
|
|
79
|
-
"@rspress/theme-default": "2.0.0-beta.
|
|
80
|
-
"@rspress/
|
|
73
|
+
"@rspress/plugin-auto-nav-sidebar": "2.0.0-beta.6",
|
|
74
|
+
"@rspress/plugin-container-syntax": "2.0.0-beta.6",
|
|
75
|
+
"@rspress/plugin-last-updated": "2.0.0-beta.6",
|
|
76
|
+
"@rspress/plugin-shiki": "2.0.0-beta.6",
|
|
77
|
+
"@rspress/plugin-medium-zoom": "2.0.0-beta.6",
|
|
78
|
+
"@rspress/theme-default": "2.0.0-beta.6",
|
|
79
|
+
"@rspress/shared": "2.0.0-beta.6",
|
|
80
|
+
"@rspress/runtime": "2.0.0-beta.6"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@microsoft/api-extractor": "^7.52.7",
|
|
84
|
-
"@rslib/core": "0.6.
|
|
84
|
+
"@rslib/core": "0.6.9",
|
|
85
85
|
"@rspress-dev/plugin-preview": "link:../plugin-preview",
|
|
86
86
|
"@types/hast": "^3.0.4",
|
|
87
87
|
"@types/html-to-text": "^9.0.4",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"remark-rehype": "^11.1.2",
|
|
100
100
|
"remark-stringify": "^11.0.0",
|
|
101
101
|
"rimraf": "^6.0.1",
|
|
102
|
-
"rsbuild-plugin-publint": "^0.3.
|
|
102
|
+
"rsbuild-plugin-publint": "^0.3.2",
|
|
103
103
|
"rsbuild-plugin-virtual-module": "0.1.1",
|
|
104
104
|
"tailwindcss": "^3.4.17",
|
|
105
105
|
"typescript": "^5.8.2",
|