@rspress-theme-anatole/shared 0.0.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/dist/constants.d.ts +7 -0
- package/dist/constants.js +54 -0
- package/dist/constants.mjs +18 -0
- package/dist/index.d.ts +939 -0
- package/dist/index.js +223 -0
- package/dist/index.mjs +159 -0
- package/dist/logger.d.ts +5 -0
- package/dist/logger.js +36 -0
- package/dist/logger.mjs +3 -0
- package/dist/node-utils.d.ts +762 -0
- package/dist/node-utils.js +118 -0
- package/dist/node-utils.mjs +50 -0
- package/package.json +42 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"lodash-es": function(module) {
|
|
4
|
+
module.exports = import("lodash-es");
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
var __webpack_module_cache__ = {};
|
|
8
|
+
function __webpack_require__(moduleId) {
|
|
9
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
10
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
11
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
12
|
+
exports: {}
|
|
13
|
+
};
|
|
14
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
15
|
+
return module.exports;
|
|
16
|
+
}
|
|
17
|
+
(()=>{
|
|
18
|
+
__webpack_require__.n = function(module) {
|
|
19
|
+
var getter = module && module.__esModule ? function() {
|
|
20
|
+
return module['default'];
|
|
21
|
+
} : function() {
|
|
22
|
+
return module;
|
|
23
|
+
};
|
|
24
|
+
__webpack_require__.d(getter, {
|
|
25
|
+
a: getter
|
|
26
|
+
});
|
|
27
|
+
return getter;
|
|
28
|
+
};
|
|
29
|
+
})();
|
|
30
|
+
(()=>{
|
|
31
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
32
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: definition[key]
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
(()=>{
|
|
39
|
+
__webpack_require__.o = function(obj, prop) {
|
|
40
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
(()=>{
|
|
44
|
+
__webpack_require__.r = function(exports1) {
|
|
45
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
46
|
+
value: 'Module'
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
49
|
+
value: true
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
})();
|
|
53
|
+
var __webpack_exports__ = {};
|
|
54
|
+
(()=>{
|
|
55
|
+
__webpack_require__.r(__webpack_exports__);
|
|
56
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
57
|
+
extractTextAndId: ()=>extractTextAndId,
|
|
58
|
+
loadFrontMatter: ()=>loadFrontMatter,
|
|
59
|
+
getNodeAttribute: ()=>getNodeAttribute,
|
|
60
|
+
mergeDocConfig: ()=>mergeDocConfig
|
|
61
|
+
});
|
|
62
|
+
const extractTextAndId = (title)=>{
|
|
63
|
+
if (!title) return [
|
|
64
|
+
'',
|
|
65
|
+
''
|
|
66
|
+
];
|
|
67
|
+
const customIdReg = /\\?{#.*}/;
|
|
68
|
+
const text = title.replace(customIdReg, '').trimEnd();
|
|
69
|
+
const customId = title.match(customIdReg)?.[0]?.slice(2, -1) || '';
|
|
70
|
+
return [
|
|
71
|
+
text,
|
|
72
|
+
customId
|
|
73
|
+
];
|
|
74
|
+
};
|
|
75
|
+
const getNodeAttribute = (node, attrName)=>node.attributes.find((attr)=>'name' in attr && attr.name === attrName)?.value;
|
|
76
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
77
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
78
|
+
const external_gray_matter_namespaceObject = require("gray-matter");
|
|
79
|
+
var external_gray_matter_default = /*#__PURE__*/ __webpack_require__.n(external_gray_matter_namespaceObject);
|
|
80
|
+
const core_namespaceObject = require("@rsbuild/core");
|
|
81
|
+
function loadFrontMatter(source, filepath, root, outputWarning = false) {
|
|
82
|
+
try {
|
|
83
|
+
const { content, data } = external_gray_matter_default()(source);
|
|
84
|
+
return {
|
|
85
|
+
content,
|
|
86
|
+
frontmatter: data
|
|
87
|
+
};
|
|
88
|
+
} catch (e) {
|
|
89
|
+
if (outputWarning) core_namespaceObject.logger.warn(`Parse frontmatter error in ${external_node_path_default().relative(root, filepath)}: \n`, e);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
content: '',
|
|
93
|
+
frontmatter: {}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const castArray = (value)=>Array.isArray(value) ? value : [
|
|
97
|
+
value
|
|
98
|
+
];
|
|
99
|
+
const mergeDocConfig = async (...configs)=>{
|
|
100
|
+
const { mergeWith } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "lodash-es"));
|
|
101
|
+
return mergeWith({}, ...configs, (target, source)=>{
|
|
102
|
+
const pair = [
|
|
103
|
+
target,
|
|
104
|
+
source
|
|
105
|
+
];
|
|
106
|
+
if (pair.some((item)=>void 0 === item)) return;
|
|
107
|
+
if (pair.some((item)=>Array.isArray(item))) return [
|
|
108
|
+
...castArray(target),
|
|
109
|
+
...castArray(source)
|
|
110
|
+
];
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
})();
|
|
114
|
+
var __webpack_export_target__ = exports;
|
|
115
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
116
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
117
|
+
value: true
|
|
118
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_gray_matter_90c6cd0b__ from "gray-matter";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
|
|
4
|
+
const extractTextAndId = (title)=>{
|
|
5
|
+
if (!title) return [
|
|
6
|
+
'',
|
|
7
|
+
''
|
|
8
|
+
];
|
|
9
|
+
const customIdReg = /\\?{#.*}/;
|
|
10
|
+
const text = title.replace(customIdReg, '').trimEnd();
|
|
11
|
+
const customId = title.match(customIdReg)?.[0]?.slice(2, -1) || '';
|
|
12
|
+
return [
|
|
13
|
+
text,
|
|
14
|
+
customId
|
|
15
|
+
];
|
|
16
|
+
};
|
|
17
|
+
const getNodeAttribute = (node, attrName)=>node.attributes.find((attr)=>'name' in attr && attr.name === attrName)?.value;
|
|
18
|
+
function loadFrontMatter(source, filepath, root, outputWarning = false) {
|
|
19
|
+
try {
|
|
20
|
+
const { content, data } = (0, __WEBPACK_EXTERNAL_MODULE_gray_matter_90c6cd0b__["default"])(source);
|
|
21
|
+
return {
|
|
22
|
+
content,
|
|
23
|
+
frontmatter: data
|
|
24
|
+
};
|
|
25
|
+
} catch (e) {
|
|
26
|
+
if (outputWarning) __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.logger.warn(`Parse frontmatter error in ${__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, filepath)}: \n`, e);
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
content: '',
|
|
30
|
+
frontmatter: {}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const castArray = (value)=>Array.isArray(value) ? value : [
|
|
34
|
+
value
|
|
35
|
+
];
|
|
36
|
+
const mergeDocConfig = async (...configs)=>{
|
|
37
|
+
const { mergeWith } = await import("lodash-es");
|
|
38
|
+
return mergeWith({}, ...configs, (target, source)=>{
|
|
39
|
+
const pair = [
|
|
40
|
+
target,
|
|
41
|
+
source
|
|
42
|
+
];
|
|
43
|
+
if (pair.some((item)=>void 0 === item)) return;
|
|
44
|
+
if (pair.some((item)=>Array.isArray(item))) return [
|
|
45
|
+
...castArray(target),
|
|
46
|
+
...castArray(source)
|
|
47
|
+
];
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
export { extractTextAndId, getNodeAttribute, loadFrontMatter, mergeDocConfig };
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rspress-theme-anatole/shared",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"import": "./dist/index.mjs",
|
|
9
|
+
"require": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./constants": {
|
|
12
|
+
"types": "./dist/constants.d.ts",
|
|
13
|
+
"import": "./dist/constants.mjs",
|
|
14
|
+
"require": "./dist/constants.js"
|
|
15
|
+
},
|
|
16
|
+
"./logger": {
|
|
17
|
+
"types": "./dist/logger.d.ts",
|
|
18
|
+
"import": "./dist/logger.mjs",
|
|
19
|
+
"require": "./dist/logger.js"
|
|
20
|
+
},
|
|
21
|
+
"./node-utils": {
|
|
22
|
+
"types": "./dist/node-utils.d.ts",
|
|
23
|
+
"import": "./dist/node-utils.mjs",
|
|
24
|
+
"require": "./dist/node-utils.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.mjs",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@rsbuild/core": "1.2.3",
|
|
35
|
+
"gray-matter": "4.0.3",
|
|
36
|
+
"lodash-es": "^4.17.21",
|
|
37
|
+
"unified": "^10.1.2"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
}
|
|
42
|
+
}
|