@rspress/core 2.0.0-beta.32 → 2.0.0-beta.34
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/{101.js → 4~101.js} +16 -16
- package/dist/cli.js +3 -4
- package/dist/index.d.ts +1615 -5
- package/dist/index.js +127 -103
- package/dist/processor.js +10 -6
- package/dist/renderPageWorker.js +1 -1
- package/package.json +11 -12
- /package/dist/{335.js → 4~335.js} +0 -0
- /package/dist/{395.js → 4~395.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -17,11 +17,10 @@ import { chunk, groupBy } from "lodash-es";
|
|
|
17
17
|
import { compile } from "@rspress/mdx-rs";
|
|
18
18
|
import { htmlToText } from "html-to-text";
|
|
19
19
|
import { createProcessor } from "@mdx-js/mdx";
|
|
20
|
-
import
|
|
20
|
+
import { mergeRsbuildConfig as core_mergeRsbuildConfig, rspack as core_rspack } from "@rsbuild/core";
|
|
21
21
|
import { createHash } from "node:crypto";
|
|
22
22
|
import { createHead, transformHtmlTemplate } from "@unhead/react/server";
|
|
23
23
|
import { visit } from "unist-util-visit";
|
|
24
|
-
import { mergeRsbuildConfig as core_mergeRsbuildConfig } from "@rsbuild/core";
|
|
25
24
|
var __webpack_modules__ = {
|
|
26
25
|
"@rspress/shared": function(module) {
|
|
27
26
|
module.exports = __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__;
|
|
@@ -66,7 +65,7 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
66
65
|
}, []));
|
|
67
66
|
})();
|
|
68
67
|
(()=>{
|
|
69
|
-
__webpack_require__.u = (chunkId)=>"" + chunkId + ".js";
|
|
68
|
+
__webpack_require__.u = (chunkId)=>"4~" + chunkId + ".js";
|
|
70
69
|
})();
|
|
71
70
|
(()=>{
|
|
72
71
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
@@ -212,7 +211,7 @@ function normalizePath(id) {
|
|
|
212
211
|
return external_node_path_["default"].posix.normalize(isWindows ? slash(id) : id);
|
|
213
212
|
}
|
|
214
213
|
var external_node_url_ = __webpack_require__("node:url");
|
|
215
|
-
var package_namespaceObject = JSON.parse('{"rE":"2.0.0-beta.
|
|
214
|
+
var package_namespaceObject = JSON.parse('{"rE":"2.0.0-beta.34"}');
|
|
216
215
|
const RSPRESS_VERSION = package_namespaceObject.rE;
|
|
217
216
|
const isProduction = ()=>'production' === process.env.NODE_ENV;
|
|
218
217
|
const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
|
|
@@ -518,16 +517,51 @@ async function utils_readJson(path) {
|
|
|
518
517
|
return JSON.parse(raw);
|
|
519
518
|
}
|
|
520
519
|
async function extractInfoFromFrontmatterWithAbsolutePath(absolutePath, rootDir) {
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
520
|
+
const fileHandle = await node_fs_promises.open(absolutePath, 'r');
|
|
521
|
+
try {
|
|
522
|
+
const buffer = Buffer.alloc(1024);
|
|
523
|
+
let content = '';
|
|
524
|
+
let bytesRead = 0;
|
|
525
|
+
let hasFrontmatter = false;
|
|
526
|
+
let frontmatterEnd = -1;
|
|
527
|
+
let h1Match = null;
|
|
528
|
+
let frontmatter = {};
|
|
529
|
+
do {
|
|
530
|
+
const result = await fileHandle.read(buffer, 0, buffer.length, bytesRead);
|
|
531
|
+
if (0 === result.bytesRead) break;
|
|
532
|
+
content += buffer.subarray(0, result.bytesRead).toString('utf-8');
|
|
533
|
+
bytesRead += result.bytesRead;
|
|
534
|
+
if (bytesRead <= buffer.length) if (content.startsWith('---')) {
|
|
535
|
+
hasFrontmatter = true;
|
|
536
|
+
const secondDelimiter = content.indexOf('\n---\n', 4);
|
|
537
|
+
if (-1 !== secondDelimiter) {
|
|
538
|
+
frontmatterEnd = secondDelimiter + 5;
|
|
539
|
+
const { frontmatter: fm } = loadFrontMatter(content.slice(0, frontmatterEnd + 100), absolutePath, rootDir);
|
|
540
|
+
frontmatter = fm;
|
|
541
|
+
}
|
|
542
|
+
} else hasFrontmatter = false;
|
|
543
|
+
if (!h1Match) {
|
|
544
|
+
const searchStart = hasFrontmatter && frontmatterEnd > -1 ? frontmatterEnd : 0;
|
|
545
|
+
const h1RegExp = /^#\s+(.*)$/m;
|
|
546
|
+
h1Match = content.slice(searchStart).match(h1RegExp);
|
|
547
|
+
}
|
|
548
|
+
if (hasFrontmatter && frontmatterEnd > -1 && h1Match) break;
|
|
549
|
+
if (!hasFrontmatter && h1Match) break;
|
|
550
|
+
if (hasFrontmatter && frontmatterEnd > -1 && bytesRead > 16384) break;
|
|
551
|
+
}while (bytesRead < 65536);
|
|
552
|
+
if (hasFrontmatter && -1 === frontmatterEnd) {
|
|
553
|
+
const { frontmatter: fm } = loadFrontMatter(content, absolutePath, rootDir);
|
|
554
|
+
frontmatter = fm;
|
|
555
|
+
}
|
|
556
|
+
const fileNameWithoutExt = external_node_path_["default"].basename(absolutePath, external_node_path_["default"].extname(absolutePath));
|
|
557
|
+
return {
|
|
558
|
+
title: extractTextAndId(frontmatter.title || h1Match?.[1] || fileNameWithoutExt)[0],
|
|
559
|
+
overviewHeaders: frontmatter.overviewHeaders,
|
|
560
|
+
context: frontmatter.context
|
|
561
|
+
};
|
|
562
|
+
} finally{
|
|
563
|
+
await fileHandle.close();
|
|
564
|
+
}
|
|
531
565
|
}
|
|
532
566
|
function getHmrFileKey(realPath, docsDir) {
|
|
533
567
|
return realPath ? (0, shared_.slash)((0, external_node_path_.relative)(docsDir, realPath).replace((0, external_node_path_.extname)(realPath), '')) : '';
|
|
@@ -559,10 +593,10 @@ async function fsDirToMetaItems(workDir, extensions) {
|
|
|
559
593
|
}))).filter(Boolean);
|
|
560
594
|
return sideMeta;
|
|
561
595
|
}
|
|
562
|
-
async function metaItemToSidebarItem(metaItem, workDir, docsDir, extensions, metaFileSet, isFirstDir = false) {
|
|
563
|
-
if ('string' == typeof metaItem) return metaFileItemToSidebarItem(metaItem, workDir, docsDir, extensions);
|
|
596
|
+
async function metaItemToSidebarItem(metaItem, workDir, docsDir, extensions, metaFileSet, mdFileSet, isFirstDir = false) {
|
|
597
|
+
if ('string' == typeof metaItem) return metaFileItemToSidebarItem(metaItem, workDir, docsDir, extensions, mdFileSet);
|
|
564
598
|
const { type } = metaItem;
|
|
565
|
-
if ('file' === type) return metaFileItemToSidebarItem(metaItem, workDir, docsDir, extensions);
|
|
599
|
+
if ('file' === type) return metaFileItemToSidebarItem(metaItem, workDir, docsDir, extensions, mdFileSet);
|
|
566
600
|
if ('dir' === type) {
|
|
567
601
|
const { name, label, collapsible, collapsed, tag: metaJsonTag, context: metaJsonContext, overviewHeaders: metaJsonOverviewHeaders } = metaItem;
|
|
568
602
|
const dirAbsolutePath = (0, external_node_path_.join)(workDir, name);
|
|
@@ -582,11 +616,11 @@ async function metaItemToSidebarItem(metaItem, workDir, docsDir, extensions, met
|
|
|
582
616
|
name = i;
|
|
583
617
|
}
|
|
584
618
|
return 'index.md' !== name && 'index.mdx' !== i && 'index' !== i;
|
|
585
|
-
}) : dirMetaJson).map((item)=>metaItemToSidebarItem(item, dirAbsolutePath, docsDir, extensions, metaFileSet)));
|
|
619
|
+
}) : dirMetaJson).map((item)=>metaItemToSidebarItem(item, dirAbsolutePath, docsDir, extensions, metaFileSet, mdFileSet)));
|
|
586
620
|
return items;
|
|
587
621
|
}
|
|
588
622
|
try {
|
|
589
|
-
const sameNameFile = await metaFileItemToSidebarItem(name, workDir, docsDir, extensions);
|
|
623
|
+
const sameNameFile = await metaFileItemToSidebarItem(name, workDir, docsDir, extensions, mdFileSet);
|
|
590
624
|
const { link, text, _fileKey, context, overviewHeaders, tag } = sameNameFile;
|
|
591
625
|
return {
|
|
592
626
|
text: label || text || name,
|
|
@@ -618,7 +652,7 @@ async function metaItemToSidebarItem(metaItem, workDir, docsDir, extensions, met
|
|
|
618
652
|
_fileKey: getHmrFileKey(dirAbsolutePath, docsDir)
|
|
619
653
|
};
|
|
620
654
|
{
|
|
621
|
-
const indexFile = await metaFileItemToSidebarItem('index', dirAbsolutePath, docsDir, extensions);
|
|
655
|
+
const indexFile = await metaFileItemToSidebarItem('index', dirAbsolutePath, docsDir, extensions, mdFileSet);
|
|
622
656
|
const { link, text, _fileKey, context, overviewHeaders, tag } = indexFile;
|
|
623
657
|
return {
|
|
624
658
|
text: label || text || name,
|
|
@@ -647,7 +681,7 @@ async function detectFilePath(absolutePath, extensions) {
|
|
|
647
681
|
}
|
|
648
682
|
throw new Error(`The file extension "${ext}" is not supported, please use one of the following extensions: ${extensions.join(', ')}`);
|
|
649
683
|
}
|
|
650
|
-
async function metaFileItemToSidebarItem(metaItemRaw, workDir, docsDir, extensions) {
|
|
684
|
+
async function metaFileItemToSidebarItem(metaItemRaw, workDir, docsDir, extensions, mdFileSet) {
|
|
651
685
|
let metaItem = null;
|
|
652
686
|
metaItem = 'string' == typeof metaItemRaw ? {
|
|
653
687
|
name: metaItemRaw,
|
|
@@ -665,6 +699,7 @@ async function metaFileItemToSidebarItem(metaItemRaw, workDir, docsDir, extensio
|
|
|
665
699
|
const link = absolutePathToRoutePath(absolutePathWithExt, docsDir);
|
|
666
700
|
const info = await extractInfoFromFrontmatterWithAbsolutePath(absolutePathWithExt, docsDir);
|
|
667
701
|
const title = label || info.title;
|
|
702
|
+
mdFileSet.add(absolutePathWithExt);
|
|
668
703
|
return {
|
|
669
704
|
text: title,
|
|
670
705
|
link,
|
|
@@ -722,11 +757,11 @@ function metaDividerToSidebarItem(metaItem) {
|
|
|
722
757
|
tag
|
|
723
758
|
};
|
|
724
759
|
}
|
|
725
|
-
async function scanSideMeta(workDir, docsDir, extensions, metaFileSet) {
|
|
760
|
+
async function scanSideMeta(workDir, docsDir, extensions, metaFileSet, mdFileSet) {
|
|
726
761
|
const dir = await metaItemToSidebarItem({
|
|
727
762
|
type: 'dir',
|
|
728
763
|
name: ''
|
|
729
|
-
}, workDir, docsDir, extensions, metaFileSet, true);
|
|
764
|
+
}, workDir, docsDir, extensions, metaFileSet, mdFileSet, true);
|
|
730
765
|
return dir.items;
|
|
731
766
|
}
|
|
732
767
|
async function scanNav(workDir, docsDir, metaFileSet) {
|
|
@@ -747,7 +782,7 @@ async function scanNav(workDir, docsDir, metaFileSet) {
|
|
|
747
782
|
});
|
|
748
783
|
return navConfig;
|
|
749
784
|
}
|
|
750
|
-
async function walk(workDir, docsDir, extensions, metaFileSet) {
|
|
785
|
+
async function walk(workDir, docsDir, extensions, metaFileSet, mdFileSet) {
|
|
751
786
|
const rootNavJson = external_node_path_["default"].resolve(workDir, '_nav.json');
|
|
752
787
|
const rootMetaJson = external_node_path_["default"].resolve(workDir, '_meta.json');
|
|
753
788
|
const isRootNavJsonExist = await pathExists(rootNavJson);
|
|
@@ -761,7 +796,7 @@ async function walk(workDir, docsDir, extensions, metaFileSet) {
|
|
|
761
796
|
return {
|
|
762
797
|
nav: navConfig,
|
|
763
798
|
sidebar: {
|
|
764
|
-
'/': await scanSideMeta(workDir, docsDir, extensions, metaFileSet)
|
|
799
|
+
'/': await scanSideMeta(workDir, docsDir, extensions, metaFileSet, mdFileSet)
|
|
765
800
|
}
|
|
766
801
|
};
|
|
767
802
|
}
|
|
@@ -774,7 +809,7 @@ async function walk(workDir, docsDir, extensions, metaFileSet) {
|
|
|
774
809
|
const sidebarConfig = {};
|
|
775
810
|
await Promise.all(subDirs.map(async (subDir)=>{
|
|
776
811
|
const sidebarGroupKey = addRoutePrefix(workDir, docsDir, subDir);
|
|
777
|
-
sidebarConfig[sidebarGroupKey] = await scanSideMeta(external_node_path_["default"].join(workDir, subDir), docsDir, extensions, metaFileSet);
|
|
812
|
+
sidebarConfig[sidebarGroupKey] = await scanSideMeta(external_node_path_["default"].join(workDir, subDir), docsDir, extensions, metaFileSet, mdFileSet);
|
|
778
813
|
}));
|
|
779
814
|
return {
|
|
780
815
|
nav: navConfig,
|
|
@@ -784,7 +819,7 @@ async function walk(workDir, docsDir, extensions, metaFileSet) {
|
|
|
784
819
|
return {
|
|
785
820
|
nav: [],
|
|
786
821
|
sidebar: {
|
|
787
|
-
'/': await scanSideMeta(workDir, docsDir, extensions, metaFileSet)
|
|
822
|
+
'/': await scanSideMeta(workDir, docsDir, extensions, metaFileSet, mdFileSet)
|
|
788
823
|
}
|
|
789
824
|
};
|
|
790
825
|
}
|
|
@@ -803,15 +838,15 @@ function combineWalkResult(walks, versions) {
|
|
|
803
838
|
sidebar: {}
|
|
804
839
|
});
|
|
805
840
|
}
|
|
806
|
-
function processLocales(langs, versions, root, extensions, metaFileSet) {
|
|
841
|
+
function processLocales(langs, versions, root, extensions, metaFileSet, mdFileSet) {
|
|
807
842
|
return Promise.all(langs.map(async (lang)=>{
|
|
808
|
-
const walks = versions.length ? await Promise.all(versions.map((version)=>walk(external_node_path_["default"].join(root, version, lang), root, extensions, metaFileSet))) : [
|
|
809
|
-
await walk(external_node_path_["default"].join(root, lang), root, extensions, metaFileSet)
|
|
843
|
+
const walks = versions.length ? await Promise.all(versions.map((version)=>walk(external_node_path_["default"].join(root, version, lang), root, extensions, metaFileSet, mdFileSet))) : [
|
|
844
|
+
await walk(external_node_path_["default"].join(root, lang), root, extensions, metaFileSet, mdFileSet)
|
|
810
845
|
];
|
|
811
846
|
return combineWalkResult(walks, versions);
|
|
812
847
|
}));
|
|
813
848
|
}
|
|
814
|
-
async function runAutoNavSide(config, metaFileSet) {
|
|
849
|
+
async function runAutoNavSide(config, metaFileSet, mdFileSet) {
|
|
815
850
|
config.themeConfig = config.themeConfig || {};
|
|
816
851
|
config.themeConfig.locales = config.themeConfig.locales || config.locales || [];
|
|
817
852
|
const langs = config.themeConfig.locales.map((locale)=>locale.lang);
|
|
@@ -819,11 +854,11 @@ async function runAutoNavSide(config, metaFileSet) {
|
|
|
819
854
|
const versions = config.multiVersion?.versions || [];
|
|
820
855
|
const { extensions = DEFAULT_PAGE_EXTENSIONS } = config?.route || {};
|
|
821
856
|
if (hasLocales) {
|
|
822
|
-
const metaInfo = await processLocales(langs, versions, config.root, extensions, metaFileSet);
|
|
857
|
+
const metaInfo = await processLocales(langs, versions, config.root, extensions, metaFileSet, mdFileSet);
|
|
823
858
|
return metaInfo;
|
|
824
859
|
}
|
|
825
|
-
const walks = versions.length ? await Promise.all(versions.map((version)=>walk(external_node_path_["default"].join(config.root, version), config.root, extensions, metaFileSet))) : [
|
|
826
|
-
await walk(config.root, config.root, extensions, metaFileSet)
|
|
860
|
+
const walks = versions.length ? await Promise.all(versions.map((version)=>walk(external_node_path_["default"].join(config.root, version), config.root, extensions, metaFileSet, mdFileSet))) : [
|
|
861
|
+
await walk(config.root, config.root, extensions, metaFileSet, mdFileSet)
|
|
827
862
|
];
|
|
828
863
|
const combined = combineWalkResult(walks, versions);
|
|
829
864
|
return combined;
|
|
@@ -833,9 +868,9 @@ function auto_nav_sidebar_haveNavSidebarConfig(config) {
|
|
|
833
868
|
const haveNavSidebarConfig = themeConfig.nav || themeConfig.sidebar || themeConfig.locales?.[0]?.nav || themeConfig.locales?.[0]?.sidebar;
|
|
834
869
|
return Boolean(haveNavSidebarConfig);
|
|
835
870
|
}
|
|
836
|
-
async function modifyConfigWithAutoNavSide(config, metaFileSet = new Set(), force = false) {
|
|
871
|
+
async function modifyConfigWithAutoNavSide(config, metaFileSet = new Set(), mdFileSet = new Set(), force = false) {
|
|
837
872
|
if (auto_nav_sidebar_haveNavSidebarConfig(config) && !force) return;
|
|
838
|
-
const autoNavSide = await runAutoNavSide(config, metaFileSet);
|
|
873
|
+
const autoNavSide = await runAutoNavSide(config, metaFileSet, mdFileSet);
|
|
839
874
|
if (null === autoNavSide) return;
|
|
840
875
|
if (Array.isArray(autoNavSide)) {
|
|
841
876
|
config.themeConfig = config.themeConfig || {};
|
|
@@ -855,7 +890,7 @@ const pluginVirtualModule = (pluginOptions = {})=>({
|
|
|
855
890
|
name: PLUGIN_VIRTUAL_MODULE_NAME,
|
|
856
891
|
async setup (api) {
|
|
857
892
|
const { virtualModules = {}, tempDir: virtualFolderName = '.rsbuild-virtual-module' } = pluginOptions;
|
|
858
|
-
const TEMP_DIR = (0, external_node_path_.join)(api.context.rootPath,
|
|
893
|
+
const TEMP_DIR = (0, external_node_path_.join)(api.context.rootPath, virtualFolderName);
|
|
859
894
|
const virtualFileAbsolutePaths = Object.keys(virtualModules).map((i)=>{
|
|
860
895
|
let absolutePath = (0, external_node_path_.join)(TEMP_DIR, i);
|
|
861
896
|
if (!(0, external_node_path_.extname)(absolutePath)) absolutePath = `${absolutePath}.js`;
|
|
@@ -864,23 +899,26 @@ const pluginVirtualModule = (pluginOptions = {})=>({
|
|
|
864
899
|
absolutePath
|
|
865
900
|
];
|
|
866
901
|
});
|
|
867
|
-
api.
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
902
|
+
api.modifyBundlerChain((chain, { rspack })=>{
|
|
903
|
+
const pluginId = 'RSBUILD_VIRTUAL_MODULE_PLUGIN';
|
|
904
|
+
const virtualModules = Object.fromEntries(virtualFileAbsolutePaths.map((i)=>[
|
|
905
|
+
i[1],
|
|
906
|
+
''
|
|
907
|
+
]));
|
|
908
|
+
if (chain.plugins.has(pluginId)) chain.plugin(pluginId).tap((options)=>{
|
|
909
|
+
const existingPaths = new Set(Object.keys(options[0] ?? {}));
|
|
910
|
+
const conflictPath = virtualFileAbsolutePaths.find(([, path])=>existingPaths.has(path));
|
|
911
|
+
if (conflictPath) throw new Error(`Virtual module name conflicted: ${conflictPath[0]}`);
|
|
912
|
+
return [
|
|
913
|
+
{
|
|
914
|
+
...options[0],
|
|
915
|
+
...virtualModules
|
|
916
|
+
}
|
|
917
|
+
];
|
|
918
|
+
});
|
|
919
|
+
else chain.plugin(pluginId).use(rspack.experiments.VirtualModulesPlugin, [
|
|
920
|
+
virtualModules
|
|
921
|
+
]);
|
|
884
922
|
chain.resolve.alias.merge(Object.fromEntries(virtualFileAbsolutePaths));
|
|
885
923
|
});
|
|
886
924
|
for (const [moduleName, absolutePath] of virtualFileAbsolutePaths){
|
|
@@ -953,30 +991,21 @@ const i18nVMPlugin = (context)=>{
|
|
|
953
991
|
};
|
|
954
992
|
};
|
|
955
993
|
var external_node_fs_ = __webpack_require__("node:fs");
|
|
956
|
-
|
|
994
|
+
const RspackResolveFactory = core_rspack.experiments.resolver.ResolverFactory;
|
|
957
995
|
let startFlatten = false;
|
|
996
|
+
let flattenMdxContent_resolver;
|
|
958
997
|
const processor = createProcessor();
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
async function resolveDepPath(importPath, importer, alias) {
|
|
962
|
-
if (!flattenMdxContent_resolver) flattenMdxContent_resolver = ResolverFactory.createResolver({
|
|
963
|
-
fileSystem: new CachedInputFileSystem(fileSystem, 0),
|
|
998
|
+
async function resolveDepPath(moduleSpecifier, importer, alias) {
|
|
999
|
+
if (!flattenMdxContent_resolver) flattenMdxContent_resolver = new RspackResolveFactory({
|
|
964
1000
|
extensions: [
|
|
965
1001
|
'.mdx',
|
|
966
1002
|
'.md'
|
|
967
1003
|
],
|
|
968
1004
|
alias
|
|
969
1005
|
});
|
|
970
|
-
const
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
}, importer, importPath, {}, (err, filePath)=>{
|
|
974
|
-
if (err) return reject(err);
|
|
975
|
-
if (!filePath) return reject(new Error(`Empty result when resolving ${importPath} from ${importer}`));
|
|
976
|
-
return resolve(filePath);
|
|
977
|
-
});
|
|
978
|
-
});
|
|
979
|
-
return resolveResult;
|
|
1006
|
+
const resolved = await flattenMdxContent_resolver.async(importer, moduleSpecifier);
|
|
1007
|
+
if (resolved.path) return resolved.path;
|
|
1008
|
+
throw new Error(`Empty result when resolving ${moduleSpecifier} from ${importer}`);
|
|
980
1009
|
}
|
|
981
1010
|
async function flattenMdxContent(content, basePath, alias) {
|
|
982
1011
|
const deps = [];
|
|
@@ -986,8 +1015,7 @@ async function flattenMdxContent(content, basePath, alias) {
|
|
|
986
1015
|
deps
|
|
987
1016
|
};
|
|
988
1017
|
if (!startFlatten) {
|
|
989
|
-
flattenMdxContent_resolver =
|
|
990
|
-
fileSystem: new CachedInputFileSystem(fileSystem, 0),
|
|
1018
|
+
flattenMdxContent_resolver = new RspackResolveFactory({
|
|
991
1019
|
extensions: [
|
|
992
1020
|
'.mdx',
|
|
993
1021
|
'.md',
|
|
@@ -1393,10 +1421,14 @@ const siteDataVMPlugin = (context)=>{
|
|
|
1393
1421
|
["virtual-site-data"]: async ({ addDependency })=>{
|
|
1394
1422
|
const force = !pluginDriver.haveNavSidebarConfig;
|
|
1395
1423
|
const metaFileSet = new Set();
|
|
1424
|
+
const mdFileSet = new Set();
|
|
1425
|
+
const now = performance.now();
|
|
1396
1426
|
try {
|
|
1397
|
-
await modifyConfigWithAutoNavSide(config, metaFileSet, force);
|
|
1427
|
+
await modifyConfigWithAutoNavSide(config, metaFileSet, mdFileSet, force);
|
|
1398
1428
|
} finally{
|
|
1399
|
-
|
|
1429
|
+
for (const metaFile of metaFileSet)addDependency(metaFile);
|
|
1430
|
+
for (const mdFile of mdFileSet)addDependency(mdFile);
|
|
1431
|
+
logger.debug(`modifyConfigWithAutoNavSide - size: ${mdFileSet.size} cost: ${performance.now() - now}ms`);
|
|
1400
1432
|
}
|
|
1401
1433
|
const { siteData } = await createSiteData(config);
|
|
1402
1434
|
return `export default ${JSON.stringify(siteData, null, 2)}`;
|
|
@@ -1806,7 +1838,7 @@ const rsbuildPluginSSG = ({ routeService, config })=>({
|
|
|
1806
1838
|
});
|
|
1807
1839
|
}
|
|
1808
1840
|
});
|
|
1809
|
-
const
|
|
1841
|
+
const Resolver = core_rspack.experiments.resolver.ResolverFactory;
|
|
1810
1842
|
async function detectPackageMajorVersion(name) {
|
|
1811
1843
|
const cwd = process.cwd();
|
|
1812
1844
|
const pkgPath = external_node_path_["default"].join(cwd, 'node_modules', name);
|
|
@@ -1822,8 +1854,7 @@ async function detectReactVersion() {
|
|
|
1822
1854
|
}
|
|
1823
1855
|
async function resolveReactRouterDomAlias() {
|
|
1824
1856
|
const alias = {};
|
|
1825
|
-
const resolver =
|
|
1826
|
-
fileSystem: new detectReactVersion_CachedInputFileSystem(external_node_fs_["default"], 0),
|
|
1857
|
+
const resolver = new Resolver({
|
|
1827
1858
|
mainFields: [
|
|
1828
1859
|
'browser',
|
|
1829
1860
|
'module',
|
|
@@ -1835,16 +1866,11 @@ async function resolveReactRouterDomAlias() {
|
|
|
1835
1866
|
alias
|
|
1836
1867
|
});
|
|
1837
1868
|
try {
|
|
1838
|
-
const
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
}, PACKAGE_ROOT, 'react-router-dom', {}, (err, filePath)=>{
|
|
1842
|
-
if (err || !filePath) return reject(err);
|
|
1843
|
-
return resolve(filePath);
|
|
1844
|
-
});
|
|
1845
|
-
});
|
|
1869
|
+
const resolved = await resolver.async(PACKAGE_ROOT, 'react-router-dom');
|
|
1870
|
+
if (resolved.error) throw Error(resolved.error);
|
|
1871
|
+
if (!resolved.path) throw Error("'react-router-dom' resolved to empty path");
|
|
1846
1872
|
return {
|
|
1847
|
-
'react-router-dom':
|
|
1873
|
+
'react-router-dom': resolved.path
|
|
1848
1874
|
};
|
|
1849
1875
|
} catch (e) {
|
|
1850
1876
|
logger.warn('react-router-dom not found: \n', e);
|
|
@@ -1862,8 +1888,7 @@ async function resolveReactAlias(reactVersion, isSSR) {
|
|
|
1862
1888
|
'react-dom/server'
|
|
1863
1889
|
];
|
|
1864
1890
|
const alias = {};
|
|
1865
|
-
const resolver =
|
|
1866
|
-
fileSystem: new detectReactVersion_CachedInputFileSystem(external_node_fs_["default"], 0),
|
|
1891
|
+
const resolver = new Resolver({
|
|
1867
1892
|
extensions: [
|
|
1868
1893
|
'.js'
|
|
1869
1894
|
],
|
|
@@ -1877,14 +1902,9 @@ async function resolveReactAlias(reactVersion, isSSR) {
|
|
|
1877
1902
|
});
|
|
1878
1903
|
await Promise.all(libPaths.map(async (lib)=>{
|
|
1879
1904
|
try {
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
}, basedir, lib, {}, (err, filePath)=>{
|
|
1884
|
-
if (err || !filePath) return reject(err);
|
|
1885
|
-
return resolve(filePath);
|
|
1886
|
-
});
|
|
1887
|
-
});
|
|
1905
|
+
const resolved = await resolver.async(basedir, lib);
|
|
1906
|
+
if (resolved.error || !resolved.path) throw Error(resolved.error);
|
|
1907
|
+
alias[lib] = resolved.path;
|
|
1888
1908
|
} catch (e) {
|
|
1889
1909
|
if (e instanceof Error) {
|
|
1890
1910
|
logger.warn(`${lib} not found: \n ${picocolors.gray(e.toString())}`);
|
|
@@ -2484,7 +2504,7 @@ Please use below:
|
|
|
2484
2504
|
});
|
|
2485
2505
|
await Promise.all(promiseList);
|
|
2486
2506
|
};
|
|
2487
|
-
function link_checkDeadLinks(checkDeadLinks, internalLinks,
|
|
2507
|
+
function link_checkDeadLinks(checkDeadLinks, internalLinks, file, lint) {
|
|
2488
2508
|
const errorInfos = [];
|
|
2489
2509
|
const excludes = 'object' == typeof checkDeadLinks ? checkDeadLinks.excludes : void 0;
|
|
2490
2510
|
const excludesUrl = Array.isArray(excludes) ? new Set(excludes) : void 0;
|
|
@@ -2503,9 +2523,13 @@ function link_checkDeadLinks(checkDeadLinks, internalLinks, filePath) {
|
|
|
2503
2523
|
});
|
|
2504
2524
|
if (errorInfos.length > 0) {
|
|
2505
2525
|
if (possibleBreakingChange) hintRelativeMarkdownLink();
|
|
2506
|
-
|
|
2507
|
-
${errorInfos.map(([nodeUrl, link])=>` ${picocolors.green(`"[..](${nodeUrl})"`)} ${picocolors.gray(link)}`).join('\n')}
|
|
2508
|
-
if (
|
|
2526
|
+
const message = `Dead links found${lint ? '' : ` in ${picocolors.cyan(file.path)}`}:
|
|
2527
|
+
${errorInfos.map(([nodeUrl, link])=>` ${picocolors.green(`"[..](${nodeUrl})"`)} ${picocolors.gray(link)}`).join('\n')}`;
|
|
2528
|
+
if (lint) file.message(message);
|
|
2529
|
+
else {
|
|
2530
|
+
logger.error(message);
|
|
2531
|
+
if ((0, shared_.isProduction)()) throw new Error('Dead link found');
|
|
2532
|
+
}
|
|
2509
2533
|
}
|
|
2510
2534
|
}
|
|
2511
2535
|
function looseMarkdownLink(url, routeService, filePath) {
|
|
@@ -2552,7 +2576,7 @@ function normalizeLink(nodeUrl, routeService, filePath, cleanUrls, autoPrefix, d
|
|
|
2552
2576
|
if (__base) url = (0, shared_.withBase)(url, __base);
|
|
2553
2577
|
return url;
|
|
2554
2578
|
}
|
|
2555
|
-
const remarkLink = ({ cleanUrls, routeService, remarkLinkOptions, __base })=>(tree, file)=>{
|
|
2579
|
+
const remarkLink = ({ cleanUrls, routeService, remarkLinkOptions, lint, __base })=>(tree, file)=>{
|
|
2556
2580
|
const { checkDeadLinks: shouldCheckDeadLinks = true, autoPrefix = true } = remarkLinkOptions ?? {};
|
|
2557
2581
|
const deadLinks = new Map();
|
|
2558
2582
|
visit(tree, 'link', (node)=>{
|
|
@@ -2565,7 +2589,7 @@ const remarkLink = ({ cleanUrls, routeService, remarkLinkOptions, __base })=>(tr
|
|
|
2565
2589
|
const link = normalizeLink(nodeUrl, routeService, file.path, cleanUrls, autoPrefix, deadLinks, __base);
|
|
2566
2590
|
node.url = link;
|
|
2567
2591
|
});
|
|
2568
|
-
if (shouldCheckDeadLinks && routeService) link_checkDeadLinks(shouldCheckDeadLinks, deadLinks, file
|
|
2592
|
+
if (shouldCheckDeadLinks && routeService) link_checkDeadLinks(shouldCheckDeadLinks, deadLinks, file, lint);
|
|
2569
2593
|
};
|
|
2570
2594
|
async function serve(options) {
|
|
2571
2595
|
const { config, port: userPort, host: userHost, configFilePath } = options;
|
|
@@ -2591,4 +2615,4 @@ var __webpack_exports__normalizeHref = shared_.normalizeHref;
|
|
|
2591
2615
|
var __webpack_exports__normalizePosixPath = shared_.normalizePosixPath;
|
|
2592
2616
|
var __webpack_exports__removeTrailingSlash = shared_.removeTrailingSlash;
|
|
2593
2617
|
var __webpack_exports__withBase = shared_.withBase;
|
|
2594
|
-
export { build, defineConfig, dev, getIconUrlPath, getNodeAttribute, logger, matchPath, mergeDocConfig, remarkFileCodeBlock, remarkLink, serve, __webpack_exports__RSPRESS_TEMP_DIR as RSPRESS_TEMP_DIR, __webpack_exports__getSidebarDataGroup as getSidebarDataGroup, __webpack_exports__normalizeHref as normalizeHref, __webpack_exports__normalizePosixPath as normalizePosixPath, __webpack_exports__removeTrailingSlash as removeTrailingSlash, __webpack_exports__withBase as withBase };
|
|
2618
|
+
export { PluginDriver, RouteService, build, defineConfig, dev, getIconUrlPath, getNodeAttribute, logger, matchPath, mergeDocConfig, remarkFileCodeBlock, remarkLink, serve, __webpack_exports__RSPRESS_TEMP_DIR as RSPRESS_TEMP_DIR, __webpack_exports__getSidebarDataGroup as getSidebarDataGroup, __webpack_exports__normalizeHref as normalizeHref, __webpack_exports__normalizePosixPath as normalizePosixPath, __webpack_exports__removeTrailingSlash as removeTrailingSlash, __webpack_exports__withBase as withBase };
|
package/dist/processor.js
CHANGED
|
@@ -510,7 +510,7 @@ function hintRelativeMarkdownLink() {
|
|
|
510
510
|
isLogged = true;
|
|
511
511
|
logger_logger.info('[Rspress v2] Markdown links without "./" prefix are now relative links, e.g: [](guide/getting-started) is equal to [](./guide/getting-started). You can rewrite it to [](/guide/getting-started) to always use absolute links, or use [](./getting-started.md)');
|
|
512
512
|
}
|
|
513
|
-
function link_checkDeadLinks(checkDeadLinks, internalLinks,
|
|
513
|
+
function link_checkDeadLinks(checkDeadLinks, internalLinks, file, lint) {
|
|
514
514
|
const errorInfos = [];
|
|
515
515
|
const excludes = 'object' == typeof checkDeadLinks ? checkDeadLinks.excludes : void 0;
|
|
516
516
|
const excludesUrl = Array.isArray(excludes) ? new Set(excludes) : void 0;
|
|
@@ -529,9 +529,13 @@ function link_checkDeadLinks(checkDeadLinks, internalLinks, filePath) {
|
|
|
529
529
|
});
|
|
530
530
|
if (errorInfos.length > 0) {
|
|
531
531
|
if (possibleBreakingChange) hintRelativeMarkdownLink();
|
|
532
|
-
|
|
533
|
-
${errorInfos.map(([nodeUrl, link])=>` ${picocolors_0.green(`"[..](${nodeUrl})"`)} ${picocolors_0.gray(link)}`).join('\n')}
|
|
534
|
-
if (
|
|
532
|
+
const message = `Dead links found${lint ? '' : ` in ${picocolors_0.cyan(file.path)}`}:
|
|
533
|
+
${errorInfos.map(([nodeUrl, link])=>` ${picocolors_0.green(`"[..](${nodeUrl})"`)} ${picocolors_0.gray(link)}`).join('\n')}`;
|
|
534
|
+
if (lint) file.message(message);
|
|
535
|
+
else {
|
|
536
|
+
logger_logger.error(message);
|
|
537
|
+
if (isProduction()) throw new Error('Dead link found');
|
|
538
|
+
}
|
|
535
539
|
}
|
|
536
540
|
}
|
|
537
541
|
function looseMarkdownLink(url, routeService, filePath) {
|
|
@@ -578,7 +582,7 @@ function normalizeLink(nodeUrl, routeService, filePath, cleanUrls, autoPrefix, d
|
|
|
578
582
|
if (__base) url = withBase(url, __base);
|
|
579
583
|
return url;
|
|
580
584
|
}
|
|
581
|
-
const remarkLink = ({ cleanUrls, routeService, remarkLinkOptions, __base })=>(tree, file)=>{
|
|
585
|
+
const remarkLink = ({ cleanUrls, routeService, remarkLinkOptions, lint, __base })=>(tree, file)=>{
|
|
582
586
|
const { checkDeadLinks: shouldCheckDeadLinks = true, autoPrefix = true } = remarkLinkOptions ?? {};
|
|
583
587
|
const deadLinks = new Map();
|
|
584
588
|
visit(tree, 'link', (node)=>{
|
|
@@ -591,7 +595,7 @@ const remarkLink = ({ cleanUrls, routeService, remarkLinkOptions, __base })=>(tr
|
|
|
591
595
|
const link = normalizeLink(nodeUrl, routeService, file.path, cleanUrls, autoPrefix, deadLinks, __base);
|
|
592
596
|
node.url = link;
|
|
593
597
|
});
|
|
594
|
-
if (shouldCheckDeadLinks && routeService) link_checkDeadLinks(shouldCheckDeadLinks, deadLinks, file
|
|
598
|
+
if (shouldCheckDeadLinks && routeService) link_checkDeadLinks(shouldCheckDeadLinks, deadLinks, file, lint);
|
|
595
599
|
};
|
|
596
600
|
const parseToc = (tree)=>{
|
|
597
601
|
let title = '';
|
package/dist/renderPageWorker.js
CHANGED
|
@@ -102,7 +102,7 @@ function hintSSGFailed() {
|
|
|
102
102
|
1. Fix code to make it SSR-compatible.
|
|
103
103
|
2. Set \`ssg: false\` if the code in node_modules may be difficult to fix, but the SSG feature will be lost.`);
|
|
104
104
|
}
|
|
105
|
-
var package_namespaceObject = JSON.parse('{"rE":"2.0.0-beta.
|
|
105
|
+
var package_namespaceObject = JSON.parse('{"rE":"2.0.0-beta.34"}');
|
|
106
106
|
const RSPRESS_VERSION = package_namespaceObject.rE;
|
|
107
107
|
`{
|
|
108
108
|
const saved = localStorage.getItem('${APPEARANCE_KEY}')
|
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.34",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -53,15 +53,14 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@mdx-js/mdx": "^3.1.1",
|
|
55
55
|
"@mdx-js/react": "^3.1.1",
|
|
56
|
-
"@rsbuild/core": "~1.5.
|
|
56
|
+
"@rsbuild/core": "~1.5.12",
|
|
57
57
|
"@rsbuild/plugin-react": "~1.4.0",
|
|
58
58
|
"@rspress/mdx-rs": "0.6.6",
|
|
59
59
|
"@shikijs/rehype": "^3.12.2",
|
|
60
60
|
"@types/unist": "^3.0.3",
|
|
61
|
-
"@unhead/react": "^2.0.
|
|
61
|
+
"@unhead/react": "^2.0.17",
|
|
62
62
|
"cac": "^6.7.14",
|
|
63
63
|
"chokidar": "^3.6.0",
|
|
64
|
-
"enhanced-resolve": "5.18.3",
|
|
65
64
|
"github-slugger": "^2.0.0",
|
|
66
65
|
"hast-util-heading-rank": "^3.0.0",
|
|
67
66
|
"html-to-text": "^9.0.5",
|
|
@@ -82,24 +81,24 @@
|
|
|
82
81
|
"unified": "^11.0.5",
|
|
83
82
|
"unist-util-visit": "^5.0.0",
|
|
84
83
|
"unist-util-visit-children": "^3.0.0",
|
|
85
|
-
"@rspress/runtime": "2.0.0-beta.
|
|
86
|
-
"@rspress/
|
|
87
|
-
"@rspress/
|
|
84
|
+
"@rspress/runtime": "2.0.0-beta.34",
|
|
85
|
+
"@rspress/theme-default": "2.0.0-beta.34",
|
|
86
|
+
"@rspress/shared": "2.0.0-beta.34"
|
|
88
87
|
},
|
|
89
88
|
"devDependencies": {
|
|
90
|
-
"@microsoft/api-extractor": "^7.52.
|
|
91
|
-
"@rslib/core": "0.
|
|
89
|
+
"@microsoft/api-extractor": "^7.52.13",
|
|
90
|
+
"@rslib/core": "0.13.3",
|
|
92
91
|
"@types/hast": "^3.0.4",
|
|
93
92
|
"@types/html-to-text": "^9.0.4",
|
|
94
93
|
"@types/lodash-es": "^4.17.12",
|
|
95
94
|
"@types/mdast": "^4.0.4",
|
|
96
95
|
"@types/node": "^22.8.1",
|
|
97
|
-
"@types/react": "^19.1.
|
|
96
|
+
"@types/react": "^19.1.13",
|
|
98
97
|
"@types/react-dom": "^19.1.9",
|
|
99
98
|
"execa": "8.0.1",
|
|
100
99
|
"mdast-util-directive": "^3.1.0",
|
|
101
100
|
"mdast-util-mdx-expression": "^2.0.1",
|
|
102
|
-
"memfs": "^4.
|
|
101
|
+
"memfs": "^4.43.0",
|
|
103
102
|
"p-map": "^7.0.3",
|
|
104
103
|
"postcss": "8.5.6",
|
|
105
104
|
"rehype-stringify": "^10.0.1",
|
|
@@ -110,7 +109,7 @@
|
|
|
110
109
|
"remark-stringify": "^11.0.0",
|
|
111
110
|
"rimraf": "^6.0.1",
|
|
112
111
|
"rsbuild-plugin-publint": "^0.3.3",
|
|
113
|
-
"rsbuild-plugin-virtual-module": "0.
|
|
112
|
+
"rsbuild-plugin-virtual-module": "0.4.1",
|
|
114
113
|
"tailwindcss": "^3.4.17",
|
|
115
114
|
"ts-json-schema-generator": "^2.4.0",
|
|
116
115
|
"typescript": "^5.8.2",
|
|
File without changes
|
|
File without changes
|