@rspress/shared 2.0.22 → 2.1.0-beta.1
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/LICENSE +21 -0
- package/dist/gray-matter.js +1 -4
- package/dist/index.d.ts +51 -4
- package/dist/index.js +2 -2
- package/dist/node-utils.d.ts +51 -4
- package/package.json +4 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present Bytedance, Inc. and its affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/gray-matter.js
CHANGED
|
@@ -22,7 +22,7 @@ moduleFactories.add({
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/index.js" (module) {
|
|
25
|
-
const fs =
|
|
25
|
+
const fs = __rspack_createRequire_require("fs");
|
|
26
26
|
const sections = rspackRequire("../../node_modules/.pnpm/section-matter@1.0.0/node_modules/section-matter/index.js");
|
|
27
27
|
const defaults = rspackRequire("../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/defaults.js");
|
|
28
28
|
const stringify = rspackRequire("../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/stringify.js");
|
|
@@ -2758,9 +2758,6 @@ moduleFactories.add({
|
|
|
2758
2758
|
if ('string' == typeof str && '\ufeff' === str.charAt(0)) return str.slice(1);
|
|
2759
2759
|
return str;
|
|
2760
2760
|
};
|
|
2761
|
-
},
|
|
2762
|
-
fs (module) {
|
|
2763
|
-
module.exports = __rspack_createRequire_require("fs");
|
|
2764
2761
|
}
|
|
2765
2762
|
});
|
|
2766
2763
|
const gray_matter = rspackRequire("../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/index.js");
|
package/dist/index.d.ts
CHANGED
|
@@ -22,10 +22,16 @@ export declare function addTrailingSlash(url: string): string;
|
|
|
22
22
|
|
|
23
23
|
export declare type BaseRuntimePageInfo = Omit<RemoveUnderscoreProps<PageIndexInfo>, 'id' | 'content' | 'domain'>;
|
|
24
24
|
|
|
25
|
+
declare type ChangeFreq = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
26
|
+
|
|
25
27
|
export declare const cleanUrl: (url: string) => string;
|
|
26
28
|
|
|
27
29
|
export declare type Config = UserConfig | Promise<UserConfig> | ((...args: Parameters<typeof loadConfig>) => UserConfig | Promise<UserConfig>);
|
|
28
30
|
|
|
31
|
+
declare interface CustomMaps {
|
|
32
|
+
[routePath: string]: Sitemap;
|
|
33
|
+
}
|
|
34
|
+
|
|
29
35
|
export declare type DarkMode = boolean | NormalizedDarkMode;
|
|
30
36
|
|
|
31
37
|
export declare interface EditLink {
|
|
@@ -165,6 +171,10 @@ export declare interface I18nText {
|
|
|
165
171
|
codeButtonGroupWrapButtonText?: I18nTextValue;
|
|
166
172
|
notFoundText?: I18nTextValue;
|
|
167
173
|
takeMeHomeText?: I18nTextValue;
|
|
174
|
+
errorTitleText?: I18nTextValue;
|
|
175
|
+
errorDescriptionText?: I18nTextValue;
|
|
176
|
+
reloadPageText?: I18nTextValue;
|
|
177
|
+
errorDetailsText?: I18nTextValue;
|
|
168
178
|
promptCopyText?: I18nTextValue;
|
|
169
179
|
promptCopiedText?: I18nTextValue;
|
|
170
180
|
promptExpandText?: I18nTextValue;
|
|
@@ -567,6 +577,8 @@ export declare const parseUrl: (url: string) => {
|
|
|
567
577
|
search: string;
|
|
568
578
|
};
|
|
569
579
|
|
|
580
|
+
declare type Priority = '0.0' | '0.1' | '0.2' | '0.3' | '0.4' | '0.5' | '0.6' | '0.7' | '0.8' | '0.9' | '1.0';
|
|
581
|
+
|
|
570
582
|
export declare const QUERY_REGEXP: RegExp;
|
|
571
583
|
|
|
572
584
|
export declare type RemarkImageOptions = {
|
|
@@ -909,6 +921,20 @@ export declare interface SiteData {
|
|
|
909
921
|
};
|
|
910
922
|
}
|
|
911
923
|
|
|
924
|
+
declare interface Sitemap {
|
|
925
|
+
loc: string;
|
|
926
|
+
lastmod?: string;
|
|
927
|
+
changefreq?: ChangeFreq;
|
|
928
|
+
priority?: Priority;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
export declare interface SitemapOptions {
|
|
932
|
+
siteUrl?: string;
|
|
933
|
+
customMaps?: CustomMaps;
|
|
934
|
+
defaultPriority?: Priority;
|
|
935
|
+
defaultChangeFreq?: ChangeFreq;
|
|
936
|
+
}
|
|
937
|
+
|
|
912
938
|
export declare function slash(str: string): string;
|
|
913
939
|
|
|
914
940
|
export declare interface SocialLink {
|
|
@@ -1054,6 +1080,11 @@ export declare interface UserConfig {
|
|
|
1054
1080
|
* Origin of the site, such as `https://example.com`.
|
|
1055
1081
|
*/
|
|
1056
1082
|
siteOrigin?: string;
|
|
1083
|
+
/**
|
|
1084
|
+
* Generate sitemap.xml during production builds.
|
|
1085
|
+
* @default true
|
|
1086
|
+
*/
|
|
1087
|
+
sitemap?: boolean | SitemapOptions;
|
|
1057
1088
|
/**
|
|
1058
1089
|
* Path to html icon file.
|
|
1059
1090
|
* @default ''
|
|
@@ -1141,7 +1172,10 @@ export declare interface UserConfig {
|
|
|
1141
1172
|
*/
|
|
1142
1173
|
search?: SearchOptions;
|
|
1143
1174
|
/**
|
|
1144
|
-
* Whether to
|
|
1175
|
+
* Whether to prerender page content into HTML at build time (SSG).
|
|
1176
|
+
* Set to `false` to generate HTML shells for client-side rendering instead.
|
|
1177
|
+
* This does not disable SSG-MD or llms.txt generation, which are controlled
|
|
1178
|
+
* independently by `llms`.
|
|
1145
1179
|
* @default true
|
|
1146
1180
|
*/
|
|
1147
1181
|
ssg?: boolean | {
|
|
@@ -1152,14 +1186,18 @@ export declare interface UserConfig {
|
|
|
1152
1186
|
experimentalWorker?: boolean;
|
|
1153
1187
|
/**
|
|
1154
1188
|
* After enabled, some pages will not be rendered by SSG, and they will directly use html under CSR. This is suitable for SSG errors in large document sites bypassing a small number of pages. It is not recommended to enable this option actively.
|
|
1189
|
+
* Only affects SSG, not SSG-MD. If excluded pages are not SSR-compatible,
|
|
1190
|
+
* fix their SSR compatibility or set `llms: false` to disable SSG-MD.
|
|
1155
1191
|
* @default []
|
|
1156
1192
|
*/
|
|
1157
1193
|
experimentalExcludeRoutePaths?: (string | RegExp)[];
|
|
1158
1194
|
};
|
|
1159
1195
|
/**
|
|
1160
|
-
* Whether to
|
|
1161
|
-
*
|
|
1162
|
-
*
|
|
1196
|
+
* Whether to render pages to Markdown (SSG-MD) and generate llms.txt and
|
|
1197
|
+
* llms-full.txt at build time.
|
|
1198
|
+
* Independent of `ssg`: these files are still generated when `ssg: false`.
|
|
1199
|
+
* Set to `false` to disable these outputs without affecting SSG.
|
|
1200
|
+
* @default true
|
|
1163
1201
|
*/
|
|
1164
1202
|
llms?: boolean | {
|
|
1165
1203
|
/**
|
|
@@ -1172,6 +1210,15 @@ export declare interface UserConfig {
|
|
|
1172
1210
|
*/
|
|
1173
1211
|
remarkSplitMdxOptions?: RemarkSplitMdxOptions;
|
|
1174
1212
|
};
|
|
1213
|
+
/**
|
|
1214
|
+
* Expose built-in documentation tools through the browser WebMCP API.
|
|
1215
|
+
* Markdown tools require `llms: true` in production.
|
|
1216
|
+
* @default true
|
|
1217
|
+
* @experimental
|
|
1218
|
+
*/
|
|
1219
|
+
webMcp?: boolean | {
|
|
1220
|
+
exposedTo?: string[];
|
|
1221
|
+
};
|
|
1175
1222
|
/**
|
|
1176
1223
|
* Whether to enable medium-zoom
|
|
1177
1224
|
* @default true
|
package/dist/index.js
CHANGED
|
@@ -132,7 +132,7 @@ function normalizeSlash(url) {
|
|
|
132
132
|
function withBase(url, base) {
|
|
133
133
|
const normalizedUrl = addLeadingSlash(url);
|
|
134
134
|
const normalizedBase = normalizeSlash(base);
|
|
135
|
-
const hasBase = normalizedUrl.startsWith(normalizedBase);
|
|
135
|
+
const hasBase = normalizedUrl === normalizedBase || normalizedUrl.startsWith(`${normalizedBase}/`);
|
|
136
136
|
if (hasBase) {
|
|
137
137
|
if (`${normalizedUrl}/` === base) return base;
|
|
138
138
|
return normalizedUrl;
|
|
@@ -146,7 +146,7 @@ function withSiteOrigin(url, siteOrigin) {
|
|
|
146
146
|
function removeBase(url, base) {
|
|
147
147
|
const normalizedUrl = addLeadingSlash(url);
|
|
148
148
|
const normalizedBase = normalizeSlash(base);
|
|
149
|
-
const removedBaseUrl = normalizedUrl.replace(new RegExp(`^${normalizedBase}`), '');
|
|
149
|
+
const removedBaseUrl = normalizedUrl.replace(new RegExp(`^${normalizedBase}(?=/|$)`), '');
|
|
150
150
|
if ('' === removedBaseUrl) return '/';
|
|
151
151
|
return removedBaseUrl;
|
|
152
152
|
}
|
package/dist/node-utils.d.ts
CHANGED
|
@@ -18,6 +18,12 @@ declare interface AdditionalPage {
|
|
|
18
18
|
filepath?: string;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
declare type ChangeFreq = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
22
|
+
|
|
23
|
+
declare interface CustomMaps {
|
|
24
|
+
[routePath: string]: Sitemap;
|
|
25
|
+
}
|
|
26
|
+
|
|
21
27
|
declare type DarkMode = boolean | NormalizedDarkMode;
|
|
22
28
|
|
|
23
29
|
declare interface EditLink {
|
|
@@ -166,6 +172,10 @@ declare interface I18nText {
|
|
|
166
172
|
codeButtonGroupWrapButtonText?: I18nTextValue;
|
|
167
173
|
notFoundText?: I18nTextValue;
|
|
168
174
|
takeMeHomeText?: I18nTextValue;
|
|
175
|
+
errorTitleText?: I18nTextValue;
|
|
176
|
+
errorDescriptionText?: I18nTextValue;
|
|
177
|
+
reloadPageText?: I18nTextValue;
|
|
178
|
+
errorDetailsText?: I18nTextValue;
|
|
169
179
|
promptCopyText?: I18nTextValue;
|
|
170
180
|
promptCopiedText?: I18nTextValue;
|
|
171
181
|
promptExpandText?: I18nTextValue;
|
|
@@ -487,6 +497,8 @@ declare interface PageIndexInfo {
|
|
|
487
497
|
|
|
488
498
|
declare type PageType = 'home' | 'doc' | 'doc-wide' | 'custom' | '404' | 'blank';
|
|
489
499
|
|
|
500
|
+
declare type Priority = '0.0' | '0.1' | '0.2' | '0.3' | '0.4' | '0.5' | '0.6' | '0.7' | '0.8' | '0.9' | '1.0';
|
|
501
|
+
|
|
490
502
|
declare type RemarkImageOptions = {
|
|
491
503
|
/**
|
|
492
504
|
* Whether to enable check dead images
|
|
@@ -744,6 +756,20 @@ declare type SidebarSectionHeader = {
|
|
|
744
756
|
tag?: string;
|
|
745
757
|
};
|
|
746
758
|
|
|
759
|
+
declare interface Sitemap {
|
|
760
|
+
loc: string;
|
|
761
|
+
lastmod?: string;
|
|
762
|
+
changefreq?: ChangeFreq;
|
|
763
|
+
priority?: Priority;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
declare interface SitemapOptions {
|
|
767
|
+
siteUrl?: string;
|
|
768
|
+
customMaps?: CustomMaps;
|
|
769
|
+
defaultPriority?: Priority;
|
|
770
|
+
defaultChangeFreq?: ChangeFreq;
|
|
771
|
+
}
|
|
772
|
+
|
|
747
773
|
declare interface SocialLink {
|
|
748
774
|
icon: SocialLinkIcon;
|
|
749
775
|
mode: 'link' | 'text' | 'img' | 'dom' | 'github-stars';
|
|
@@ -883,6 +909,11 @@ declare interface UserConfig {
|
|
|
883
909
|
* Origin of the site, such as `https://example.com`.
|
|
884
910
|
*/
|
|
885
911
|
siteOrigin?: string;
|
|
912
|
+
/**
|
|
913
|
+
* Generate sitemap.xml during production builds.
|
|
914
|
+
* @default true
|
|
915
|
+
*/
|
|
916
|
+
sitemap?: boolean | SitemapOptions;
|
|
886
917
|
/**
|
|
887
918
|
* Path to html icon file.
|
|
888
919
|
* @default ''
|
|
@@ -970,7 +1001,10 @@ declare interface UserConfig {
|
|
|
970
1001
|
*/
|
|
971
1002
|
search?: SearchOptions;
|
|
972
1003
|
/**
|
|
973
|
-
* Whether to
|
|
1004
|
+
* Whether to prerender page content into HTML at build time (SSG).
|
|
1005
|
+
* Set to `false` to generate HTML shells for client-side rendering instead.
|
|
1006
|
+
* This does not disable SSG-MD or llms.txt generation, which are controlled
|
|
1007
|
+
* independently by `llms`.
|
|
974
1008
|
* @default true
|
|
975
1009
|
*/
|
|
976
1010
|
ssg?: boolean | {
|
|
@@ -981,14 +1015,18 @@ declare interface UserConfig {
|
|
|
981
1015
|
experimentalWorker?: boolean;
|
|
982
1016
|
/**
|
|
983
1017
|
* After enabled, some pages will not be rendered by SSG, and they will directly use html under CSR. This is suitable for SSG errors in large document sites bypassing a small number of pages. It is not recommended to enable this option actively.
|
|
1018
|
+
* Only affects SSG, not SSG-MD. If excluded pages are not SSR-compatible,
|
|
1019
|
+
* fix their SSR compatibility or set `llms: false` to disable SSG-MD.
|
|
984
1020
|
* @default []
|
|
985
1021
|
*/
|
|
986
1022
|
experimentalExcludeRoutePaths?: (string | RegExp)[];
|
|
987
1023
|
};
|
|
988
1024
|
/**
|
|
989
|
-
* Whether to
|
|
990
|
-
*
|
|
991
|
-
*
|
|
1025
|
+
* Whether to render pages to Markdown (SSG-MD) and generate llms.txt and
|
|
1026
|
+
* llms-full.txt at build time.
|
|
1027
|
+
* Independent of `ssg`: these files are still generated when `ssg: false`.
|
|
1028
|
+
* Set to `false` to disable these outputs without affecting SSG.
|
|
1029
|
+
* @default true
|
|
992
1030
|
*/
|
|
993
1031
|
llms?: boolean | {
|
|
994
1032
|
/**
|
|
@@ -1001,6 +1039,15 @@ declare interface UserConfig {
|
|
|
1001
1039
|
*/
|
|
1002
1040
|
remarkSplitMdxOptions?: RemarkSplitMdxOptions;
|
|
1003
1041
|
};
|
|
1042
|
+
/**
|
|
1043
|
+
* Expose built-in documentation tools through the browser WebMCP API.
|
|
1044
|
+
* Markdown tools require `llms: true` in production.
|
|
1045
|
+
* @default true
|
|
1046
|
+
* @experimental
|
|
1047
|
+
*/
|
|
1048
|
+
webMcp?: boolean | {
|
|
1049
|
+
exposedTo?: string[];
|
|
1050
|
+
};
|
|
1004
1051
|
/**
|
|
1005
1052
|
* Whether to enable medium-zoom
|
|
1006
1053
|
* @default true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/shared",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.1.0-beta.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/web-infra-dev/rspress.git",
|
|
@@ -45,13 +45,14 @@
|
|
|
45
45
|
"dist"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@rsbuild/core": "^2.2.
|
|
48
|
+
"@rsbuild/core": "^2.2.12",
|
|
49
49
|
"@shikijs/rehype": "^4.2.0",
|
|
50
50
|
"@types/react": "^19.2.18",
|
|
51
51
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
52
52
|
"unified": "^11.0.5"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
+
"@rspress/config": "1.0.0",
|
|
55
56
|
"@types/lodash-es": "^4.17.12",
|
|
56
57
|
"@types/node": "^22.8.1",
|
|
57
58
|
"github-slugger": "^2.0.0",
|
|
@@ -60,8 +61,7 @@
|
|
|
60
61
|
"medium-zoom": "1.1.0",
|
|
61
62
|
"rimraf": "^6.1.3",
|
|
62
63
|
"rsbuild-plugin-publint": "^1.0.0",
|
|
63
|
-
"typescript": "^6.0.3"
|
|
64
|
-
"@rspress/config": "1.0.0"
|
|
64
|
+
"typescript": "^6.0.3"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public",
|