@rspress/shared 2.0.0-alpha.1 → 2.0.0-alpha.10
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/constants.js +10 -4
- package/dist/index.d.ts +2 -5
- package/dist/index.js +72 -10
- package/dist/index.mjs +6 -6
- package/dist/logger.js +6 -4
- package/dist/node-utils.d.ts +8 -7
- package/dist/node-utils.js +16 -5
- package/dist/node-utils.mjs +4 -1
- package/package.json +7 -8
package/dist/constants.js
CHANGED
@@ -12,7 +12,7 @@ var __webpack_require__ = {};
|
|
12
12
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
13
13
|
})();
|
14
14
|
(()=>{
|
15
|
-
__webpack_require__.r =
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
16
16
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
17
17
|
value: 'Module'
|
18
18
|
});
|
@@ -45,8 +45,14 @@ const DEFAULT_PAGE_EXTENSIONS = [
|
|
45
45
|
'.md',
|
46
46
|
'.mdx'
|
47
47
|
];
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
exports.DEFAULT_CONFIG_EXTENSIONS = __webpack_exports__.DEFAULT_CONFIG_EXTENSIONS;
|
49
|
+
exports.DEFAULT_CONFIG_NAME = __webpack_exports__.DEFAULT_CONFIG_NAME;
|
50
|
+
exports.DEFAULT_PAGE_EXTENSIONS = __webpack_exports__.DEFAULT_PAGE_EXTENSIONS;
|
51
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
52
|
+
"DEFAULT_CONFIG_EXTENSIONS",
|
53
|
+
"DEFAULT_CONFIG_NAME",
|
54
|
+
"DEFAULT_PAGE_EXTENSIONS"
|
55
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
56
|
+
Object.defineProperty(exports, '__esModule', {
|
51
57
|
value: true
|
52
58
|
});
|
package/dist/index.d.ts
CHANGED
@@ -210,6 +210,7 @@ export declare interface FrontMatterMeta {
|
|
210
210
|
titleSuffix?: string;
|
211
211
|
head?: [string, Record<string, string>][];
|
212
212
|
context?: string;
|
213
|
+
footer?: boolean;
|
213
214
|
[key: string]: unknown;
|
214
215
|
}
|
215
216
|
|
@@ -736,10 +737,6 @@ export declare type SocialLinkIcon = 'lark' | 'discord' | 'facebook' | 'github'
|
|
736
737
|
svg: string;
|
737
738
|
};
|
738
739
|
|
739
|
-
export declare type SSGConfig = boolean | {
|
740
|
-
strict?: boolean;
|
741
|
-
};
|
742
|
-
|
743
740
|
export declare interface UserConfig<ThemeConfig = DefaultThemeConfig> {
|
744
741
|
/**
|
745
742
|
* The root directory of the site.
|
@@ -840,7 +837,7 @@ export declare interface UserConfig<ThemeConfig = DefaultThemeConfig> {
|
|
840
837
|
/**
|
841
838
|
* Whether to enable ssg, default is true
|
842
839
|
*/
|
843
|
-
ssg?:
|
840
|
+
ssg?: boolean;
|
844
841
|
/**
|
845
842
|
* Whether to enable medium-zoom, default is true
|
846
843
|
*/
|
package/dist/index.js
CHANGED
@@ -12,7 +12,7 @@ var __webpack_require__ = {};
|
|
12
12
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
13
13
|
})();
|
14
14
|
(()=>{
|
15
|
-
__webpack_require__.r =
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
16
16
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
17
17
|
value: 'Module'
|
18
18
|
});
|
@@ -190,13 +190,13 @@ const parseUrl = (url)=>{
|
|
190
190
|
function normalizeHref(url, cleanUrls = false) {
|
191
191
|
if (!url) return '/';
|
192
192
|
if (isExternalUrl(url)) return url;
|
193
|
+
if (url.startsWith('#')) return url;
|
193
194
|
let { url: cleanUrl, hash } = parseUrl(decodeURIComponent(url));
|
194
|
-
if (
|
195
|
-
if (cleanUrl.endsWith('
|
196
|
-
|
197
|
-
}
|
198
|
-
|
199
|
-
if (cleanUrls && cleanUrl.endsWith('.html')) cleanUrl = cleanUrl.replace(/\.html$/, '');
|
195
|
+
if (cleanUrls) {
|
196
|
+
if (cleanUrl.endsWith('.html')) cleanUrl = cleanUrl.replace(/\.html$/, '');
|
197
|
+
if (cleanUrls && cleanUrl.endsWith('/index')) cleanUrl = cleanUrl.replace(/\/index$/, '/');
|
198
|
+
} else if (!cleanUrl.endsWith('.html')) if (cleanUrl.endsWith('/')) cleanUrl += 'index.html';
|
199
|
+
else cleanUrl += '.html';
|
200
200
|
return addLeadingSlash(hash ? `${cleanUrl}#${hash}` : cleanUrl);
|
201
201
|
}
|
202
202
|
function withoutLang(path, langs) {
|
@@ -214,8 +214,70 @@ function withBase(url, base) {
|
|
214
214
|
function removeBase(url, base) {
|
215
215
|
return addLeadingSlash(url).replace(new RegExp(`^${normalizeSlash(base)}`), '');
|
216
216
|
}
|
217
|
-
|
218
|
-
|
219
|
-
|
217
|
+
exports.APPEARANCE_KEY = __webpack_exports__.APPEARANCE_KEY;
|
218
|
+
exports.DEFAULT_HIGHLIGHT_LANGUAGES = __webpack_exports__.DEFAULT_HIGHLIGHT_LANGUAGES;
|
219
|
+
exports.HASH_REGEXP = __webpack_exports__.HASH_REGEXP;
|
220
|
+
exports.MDX_OR_MD_REGEXP = __webpack_exports__.MDX_OR_MD_REGEXP;
|
221
|
+
exports.QUERY_REGEXP = __webpack_exports__.QUERY_REGEXP;
|
222
|
+
exports.RSPRESS_TEMP_DIR = __webpack_exports__.RSPRESS_TEMP_DIR;
|
223
|
+
exports.SEARCH_INDEX_NAME = __webpack_exports__.SEARCH_INDEX_NAME;
|
224
|
+
exports.addLeadingSlash = __webpack_exports__.addLeadingSlash;
|
225
|
+
exports.addTrailingSlash = __webpack_exports__.addTrailingSlash;
|
226
|
+
exports.cleanUrl = __webpack_exports__.cleanUrl;
|
227
|
+
exports.inBrowser = __webpack_exports__.inBrowser;
|
228
|
+
exports.isDataUrl = __webpack_exports__.isDataUrl;
|
229
|
+
exports.isDebugMode = __webpack_exports__.isDebugMode;
|
230
|
+
exports.isDevDebugMode = __webpack_exports__.isDevDebugMode;
|
231
|
+
exports.isExternalUrl = __webpack_exports__.isExternalUrl;
|
232
|
+
exports.isProduction = __webpack_exports__.isProduction;
|
233
|
+
exports.isSCM = __webpack_exports__.isSCM;
|
234
|
+
exports.normalizeHref = __webpack_exports__.normalizeHref;
|
235
|
+
exports.normalizePosixPath = __webpack_exports__.normalizePosixPath;
|
236
|
+
exports.normalizeSlash = __webpack_exports__.normalizeSlash;
|
237
|
+
exports.parseUrl = __webpack_exports__.parseUrl;
|
238
|
+
exports.removeBase = __webpack_exports__.removeBase;
|
239
|
+
exports.removeHash = __webpack_exports__.removeHash;
|
240
|
+
exports.removeLeadingSlash = __webpack_exports__.removeLeadingSlash;
|
241
|
+
exports.removeTrailingSlash = __webpack_exports__.removeTrailingSlash;
|
242
|
+
exports.replaceLang = __webpack_exports__.replaceLang;
|
243
|
+
exports.replaceVersion = __webpack_exports__.replaceVersion;
|
244
|
+
exports.slash = __webpack_exports__.slash;
|
245
|
+
exports.withBase = __webpack_exports__.withBase;
|
246
|
+
exports.withoutBase = __webpack_exports__.withoutBase;
|
247
|
+
exports.withoutLang = __webpack_exports__.withoutLang;
|
248
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
249
|
+
"APPEARANCE_KEY",
|
250
|
+
"DEFAULT_HIGHLIGHT_LANGUAGES",
|
251
|
+
"HASH_REGEXP",
|
252
|
+
"MDX_OR_MD_REGEXP",
|
253
|
+
"QUERY_REGEXP",
|
254
|
+
"RSPRESS_TEMP_DIR",
|
255
|
+
"SEARCH_INDEX_NAME",
|
256
|
+
"addLeadingSlash",
|
257
|
+
"addTrailingSlash",
|
258
|
+
"cleanUrl",
|
259
|
+
"inBrowser",
|
260
|
+
"isDataUrl",
|
261
|
+
"isDebugMode",
|
262
|
+
"isDevDebugMode",
|
263
|
+
"isExternalUrl",
|
264
|
+
"isProduction",
|
265
|
+
"isSCM",
|
266
|
+
"normalizeHref",
|
267
|
+
"normalizePosixPath",
|
268
|
+
"normalizeSlash",
|
269
|
+
"parseUrl",
|
270
|
+
"removeBase",
|
271
|
+
"removeHash",
|
272
|
+
"removeLeadingSlash",
|
273
|
+
"removeTrailingSlash",
|
274
|
+
"replaceLang",
|
275
|
+
"replaceVersion",
|
276
|
+
"slash",
|
277
|
+
"withBase",
|
278
|
+
"withoutBase",
|
279
|
+
"withoutLang"
|
280
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
281
|
+
Object.defineProperty(exports, '__esModule', {
|
220
282
|
value: true
|
221
283
|
});
|
package/dist/index.mjs
CHANGED
@@ -132,13 +132,13 @@ const parseUrl = (url)=>{
|
|
132
132
|
function normalizeHref(url, cleanUrls = false) {
|
133
133
|
if (!url) return '/';
|
134
134
|
if (isExternalUrl(url)) return url;
|
135
|
+
if (url.startsWith('#')) return url;
|
135
136
|
let { url: cleanUrl, hash } = parseUrl(decodeURIComponent(url));
|
136
|
-
if (
|
137
|
-
if (cleanUrl.endsWith('
|
138
|
-
|
139
|
-
}
|
140
|
-
|
141
|
-
if (cleanUrls && cleanUrl.endsWith('.html')) cleanUrl = cleanUrl.replace(/\.html$/, '');
|
137
|
+
if (cleanUrls) {
|
138
|
+
if (cleanUrl.endsWith('.html')) cleanUrl = cleanUrl.replace(/\.html$/, '');
|
139
|
+
if (cleanUrls && cleanUrl.endsWith('/index')) cleanUrl = cleanUrl.replace(/\/index$/, '/');
|
140
|
+
} else if (!cleanUrl.endsWith('.html')) if (cleanUrl.endsWith('/')) cleanUrl += 'index.html';
|
141
|
+
else cleanUrl += '.html';
|
142
142
|
return addLeadingSlash(hash ? `${cleanUrl}#${hash}` : cleanUrl);
|
143
143
|
}
|
144
144
|
function withoutLang(path, langs) {
|
package/dist/logger.js
CHANGED
@@ -12,7 +12,7 @@ var __webpack_require__ = {};
|
|
12
12
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
13
13
|
})();
|
14
14
|
(()=>{
|
15
|
-
__webpack_require__.r =
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
16
16
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
17
17
|
value: 'Module'
|
18
18
|
});
|
@@ -27,8 +27,10 @@ __webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
logger: ()=>core_namespaceObject.logger
|
28
28
|
});
|
29
29
|
const core_namespaceObject = require("@rsbuild/core");
|
30
|
-
|
31
|
-
for(var __webpack_i__ in __webpack_exports__)
|
32
|
-
|
30
|
+
exports.logger = __webpack_exports__.logger;
|
31
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
32
|
+
"logger"
|
33
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
34
|
+
Object.defineProperty(exports, '__esModule', {
|
33
35
|
value: true
|
34
36
|
});
|
package/dist/node-utils.d.ts
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
import {
|
1
|
+
import type { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
|
2
|
+
import type { MdxJsxAttributeValueExpression } from 'mdast-util-mdx-jsx';
|
3
|
+
import type { MdxJsxExpressionAttribute } from 'mdast-util-mdx-jsx';
|
2
4
|
import type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
|
3
5
|
import type { MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
4
6
|
import type { PluggableList } from 'unified';
|
@@ -201,10 +203,13 @@ declare interface FrontMatterMeta {
|
|
201
203
|
titleSuffix?: string;
|
202
204
|
head?: [string, Record<string, string>][];
|
203
205
|
context?: string;
|
206
|
+
footer?: boolean;
|
204
207
|
[key: string]: unknown;
|
205
208
|
}
|
206
209
|
|
207
|
-
export declare
|
210
|
+
export declare function getNodeAttribute(node: MdxJsxFlowElement | MdxJsxTextElement, attrName: string, attribute?: false): string | MdxJsxAttributeValueExpression | null | undefined;
|
211
|
+
|
212
|
+
export declare function getNodeAttribute(node: MdxJsxFlowElement | MdxJsxTextElement, attrName: string, attribute: true): MdxJsxAttribute | MdxJsxExpressionAttribute | undefined;
|
208
213
|
|
209
214
|
declare interface Header {
|
210
215
|
id: string;
|
@@ -565,10 +570,6 @@ declare type SocialLinkIcon = 'lark' | 'discord' | 'facebook' | 'github' | 'inst
|
|
565
570
|
svg: string;
|
566
571
|
};
|
567
572
|
|
568
|
-
declare type SSGConfig = boolean | {
|
569
|
-
strict?: boolean;
|
570
|
-
};
|
571
|
-
|
572
573
|
declare interface UserConfig<ThemeConfig = Config> {
|
573
574
|
/**
|
574
575
|
* The root directory of the site.
|
@@ -669,7 +670,7 @@ declare interface UserConfig<ThemeConfig = Config> {
|
|
669
670
|
/**
|
670
671
|
* Whether to enable ssg, default is true
|
671
672
|
*/
|
672
|
-
ssg?:
|
673
|
+
ssg?: boolean;
|
673
674
|
/**
|
674
675
|
* Whether to enable medium-zoom, default is true
|
675
676
|
*/
|
package/dist/node-utils.js
CHANGED
@@ -35,7 +35,7 @@ function __webpack_require__(moduleId) {
|
|
35
35
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
36
36
|
})();
|
37
37
|
(()=>{
|
38
|
-
__webpack_require__.r =
|
38
|
+
__webpack_require__.r = (exports1)=>{
|
39
39
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
40
40
|
value: 'Module'
|
41
41
|
});
|
@@ -66,7 +66,10 @@ var __webpack_exports__ = {};
|
|
66
66
|
customId
|
67
67
|
];
|
68
68
|
};
|
69
|
-
|
69
|
+
function getNodeAttribute(node, attrName, attribute) {
|
70
|
+
const found = node.attributes.find((attr)=>'name' in attr && attr.name === attrName);
|
71
|
+
return attribute ? found : found?.value;
|
72
|
+
}
|
70
73
|
const external_node_path_namespaceObject = require("node:path");
|
71
74
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
72
75
|
const external_gray_matter_namespaceObject = require("gray-matter");
|
@@ -105,8 +108,16 @@ var __webpack_exports__ = {};
|
|
105
108
|
});
|
106
109
|
};
|
107
110
|
})();
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
+
exports.extractTextAndId = __webpack_exports__.extractTextAndId;
|
112
|
+
exports.getNodeAttribute = __webpack_exports__.getNodeAttribute;
|
113
|
+
exports.loadFrontMatter = __webpack_exports__.loadFrontMatter;
|
114
|
+
exports.mergeDocConfig = __webpack_exports__.mergeDocConfig;
|
115
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
116
|
+
"extractTextAndId",
|
117
|
+
"getNodeAttribute",
|
118
|
+
"loadFrontMatter",
|
119
|
+
"mergeDocConfig"
|
120
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
121
|
+
Object.defineProperty(exports, '__esModule', {
|
111
122
|
value: true
|
112
123
|
});
|
package/dist/node-utils.mjs
CHANGED
@@ -14,7 +14,10 @@ const extractTextAndId = (title)=>{
|
|
14
14
|
customId
|
15
15
|
];
|
16
16
|
};
|
17
|
-
|
17
|
+
function getNodeAttribute(node, attrName, attribute) {
|
18
|
+
const found = node.attributes.find((attr)=>'name' in attr && attr.name === attrName);
|
19
|
+
return attribute ? found : found?.value;
|
20
|
+
}
|
18
21
|
function loadFrontMatter(source, filepath, root, outputWarning = false) {
|
19
22
|
try {
|
20
23
|
const { content, data } = (0, __WEBPACK_EXTERNAL_MODULE_gray_matter_90c6cd0b__["default"])(source);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/shared",
|
3
|
-
"version": "2.0.0-alpha.
|
3
|
+
"version": "2.0.0-alpha.10",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "https://github.com/web-infra-dev/rspress",
|
@@ -36,22 +36,21 @@
|
|
36
36
|
"dist"
|
37
37
|
],
|
38
38
|
"dependencies": {
|
39
|
-
"@rsbuild/core": "1.
|
39
|
+
"@rsbuild/core": "1.3.4",
|
40
40
|
"gray-matter": "4.0.3",
|
41
41
|
"lodash-es": "^4.17.21",
|
42
|
-
"unified": "^
|
42
|
+
"unified": "^11.0.5"
|
43
43
|
},
|
44
44
|
"devDependencies": {
|
45
|
-
"@rslib/core": "0.
|
46
|
-
"@types/fs-extra": "11.0.4",
|
45
|
+
"@rslib/core": "0.6.1",
|
47
46
|
"@types/jest": "~29.5.14",
|
48
47
|
"@types/lodash-es": "^4.17.12",
|
49
48
|
"@types/node": "^18.11.17",
|
50
|
-
"@types/react": "^18.3.
|
51
|
-
"mdast-util-mdx-jsx": "^2.
|
49
|
+
"@types/react": "^18.3.20",
|
50
|
+
"mdast-util-mdx-jsx": "^3.2.0",
|
52
51
|
"medium-zoom": "1.1.0",
|
53
52
|
"rimraf": "^6.0.1",
|
54
|
-
"typescript": "^5.
|
53
|
+
"typescript": "^5.8.2"
|
55
54
|
},
|
56
55
|
"publishConfig": {
|
57
56
|
"access": "public",
|