@rspress/shared 0.0.0-next-20231110091005 → 0.0.0-next-20231115072918
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.d.ts +9 -3
- package/dist/index.js +28 -1
- package/dist/index.mjs +26 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
import { RsbuildPlugin } from '@rsbuild/core';
|
2
|
-
import { RsbuildConfig } from '@rsbuild/core/rspack-provider';
|
1
|
+
import { RsbuildConfig, RsbuildPlugin } from '@rsbuild/core';
|
3
2
|
import { PluggableList } from 'unified';
|
4
3
|
|
5
4
|
interface ZoomOptions {
|
@@ -513,6 +512,7 @@ interface SiteData<ThemeConfig = NormalizedConfig> {
|
|
513
512
|
markdown: {
|
514
513
|
showLineNumbers: boolean;
|
515
514
|
defaultWrapCode: boolean;
|
515
|
+
codeHighlighter: 'prism' | 'shiki';
|
516
516
|
};
|
517
517
|
multiVersion: {
|
518
518
|
default: string;
|
@@ -646,6 +646,10 @@ interface MarkdownOptions {
|
|
646
646
|
* Register global components in mdx files
|
647
647
|
*/
|
648
648
|
globalComponents?: string[];
|
649
|
+
/**
|
650
|
+
* Code highlighter, default is prism for performance reason
|
651
|
+
*/
|
652
|
+
codeHighlighter?: 'prism' | 'shiki';
|
649
653
|
/**
|
650
654
|
* Register prism languages
|
651
655
|
*/
|
@@ -667,11 +671,13 @@ declare const MDX_REGEXP: RegExp;
|
|
667
671
|
declare const APPEARANCE_KEY = "rspress-theme-appearance";
|
668
672
|
declare const SEARCH_INDEX_NAME = "search_index";
|
669
673
|
declare const RSPRESS_TEMP_DIR = ".rspress";
|
674
|
+
declare const DEFAULT_HIGHLIGHT_LANGUAGES: (string | string[])[];
|
670
675
|
declare const isSCM: () => boolean;
|
671
676
|
declare const isProduction: () => boolean;
|
672
677
|
declare const isDebugMode: () => boolean;
|
673
678
|
declare const cleanUrl: (url: string) => string;
|
674
679
|
declare function slash(str: string): string;
|
680
|
+
declare function removeHash(str: string): string;
|
675
681
|
declare function normalizePosixPath(id: string): string;
|
676
682
|
declare const inBrowser: () => boolean;
|
677
683
|
declare function addLeadingSlash(url: string): string;
|
@@ -708,4 +714,4 @@ declare function removeBase(url: string, base: string): string;
|
|
708
714
|
declare function withoutHash(url: string): string;
|
709
715
|
declare const mergeDocConfig: (...configs: UserConfig[]) => UserConfig;
|
710
716
|
|
711
|
-
export { APPEARANCE_KEY, AdditionalPage, BaseRuntimePageInfo, Config, Config$1 as DefaultThemeConfig, DocFooter, EditLink, Feature, Footer, FrontMatterMeta, HASH_REGEXP, Header, Hero, Image, LocalSearchOptions, Locale, LocaleConfig, LocaleLink, LocaleLinks, MDX_REGEXP, MarkdownOptions, Nav, NavItem, NavItemWithChildren, NavItemWithLink, NavItemWithLinkAndChildren, NormalizedConfig, NormalizedConfig as NormalizedDefaultThemeConfig, NormalizedLocales, NormalizedSidebar, NormalizedSidebarGroup, PageData, PageIndexInfo, PageModule, PageType, RspressPlugin as Plugin, QUERY_REGEXP, RSPRESS_TEMP_DIR, RemotePageInfo, RemoteSearchIndexInfo, RemoteSearchOptions, ReplaceRule, Route, RouteMeta, RouteOptions, RspressPlugin, SEARCH_INDEX_NAME, SearchHooks, SearchOptions, Sidebar, SidebarDivider, SidebarGroup, SidebarItem, SiteData, SocialLink, SocialLinkIcon, UserConfig, addLeadingSlash, addTrailingSlash, cleanUrl, inBrowser, isDebugMode, isExternalUrl, isProduction, isSCM, mergeDocConfig, normalizeHref, normalizePosixPath, normalizeSlash, omit, parseUrl, removeBase, removeLeadingSlash, removeTrailingSlash, replaceLang, replaceVersion, slash, withBase, withoutBase, withoutHash, withoutLang };
|
717
|
+
export { APPEARANCE_KEY, AdditionalPage, BaseRuntimePageInfo, Config, DEFAULT_HIGHLIGHT_LANGUAGES, Config$1 as DefaultThemeConfig, DocFooter, EditLink, Feature, Footer, FrontMatterMeta, HASH_REGEXP, Header, Hero, Image, LocalSearchOptions, Locale, LocaleConfig, LocaleLink, LocaleLinks, MDX_REGEXP, MarkdownOptions, Nav, NavItem, NavItemWithChildren, NavItemWithLink, NavItemWithLinkAndChildren, NormalizedConfig, NormalizedConfig as NormalizedDefaultThemeConfig, NormalizedLocales, NormalizedSidebar, NormalizedSidebarGroup, PageData, PageIndexInfo, PageModule, PageType, RspressPlugin as Plugin, QUERY_REGEXP, RSPRESS_TEMP_DIR, RemotePageInfo, RemoteSearchIndexInfo, RemoteSearchOptions, ReplaceRule, Route, RouteMeta, RouteOptions, RspressPlugin, SEARCH_INDEX_NAME, SearchHooks, SearchOptions, Sidebar, SidebarDivider, SidebarGroup, SidebarItem, SiteData, SocialLink, SocialLinkIcon, UserConfig, addLeadingSlash, addTrailingSlash, cleanUrl, inBrowser, isDebugMode, isExternalUrl, isProduction, isSCM, mergeDocConfig, normalizeHref, normalizePosixPath, normalizeSlash, omit, parseUrl, removeBase, removeHash, removeLeadingSlash, removeTrailingSlash, replaceLang, replaceVersion, slash, withBase, withoutBase, withoutHash, withoutLang };
|
package/dist/index.js
CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
21
21
|
var src_exports = {};
|
22
22
|
__export(src_exports, {
|
23
23
|
APPEARANCE_KEY: () => APPEARANCE_KEY,
|
24
|
+
DEFAULT_HIGHLIGHT_LANGUAGES: () => DEFAULT_HIGHLIGHT_LANGUAGES,
|
24
25
|
HASH_REGEXP: () => HASH_REGEXP,
|
25
26
|
MDX_REGEXP: () => MDX_REGEXP,
|
26
27
|
QUERY_REGEXP: () => QUERY_REGEXP,
|
@@ -41,6 +42,7 @@ __export(src_exports, {
|
|
41
42
|
omit: () => omit,
|
42
43
|
parseUrl: () => parseUrl,
|
43
44
|
removeBase: () => removeBase,
|
45
|
+
removeHash: () => removeHash,
|
44
46
|
removeLeadingSlash: () => removeLeadingSlash,
|
45
47
|
removeTrailingSlash: () => removeTrailingSlash,
|
46
48
|
replaceLang: () => replaceLang,
|
@@ -1115,6 +1117,22 @@ var MDX_REGEXP = /\.mdx?$/;
|
|
1115
1117
|
var APPEARANCE_KEY = "rspress-theme-appearance";
|
1116
1118
|
var SEARCH_INDEX_NAME = "search_index";
|
1117
1119
|
var RSPRESS_TEMP_DIR = ".rspress";
|
1120
|
+
var DEFAULT_HIGHLIGHT_LANGUAGES = [
|
1121
|
+
["js", "javascript"],
|
1122
|
+
["ts", "typescript"],
|
1123
|
+
["jsx", "tsx"],
|
1124
|
+
"tsx",
|
1125
|
+
"json",
|
1126
|
+
"css",
|
1127
|
+
"scss",
|
1128
|
+
"less",
|
1129
|
+
["xml", "xml-doc"],
|
1130
|
+
"diff",
|
1131
|
+
"yaml",
|
1132
|
+
["md", "markdown"],
|
1133
|
+
["mdx", "tsx"],
|
1134
|
+
"bash"
|
1135
|
+
];
|
1118
1136
|
var isSCM = () => Boolean(process.env.BUILD_VERSION);
|
1119
1137
|
var isProduction = () => process.env.NODE_ENV === "production";
|
1120
1138
|
var isDebugMode = () => Boolean(process.env.DOC_DEBUG);
|
@@ -1122,6 +1140,9 @@ var cleanUrl = (url) => url.replace(HASH_REGEXP, "").replace(QUERY_REGEXP, "");
|
|
1122
1140
|
function slash(str) {
|
1123
1141
|
return str.replace(/\\/g, "/");
|
1124
1142
|
}
|
1143
|
+
function removeHash(str) {
|
1144
|
+
return str.replace(/#.*$/, "");
|
1145
|
+
}
|
1125
1146
|
function normalizePosixPath(id) {
|
1126
1147
|
const path = slash(id);
|
1127
1148
|
const isAbsolutePath = path.startsWith("/");
|
@@ -1170,6 +1191,9 @@ function replaceLang(rawUrl, lang, version, base = "") {
|
|
1170
1191
|
if (!url) {
|
1171
1192
|
url = "/index.html";
|
1172
1193
|
}
|
1194
|
+
if (url.endsWith("/")) {
|
1195
|
+
url += "index.html";
|
1196
|
+
}
|
1173
1197
|
let versionPart = "";
|
1174
1198
|
let langPart = "";
|
1175
1199
|
let purePathPart = "";
|
@@ -1245,7 +1269,8 @@ function normalizeHref(url, cleanUrls = false) {
|
|
1245
1269
|
if (url.startsWith("mailto:") || url.startsWith("tel:")) {
|
1246
1270
|
return url;
|
1247
1271
|
}
|
1248
|
-
|
1272
|
+
const hasExt = cleanUrl2.split("/").pop()?.includes(".");
|
1273
|
+
if (!cleanUrls && !cleanUrl2.endsWith(".html") && !hasExt) {
|
1249
1274
|
if (cleanUrl2.endsWith("/")) {
|
1250
1275
|
cleanUrl2 += "index.html";
|
1251
1276
|
} else {
|
@@ -1288,6 +1313,7 @@ var mergeDocConfig = (...configs) => mergeWith_default({}, ...configs, (target,
|
|
1288
1313
|
// Annotate the CommonJS export names for ESM import in node:
|
1289
1314
|
0 && (module.exports = {
|
1290
1315
|
APPEARANCE_KEY,
|
1316
|
+
DEFAULT_HIGHLIGHT_LANGUAGES,
|
1291
1317
|
HASH_REGEXP,
|
1292
1318
|
MDX_REGEXP,
|
1293
1319
|
QUERY_REGEXP,
|
@@ -1308,6 +1334,7 @@ var mergeDocConfig = (...configs) => mergeWith_default({}, ...configs, (target,
|
|
1308
1334
|
omit,
|
1309
1335
|
parseUrl,
|
1310
1336
|
removeBase,
|
1337
|
+
removeHash,
|
1311
1338
|
removeLeadingSlash,
|
1312
1339
|
removeTrailingSlash,
|
1313
1340
|
replaceLang,
|
package/dist/index.mjs
CHANGED
@@ -1060,6 +1060,22 @@ var MDX_REGEXP = /\.mdx?$/;
|
|
1060
1060
|
var APPEARANCE_KEY = "rspress-theme-appearance";
|
1061
1061
|
var SEARCH_INDEX_NAME = "search_index";
|
1062
1062
|
var RSPRESS_TEMP_DIR = ".rspress";
|
1063
|
+
var DEFAULT_HIGHLIGHT_LANGUAGES = [
|
1064
|
+
["js", "javascript"],
|
1065
|
+
["ts", "typescript"],
|
1066
|
+
["jsx", "tsx"],
|
1067
|
+
"tsx",
|
1068
|
+
"json",
|
1069
|
+
"css",
|
1070
|
+
"scss",
|
1071
|
+
"less",
|
1072
|
+
["xml", "xml-doc"],
|
1073
|
+
"diff",
|
1074
|
+
"yaml",
|
1075
|
+
["md", "markdown"],
|
1076
|
+
["mdx", "tsx"],
|
1077
|
+
"bash"
|
1078
|
+
];
|
1063
1079
|
var isSCM = () => Boolean(process.env.BUILD_VERSION);
|
1064
1080
|
var isProduction = () => process.env.NODE_ENV === "production";
|
1065
1081
|
var isDebugMode = () => Boolean(process.env.DOC_DEBUG);
|
@@ -1067,6 +1083,9 @@ var cleanUrl = (url) => url.replace(HASH_REGEXP, "").replace(QUERY_REGEXP, "");
|
|
1067
1083
|
function slash(str) {
|
1068
1084
|
return str.replace(/\\/g, "/");
|
1069
1085
|
}
|
1086
|
+
function removeHash(str) {
|
1087
|
+
return str.replace(/#.*$/, "");
|
1088
|
+
}
|
1070
1089
|
function normalizePosixPath(id) {
|
1071
1090
|
const path = slash(id);
|
1072
1091
|
const isAbsolutePath = path.startsWith("/");
|
@@ -1115,6 +1134,9 @@ function replaceLang(rawUrl, lang, version, base = "") {
|
|
1115
1134
|
if (!url) {
|
1116
1135
|
url = "/index.html";
|
1117
1136
|
}
|
1137
|
+
if (url.endsWith("/")) {
|
1138
|
+
url += "index.html";
|
1139
|
+
}
|
1118
1140
|
let versionPart = "";
|
1119
1141
|
let langPart = "";
|
1120
1142
|
let purePathPart = "";
|
@@ -1190,7 +1212,8 @@ function normalizeHref(url, cleanUrls = false) {
|
|
1190
1212
|
if (url.startsWith("mailto:") || url.startsWith("tel:")) {
|
1191
1213
|
return url;
|
1192
1214
|
}
|
1193
|
-
|
1215
|
+
const hasExt = cleanUrl2.split("/").pop()?.includes(".");
|
1216
|
+
if (!cleanUrls && !cleanUrl2.endsWith(".html") && !hasExt) {
|
1194
1217
|
if (cleanUrl2.endsWith("/")) {
|
1195
1218
|
cleanUrl2 += "index.html";
|
1196
1219
|
} else {
|
@@ -1232,6 +1255,7 @@ var mergeDocConfig = (...configs) => mergeWith_default({}, ...configs, (target,
|
|
1232
1255
|
});
|
1233
1256
|
export {
|
1234
1257
|
APPEARANCE_KEY,
|
1258
|
+
DEFAULT_HIGHLIGHT_LANGUAGES,
|
1235
1259
|
HASH_REGEXP,
|
1236
1260
|
MDX_REGEXP,
|
1237
1261
|
QUERY_REGEXP,
|
@@ -1252,6 +1276,7 @@ export {
|
|
1252
1276
|
omit,
|
1253
1277
|
parseUrl,
|
1254
1278
|
removeBase,
|
1279
|
+
removeHash,
|
1255
1280
|
removeLeadingSlash,
|
1256
1281
|
removeTrailingSlash,
|
1257
1282
|
replaceLang,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/shared",
|
3
|
-
"version": "0.0.0-next-
|
3
|
+
"version": "0.0.0-next-20231115072918",
|
4
4
|
"types": "./dist/index.d.ts",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"module": "./dist/index.mjs",
|
@@ -22,7 +22,7 @@
|
|
22
22
|
}
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@rsbuild/core": "0.0.
|
25
|
+
"@rsbuild/core": "0.0.0-next-20231115072032",
|
26
26
|
"unified": "10.1.2",
|
27
27
|
"chalk": "4.1.2",
|
28
28
|
"rslog": "^1.1.0"
|