@rspress/core 1.13.1 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +21 -31
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +2 -2
- package/dist/loader.js +42 -27
- package/dist/loader.js.map +1 -1
- package/dist/runtime/App.js +3 -1
- package/package.json +11 -19
- package/src/runtime/App.tsx +2 -0
package/dist/index.js
CHANGED
|
@@ -66,7 +66,7 @@ var require_package = __commonJS({
|
|
|
66
66
|
"package.json"(exports, module) {
|
|
67
67
|
module.exports = {
|
|
68
68
|
name: "@rspress/core",
|
|
69
|
-
version: "1.
|
|
69
|
+
version: "1.14.0",
|
|
70
70
|
description: "The Rspress Documentation Framework",
|
|
71
71
|
bugs: "https://github.com/web-infra-dev/rspress/issues",
|
|
72
72
|
repository: {
|
|
@@ -113,25 +113,20 @@ var require_package = __commonJS({
|
|
|
113
113
|
engines: {
|
|
114
114
|
node: ">=14.17.6"
|
|
115
115
|
},
|
|
116
|
-
eslintIgnore: [
|
|
117
|
-
"node_modules/",
|
|
118
|
-
"dist/"
|
|
119
|
-
],
|
|
120
116
|
dependencies: {
|
|
121
117
|
"@loadable/component": "5.15.2",
|
|
122
118
|
"@mdx-js/loader": "2.2.1",
|
|
123
119
|
"@mdx-js/mdx": "2.2.1",
|
|
124
120
|
"@mdx-js/react": "2.2.1",
|
|
125
121
|
"@modern-js/utils": "2.48.0",
|
|
126
|
-
"@rsbuild/core": "0.4.
|
|
127
|
-
"@rsbuild/plugin-react": "0.4.
|
|
128
|
-
"@rsbuild/plugin-svgr": "0.4.0",
|
|
122
|
+
"@rsbuild/core": "0.4.11",
|
|
123
|
+
"@rsbuild/plugin-react": "0.4.11",
|
|
129
124
|
"@rspress/theme-default": "workspace:*",
|
|
130
125
|
"@rspress/runtime": "workspace:*",
|
|
131
126
|
"@rspress/plugin-medium-zoom": "workspace:*",
|
|
132
127
|
"@rspress/plugin-last-updated": "workspace:*",
|
|
133
128
|
"@rspress/plugin-auto-nav-sidebar": "workspace:*",
|
|
134
|
-
"@rspress/mdx-rs": "0.
|
|
129
|
+
"@rspress/mdx-rs": "0.5.0",
|
|
135
130
|
"@rspress/plugin-container-syntax": "workspace:*",
|
|
136
131
|
"@rspress/shared": "workspace:*",
|
|
137
132
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
@@ -187,9 +182,6 @@ var require_package = __commonJS({
|
|
|
187
182
|
"@types/react": "^18",
|
|
188
183
|
"@types/react-dom": "^18",
|
|
189
184
|
"@types/yaml-front-matter": "^4.1.0",
|
|
190
|
-
husky: "^8",
|
|
191
|
-
"lint-staged": "~13.1.0",
|
|
192
|
-
"@biomejs/biome": "1.5.2",
|
|
193
185
|
rimraf: "^3.0.2",
|
|
194
186
|
typescript: "^5",
|
|
195
187
|
vite: "^4.0.5",
|
|
@@ -358,6 +350,9 @@ function normalizeThemeConfig(docConfig, pages = []) {
|
|
|
358
350
|
return {};
|
|
359
351
|
}
|
|
360
352
|
const normalizeSidebarItem = (item) => {
|
|
353
|
+
if (typeof item === "object" && ("dividerType" in item || "sectionHeaderText" in item)) {
|
|
354
|
+
return item;
|
|
355
|
+
}
|
|
361
356
|
if (typeof item === "object" && "items" in item) {
|
|
362
357
|
return {
|
|
363
358
|
...item,
|
|
@@ -374,9 +369,6 @@ function normalizeThemeConfig(docConfig, pages = []) {
|
|
|
374
369
|
})
|
|
375
370
|
};
|
|
376
371
|
}
|
|
377
|
-
if (typeof item === "object" && "dividerType" in item) {
|
|
378
|
-
return item;
|
|
379
|
-
}
|
|
380
372
|
if (typeof item === "string") {
|
|
381
373
|
const normalizedItem = normalizeLinkPrefix(item, currentLang);
|
|
382
374
|
const page = pages.find(
|
|
@@ -615,9 +607,10 @@ async function resolveDepPath(importPath, importer, alias) {
|
|
|
615
607
|
return resolveResult;
|
|
616
608
|
}
|
|
617
609
|
async function flattenMdxContent(content, basePath, alias) {
|
|
610
|
+
const deps = [];
|
|
618
611
|
const regex = new RegExp(importStatementRegex);
|
|
619
612
|
if (!regex.test(content)) {
|
|
620
|
-
return content;
|
|
613
|
+
return { flattenContent: content, deps };
|
|
621
614
|
}
|
|
622
615
|
let result = content;
|
|
623
616
|
if (!startFlatten) {
|
|
@@ -632,7 +625,7 @@ async function flattenMdxContent(content, basePath, alias) {
|
|
|
632
625
|
try {
|
|
633
626
|
ast = processor.parse(content);
|
|
634
627
|
} catch (e) {
|
|
635
|
-
return content;
|
|
628
|
+
return { flattenContent: content, deps };
|
|
636
629
|
}
|
|
637
630
|
const importNodes = ast.children.filter((node) => node.type === "mdxjsEsm").map((node) => {
|
|
638
631
|
return node.data?.estree?.body || [];
|
|
@@ -652,18 +645,15 @@ async function flattenMdxContent(content, basePath, alias) {
|
|
|
652
645
|
}
|
|
653
646
|
if (MDX_REGEXP.test(absoluteImportPath)) {
|
|
654
647
|
const importedContent = fs2.readFileSync(absoluteImportPath, "utf-8");
|
|
655
|
-
const replacedValue = await flattenMdxContent(
|
|
656
|
-
importedContent,
|
|
657
|
-
absoluteImportPath,
|
|
658
|
-
alias
|
|
659
|
-
);
|
|
648
|
+
const { flattenContent: replacedValue, deps: subDeps } = await flattenMdxContent(importedContent, absoluteImportPath, alias);
|
|
660
649
|
result = result.replace(
|
|
661
650
|
new RegExp(`import\\s+${id}\\s+from\\s+['"](${importPath})['"];?`),
|
|
662
651
|
""
|
|
663
|
-
).replace(new RegExp(`<${id}\\s
|
|
652
|
+
).replace(new RegExp(`<${id}\\s*/>`, "g"), () => replacedValue);
|
|
653
|
+
deps.push(...subDeps, absoluteImportPath);
|
|
664
654
|
}
|
|
665
655
|
}
|
|
666
|
-
return result;
|
|
656
|
+
return { flattenContent: result, deps };
|
|
667
657
|
}
|
|
668
658
|
|
|
669
659
|
// src/node/runtimeModule/siteData/extractPageData.ts
|
|
@@ -697,7 +687,7 @@ async function extractPageData(replaceRules, alias, domain, root, routeService2)
|
|
|
697
687
|
frontmatter[key] = applyReplaceRules(frontmatter[key], replaceRules);
|
|
698
688
|
}
|
|
699
689
|
});
|
|
700
|
-
const flattenContent = await flattenMdxContent(
|
|
690
|
+
const { flattenContent } = await flattenMdxContent(
|
|
701
691
|
applyReplaceRules(strippedFrontMatter, replaceRules),
|
|
702
692
|
route.absolutePath,
|
|
703
693
|
alias
|
|
@@ -858,7 +848,7 @@ async function siteDataVMPlugin(context) {
|
|
|
858
848
|
search: userConfig?.search ?? { mode: "local" },
|
|
859
849
|
pages: pages.map((page) => {
|
|
860
850
|
const { content, id, domain: domain2, _filepath, ...rest } = page;
|
|
861
|
-
return rest;
|
|
851
|
+
return isProduction() ? rest : { ...rest, _filepath };
|
|
862
852
|
}),
|
|
863
853
|
markdown: {
|
|
864
854
|
showLineNumbers: userConfig?.markdown?.showLineNumbers ?? false,
|
|
@@ -1365,9 +1355,14 @@ async function initRouteService(options) {
|
|
|
1365
1355
|
}
|
|
1366
1356
|
|
|
1367
1357
|
// src/node/utils/detectCustomIcon.ts
|
|
1358
|
+
import { existsSync } from "fs";
|
|
1368
1359
|
import path10 from "path";
|
|
1369
1360
|
var detectCustomIcon = async (customThemeDir) => {
|
|
1370
1361
|
const assetsDir = path10.join(customThemeDir, "assets");
|
|
1362
|
+
const alias = {};
|
|
1363
|
+
if (!existsSync(assetsDir)) {
|
|
1364
|
+
return alias;
|
|
1365
|
+
}
|
|
1371
1366
|
const globby = (await import(
|
|
1372
1367
|
// @ts-expect-error
|
|
1373
1368
|
// eslint-disable-next-line node/file-extension-in-import
|
|
@@ -1376,7 +1371,6 @@ var detectCustomIcon = async (customThemeDir) => {
|
|
|
1376
1371
|
const files = await globby("*.svg", {
|
|
1377
1372
|
cwd: assetsDir
|
|
1378
1373
|
});
|
|
1379
|
-
const alias = {};
|
|
1380
1374
|
files.forEach((file) => {
|
|
1381
1375
|
const name = path10.basename(file, ".svg");
|
|
1382
1376
|
alias[`@theme-assets/${name}`] = path10.join(assetsDir, file);
|
|
@@ -1529,7 +1523,6 @@ async function initRsbuild(rootDir, config, pluginDriver, isSSR = false, extraRs
|
|
|
1529
1523
|
default: { createRsbuild, mergeRsbuildConfig: mergeRsbuildConfig2 }
|
|
1530
1524
|
} = await import("@rsbuild/core");
|
|
1531
1525
|
const { pluginReact } = await import("@rsbuild/plugin-react");
|
|
1532
|
-
const { pluginSvgr } = await import("@rsbuild/plugin-svgr");
|
|
1533
1526
|
const internalRsbuildConfig = await createInternalBuildConfig(
|
|
1534
1527
|
userDocRoot,
|
|
1535
1528
|
config,
|
|
@@ -1555,9 +1548,6 @@ async function initRsbuild(rootDir, config, pluginDriver, isSSR = false, extraRs
|
|
|
1555
1548
|
pluginDriver
|
|
1556
1549
|
}),
|
|
1557
1550
|
pluginReact(),
|
|
1558
|
-
pluginSvgr({
|
|
1559
|
-
svgDefaultExport: "component"
|
|
1560
|
-
}),
|
|
1561
1551
|
...builderPlugins
|
|
1562
1552
|
]);
|
|
1563
1553
|
return rsbuild;
|