@rspress/core 2.0.12 → 2.0.14
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/0~execa.js +1 -1
- package/dist/0~rslib-runtime.js +9 -5
- package/dist/{2235.js → 4942.js} +12 -9
- package/dist/{8857.js → 5580.js} +3 -3
- package/dist/6646.js +3 -0
- package/dist/{1688.js → 7261.js} +6 -1
- package/dist/{8006.js → 7986.js} +1 -6
- package/dist/cli/index.js +4 -4
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/Banner/index.scss +11 -0
- package/dist/eject-theme/components/Banner/index.tsx +5 -1
- package/dist/eject-theme/components/CodeBlock/index.test.tsx +49 -0
- package/dist/eject-theme/components/CodeBlock/index.tsx +1 -1
- package/dist/eject-theme/components/CodeButtonGroup/index.tsx +5 -2
- package/dist/eject-theme/components/FallbackHeading/index.test.tsx +45 -0
- package/dist/eject-theme/components/FallbackHeading/index.tsx +1 -1
- package/dist/eject-theme/components/Link/index.tsx +6 -0
- package/dist/eject-theme/components/Link/useLinkNavigate.ts +2 -2
- package/dist/eject-theme/components/Outline/index.tsx +0 -6
- package/dist/eject-theme/components/Overview/index.test.tsx +57 -0
- package/dist/eject-theme/components/Overview/index.tsx +1 -1
- package/dist/eject-theme/components/OverviewGroup/index.test.tsx +61 -0
- package/dist/eject-theme/components/OverviewGroup/index.tsx +1 -1
- package/dist/eject-theme/components/PackageManagerTabs/index.test.tsx +54 -0
- package/dist/eject-theme/components/PackageManagerTabs/index.tsx +1 -1
- package/dist/eject-theme/components/Search/SearchPanel.tsx +1 -0
- package/dist/eject-theme/components/Search/logic/search.ts +15 -16
- package/dist/eject-theme/components/SidebarMenu/index.tsx +10 -3
- package/dist/eject-theme/components/SidebarMenu/useSidebarMenu.tsx +12 -3
- package/dist/eject-theme/components/SocialLinks/GithubStars.tsx +120 -0
- package/dist/eject-theme/components/SocialLinks/SocialLink.tsx +5 -0
- package/dist/eject-theme/components/SocialLinks/index.scss +17 -0
- package/dist/eject-theme/components/Steps/index.scss +6 -4
- package/dist/eject-theme/components/Tabs/index.test.tsx +51 -0
- package/dist/eject-theme/components/Tabs/index.tsx +1 -1
- package/dist/eject-theme/components/Tag/index.test.tsx +55 -0
- package/dist/eject-theme/components/Tag/index.tsx +19 -5
- package/dist/index.js +1 -1
- package/dist/node/PluginDriver.js +1 -1
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +3 -4
- package/dist/node/auto-nav-sidebar/utils.js +1 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/constants.js +3 -3
- package/dist/node/eject.js +2 -2
- package/dist/node/initRsbuild.js +20 -14
- package/dist/node/logger/hint.js +1 -1
- package/dist/node/mdx/options.js +1 -1
- package/dist/node/mdx/processor.js +1 -1
- package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
- package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
- package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +2 -2
- package/dist/node/mdx/remarkPlugins/image.js +3 -4
- package/dist/node/mdx/remarkPlugins/link.js +2 -2
- package/dist/node/mdx/remarkPlugins/toc.js +1 -1
- package/dist/node/medium-zoom/index.js +1 -1
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.js +2 -3
- package/dist/node/route/extractPageData.js +1 -1
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +119 -112
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +7 -0
- package/dist/node/runtimeModule/i18n.js +2 -2
- package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/searchHooks.js +1 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +33 -9
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/htmlFile.d.ts +2 -0
- package/dist/node/ssg/htmlFile.js +14 -0
- package/dist/node/ssg/renderPage.js +2 -2
- package/dist/node/ssg/renderPageWorker.d.ts +3 -6
- package/dist/node/ssg/renderPageWorker.js +24 -4
- package/dist/node/ssg/renderPages.d.ts +1 -1
- package/dist/node/ssg/renderPages.js +19 -18
- package/dist/node/ssg/rsbuildPluginSSG.js +2 -2
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
- package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
- package/dist/node/ssg-md/remarkSplitMdx.js +1 -1
- package/dist/node/ssg-md/renderPage.js +2 -2
- package/dist/node/ssg-md/renderPages.js +3 -3
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/error.js +1 -1
- package/dist/node/utils/flattenMdxContent.js +1 -1
- package/dist/node/utils/fs.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/normalizePath.js +1 -1
- package/dist/node/utils/reactAlias.js +2 -2
- package/dist/runtime/App.js +1 -1
- package/dist/theme/components/Banner/index.css +11 -0
- package/dist/theme/components/Banner/index.js +1 -0
- package/dist/theme/components/CodeBlock/index.js +1 -1
- package/dist/theme/components/CodeButtonGroup/index.js +4 -2
- package/dist/theme/components/FallbackHeading/index.js +1 -1
- package/dist/theme/components/Link/index.js +6 -0
- package/dist/theme/components/Link/useLinkNavigate.js +2 -2
- package/dist/theme/components/Outline/index.js +1 -3
- package/dist/theme/components/Overview/index.js +1 -1
- package/dist/theme/components/OverviewGroup/index.js +1 -1
- package/dist/theme/components/PackageManagerTabs/index.js +1 -1
- package/dist/theme/components/Search/SearchPanel.js +1 -0
- package/dist/theme/components/Search/logic/search.js +12 -7
- package/dist/theme/components/SidebarMenu/index.d.ts +3 -0
- package/dist/theme/components/SidebarMenu/index.js +4 -3
- package/dist/theme/components/SidebarMenu/useSidebarMenu.d.ts +2 -1
- package/dist/theme/components/SidebarMenu/useSidebarMenu.js +7 -3
- package/dist/theme/components/SocialLinks/GithubStars.d.ts +7 -0
- package/dist/theme/components/SocialLinks/GithubStars.js +85 -0
- package/dist/theme/components/SocialLinks/SocialLink.js +5 -0
- package/dist/theme/components/SocialLinks/index.css +19 -0
- package/dist/theme/components/Steps/index.css +6 -4
- package/dist/theme/components/Tabs/index.js +1 -1
- package/dist/theme/components/Tag/index.js +9 -5
- package/dist/theme/layout/DocLayout/index.js +2 -2
- package/dist/theme/layout/HomeLayout/index.js +1 -1
- package/dist/theme/layout/Layout/index.js +1 -1
- package/package.json +13 -14
- package/dist/9224.js +0 -1
- package/dist/runtime/BrowserOnly.test.d.ts +0 -1
- /package/dist/{0~1402.js → 0~8787.js} +0 -0
- /package/dist/{3323.js → 3358.js} +0 -0
- /package/dist/{8857.js.LICENSE.txt → 5580.js.LICENSE.txt} +0 -0
- /package/dist/{3294.js → 8005.js} +0 -0
- /package/dist/{6162.js → 9283.js} +0 -0
- /package/dist/{8474.js → 9882.js} +0 -0
package/dist/0~execa.js
CHANGED
|
@@ -8,7 +8,7 @@ import { createReadStream, createWriteStream, readFileSync } from "node:fs";
|
|
|
8
8
|
import { setTimeout as promises_setTimeout } from "node:timers/promises";
|
|
9
9
|
import { debuglog } from "node:util";
|
|
10
10
|
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
11
|
-
import "./
|
|
11
|
+
import "./4942.js";
|
|
12
12
|
__webpack_require__.add({
|
|
13
13
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
14
14
|
const cp = __webpack_require__("child_process");
|
package/dist/0~rslib-runtime.js
CHANGED
|
@@ -20,11 +20,15 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
20
20
|
};
|
|
21
21
|
})();
|
|
22
22
|
(()=>{
|
|
23
|
-
__webpack_require__.d = (exports,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
__webpack_require__.d = (exports, getters, values)=>{
|
|
24
|
+
var define = (defs, kind)=>{
|
|
25
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
[kind]: defs[key]
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
define(getters, "get");
|
|
31
|
+
define(values, "value");
|
|
28
32
|
};
|
|
29
33
|
})();
|
|
30
34
|
(()=>{
|
package/dist/{2235.js → 4942.js}
RENAMED
|
@@ -2128,6 +2128,7 @@ var Builder = class {
|
|
|
2128
2128
|
const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js");
|
|
2129
2129
|
const isReadonlyArray = Array.isArray;
|
|
2130
2130
|
const BACKSLASHES = /\\/g;
|
|
2131
|
+
const DRIVE_RELATIVE_PATH = /^[A-Za-z]:$/;
|
|
2131
2132
|
const isWin = "win32" === process.platform;
|
|
2132
2133
|
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
|
2133
2134
|
function getPartialMatcher(patterns, options = {}) {
|
|
@@ -2193,6 +2194,9 @@ function buildRelative(cwd, root) {
|
|
|
2193
2194
|
return "/" === p[p.length - 1] && "" !== result ? `${result}/` : result || ".";
|
|
2194
2195
|
};
|
|
2195
2196
|
}
|
|
2197
|
+
function ensureNonDriveRelativePath(path) {
|
|
2198
|
+
return path.replace(DRIVE_RELATIVE_PATH, (match)=>`${match}/`);
|
|
2199
|
+
}
|
|
2196
2200
|
const splitPatternOptions = {
|
|
2197
2201
|
parts: true
|
|
2198
2202
|
};
|
|
@@ -2243,7 +2247,7 @@ function normalizePattern(pattern, opts, props, isIgnore) {
|
|
|
2243
2247
|
}
|
|
2244
2248
|
const potentialRoot = posix.join(cwd, parentDir.slice(3 * i));
|
|
2245
2249
|
if ("." !== potentialRoot[0] && props.root.length > potentialRoot.length) {
|
|
2246
|
-
props.root = potentialRoot;
|
|
2250
|
+
props.root = ensureNonDriveRelativePath(potentialRoot);
|
|
2247
2251
|
props.depthOffset = -n + i;
|
|
2248
2252
|
}
|
|
2249
2253
|
}
|
|
@@ -2262,7 +2266,7 @@ function normalizePattern(pattern, opts, props, isIgnore) {
|
|
|
2262
2266
|
}
|
|
2263
2267
|
props.depthOffset = newCommonPath.length;
|
|
2264
2268
|
props.commonPath = newCommonPath;
|
|
2265
|
-
props.root = newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd;
|
|
2269
|
+
props.root = ensureNonDriveRelativePath(newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd);
|
|
2266
2270
|
}
|
|
2267
2271
|
return result;
|
|
2268
2272
|
}
|
|
@@ -2354,18 +2358,17 @@ function formatPaths(paths, mapper) {
|
|
|
2354
2358
|
}
|
|
2355
2359
|
const defaultOptions = {
|
|
2356
2360
|
caseSensitiveMatch: true,
|
|
2357
|
-
cwd: process.cwd(),
|
|
2358
2361
|
debug: !!process.env.TINYGLOBBY_DEBUG,
|
|
2359
2362
|
expandDirectories: true,
|
|
2360
2363
|
followSymbolicLinks: true,
|
|
2361
2364
|
onlyFiles: true
|
|
2362
2365
|
};
|
|
2363
2366
|
function getOptions(options) {
|
|
2364
|
-
const opts = {
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
};
|
|
2368
|
-
opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) : resolve(opts.cwd)).replace(BACKSLASHES, "/");
|
|
2367
|
+
const opts = Object.assign({}, options);
|
|
2368
|
+
for(const key in defaultOptions)if (void 0 === opts[key]) Object.assign(opts, {
|
|
2369
|
+
[key]: defaultOptions[key]
|
|
2370
|
+
});
|
|
2371
|
+
opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) : resolve(opts.cwd || process.cwd())).replace(BACKSLASHES, "/");
|
|
2369
2372
|
opts.ignore = ensureStringArray(opts.ignore);
|
|
2370
2373
|
opts.fs && (opts.fs = {
|
|
2371
2374
|
readdir: opts.fs.readdir || readdir,
|
|
@@ -2436,7 +2439,7 @@ const pluginVirtualModule = (pluginOptions = {})=>({
|
|
|
2436
2439
|
});
|
|
2437
2440
|
export { DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
|
|
2438
2441
|
export { default as promises, mkdir, readdir as promises_readdir, rm, stat as promises_stat, writeFile } from "node:fs/promises";
|
|
2439
|
-
export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, normalizeHref, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
|
|
2442
|
+
export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeHref, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
|
|
2440
2443
|
export { logger } from "@rspress/shared/logger";
|
|
2441
2444
|
export { extractTextAndId, getIconUrlPath, loadFrontMatter } from "@rspress/shared/node-utils";
|
|
2442
2445
|
export { createRequire as external_node_module_createRequire } from "node:module";
|
package/dist/{8857.js → 5580.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! LICENSE:
|
|
1
|
+
/*! LICENSE: 5580.js.LICENSE.txt */
|
|
2
2
|
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
3
|
-
import "./
|
|
3
|
+
import "./4942.js";
|
|
4
4
|
import { createRequire as __rspack_createRequire } from "node:module";
|
|
5
5
|
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
6
6
|
__webpack_require__.add({
|
|
@@ -4268,7 +4268,7 @@ __webpack_require__.add({
|
|
|
4268
4268
|
module.exports = __rspack_createRequire_require("util");
|
|
4269
4269
|
},
|
|
4270
4270
|
"../../node_modules/.pnpm/binary-extensions@2.3.0/node_modules/binary-extensions/binary-extensions.json" (module) {
|
|
4271
|
-
module.exports = JSON.parse('["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]');
|
|
4271
|
+
module.exports = /*#__PURE__*/ JSON.parse('["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]');
|
|
4272
4272
|
}
|
|
4273
4273
|
});
|
|
4274
4274
|
function toArr(any) {
|
package/dist/6646.js
ADDED
package/dist/{1688.js → 7261.js}
RENAMED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
var package_namespaceObject = {
|
|
2
|
+
rE: "2.0.14"
|
|
3
|
+
};
|
|
1
4
|
async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
|
|
2
5
|
return new Promise((resolve_, reject_)=>{
|
|
3
6
|
if (void 0 === iterable[Symbol.iterator] && void 0 === iterable[Symbol.asyncIterator]) throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
|
|
@@ -89,7 +92,9 @@ async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true,
|
|
|
89
92
|
});
|
|
90
93
|
}
|
|
91
94
|
const pMapSkip = Symbol('skip');
|
|
95
|
+
export { createRequire } from "node:module";
|
|
96
|
+
export { default as node_path, isAbsolute, relative, resolve as external_node_path_resolve } from "node:path";
|
|
92
97
|
export { pathToFileURL } from "node:url";
|
|
93
98
|
export { logger } from "@rspress/shared/logger";
|
|
94
99
|
export { createHead, transformHtmlTemplate } from "@unhead/react/server";
|
|
95
|
-
export { pMap };
|
|
100
|
+
export { pMap, package_namespaceObject };
|
package/dist/{8006.js → 7986.js}
RENAMED
|
@@ -67,11 +67,6 @@ __webpack_require__.add({
|
|
|
67
67
|
module.exports.createColors = createColors;
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
|
-
var package_namespaceObject = {
|
|
71
|
-
rE: "2.0.12"
|
|
72
|
-
};
|
|
73
70
|
export { default as promises, readFile } from "node:fs/promises";
|
|
74
|
-
export {
|
|
71
|
+
export { join, relative } from "node:path";
|
|
75
72
|
export { logger } from "@rspress/shared/logger";
|
|
76
|
-
export { createRequire } from "node:module";
|
|
77
|
-
export { package_namespaceObject };
|
package/dist/cli/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../0~rslib-runtime.js";
|
|
2
|
-
import { node_path, logger, join, cac } from "../
|
|
3
|
-
import
|
|
2
|
+
import { node_path, logger, join, cac } from "../5580.js";
|
|
3
|
+
import "../7986.js";
|
|
4
|
+
import { package_namespaceObject } from "../7261.js";
|
|
4
5
|
import { loadConfigFile, resolveDocRoot } from "../config/loadConfigFile.js";
|
|
5
6
|
import { dev } from "../node/dev.js";
|
|
6
|
-
import { PUBLIC_DIR } from "../node/constants.js";
|
|
7
7
|
import { build } from "../node/build.js";
|
|
8
8
|
import { serve } from "../node/serve.js";
|
|
9
9
|
import { listComponents, ejectComponent } from "../node/eject.js";
|
|
@@ -54,7 +54,7 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
|
|
|
54
54
|
'**/node_modules/**',
|
|
55
55
|
'**/.git/**',
|
|
56
56
|
'**/.DS_Store/**',
|
|
57
|
-
join(docDirectory,
|
|
57
|
+
join(docDirectory, "public")
|
|
58
58
|
]
|
|
59
59
|
});
|
|
60
60
|
cliWatcher.on('all', async (eventName, filepath)=>{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_fs, node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../
|
|
1
|
+
import { node_fs, node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../5580.js";
|
|
2
2
|
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
|
|
3
3
|
async function loadConfigFile(customConfigFile) {
|
|
4
4
|
const baseDir = process.cwd();
|
|
@@ -17,11 +17,22 @@
|
|
|
17
17
|
z-index: 999;
|
|
18
18
|
background: var(--rp-banner-background);
|
|
19
19
|
height: 36px;
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
padding: 0 3.5rem;
|
|
20
22
|
|
|
21
23
|
&__link {
|
|
24
|
+
display: block;
|
|
25
|
+
flex: 1 1 auto;
|
|
26
|
+
min-width: 0;
|
|
27
|
+
max-width: 100%;
|
|
28
|
+
overflow: hidden;
|
|
22
29
|
color: #fff;
|
|
23
30
|
font-weight: 700;
|
|
31
|
+
line-height: 36px;
|
|
32
|
+
text-align: center;
|
|
24
33
|
text-decoration: none;
|
|
34
|
+
text-overflow: ellipsis;
|
|
35
|
+
white-space: nowrap;
|
|
25
36
|
|
|
26
37
|
&:hover {
|
|
27
38
|
text-decoration: underline;
|
|
@@ -97,7 +97,11 @@ export const Banner = forwardRef<HTMLDivElement, BannerProps>(
|
|
|
97
97
|
<div className={clsx('rp-banner', className)} ref={ref}>
|
|
98
98
|
{customChildren ?? (
|
|
99
99
|
<>
|
|
100
|
-
<Link
|
|
100
|
+
<Link
|
|
101
|
+
href={href}
|
|
102
|
+
className="rp-banner__link"
|
|
103
|
+
title={typeof message === 'string' ? message : undefined}
|
|
104
|
+
>
|
|
101
105
|
{message}
|
|
102
106
|
</Link>
|
|
103
107
|
<SvgWrapper
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, rs } from '@rstest/core';
|
|
2
|
+
import { renderToMarkdownString } from 'react-render-to-markdown';
|
|
3
|
+
import { CodeBlock } from './index';
|
|
4
|
+
|
|
5
|
+
rs.mock('@rspress/core/theme', () => ({
|
|
6
|
+
CodeButtonGroup: () => null,
|
|
7
|
+
IconArrowDown: () => null,
|
|
8
|
+
SvgWrapper: () => null,
|
|
9
|
+
useCodeButtonGroup: () => ({
|
|
10
|
+
copyElementRef: { current: null },
|
|
11
|
+
toggleWrapCode: () => {},
|
|
12
|
+
wrapCode: false,
|
|
13
|
+
}),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
const originalSsgMd = import.meta.env.SSG_MD;
|
|
17
|
+
|
|
18
|
+
const setSsgMd = (value: boolean | undefined) => {
|
|
19
|
+
if (value === undefined) {
|
|
20
|
+
delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
(import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
setSsgMd(originalSsgMd);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('CodeBlock', () => {
|
|
32
|
+
it('renders only its children when SSG_MD is enabled', async () => {
|
|
33
|
+
setSsgMd(true);
|
|
34
|
+
|
|
35
|
+
expect(
|
|
36
|
+
await renderToMarkdownString(
|
|
37
|
+
<CodeBlock title="example.ts">
|
|
38
|
+
<pre>const value = true;</pre>
|
|
39
|
+
</CodeBlock>,
|
|
40
|
+
),
|
|
41
|
+
).toMatchInlineSnapshot(`
|
|
42
|
+
"
|
|
43
|
+
\`\`\`\`
|
|
44
|
+
const value = true;
|
|
45
|
+
\`\`\`\`
|
|
46
|
+
"
|
|
47
|
+
`);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useSite } from '@rspress/core/runtime';
|
|
1
|
+
import { useI18n, useSite } from '@rspress/core/runtime';
|
|
2
2
|
import { IconWrap, IconWrapped, SvgWrapper } from '@rspress/core/theme';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { useRef, useState } from 'react';
|
|
@@ -43,6 +43,8 @@ export function CodeButtonGroup({
|
|
|
43
43
|
showWrapCodeButton = true,
|
|
44
44
|
showCopyButton = true,
|
|
45
45
|
}: CodeButtonGroupProps) {
|
|
46
|
+
const t = useI18n();
|
|
47
|
+
|
|
46
48
|
return (
|
|
47
49
|
<>
|
|
48
50
|
<div className="rp-code-button-group">
|
|
@@ -54,7 +56,8 @@ export function CodeButtonGroup({
|
|
|
54
56
|
wrapCode && 'rp-code-wrap-button--wrapped',
|
|
55
57
|
)}
|
|
56
58
|
onClick={() => toggleWrapCode()}
|
|
57
|
-
title=
|
|
59
|
+
title={t('codeButtonGroupWrapButtonText')}
|
|
60
|
+
aria-label={t('codeButtonGroupWrapButtonText')}
|
|
58
61
|
>
|
|
59
62
|
<SvgWrapper
|
|
60
63
|
icon={IconWrapped}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, rs } from '@rstest/core';
|
|
2
|
+
import { renderToMarkdownString } from 'react-render-to-markdown';
|
|
3
|
+
import { FallbackHeading } from './index';
|
|
4
|
+
|
|
5
|
+
rs.mock('@rspress/core/theme', () => ({
|
|
6
|
+
getCustomMDXComponent: () => ({
|
|
7
|
+
a: 'a',
|
|
8
|
+
h1: 'h1',
|
|
9
|
+
h2: 'h2',
|
|
10
|
+
h3: 'h3',
|
|
11
|
+
h4: 'h4',
|
|
12
|
+
h5: 'h5',
|
|
13
|
+
h6: 'h6',
|
|
14
|
+
}),
|
|
15
|
+
renderInlineMarkdown: (text: string) => ({
|
|
16
|
+
dangerouslySetInnerHTML: { __html: text },
|
|
17
|
+
}),
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
const originalSsgMd = import.meta.env.SSG_MD;
|
|
21
|
+
|
|
22
|
+
const setSsgMd = (value: boolean | undefined) => {
|
|
23
|
+
if (value === undefined) {
|
|
24
|
+
delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
(import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
afterEach(() => {
|
|
32
|
+
setSsgMd(originalSsgMd);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('FallbackHeading', () => {
|
|
36
|
+
it('renders markdown when SSG_MD is enabled', async () => {
|
|
37
|
+
setSsgMd(true);
|
|
38
|
+
|
|
39
|
+
expect(
|
|
40
|
+
await renderToMarkdownString(
|
|
41
|
+
<FallbackHeading level={2} title="Getting Started" />,
|
|
42
|
+
),
|
|
43
|
+
).toBe('## Getting Started\n\n');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -100,6 +100,9 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>((props, ref) => {
|
|
|
100
100
|
onMouseEnter?.(event);
|
|
101
101
|
preloadLink(removeBaseHref);
|
|
102
102
|
}}
|
|
103
|
+
onTouchStart={() => {
|
|
104
|
+
preloadLink(removeBaseHref);
|
|
105
|
+
}}
|
|
103
106
|
onClick={e => {
|
|
104
107
|
onClick?.(e);
|
|
105
108
|
if (
|
|
@@ -134,6 +137,9 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>((props, ref) => {
|
|
|
134
137
|
onMouseEnter?.(event);
|
|
135
138
|
preloadLink(removeBaseHref);
|
|
136
139
|
}}
|
|
140
|
+
onTouchStart={() => {
|
|
141
|
+
preloadLink(removeBaseHref);
|
|
142
|
+
}}
|
|
137
143
|
onClick={e => {
|
|
138
144
|
onClick?.(e);
|
|
139
145
|
if (
|
|
@@ -52,7 +52,7 @@ export function getHref(href: string): {
|
|
|
52
52
|
return { linkType: linkType, withBaseHref: href, removeBaseHref: href };
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
if (linkType === 'relative' && !
|
|
55
|
+
if (linkType === 'relative' && !import.meta.env.SSR) {
|
|
56
56
|
withBaseHref = new URL(href, window.location.href).pathname;
|
|
57
57
|
} else {
|
|
58
58
|
withBaseHref = withBase(cleanUrlByConfig(href));
|
|
@@ -84,7 +84,7 @@ export function useLinkNavigate(
|
|
|
84
84
|
|
|
85
85
|
const preloadChunkThenNavigate = async () => {
|
|
86
86
|
const inCurrPage = isActive(removeBaseHref, currPagePathname);
|
|
87
|
-
if (!
|
|
87
|
+
if (!import.meta.env.SSR && !inCurrPage) {
|
|
88
88
|
const matchedRoute = pathnameToRouteService(removeBaseHref);
|
|
89
89
|
if (matchedRoute) {
|
|
90
90
|
const timer = setTimeout(() => {
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
LlmsOpenRow,
|
|
6
6
|
ReadPercent,
|
|
7
7
|
Toc,
|
|
8
|
-
useDynamicToc,
|
|
9
8
|
} from '@rspress/core/theme';
|
|
10
9
|
import './index.scss';
|
|
11
10
|
import { ScrollToTop } from './ScrollToTop';
|
|
@@ -13,17 +12,12 @@ import { ScrollToTop } from './ScrollToTop';
|
|
|
13
12
|
export function Outline() {
|
|
14
13
|
const t = useI18n();
|
|
15
14
|
|
|
16
|
-
const headers = useDynamicToc();
|
|
17
15
|
const {
|
|
18
16
|
site: {
|
|
19
17
|
themeConfig: { enableScrollToTop = true, llmsUI },
|
|
20
18
|
},
|
|
21
19
|
} = useSite();
|
|
22
20
|
|
|
23
|
-
if (headers.length === 0) {
|
|
24
|
-
return <></>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
21
|
const placement =
|
|
28
22
|
typeof llmsUI === 'object' ? (llmsUI?.placement ?? 'title') : 'title';
|
|
29
23
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, rs } from '@rstest/core';
|
|
2
|
+
import { renderToMarkdownString } from 'react-render-to-markdown';
|
|
3
|
+
import { Overview } from './index';
|
|
4
|
+
|
|
5
|
+
rs.mock('@rspress/core/runtime', () => ({
|
|
6
|
+
isEqualPath: (a: string, b: string) => a === b,
|
|
7
|
+
useI18n: () => (key: string) => key,
|
|
8
|
+
usePageData: () => ({
|
|
9
|
+
page: {
|
|
10
|
+
frontmatter: { overview: true },
|
|
11
|
+
routePath: '/guide/overview',
|
|
12
|
+
title: 'Guide Overview',
|
|
13
|
+
},
|
|
14
|
+
siteData: { pages: [] },
|
|
15
|
+
}),
|
|
16
|
+
useSidebar: () => [{ link: '/guide/overview', text: 'Overview' }],
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
rs.mock('@rspress/core/theme', () => ({
|
|
20
|
+
FallbackHeading: ({ level, title }: { level: number; title: string }) =>
|
|
21
|
+
`${'#'.repeat(level)} ${title}\n\n`,
|
|
22
|
+
OverviewGroup: ({ group }: { group: { name: string } }) =>
|
|
23
|
+
`## ${group.name}\n\n`,
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
const originalSsgMd = import.meta.env.SSG_MD;
|
|
27
|
+
|
|
28
|
+
const setSsgMd = (value: boolean | undefined) => {
|
|
29
|
+
if (value === undefined) {
|
|
30
|
+
delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
(import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
afterEach(() => {
|
|
38
|
+
setSsgMd(originalSsgMd);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('Overview', () => {
|
|
42
|
+
it('renders heading and groups as markdown when SSG_MD is enabled', async () => {
|
|
43
|
+
setSsgMd(true);
|
|
44
|
+
|
|
45
|
+
expect(
|
|
46
|
+
await renderToMarkdownString(
|
|
47
|
+
<Overview groups={[{ name: 'Guides', items: [] }]} />,
|
|
48
|
+
),
|
|
49
|
+
).toMatchInlineSnapshot(`
|
|
50
|
+
"# Guide Overview
|
|
51
|
+
|
|
52
|
+
## Guides
|
|
53
|
+
|
|
54
|
+
"
|
|
55
|
+
`);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, rs } from '@rstest/core';
|
|
2
|
+
import { renderToMarkdownString } from 'react-render-to-markdown';
|
|
3
|
+
import { OverviewGroup, type Group } from './index';
|
|
4
|
+
|
|
5
|
+
rs.mock('@rspress/core/runtime', () => ({
|
|
6
|
+
routePathToMdPath: (routePath: string) => `${routePath}.md`,
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
rs.mock('@rspress/core/theme', () => ({
|
|
10
|
+
FallbackHeading: () => null,
|
|
11
|
+
Link: 'a',
|
|
12
|
+
SvgWrapper: () => null,
|
|
13
|
+
renderInlineMarkdown: (text: string) => ({
|
|
14
|
+
dangerouslySetInnerHTML: { __html: text },
|
|
15
|
+
}),
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
const originalSsgMd = import.meta.env.SSG_MD;
|
|
19
|
+
|
|
20
|
+
const setSsgMd = (value: boolean | undefined) => {
|
|
21
|
+
if (value === undefined) {
|
|
22
|
+
delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
(import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
setSsgMd(originalSsgMd);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('OverviewGroup', () => {
|
|
34
|
+
it('renders overview links as markdown when SSG_MD is enabled', async () => {
|
|
35
|
+
setSsgMd(true);
|
|
36
|
+
|
|
37
|
+
const group: Group = {
|
|
38
|
+
name: 'Guide',
|
|
39
|
+
items: [
|
|
40
|
+
{
|
|
41
|
+
text: 'Introduction',
|
|
42
|
+
link: '/guide/introduction',
|
|
43
|
+
headers: [{ id: 'install', text: 'Install', depth: 2 }],
|
|
44
|
+
items: [{ text: 'Configuration', link: '/guide/configuration' }],
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
expect(await renderToMarkdownString(<OverviewGroup group={group} />))
|
|
50
|
+
.toMatchInlineSnapshot(`
|
|
51
|
+
"## Guide
|
|
52
|
+
|
|
53
|
+
### [Introduction](/guide/introduction.md)
|
|
54
|
+
|
|
55
|
+
- [Install](/guide/introduction.md#install)
|
|
56
|
+
|
|
57
|
+
- [Configuration](/guide/configuration.md)
|
|
58
|
+
"
|
|
59
|
+
`);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, rs } from '@rstest/core';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import { renderToMarkdownString } from 'react-render-to-markdown';
|
|
4
|
+
import { PackageManagerTabs } from './index';
|
|
5
|
+
|
|
6
|
+
rs.mock('@rspress/core/theme', () => ({
|
|
7
|
+
getCustomMDXComponent: () => ({
|
|
8
|
+
pre: 'pre',
|
|
9
|
+
}),
|
|
10
|
+
Tab: ({ children }: { children: ReactNode }) => children,
|
|
11
|
+
Tabs: ({ children }: { children: ReactNode }) => children,
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
const originalSsgMd = import.meta.env.SSG_MD;
|
|
15
|
+
|
|
16
|
+
const setSsgMd = (value: boolean | undefined) => {
|
|
17
|
+
if (value === undefined) {
|
|
18
|
+
delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
(import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
setSsgMd(originalSsgMd);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('PackageManagerTabs', () => {
|
|
30
|
+
it('renders install commands as markdown code fences when SSG_MD is enabled', async () => {
|
|
31
|
+
setSsgMd(true);
|
|
32
|
+
|
|
33
|
+
expect(
|
|
34
|
+
await renderToMarkdownString(
|
|
35
|
+
<PackageManagerTabs
|
|
36
|
+
command={{
|
|
37
|
+
npm: 'npm install rspress',
|
|
38
|
+
pnpm: 'pnpm add rspress',
|
|
39
|
+
}}
|
|
40
|
+
/>,
|
|
41
|
+
),
|
|
42
|
+
).toMatchInlineSnapshot(`
|
|
43
|
+
"
|
|
44
|
+
\`\`\`sh [npm]
|
|
45
|
+
npm install rspress
|
|
46
|
+
\`\`\`
|
|
47
|
+
|
|
48
|
+
\`\`\`sh [pnpm]
|
|
49
|
+
pnpm add rspress
|
|
50
|
+
\`\`\`
|
|
51
|
+
"
|
|
52
|
+
`);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -218,7 +218,7 @@ export function PackageManagerTabs({
|
|
|
218
218
|
commandInfo = command;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
if (
|
|
221
|
+
if (import.meta.env.SSG_MD) {
|
|
222
222
|
return Object.values(commandInfo).reduce((previous, current) => {
|
|
223
223
|
const [packageManager, command] = splitTo2Parts(current);
|
|
224
224
|
return (
|