@rspress/shared 1.6.2 → 1.7.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.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,6 +671,7 @@ 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;
@@ -709,4 +714,4 @@ declare function removeBase(url: string, base: string): string;
709
714
  declare function withoutHash(url: string): string;
710
715
  declare const mergeDocConfig: (...configs: UserConfig[]) => UserConfig;
711
716
 
712
- 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, removeHash, 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,
@@ -1116,6 +1117,22 @@ var MDX_REGEXP = /\.mdx?$/;
1116
1117
  var APPEARANCE_KEY = "rspress-theme-appearance";
1117
1118
  var SEARCH_INDEX_NAME = "search_index";
1118
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
+ ];
1119
1136
  var isSCM = () => Boolean(process.env.BUILD_VERSION);
1120
1137
  var isProduction = () => process.env.NODE_ENV === "production";
1121
1138
  var isDebugMode = () => Boolean(process.env.DOC_DEBUG);
@@ -1252,7 +1269,8 @@ function normalizeHref(url, cleanUrls = false) {
1252
1269
  if (url.startsWith("mailto:") || url.startsWith("tel:")) {
1253
1270
  return url;
1254
1271
  }
1255
- if (!cleanUrls && !cleanUrl2.endsWith(".html")) {
1272
+ const hasExt = cleanUrl2.split("/").pop()?.includes(".");
1273
+ if (!cleanUrls && !cleanUrl2.endsWith(".html") && !hasExt) {
1256
1274
  if (cleanUrl2.endsWith("/")) {
1257
1275
  cleanUrl2 += "index.html";
1258
1276
  } else {
@@ -1295,6 +1313,7 @@ var mergeDocConfig = (...configs) => mergeWith_default({}, ...configs, (target,
1295
1313
  // Annotate the CommonJS export names for ESM import in node:
1296
1314
  0 && (module.exports = {
1297
1315
  APPEARANCE_KEY,
1316
+ DEFAULT_HIGHLIGHT_LANGUAGES,
1298
1317
  HASH_REGEXP,
1299
1318
  MDX_REGEXP,
1300
1319
  QUERY_REGEXP,
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);
@@ -1196,7 +1212,8 @@ function normalizeHref(url, cleanUrls = false) {
1196
1212
  if (url.startsWith("mailto:") || url.startsWith("tel:")) {
1197
1213
  return url;
1198
1214
  }
1199
- if (!cleanUrls && !cleanUrl2.endsWith(".html")) {
1215
+ const hasExt = cleanUrl2.split("/").pop()?.includes(".");
1216
+ if (!cleanUrls && !cleanUrl2.endsWith(".html") && !hasExt) {
1200
1217
  if (cleanUrl2.endsWith("/")) {
1201
1218
  cleanUrl2 += "index.html";
1202
1219
  } else {
@@ -1238,6 +1255,7 @@ var mergeDocConfig = (...configs) => mergeWith_default({}, ...configs, (target,
1238
1255
  });
1239
1256
  export {
1240
1257
  APPEARANCE_KEY,
1258
+ DEFAULT_HIGHLIGHT_LANGUAGES,
1241
1259
  HASH_REGEXP,
1242
1260
  MDX_REGEXP,
1243
1261
  QUERY_REGEXP,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/shared",
3
- "version": "1.6.2",
3
+ "version": "1.7.0",
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.14",
25
+ "@rsbuild/core": "0.0.24",
26
26
  "unified": "10.1.2",
27
27
  "chalk": "4.1.2",
28
28
  "rslog": "^1.1.0"