@rspress-theme-anatole/core 0.7.2 → 0.7.4
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.js +1709 -1707
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,1707 +1,1709 @@
|
|
|
1
|
-
import __rslib_shim_module__ from 'module';
|
|
2
|
-
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rspress_plugin_container_syntax_12d3c700__ from "@rspress-theme-anatole/plugin-container-syntax";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress-theme-anatole/shared";
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
|
|
6
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
7
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_less_4c557a99__ from "@rsbuild/plugin-less";
|
|
8
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__ from "@rsbuild/plugin-react";
|
|
9
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_sass_b13a7d33__ from "@rsbuild/plugin-sass";
|
|
10
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
|
|
11
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__ from "@rspress-theme-anatole/shared/constants";
|
|
12
|
-
import * as __WEBPACK_EXTERNAL_MODULE_tinyglobby__ from "tinyglobby";
|
|
13
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
|
|
14
|
-
import * as __WEBPACK_EXTERNAL_MODULE_rspack_plugin_virtual_module_609978fd__ from "rspack-plugin-virtual-module";
|
|
15
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__ from "@rspress-theme-anatole/shared/logger";
|
|
16
|
-
import * as __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__ from "lodash-es";
|
|
17
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__ from "node:crypto";
|
|
18
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rspress_mdx_rs_d2f3021f__ from "@rspress/mdx-rs";
|
|
19
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__ from "@rspress-theme-anatole/shared/node-utils";
|
|
20
|
-
import * as __WEBPACK_EXTERNAL_MODULE_html_to_text_2c51ed38__ from "html-to-text";
|
|
21
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
22
|
-
import * as __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__ from "@mdx-js/mdx";
|
|
23
|
-
import * as __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__ from "enhanced-resolve";
|
|
24
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
|
|
25
|
-
import * as __WEBPACK_EXTERNAL_MODULE_picocolors__ from "picocolors";
|
|
26
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__ from "react-helmet-async";
|
|
27
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
|
|
28
|
-
export * from "@rspress-theme-anatole/shared";
|
|
29
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
30
|
-
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
31
|
-
}
|
|
32
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
33
|
-
if (descriptor.get) return descriptor.get.call(receiver);
|
|
34
|
-
return descriptor.value;
|
|
35
|
-
}
|
|
36
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
37
|
-
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
38
|
-
else {
|
|
39
|
-
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
40
|
-
descriptor.value = value;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
44
|
-
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
45
|
-
return privateMap.get(receiver);
|
|
46
|
-
}
|
|
47
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
48
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
49
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
50
|
-
}
|
|
51
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
52
|
-
_check_private_redeclaration(obj, privateMap);
|
|
53
|
-
privateMap.set(obj, value);
|
|
54
|
-
}
|
|
55
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
56
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
57
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
58
|
-
return value;
|
|
59
|
-
}
|
|
60
|
-
var _config = /*#__PURE__*/ new WeakMap(), _plugins = /*#__PURE__*/ new WeakMap(), _isProd = /*#__PURE__*/ new WeakMap();
|
|
61
|
-
class PluginDriver {
|
|
62
|
-
async init() {
|
|
63
|
-
var _themeConfig_locales, _themeConfig_locales_, _themeConfig_locales1, _themeConfig_locales_1, _themeConfig_locales2;
|
|
64
|
-
this.clearPlugins();
|
|
65
|
-
const config = _class_private_field_get(this, _config);
|
|
66
|
-
const themeConfig = (null == config ? void 0 : config.themeConfig) || {};
|
|
67
|
-
const enableLastUpdated = (null == themeConfig ? void 0 : themeConfig.lastUpdated) || (null == themeConfig ? void 0 : null === (_themeConfig_locales = themeConfig.locales) || void 0 === _themeConfig_locales ? void 0 : _themeConfig_locales.some((locale)=>locale.lastUpdated));
|
|
68
|
-
const mediumZoomConfig = (null == config ? void 0 : config.mediumZoom) ?? true;
|
|
69
|
-
const haveNavSidebarConfig = themeConfig.nav || themeConfig.sidebar || (null === (_themeConfig_locales1 = themeConfig.locales) || void 0 === _themeConfig_locales1 ? void 0 : null === (_themeConfig_locales_ = _themeConfig_locales1[0]) || void 0 === _themeConfig_locales_ ? void 0 : _themeConfig_locales_.nav) || (null === (_themeConfig_locales2 = themeConfig.locales) || void 0 === _themeConfig_locales2 ? void 0 : null === (_themeConfig_locales_1 = _themeConfig_locales2[0]) || void 0 === _themeConfig_locales_1 ? void 0 : _themeConfig_locales_1.sidebar);
|
|
70
|
-
if (enableLastUpdated) {
|
|
71
|
-
const { pluginLastUpdated } = await import("@rspress/plugin-last-updated");
|
|
72
|
-
this.addPlugin(pluginLastUpdated());
|
|
73
|
-
}
|
|
74
|
-
if (mediumZoomConfig) {
|
|
75
|
-
const { pluginMediumZoom } = await import("@rspress/plugin-medium-zoom");
|
|
76
|
-
this.addPlugin(pluginMediumZoom('object' == typeof mediumZoomConfig ? mediumZoomConfig : void 0));
|
|
77
|
-
}
|
|
78
|
-
this.addPlugin((0, __WEBPACK_EXTERNAL_MODULE__rspress_plugin_container_syntax_12d3c700__.pluginContainerSyntax)());
|
|
79
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isDevDebugMode)()) {
|
|
80
|
-
const SourceBuildPlugin = await import("@rspress-theme-anatole/theme-default/node/source-build-plugin.js").then((r)=>r.SourceBuildPlugin, ()=>null);
|
|
81
|
-
if (SourceBuildPlugin) this.addPlugin(SourceBuildPlugin());
|
|
82
|
-
}
|
|
83
|
-
(config.plugins || []).forEach((plugin)=>{
|
|
84
|
-
this.addPlugin(plugin);
|
|
85
|
-
});
|
|
86
|
-
if (!haveNavSidebarConfig) {
|
|
87
|
-
const { pluginAutoNavSidebar } = await import("@rspress/plugin-auto-nav-sidebar");
|
|
88
|
-
this.addPlugin(pluginAutoNavSidebar());
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
addPlugin(plugin) {
|
|
92
|
-
const existedIndex = _class_private_field_get(this, _plugins).findIndex((item)=>item.name === plugin.name);
|
|
93
|
-
if (-1 !== existedIndex) throw new Error(`The plugin "${plugin.name}" has been registered`);
|
|
94
|
-
_class_private_field_get(this, _plugins).push(plugin);
|
|
95
|
-
}
|
|
96
|
-
getPlugins() {
|
|
97
|
-
return _class_private_field_get(this, _plugins);
|
|
98
|
-
}
|
|
99
|
-
clearPlugins() {
|
|
100
|
-
_class_private_field_set(this, _plugins, []);
|
|
101
|
-
}
|
|
102
|
-
removePlugin(pluginName) {
|
|
103
|
-
const index = _class_private_field_get(this, _plugins).findIndex((item)=>item.name === pluginName);
|
|
104
|
-
if (-1 !== index) _class_private_field_get(this, _plugins).splice(index, 1);
|
|
105
|
-
}
|
|
106
|
-
async modifyConfig() {
|
|
107
|
-
let config = _class_private_field_get(this, _config);
|
|
108
|
-
for(let i = 0; i < _class_private_field_get(this, _plugins).length; i++){
|
|
109
|
-
const plugin = _class_private_field_get(this, _plugins)[i];
|
|
110
|
-
if ('function' == typeof plugin.config) config = await plugin.config(config || {}, {
|
|
111
|
-
addPlugin: this.addPlugin.bind(this),
|
|
112
|
-
removePlugin: (pluginName)=>{
|
|
113
|
-
const index = _class_private_field_get(this, _plugins).findIndex((item)=>item.name === pluginName);
|
|
114
|
-
this.removePlugin(pluginName);
|
|
115
|
-
if (index <= i && index > 0) i--;
|
|
116
|
-
}
|
|
117
|
-
}, _class_private_field_get(this, _isProd));
|
|
118
|
-
}
|
|
119
|
-
_class_private_field_set(this, _config, config);
|
|
120
|
-
return _class_private_field_get(this, _config);
|
|
121
|
-
}
|
|
122
|
-
async beforeBuild() {
|
|
123
|
-
return this._runParallelAsyncHook('beforeBuild', _class_private_field_get(this, _config) || {}, _class_private_field_get(this, _isProd));
|
|
124
|
-
}
|
|
125
|
-
async afterBuild() {
|
|
126
|
-
return this._runParallelAsyncHook('afterBuild', _class_private_field_get(this, _config) || {}, _class_private_field_get(this, _isProd));
|
|
127
|
-
}
|
|
128
|
-
async modifySearchIndexData(pages) {
|
|
129
|
-
return this._runParallelAsyncHook('modifySearchIndexData', pages, _class_private_field_get(this, _isProd));
|
|
130
|
-
}
|
|
131
|
-
async extendPageData(pageData) {
|
|
132
|
-
return this._runParallelAsyncHook('extendPageData', pageData, _class_private_field_get(this, _isProd));
|
|
133
|
-
}
|
|
134
|
-
async addPages() {
|
|
135
|
-
const result = await this._runParallelAsyncHook('addPages', _class_private_field_get(this, _config) || {}, _class_private_field_get(this, _isProd));
|
|
136
|
-
return result.flat();
|
|
137
|
-
}
|
|
138
|
-
async routeGenerated(routes) {
|
|
139
|
-
return this._runParallelAsyncHook('routeGenerated', routes, _class_private_field_get(this, _isProd));
|
|
140
|
-
}
|
|
141
|
-
async addRuntimeModules() {
|
|
142
|
-
const result = await this._runParallelAsyncHook('addRuntimeModules', _class_private_field_get(this, _config) || {}, _class_private_field_get(this, _isProd));
|
|
143
|
-
return result.reduce((prev, current)=>({
|
|
144
|
-
...prev,
|
|
145
|
-
...current
|
|
146
|
-
}), {});
|
|
147
|
-
}
|
|
148
|
-
async addSSGRoutes() {
|
|
149
|
-
const result = await this._runParallelAsyncHook('addSSGRoutes', _class_private_field_get(this, _config) || {}, _class_private_field_get(this, _isProd));
|
|
150
|
-
return result.flat();
|
|
151
|
-
}
|
|
152
|
-
globalUIComponents() {
|
|
153
|
-
const result = _class_private_field_get(this, _plugins).map((plugin)=>plugin.globalUIComponents || []);
|
|
154
|
-
return result.flat();
|
|
155
|
-
}
|
|
156
|
-
globalStyles() {
|
|
157
|
-
return _class_private_field_get(this, _plugins).filter((plugin)=>'string' == typeof plugin.globalStyles).map((plugin)=>plugin.globalStyles);
|
|
158
|
-
}
|
|
159
|
-
_runParallelAsyncHook(hookName, ...args) {
|
|
160
|
-
return Promise.all(_class_private_field_get(this, _plugins).filter((plugin)=>'function' == typeof plugin[hookName]).map((plugin)=>plugin[hookName](...args)));
|
|
161
|
-
}
|
|
162
|
-
_runSerialAsyncHook(hookName, ...args) {
|
|
163
|
-
return _class_private_field_get(this, _plugins).reduce(async (prev, plugin)=>{
|
|
164
|
-
if ('function' == typeof plugin[hookName]) {
|
|
165
|
-
await prev;
|
|
166
|
-
return plugin[hookName](...args);
|
|
167
|
-
}
|
|
168
|
-
return prev;
|
|
169
|
-
}, Promise.resolve());
|
|
170
|
-
}
|
|
171
|
-
constructor(config, isProd){
|
|
172
|
-
_class_private_field_init(this, _config, {
|
|
173
|
-
writable: true,
|
|
174
|
-
value: void 0
|
|
175
|
-
});
|
|
176
|
-
_class_private_field_init(this, _plugins, {
|
|
177
|
-
writable: true,
|
|
178
|
-
value: void 0
|
|
179
|
-
});
|
|
180
|
-
_class_private_field_init(this, _isProd, {
|
|
181
|
-
writable: true,
|
|
182
|
-
value: void 0
|
|
183
|
-
});
|
|
184
|
-
_class_private_field_set(this, _config, config);
|
|
185
|
-
_class_private_field_set(this, _isProd, isProd);
|
|
186
|
-
_class_private_field_set(this, _plugins, []);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
const isProduction = ()=>'production' === process.env.NODE_ENV;
|
|
190
|
-
const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
|
|
191
|
-
const inlineThemeScript = `{
|
|
192
|
-
const saved = localStorage.getItem('${__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.APPEARANCE_KEY}')
|
|
193
|
-
const preferDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
194
|
-
const isDark = !saved || saved === 'auto' ? preferDark : saved === 'dark'
|
|
195
|
-
document.documentElement.classList.toggle('dark', isDark)
|
|
196
|
-
document.documentElement.style.colorScheme = isDark ? 'dark' : 'light'
|
|
197
|
-
}`.replace(/\n/g, ';').replace(/\s{2,}/g, '');
|
|
198
|
-
const dirname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(new URL(import.meta.url)));
|
|
199
|
-
const PACKAGE_ROOT = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dirname, '..');
|
|
200
|
-
const CLIENT_ENTRY = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'clientEntry.js');
|
|
201
|
-
const SSR_ENTRY = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrEntry.js');
|
|
202
|
-
const OUTPUT_DIR = 'doc_build';
|
|
203
|
-
const APP_HTML_MARKER = '<!--<?- DOC_CONTENT ?>-->';
|
|
204
|
-
const HEAD_MARKER = '<!--<?- HEAD ?>-->';
|
|
205
|
-
const META_GENERATOR = '<!--<?- GENERATOR ?>-->';
|
|
206
|
-
const HTML_START_TAG = '<html';
|
|
207
|
-
const BODY_START_TAG = '<body';
|
|
208
|
-
const DEFAULT_TITLE = 'Rspress';
|
|
209
|
-
const PUBLIC_DIR = 'public';
|
|
210
|
-
const TEMP_DIR = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), 'node_modules', __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.RSPRESS_TEMP_DIR);
|
|
211
|
-
const isWindows = 'win32' === __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__["default"].platform();
|
|
212
|
-
function slash(p) {
|
|
213
|
-
return p.replace(/\\/g, '/');
|
|
214
|
-
}
|
|
215
|
-
function normalizePath(id) {
|
|
216
|
-
return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.normalize(isWindows ? slash(id) : id);
|
|
217
|
-
}
|
|
218
|
-
function getPageKey(route) {
|
|
219
|
-
const cleanRoute = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.removeLeadingSlash)(route);
|
|
220
|
-
return cleanRoute.replace(/\//g, '_').replace(/\.[^.]+$/, '') || 'index';
|
|
221
|
-
}
|
|
222
|
-
const normalizeRoutePath = (routePath, base, lang, version, langs, versions, extensions = __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__.DEFAULT_PAGE_EXTENSIONS)=>{
|
|
223
|
-
const hasTrailSlash = routePath.endsWith('/');
|
|
224
|
-
let versionPart = '';
|
|
225
|
-
let langPart = '';
|
|
226
|
-
let purePathPart = '';
|
|
227
|
-
const parts = routePath.split('/').filter(Boolean);
|
|
228
|
-
if (version) {
|
|
229
|
-
const versionToMatch = parts[0];
|
|
230
|
-
if (versions.includes(versionToMatch)) {
|
|
231
|
-
if (versionToMatch !== version) versionPart = versionToMatch;
|
|
232
|
-
parts.shift();
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
if (lang) {
|
|
236
|
-
const langToMatch = parts[0];
|
|
237
|
-
if (langs.includes(langToMatch)) {
|
|
238
|
-
if (langToMatch !== lang) langPart = langToMatch;
|
|
239
|
-
parts.shift();
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
purePathPart = parts.join('/');
|
|
243
|
-
const extensionsWithoutDot = extensions.map((i)=>i.slice(1));
|
|
244
|
-
const cleanExtensionPattern = new RegExp(`\\.(${extensionsWithoutDot.join('|')})$`, 'i');
|
|
245
|
-
let normalizedRoutePath = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.addLeadingSlash)([
|
|
246
|
-
versionPart,
|
|
247
|
-
langPart,
|
|
248
|
-
purePathPart
|
|
249
|
-
].filter(Boolean).join('/')).replace(cleanExtensionPattern, '').replace(/\.html$/, '').replace(/\/index$/, '/');
|
|
250
|
-
if (hasTrailSlash) normalizedRoutePath = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.addTrailingSlash)(normalizedRoutePath);
|
|
251
|
-
return {
|
|
252
|
-
routePath: (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.withBase)(normalizedRoutePath, base),
|
|
253
|
-
lang: langPart || lang,
|
|
254
|
-
version: versionPart || version
|
|
255
|
-
};
|
|
256
|
-
};
|
|
257
|
-
function RouteService_check_private_redeclaration(obj, privateCollection) {
|
|
258
|
-
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
259
|
-
}
|
|
260
|
-
function RouteService_class_apply_descriptor_get(receiver, descriptor) {
|
|
261
|
-
if (descriptor.get) return descriptor.get.call(receiver);
|
|
262
|
-
return descriptor.value;
|
|
263
|
-
}
|
|
264
|
-
function RouteService_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
265
|
-
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
266
|
-
else {
|
|
267
|
-
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
268
|
-
descriptor.value = value;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
function RouteService_class_extract_field_descriptor(receiver, privateMap, action) {
|
|
272
|
-
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
273
|
-
return privateMap.get(receiver);
|
|
274
|
-
}
|
|
275
|
-
function RouteService_class_private_field_get(receiver, privateMap) {
|
|
276
|
-
var descriptor = RouteService_class_extract_field_descriptor(receiver, privateMap, "get");
|
|
277
|
-
return RouteService_class_apply_descriptor_get(receiver, descriptor);
|
|
278
|
-
}
|
|
279
|
-
function RouteService_class_private_field_init(obj, privateMap, value) {
|
|
280
|
-
RouteService_check_private_redeclaration(obj, privateMap);
|
|
281
|
-
privateMap.set(obj, value);
|
|
282
|
-
}
|
|
283
|
-
function RouteService_class_private_field_set(receiver, privateMap, value) {
|
|
284
|
-
var descriptor = RouteService_class_extract_field_descriptor(receiver, privateMap, "set");
|
|
285
|
-
RouteService_class_apply_descriptor_set(receiver, descriptor, value);
|
|
286
|
-
return value;
|
|
287
|
-
}
|
|
288
|
-
function _class_private_method_get(receiver, privateSet, fn) {
|
|
289
|
-
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
290
|
-
return fn;
|
|
291
|
-
}
|
|
292
|
-
function _class_private_method_init(obj, privateSet) {
|
|
293
|
-
RouteService_check_private_redeclaration(obj, privateSet);
|
|
294
|
-
privateSet.add(obj);
|
|
295
|
-
}
|
|
296
|
-
function _define_property(obj, key, value) {
|
|
297
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
298
|
-
value: value,
|
|
299
|
-
enumerable: true,
|
|
300
|
-
configurable: true,
|
|
301
|
-
writable: true
|
|
302
|
-
});
|
|
303
|
-
else obj[key] = value;
|
|
304
|
-
return obj;
|
|
305
|
-
}
|
|
306
|
-
var _scanDir = /*#__PURE__*/ new WeakMap(), _defaultLang = /*#__PURE__*/ new WeakMap(), _defaultVersion = /*#__PURE__*/ new WeakMap(), _extensions = /*#__PURE__*/ new WeakMap(), _langs = /*#__PURE__*/ new WeakMap(), _versions = /*#__PURE__*/ new WeakMap(), _include = /*#__PURE__*/ new WeakMap(), _exclude = /*#__PURE__*/ new WeakMap(), _base = /*#__PURE__*/ new WeakMap(), _tempDir = /*#__PURE__*/ new WeakMap(), _pluginDriver = /*#__PURE__*/ new WeakMap(), _writeTempFile = /*#__PURE__*/ new WeakSet(), _generateRouteInfo = /*#__PURE__*/ new WeakSet();
|
|
307
|
-
class RouteService {
|
|
308
|
-
async init() {
|
|
309
|
-
const extensions = RouteService_class_private_field_get(this, _extensions).map((i)=>i.slice(1));
|
|
310
|
-
const files = (await (0, __WEBPACK_EXTERNAL_MODULE_tinyglobby__.glob)([
|
|
311
|
-
`**/*.{${extensions.join(',')}}`,
|
|
312
|
-
...RouteService_class_private_field_get(this, _include)
|
|
313
|
-
], {
|
|
314
|
-
cwd: RouteService_class_private_field_get(this, _scanDir),
|
|
315
|
-
absolute: true,
|
|
316
|
-
onlyFiles: true,
|
|
317
|
-
ignore: [
|
|
318
|
-
...RouteService_class_private_field_get(this, _exclude),
|
|
319
|
-
'**/node_modules/**',
|
|
320
|
-
'**/.eslintrc.js',
|
|
321
|
-
'**/.nx/**',
|
|
322
|
-
`./${PUBLIC_DIR}/**`
|
|
323
|
-
]
|
|
324
|
-
})).sort();
|
|
325
|
-
files.forEach((filePath)=>{
|
|
326
|
-
const fileRelativePath = normalizePath(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(RouteService_class_private_field_get(this, _scanDir), filePath));
|
|
327
|
-
const { routePath, lang, version } = this.normalizeRoutePath(fileRelativePath);
|
|
328
|
-
const absolutePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(RouteService_class_private_field_get(this, _scanDir), fileRelativePath);
|
|
329
|
-
const routeInfo = {
|
|
330
|
-
routePath,
|
|
331
|
-
absolutePath: normalizePath(absolutePath),
|
|
332
|
-
relativePath: fileRelativePath,
|
|
333
|
-
pageName: getPageKey(fileRelativePath),
|
|
334
|
-
lang,
|
|
335
|
-
version
|
|
336
|
-
};
|
|
337
|
-
this.addRoute(routeInfo);
|
|
338
|
-
});
|
|
339
|
-
const externalPages = await RouteService_class_private_field_get(this, _pluginDriver).addPages();
|
|
340
|
-
await Promise.all(externalPages.map(async (route, index)=>{
|
|
341
|
-
const { routePath, content, filepath } = route;
|
|
342
|
-
if (filepath) {
|
|
343
|
-
const routeInfo = _class_private_method_get(this, _generateRouteInfo, generateRouteInfo).call(this, routePath, filepath);
|
|
344
|
-
this.addRoute(routeInfo);
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
if (content) {
|
|
348
|
-
const filepath = await _class_private_method_get(this, _writeTempFile, writeTempFile).call(this, index, content);
|
|
349
|
-
const routeInfo = _class_private_method_get(this, _generateRouteInfo, generateRouteInfo).call(this, routePath, filepath);
|
|
350
|
-
this.addRoute(routeInfo);
|
|
351
|
-
}
|
|
352
|
-
}));
|
|
353
|
-
await RouteService_class_private_field_get(this, _pluginDriver).routeGenerated(this.getRoutes());
|
|
354
|
-
}
|
|
355
|
-
addRoute(routeInfo) {
|
|
356
|
-
const { routePath, absolutePath } = routeInfo;
|
|
357
|
-
if (this.routeData.has(routePath)) {
|
|
358
|
-
const preRouteExtIndex = RouteService_class_private_field_get(this, _extensions).indexOf(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(this.routeData.get(routePath).absolutePath));
|
|
359
|
-
const currRouteExtIndex = RouteService_class_private_field_get(this, _extensions).indexOf(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(absolutePath));
|
|
360
|
-
if (-1 !== currRouteExtIndex && (currRouteExtIndex < preRouteExtIndex || -1 === preRouteExtIndex)) this.routeData.set(routePath, routeInfo);
|
|
361
|
-
} else this.routeData.set(routePath, routeInfo);
|
|
362
|
-
}
|
|
363
|
-
removeRoute(filePath) {
|
|
364
|
-
const fileRelativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(RouteService_class_private_field_get(this, _scanDir), filePath);
|
|
365
|
-
const { routePath } = this.normalizeRoutePath(fileRelativePath);
|
|
366
|
-
this.routeData.delete(routePath);
|
|
367
|
-
}
|
|
368
|
-
getRoutes() {
|
|
369
|
-
return Array.from(this.routeData.values());
|
|
370
|
-
}
|
|
371
|
-
isExistRoute(routePath) {
|
|
372
|
-
const { routePath: normalizedRoute } = this.normalizeRoutePath(routePath);
|
|
373
|
-
return Boolean(this.routeData.get(normalizedRoute));
|
|
374
|
-
}
|
|
375
|
-
isEmpty() {
|
|
376
|
-
return 0 === this.routeData.size;
|
|
377
|
-
}
|
|
378
|
-
generateRoutesCode(isStaticImport = false) {
|
|
379
|
-
return this.generateRoutesCodeByRouteMeta(this.getRoutes(), isStaticImport);
|
|
380
|
-
}
|
|
381
|
-
generateRoutesCodeByRouteMeta(routeMeta, isStaticImport) {
|
|
382
|
-
return `
|
|
383
|
-
import React from 'react';
|
|
384
|
-
import { lazyWithPreload } from "react-lazy-with-preload";
|
|
385
|
-
${routeMeta.map((route, index)=>isStaticImport ? `import * as Route${index} from '${route.absolutePath}';` : `const Route${index} = lazyWithPreload(() => import('${route.absolutePath}'))`).join('\n')}
|
|
386
|
-
export const routes = [
|
|
387
|
-
${routeMeta.map((route, index)=>{
|
|
388
|
-
const preload = isStaticImport ? `() => Route${index}` : `async () => {
|
|
389
|
-
await Route${index}.preload();
|
|
390
|
-
return import("${route.absolutePath}");
|
|
391
|
-
}`;
|
|
392
|
-
const component = isStaticImport ? `Route${index}.default` : `Route${index}`;
|
|
393
|
-
return `{ path: '${route.routePath}', element: React.createElement(${component}), filePath: '${route.relativePath}', preload: ${preload}, lang: '${route.lang}', version: '${route.version}' }`;
|
|
394
|
-
}).join(',\n')}
|
|
395
|
-
];
|
|
396
|
-
`;
|
|
397
|
-
}
|
|
398
|
-
normalizeRoutePath(routePath) {
|
|
399
|
-
return normalizeRoutePath(routePath, RouteService_class_private_field_get(this, _base), RouteService_class_private_field_get(this, _defaultLang), RouteService_class_private_field_get(this, _defaultVersion), RouteService_class_private_field_get(this, _langs), RouteService_class_private_field_get(this, _versions), RouteService_class_private_field_get(this, _extensions));
|
|
400
|
-
}
|
|
401
|
-
constructor(scanDir, userConfig, tempDir, pluginDriver){
|
|
402
|
-
var _userConfig_themeConfig;
|
|
403
|
-
_class_private_method_init(this, _writeTempFile);
|
|
404
|
-
_class_private_method_init(this, _generateRouteInfo);
|
|
405
|
-
_define_property(this, "routeData", new Map());
|
|
406
|
-
RouteService_class_private_field_init(this, _scanDir, {
|
|
407
|
-
writable: true,
|
|
408
|
-
value: void 0
|
|
409
|
-
});
|
|
410
|
-
RouteService_class_private_field_init(this, _defaultLang, {
|
|
411
|
-
writable: true,
|
|
412
|
-
value: void 0
|
|
413
|
-
});
|
|
414
|
-
RouteService_class_private_field_init(this, _defaultVersion, {
|
|
415
|
-
writable: true,
|
|
416
|
-
value: ''
|
|
417
|
-
});
|
|
418
|
-
RouteService_class_private_field_init(this, _extensions, {
|
|
419
|
-
writable: true,
|
|
420
|
-
value: []
|
|
421
|
-
});
|
|
422
|
-
RouteService_class_private_field_init(this, _langs, {
|
|
423
|
-
writable: true,
|
|
424
|
-
value: []
|
|
425
|
-
});
|
|
426
|
-
RouteService_class_private_field_init(this, _versions, {
|
|
427
|
-
writable: true,
|
|
428
|
-
value: []
|
|
429
|
-
});
|
|
430
|
-
RouteService_class_private_field_init(this, _include, {
|
|
431
|
-
writable: true,
|
|
432
|
-
value: []
|
|
433
|
-
});
|
|
434
|
-
RouteService_class_private_field_init(this, _exclude, {
|
|
435
|
-
writable: true,
|
|
436
|
-
value: []
|
|
437
|
-
});
|
|
438
|
-
RouteService_class_private_field_init(this, _base, {
|
|
439
|
-
writable: true,
|
|
440
|
-
value: ''
|
|
441
|
-
});
|
|
442
|
-
RouteService_class_private_field_init(this, _tempDir, {
|
|
443
|
-
writable: true,
|
|
444
|
-
value: ''
|
|
445
|
-
});
|
|
446
|
-
RouteService_class_private_field_init(this, _pluginDriver, {
|
|
447
|
-
writable: true,
|
|
448
|
-
value: void 0
|
|
449
|
-
});
|
|
450
|
-
const routeOptions = (null == userConfig ? void 0 : userConfig.route) || {};
|
|
451
|
-
RouteService_class_private_field_set(this, _scanDir, scanDir);
|
|
452
|
-
RouteService_class_private_field_set(this, _extensions, routeOptions.extensions || __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__.DEFAULT_PAGE_EXTENSIONS);
|
|
453
|
-
RouteService_class_private_field_set(this, _include, routeOptions.include || []);
|
|
454
|
-
RouteService_class_private_field_set(this, _exclude, routeOptions.exclude || []);
|
|
455
|
-
RouteService_class_private_field_set(this, _defaultLang, (null == userConfig ? void 0 : userConfig.lang) || '');
|
|
456
|
-
RouteService_class_private_field_set(this, _langs, ((null == userConfig ? void 0 : userConfig.locales) ?? (null == userConfig ? void 0 : null === (_userConfig_themeConfig = userConfig.themeConfig) || void 0 === _userConfig_themeConfig ? void 0 : _userConfig_themeConfig.locales) ?? []).map((item)=>item.lang));
|
|
457
|
-
RouteService_class_private_field_set(this, _base, (null == userConfig ? void 0 : userConfig.base) || '');
|
|
458
|
-
RouteService_class_private_field_set(this, _tempDir, tempDir);
|
|
459
|
-
RouteService_class_private_field_set(this, _pluginDriver, pluginDriver);
|
|
460
|
-
if (userConfig.multiVersion) {
|
|
461
|
-
RouteService_class_private_field_set(this, _defaultVersion, userConfig.multiVersion.default || '');
|
|
462
|
-
RouteService_class_private_field_set(this, _versions, userConfig.multiVersion.versions || []);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
async function writeTempFile(index, content) {
|
|
467
|
-
const tempFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(RouteService_class_private_field_get(this, _tempDir), `temp-${index}.mdx`);
|
|
468
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile(tempFilePath, content);
|
|
469
|
-
return tempFilePath;
|
|
470
|
-
}
|
|
471
|
-
function generateRouteInfo(routePath, filepath) {
|
|
472
|
-
const { routePath: normalizedPath, lang, version } = this.normalizeRoutePath(routePath);
|
|
473
|
-
return {
|
|
474
|
-
routePath: normalizedPath,
|
|
475
|
-
absolutePath: normalizePath(filepath),
|
|
476
|
-
relativePath: normalizePath(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(RouteService_class_private_field_get(this, _scanDir), filepath)),
|
|
477
|
-
pageName: getPageKey(routePath),
|
|
478
|
-
lang,
|
|
479
|
-
version
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
let init_routeService = null;
|
|
483
|
-
async function initRouteService(options) {
|
|
484
|
-
const { scanDir, config, runtimeTempDir, pluginDriver } = options;
|
|
485
|
-
init_routeService = new RouteService(scanDir, config, runtimeTempDir, pluginDriver);
|
|
486
|
-
await init_routeService.init();
|
|
487
|
-
return init_routeService;
|
|
488
|
-
}
|
|
489
|
-
async function globalStylesVMPlugin(context) {
|
|
490
|
-
const { config, pluginDriver } = context;
|
|
491
|
-
const globalStylesByPlugins = pluginDriver.globalStyles();
|
|
492
|
-
if (config.globalStyles) {
|
|
493
|
-
const source = config.globalStyles;
|
|
494
|
-
const styleContent = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(source, 'utf-8');
|
|
495
|
-
const patchedStyleContent = styleContent.replace(/--modern-/g, '--rp-').replace(/\.modern-doc/g, '.rspress').replace(/\.modern-/g, '.rspress-');
|
|
496
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile(source, patchedStyleContent, 'utf-8');
|
|
497
|
-
}
|
|
498
|
-
const moduleContent = (await Promise.all([
|
|
499
|
-
(null == config ? void 0 : config.globalStyles) || '',
|
|
500
|
-
...globalStylesByPlugins
|
|
501
|
-
].filter((source)=>source.length > 0).map(async (source)=>`import ${JSON.stringify(source)};`))).join('');
|
|
502
|
-
return {
|
|
503
|
-
[runtimeModule_RuntimeModuleID.GlobalStyles]: moduleContent
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
async function globalUIComponentsVMPlugin(context) {
|
|
507
|
-
const { config, pluginDriver } = context;
|
|
508
|
-
let index = 0;
|
|
509
|
-
const globalUIComponentsByPlugins = pluginDriver.globalUIComponents();
|
|
510
|
-
const globalComponents = [
|
|
511
|
-
...(null == config ? void 0 : config.globalUIComponents) || [],
|
|
512
|
-
...globalUIComponentsByPlugins
|
|
513
|
-
];
|
|
514
|
-
const moduleContent = globalComponents.map((source)=>{
|
|
515
|
-
const name = `Comp_${index}`;
|
|
516
|
-
if (Array.isArray(source)) return `import ${name} from ${JSON.stringify(source[0])};
|
|
517
|
-
const Props_${index++} = ${JSON.stringify(source[1])};\n`;
|
|
518
|
-
index++;
|
|
519
|
-
return `import ${name} from ${JSON.stringify(source)};\n`;
|
|
520
|
-
}).concat(`export default [${Array.from({
|
|
521
|
-
length: index
|
|
522
|
-
}, (_, i)=>{
|
|
523
|
-
if (Array.isArray(globalComponents[i])) return `[Comp_${i}, Props_${i}]`;
|
|
524
|
-
return `Comp_${i}`;
|
|
525
|
-
}).join(', ')}];`).join('');
|
|
526
|
-
return {
|
|
527
|
-
[runtimeModule_RuntimeModuleID.GlobalComponents]: moduleContent
|
|
528
|
-
};
|
|
529
|
-
}
|
|
530
|
-
const DEFAULT_I18N_SOURCE = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(process.cwd(), 'i18n.json');
|
|
531
|
-
function getI18nData(docConfig) {
|
|
532
|
-
const { i18nSourcePath = DEFAULT_I18N_SOURCE } = docConfig;
|
|
533
|
-
try {
|
|
534
|
-
delete require.cache[i18nSourcePath];
|
|
535
|
-
const i18nSource = require(i18nSourcePath);
|
|
536
|
-
return i18nSource;
|
|
537
|
-
} catch (e) {
|
|
538
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.debug('getI18nData Failed: \n', e);
|
|
539
|
-
return {};
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
function i18nVMPlugin(context) {
|
|
543
|
-
const { config } = context;
|
|
544
|
-
const i18nData = getI18nData(config);
|
|
545
|
-
return {
|
|
546
|
-
[runtimeModule_RuntimeModuleID.I18nText]: `export default ${JSON.stringify(i18nData, null, 2)}`
|
|
547
|
-
};
|
|
548
|
-
}
|
|
549
|
-
async function routeVMPlugin(context) {
|
|
550
|
-
const { routeService, isSSR } = context;
|
|
551
|
-
if (!isSSR) return {
|
|
552
|
-
[runtimeModule_RuntimeModuleID.RouteForClient]: routeService.generateRoutesCode(false),
|
|
553
|
-
[runtimeModule_RuntimeModuleID.RouteForSSR]: ''
|
|
554
|
-
};
|
|
555
|
-
return {
|
|
556
|
-
[runtimeModule_RuntimeModuleID.RouteForClient]: routeService.generateRoutesCode(false),
|
|
557
|
-
[runtimeModule_RuntimeModuleID.RouteForSSR]: routeService.generateRoutesCode(true)
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
async function searchHookVMPlugin(context) {
|
|
561
|
-
const { config } = context;
|
|
562
|
-
let content = 'export const onSearch = () => {};';
|
|
563
|
-
let extname = '';
|
|
564
|
-
if ('object' == typeof config.search && 'string' == typeof config.search.searchHooks) {
|
|
565
|
-
content = `export * from '${config.search.searchHooks}'`;
|
|
566
|
-
extname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(config.search.searchHooks);
|
|
567
|
-
}
|
|
568
|
-
return {
|
|
569
|
-
[`${runtimeModule_RuntimeModuleID.SearchHooks}${extname}`]: content
|
|
570
|
-
};
|
|
571
|
-
}
|
|
572
|
-
function createHash(str) {
|
|
573
|
-
return (0, __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.createHash)('sha256').update(str).digest('hex').slice(0, 8);
|
|
574
|
-
}
|
|
575
|
-
let flattenMdxContent_resolver;
|
|
576
|
-
let startFlatten = false;
|
|
577
|
-
const processor = (0, __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__.createProcessor)();
|
|
578
|
-
const { CachedInputFileSystem, ResolverFactory } = __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__["default"];
|
|
579
|
-
const fileSystem = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"];
|
|
580
|
-
async function resolveDepPath(importPath, importer, alias) {
|
|
581
|
-
if (!flattenMdxContent_resolver) flattenMdxContent_resolver = ResolverFactory.createResolver({
|
|
582
|
-
fileSystem: new CachedInputFileSystem(fileSystem, 0),
|
|
583
|
-
extensions: [
|
|
584
|
-
'.mdx',
|
|
585
|
-
'.md'
|
|
586
|
-
],
|
|
587
|
-
alias
|
|
588
|
-
});
|
|
589
|
-
const resolveResult = await new Promise((resolve, reject)=>{
|
|
590
|
-
flattenMdxContent_resolver.resolve({
|
|
591
|
-
importer
|
|
592
|
-
}, importer, importPath, {}, (err, filePath)=>{
|
|
593
|
-
if (err) return reject(err);
|
|
594
|
-
if (!filePath) return reject(new Error(`Empty result when resolving ${importPath} from ${importer}`));
|
|
595
|
-
return resolve(filePath);
|
|
596
|
-
});
|
|
597
|
-
});
|
|
598
|
-
return resolveResult;
|
|
599
|
-
}
|
|
600
|
-
async function flattenMdxContent(content, basePath, alias) {
|
|
601
|
-
const deps = [];
|
|
602
|
-
const regex = new RegExp(importStatementRegex);
|
|
603
|
-
if (!regex.test(content)) return {
|
|
604
|
-
flattenContent: content,
|
|
605
|
-
deps
|
|
606
|
-
};
|
|
607
|
-
if (!startFlatten) {
|
|
608
|
-
flattenMdxContent_resolver = ResolverFactory.createResolver({
|
|
609
|
-
fileSystem: new CachedInputFileSystem(fileSystem, 0),
|
|
610
|
-
extensions: [
|
|
611
|
-
'.mdx',
|
|
612
|
-
'.md',
|
|
613
|
-
'.js'
|
|
614
|
-
],
|
|
615
|
-
alias
|
|
616
|
-
});
|
|
617
|
-
startFlatten = true;
|
|
618
|
-
}
|
|
619
|
-
let ast;
|
|
620
|
-
let result = content;
|
|
621
|
-
try {
|
|
622
|
-
ast = processor.parse(content);
|
|
623
|
-
} catch (e) {
|
|
624
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.debug('flattenMdxContent parse failed: \n', e);
|
|
625
|
-
return {
|
|
626
|
-
flattenContent: content,
|
|
627
|
-
deps
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
const importNodes = ast.children.filter((node)=>'mdxjsEsm' === node.type).flatMap((node)=>{
|
|
631
|
-
var _node_data_estree, _node_data;
|
|
632
|
-
return (null === (_node_data = node.data) || void 0 === _node_data ? void 0 : null === (_node_data_estree = _node_data.estree) || void 0 === _node_data_estree ? void 0 : _node_data_estree.body) || [];
|
|
633
|
-
}).filter((node)=>'ImportDeclaration' === node.type);
|
|
634
|
-
for (const importNode of importNodes){
|
|
635
|
-
const id = importNode.specifiers[0].local.name;
|
|
636
|
-
const importPath = importNode.source.value;
|
|
637
|
-
let absoluteImportPath;
|
|
638
|
-
try {
|
|
639
|
-
absoluteImportPath = await resolveDepPath(importPath, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(basePath), alias);
|
|
640
|
-
} catch (_e) {
|
|
641
|
-
continue;
|
|
642
|
-
}
|
|
643
|
-
if (__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(absoluteImportPath)) {
|
|
644
|
-
const importedContent = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(absoluteImportPath, 'utf-8');
|
|
645
|
-
const { flattenContent: replacedValue, deps: subDeps } = await flattenMdxContent(importedContent, absoluteImportPath, alias);
|
|
646
|
-
result = result.replace(new RegExp(`import\\s+${id}\\s+from\\s+['"](${importPath})['"];?`), '').replace(new RegExp(`<${id}\\s*/>`, 'g'), ()=>replacedValue);
|
|
647
|
-
deps.push(...subDeps, absoluteImportPath);
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
return {
|
|
651
|
-
flattenContent: result,
|
|
652
|
-
deps
|
|
653
|
-
};
|
|
654
|
-
}
|
|
655
|
-
function applyReplaceRules(code = '', replaceRules = []) {
|
|
656
|
-
let result = code;
|
|
657
|
-
for (const rule of replaceRules)result = result.replace(rule.search, rule.replace);
|
|
658
|
-
return result;
|
|
659
|
-
}
|
|
660
|
-
function applyReplaceRulesToNestedObject(obj, replaceRules) {
|
|
661
|
-
for(const key in obj)if ('string' == typeof obj[key]) obj[key] = applyReplaceRules(obj[key], replaceRules);
|
|
662
|
-
else if ('object' == typeof obj[key] && null !== obj[key]) obj[key] = applyReplaceRulesToNestedObject(obj[key], replaceRules);
|
|
663
|
-
return obj;
|
|
664
|
-
}
|
|
665
|
-
async function extractPageData(replaceRules, alias, domain, root, routeService, highlighterLangs, searchCodeBlocks) {
|
|
666
|
-
const pageData = await Promise.all(routeService.getRoutes().map(async (route, index)=>{
|
|
667
|
-
const defaultIndexInfo = {
|
|
668
|
-
id: index,
|
|
669
|
-
title: '',
|
|
670
|
-
content: '',
|
|
671
|
-
_html: '',
|
|
672
|
-
routePath: route.routePath,
|
|
673
|
-
lang: route.lang,
|
|
674
|
-
toc: [],
|
|
675
|
-
domain,
|
|
676
|
-
frontmatter: {},
|
|
677
|
-
version: route.version,
|
|
678
|
-
_filepath: route.absolutePath,
|
|
679
|
-
_relativePath: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, route.absolutePath).split(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep).join('/')
|
|
680
|
-
};
|
|
681
|
-
if (!__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(route.absolutePath)) return defaultIndexInfo;
|
|
682
|
-
let content = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(route.absolutePath, 'utf8');
|
|
683
|
-
const { frontmatter, content: strippedFrontMatter } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.loadFrontMatter)(content, route.absolutePath, root);
|
|
684
|
-
applyReplaceRulesToNestedObject(frontmatter, replaceRules);
|
|
685
|
-
const { flattenContent } = await flattenMdxContent(applyReplaceRules(strippedFrontMatter, replaceRules), route.absolutePath, alias);
|
|
686
|
-
content = flattenContent.replace(importStatementRegex, '');
|
|
687
|
-
const { html: rawHtml, title, toc: rawToc, languages } = await (0, __WEBPACK_EXTERNAL_MODULE__rspress_mdx_rs_d2f3021f__.compile)({
|
|
688
|
-
value: content,
|
|
689
|
-
filepath: route.absolutePath,
|
|
690
|
-
development: 'production' !== process.env.NODE_ENV,
|
|
691
|
-
root
|
|
692
|
-
});
|
|
693
|
-
function encodeHtml(html) {
|
|
694
|
-
return html.replace(/<code>([\s\S]*?)<\/\s?code>/gm, function(_match, innerContent) {
|
|
695
|
-
return `<code>${innerContent.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>')}</code>`;
|
|
696
|
-
});
|
|
697
|
-
}
|
|
698
|
-
const html = encodeHtml(String(rawHtml));
|
|
699
|
-
content = (0, __WEBPACK_EXTERNAL_MODULE_html_to_text_2c51ed38__.htmlToText)(html, {
|
|
700
|
-
wordwrap: 80,
|
|
701
|
-
selectors: [
|
|
702
|
-
{
|
|
703
|
-
selector: 'a',
|
|
704
|
-
options: {
|
|
705
|
-
ignoreHref: true
|
|
706
|
-
}
|
|
707
|
-
},
|
|
708
|
-
{
|
|
709
|
-
selector: 'img',
|
|
710
|
-
format: 'skip'
|
|
711
|
-
},
|
|
712
|
-
{
|
|
713
|
-
selector: 'pre > code',
|
|
714
|
-
format: searchCodeBlocks ? 'block' : 'skip'
|
|
715
|
-
},
|
|
716
|
-
...[
|
|
717
|
-
'h1',
|
|
718
|
-
'h2',
|
|
719
|
-
'h3',
|
|
720
|
-
'h4',
|
|
721
|
-
'h5',
|
|
722
|
-
'h6'
|
|
723
|
-
].map((tag)=>({
|
|
724
|
-
selector: tag,
|
|
725
|
-
options: {
|
|
726
|
-
uppercase: false
|
|
727
|
-
}
|
|
728
|
-
}))
|
|
729
|
-
],
|
|
730
|
-
tables: true,
|
|
731
|
-
longWordSplit: {
|
|
732
|
-
forceWrapOnLimit: true
|
|
733
|
-
}
|
|
734
|
-
});
|
|
735
|
-
if (content.startsWith(title)) content = content.slice(title.length);
|
|
736
|
-
languages.forEach((lang)=>highlighterLangs.add(lang));
|
|
737
|
-
const toc = rawToc.map((item)=>{
|
|
738
|
-
const match = item.id.match(/-(\d+)$/);
|
|
739
|
-
let position = -1;
|
|
740
|
-
if (match) for(let i = 0; i < Number(match[1]); i++){
|
|
741
|
-
position = content.indexOf(`\n${item.text}#\n\n`, position + 1);
|
|
742
|
-
if (-1 === position) break;
|
|
743
|
-
}
|
|
744
|
-
return {
|
|
745
|
-
...item,
|
|
746
|
-
charIndex: content.indexOf(`\n${item.text}#\n\n`, position + 1)
|
|
747
|
-
};
|
|
748
|
-
});
|
|
749
|
-
return {
|
|
750
|
-
...defaultIndexInfo,
|
|
751
|
-
title: frontmatter.title || title,
|
|
752
|
-
toc,
|
|
753
|
-
content,
|
|
754
|
-
_html: html,
|
|
755
|
-
frontmatter: {
|
|
756
|
-
...frontmatter,
|
|
757
|
-
__content: void 0
|
|
758
|
-
}
|
|
759
|
-
};
|
|
760
|
-
}));
|
|
761
|
-
return pageData.filter(Boolean);
|
|
762
|
-
}
|
|
763
|
-
const highlightLanguages_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
|
|
764
|
-
let highlightLanguages_supportedLanguages;
|
|
765
|
-
function handleHighlightLanguages(highlightLanguages, defaultLanguages) {
|
|
766
|
-
const aliases = {};
|
|
767
|
-
if (highlightLanguages.size) {
|
|
768
|
-
if (!highlightLanguages_supportedLanguages) {
|
|
769
|
-
const langs = highlightLanguages_require('react-syntax-highlighter/dist/cjs/languages/prism/supported-languages').default;
|
|
770
|
-
highlightLanguages_supportedLanguages = new Set(langs);
|
|
771
|
-
}
|
|
772
|
-
let useDeprecatedTypeWarning = true;
|
|
773
|
-
const names = {};
|
|
774
|
-
[
|
|
775
|
-
...__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.DEFAULT_HIGHLIGHT_LANGUAGES,
|
|
776
|
-
...defaultLanguages
|
|
777
|
-
].forEach((lang)=>{
|
|
778
|
-
if (Array.isArray(lang)) {
|
|
779
|
-
const [alias, name] = lang;
|
|
780
|
-
names[alias] = name;
|
|
781
|
-
} else if (useDeprecatedTypeWarning) {
|
|
782
|
-
console.log(`${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellowBright('warning')} Automatic import is supported. \`highlightLanguages\` is now used only as alias, and string types will be ignored. \n`);
|
|
783
|
-
useDeprecatedTypeWarning = false;
|
|
784
|
-
}
|
|
785
|
-
});
|
|
786
|
-
[
|
|
787
|
-
...highlightLanguages.values()
|
|
788
|
-
].forEach((lang)=>{
|
|
789
|
-
const name = names[lang];
|
|
790
|
-
if (name && highlightLanguages_supportedLanguages.has(name)) {
|
|
791
|
-
const temp = aliases[name] || (aliases[name] = []);
|
|
792
|
-
if (!temp.includes(lang)) temp.push(lang);
|
|
793
|
-
highlightLanguages.delete(lang);
|
|
794
|
-
highlightLanguages.add(name);
|
|
795
|
-
return;
|
|
796
|
-
}
|
|
797
|
-
if (!highlightLanguages_supportedLanguages.has(lang)) highlightLanguages.delete(lang);
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
return aliases;
|
|
801
|
-
}
|
|
802
|
-
function normalizeThemeConfig(docConfig, pages = []) {
|
|
803
|
-
const { locales: siteLocales, base = '', lang, replaceRules = [], multiVersion } = docConfig;
|
|
804
|
-
const { versions = [] } = multiVersion || {};
|
|
805
|
-
const hasMultiVersion = versions.length > 0;
|
|
806
|
-
docConfig.themeConfig = docConfig.themeConfig || {};
|
|
807
|
-
const { themeConfig } = docConfig;
|
|
808
|
-
const locales = siteLocales ?? ((null == themeConfig ? void 0 : themeConfig.locales) || []);
|
|
809
|
-
const i18nTextData = getI18nData(docConfig);
|
|
810
|
-
const normalizeLinkPrefix = (link = '', currentLang = '')=>{
|
|
811
|
-
const normalizedLink = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.slash)(link);
|
|
812
|
-
if (!currentLang || !link || (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.withoutBase)(normalizedLink, base).startsWith(`/${currentLang}`) || (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isExternalUrl)(normalizedLink) || hasMultiVersion) return normalizedLink;
|
|
813
|
-
return lang === currentLang ? normalizedLink : `/${currentLang}${(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.addLeadingSlash)(normalizedLink)}`;
|
|
814
|
-
};
|
|
815
|
-
const getI18nText = (key = '', currentLang = '')=>{
|
|
816
|
-
var _i18nTextData_key;
|
|
817
|
-
const text = null === (_i18nTextData_key = i18nTextData[key]) || void 0 === _i18nTextData_key ? void 0 : _i18nTextData_key[currentLang];
|
|
818
|
-
return text || key;
|
|
819
|
-
};
|
|
820
|
-
const normalizeSidebar = (sidebar, currentLang = '')=>{
|
|
821
|
-
const normalizedSidebar = {};
|
|
822
|
-
if (!sidebar) return {};
|
|
823
|
-
const normalizeSidebarItem = (item)=>{
|
|
824
|
-
if ('object' == typeof item && 'dividerType' in item) return item;
|
|
825
|
-
if ('object' == typeof item && 'sectionHeaderText' in item) {
|
|
826
|
-
item.sectionHeaderText = applyReplaceRules(getI18nText(item.sectionHeaderText, currentLang), replaceRules);
|
|
827
|
-
return item;
|
|
828
|
-
}
|
|
829
|
-
if ('object' == typeof item && 'items' in item) return {
|
|
830
|
-
...item,
|
|
831
|
-
text: applyReplaceRules(getI18nText(item.text, currentLang), replaceRules),
|
|
832
|
-
link: normalizeLinkPrefix(item.link),
|
|
833
|
-
collapsed: item.collapsed ?? false,
|
|
834
|
-
collapsible: item.collapsible ?? true,
|
|
835
|
-
tag: item.tag,
|
|
836
|
-
items: item.items.map((subItem)=>normalizeSidebarItem(subItem))
|
|
837
|
-
};
|
|
838
|
-
if ('string' == typeof item) {
|
|
839
|
-
const normalizedItem = normalizeLinkPrefix(item, currentLang);
|
|
840
|
-
const page = pages.find((page)=>page.routePath === (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.withBase)(normalizedItem, base));
|
|
841
|
-
return {
|
|
842
|
-
text: applyReplaceRules((null == page ? void 0 : page.title) || '', replaceRules),
|
|
843
|
-
link: normalizedItem,
|
|
844
|
-
_fileKey: null == page ? void 0 : page._relativePath.replace(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(page._relativePath), '')
|
|
845
|
-
};
|
|
846
|
-
}
|
|
847
|
-
return {
|
|
848
|
-
...item,
|
|
849
|
-
text: applyReplaceRules(getI18nText(item.text, currentLang), replaceRules),
|
|
850
|
-
link: normalizeLinkPrefix(item.link),
|
|
851
|
-
tag: item.tag
|
|
852
|
-
};
|
|
853
|
-
};
|
|
854
|
-
const normalizeSidebar = (sidebar)=>{
|
|
855
|
-
Object.keys(sidebar).forEach((key)=>{
|
|
856
|
-
const value = sidebar[key];
|
|
857
|
-
normalizedSidebar[key] = value.map(normalizeSidebarItem);
|
|
858
|
-
});
|
|
859
|
-
};
|
|
860
|
-
normalizeSidebar(sidebar);
|
|
861
|
-
return normalizedSidebar;
|
|
862
|
-
};
|
|
863
|
-
const normalizeNav = (nav, currentLang)=>{
|
|
864
|
-
if (!nav) return [];
|
|
865
|
-
const transformNavItem = (navItem)=>{
|
|
866
|
-
const text = applyReplaceRules(getI18nText(navItem.text, currentLang), replaceRules);
|
|
867
|
-
if ('link' in navItem) return {
|
|
868
|
-
...navItem,
|
|
869
|
-
text,
|
|
870
|
-
link: normalizeLinkPrefix(navItem.link, currentLang)
|
|
871
|
-
};
|
|
872
|
-
if ('items' in navItem) return {
|
|
873
|
-
...navItem,
|
|
874
|
-
text,
|
|
875
|
-
items: navItem.items.map((item)=>({
|
|
876
|
-
...item,
|
|
877
|
-
text: applyReplaceRules(getI18nText(item.text, currentLang), replaceRules),
|
|
878
|
-
link: normalizeLinkPrefix(item.link, currentLang)
|
|
879
|
-
}))
|
|
880
|
-
};
|
|
881
|
-
return navItem;
|
|
882
|
-
};
|
|
883
|
-
if (Array.isArray(nav)) return nav.map(transformNavItem);
|
|
884
|
-
return Object.entries(nav).reduce((acc, [key, value])=>{
|
|
885
|
-
acc[key] = value.map(transformNavItem);
|
|
886
|
-
return acc;
|
|
887
|
-
}, {});
|
|
888
|
-
};
|
|
889
|
-
if (locales.length) themeConfig.locales = locales.map(({ lang: currentLang, label })=>{
|
|
890
|
-
var _themeConfig_locales;
|
|
891
|
-
const localeInThemeConfig = null === (_themeConfig_locales = themeConfig.locales) || void 0 === _themeConfig_locales ? void 0 : _themeConfig_locales.find((locale)=>locale.lang === currentLang);
|
|
892
|
-
return {
|
|
893
|
-
lang: currentLang,
|
|
894
|
-
label,
|
|
895
|
-
...localeInThemeConfig || {},
|
|
896
|
-
sidebar: normalizeSidebar((null == localeInThemeConfig ? void 0 : localeInThemeConfig.sidebar) ?? themeConfig.sidebar, currentLang),
|
|
897
|
-
nav: normalizeNav((null == localeInThemeConfig ? void 0 : localeInThemeConfig.nav) ?? themeConfig.nav, currentLang)
|
|
898
|
-
};
|
|
899
|
-
});
|
|
900
|
-
else {
|
|
901
|
-
themeConfig.sidebar = normalizeSidebar(null == themeConfig ? void 0 : themeConfig.sidebar);
|
|
902
|
-
themeConfig.nav = normalizeNav(null == themeConfig ? void 0 : themeConfig.nav);
|
|
903
|
-
}
|
|
904
|
-
return themeConfig;
|
|
905
|
-
}
|
|
906
|
-
function deletePrivateField(obj) {
|
|
907
|
-
if ('object' != typeof obj || null === obj) return obj;
|
|
908
|
-
const newObj = {
|
|
909
|
-
...obj
|
|
910
|
-
};
|
|
911
|
-
for(const key in newObj)if (key.startsWith('_')) delete newObj[key];
|
|
912
|
-
return newObj;
|
|
913
|
-
}
|
|
914
|
-
async function siteDataVMPlugin(context) {
|
|
915
|
-
var _userConfig_themeConfig, _userConfig_multiVersion, _userConfig_multiVersion1, _userConfig_markdown, _userConfig_markdown1, _userConfig_markdown2, _siteData_pages_;
|
|
916
|
-
const { config, alias, userDocRoot, routeService, pluginDriver } = context;
|
|
917
|
-
const userConfig = config;
|
|
918
|
-
const tempSearchObj = Object.assign({}, userConfig.search);
|
|
919
|
-
if (tempSearchObj) tempSearchObj.searchHooks = void 0;
|
|
920
|
-
const highlightLanguages = new Set();
|
|
921
|
-
const replaceRules = (null == userConfig ? void 0 : userConfig.replaceRules) || [];
|
|
922
|
-
const searchConfig = (null == userConfig ? void 0 : userConfig.search) || {};
|
|
923
|
-
const domain = (null == searchConfig ? void 0 : searchConfig.mode) === 'remote' ? searchConfig.domain ?? '' : '';
|
|
924
|
-
const searchCodeBlocks = 'codeBlocks' in searchConfig ? Boolean(searchConfig.codeBlocks) : false;
|
|
925
|
-
const pages = await extractPageData(replaceRules, alias, domain, userDocRoot, routeService, highlightLanguages, searchCodeBlocks);
|
|
926
|
-
await pluginDriver.modifySearchIndexData(pages);
|
|
927
|
-
const versioned = userConfig.search && 'remote' !== userConfig.search.mode && userConfig.search.versioned;
|
|
928
|
-
const groupedPages = (0, __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__.groupBy)(pages, (page)=>{
|
|
929
|
-
var _page_frontmatter;
|
|
930
|
-
if ((null === (_page_frontmatter = page.frontmatter) || void 0 === _page_frontmatter ? void 0 : _page_frontmatter.pageType) === 'home') return 'noindex';
|
|
931
|
-
const version = versioned ? page.version : '';
|
|
932
|
-
const lang = page.lang || '';
|
|
933
|
-
return `${version}###${lang}`;
|
|
934
|
-
});
|
|
935
|
-
delete groupedPages.noindex;
|
|
936
|
-
const indexHashByGroup = {};
|
|
937
|
-
await Promise.all(Object.keys(groupedPages).map(async (group)=>{
|
|
938
|
-
const stringifiedIndex = JSON.stringify(groupedPages[group].map(deletePrivateField));
|
|
939
|
-
const indexHash = createHash(stringifiedIndex);
|
|
940
|
-
indexHashByGroup[group] = indexHash;
|
|
941
|
-
const [version, lang] = group.split('###');
|
|
942
|
-
const indexVersion = version ? `.${version.replace('.', '_')}` : '';
|
|
943
|
-
const indexLang = lang ? `.${lang}` : '';
|
|
944
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].mkdir(TEMP_DIR, {
|
|
945
|
-
recursive: true
|
|
946
|
-
});
|
|
947
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(TEMP_DIR, `${__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.SEARCH_INDEX_NAME}${indexVersion}${indexLang}.${indexHash}.json`), stringifiedIndex);
|
|
948
|
-
}));
|
|
949
|
-
await Promise.all(pages.map(async (pageData)=>pluginDriver.extendPageData(pageData)));
|
|
950
|
-
const siteData = {
|
|
951
|
-
title: (null == userConfig ? void 0 : userConfig.title) || '',
|
|
952
|
-
description: (null == userConfig ? void 0 : userConfig.description) || '',
|
|
953
|
-
icon: (null == userConfig ? void 0 : userConfig.icon) || '',
|
|
954
|
-
route: (null == userConfig ? void 0 : userConfig.route) || {},
|
|
955
|
-
themeConfig: normalizeThemeConfig(userConfig, pages),
|
|
956
|
-
base: (null == userConfig ? void 0 : userConfig.base) || '/',
|
|
957
|
-
lang: (null == userConfig ? void 0 : userConfig.lang) || '',
|
|
958
|
-
locales: (null == userConfig ? void 0 : userConfig.locales) || (null === (_userConfig_themeConfig = userConfig.themeConfig) || void 0 === _userConfig_themeConfig ? void 0 : _userConfig_themeConfig.locales) || [],
|
|
959
|
-
logo: (null == userConfig ? void 0 : userConfig.logo) || '',
|
|
960
|
-
logoText: (null == userConfig ? void 0 : userConfig.logoText) || '',
|
|
961
|
-
ssg: Boolean(null == userConfig ? void 0 : userConfig.ssg) ?? true,
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
const
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
[runtimeModule_RuntimeModuleID.
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
RuntimeModuleID["
|
|
1037
|
-
RuntimeModuleID["
|
|
1038
|
-
RuntimeModuleID["
|
|
1039
|
-
RuntimeModuleID["
|
|
1040
|
-
RuntimeModuleID["
|
|
1041
|
-
RuntimeModuleID["
|
|
1042
|
-
RuntimeModuleID["
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
const
|
|
1051
|
-
const
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1063
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info(__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
(0
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
return
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
'react
|
|
1127
|
-
'react-
|
|
1128
|
-
'react-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
'
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
const
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
};
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
const
|
|
1212
|
-
const
|
|
1213
|
-
const
|
|
1214
|
-
const
|
|
1215
|
-
const
|
|
1216
|
-
const
|
|
1217
|
-
const
|
|
1218
|
-
const
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
]
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
]
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
]
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
'
|
|
1294
|
-
'
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
'process.env.
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
const
|
|
1329
|
-
const
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
if (
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
const
|
|
1421
|
-
const
|
|
1422
|
-
const
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
const
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
const
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
const
|
|
1522
|
-
|
|
1523
|
-
const
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
await
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
const
|
|
1611
|
-
const
|
|
1612
|
-
const
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
helmet.
|
|
1642
|
-
helmet.
|
|
1643
|
-
helmet.
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
const
|
|
1679
|
-
await pluginDriver.
|
|
1680
|
-
const
|
|
1681
|
-
await
|
|
1682
|
-
|
|
1683
|
-
await
|
|
1684
|
-
await pluginDriver
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
const
|
|
1691
|
-
const
|
|
1692
|
-
const
|
|
1693
|
-
const
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
const
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1
|
+
import __rslib_shim_module__ from 'module';
|
|
2
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_plugin_container_syntax_12d3c700__ from "@rspress-theme-anatole/plugin-container-syntax";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress-theme-anatole/shared";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_less_4c557a99__ from "@rsbuild/plugin-less";
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__ from "@rsbuild/plugin-react";
|
|
9
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_sass_b13a7d33__ from "@rsbuild/plugin-sass";
|
|
10
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
|
|
11
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__ from "@rspress-theme-anatole/shared/constants";
|
|
12
|
+
import * as __WEBPACK_EXTERNAL_MODULE_tinyglobby__ from "tinyglobby";
|
|
13
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
|
|
14
|
+
import * as __WEBPACK_EXTERNAL_MODULE_rspack_plugin_virtual_module_609978fd__ from "rspack-plugin-virtual-module";
|
|
15
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__ from "@rspress-theme-anatole/shared/logger";
|
|
16
|
+
import * as __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__ from "lodash-es";
|
|
17
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__ from "node:crypto";
|
|
18
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_mdx_rs_d2f3021f__ from "@rspress/mdx-rs";
|
|
19
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__ from "@rspress-theme-anatole/shared/node-utils";
|
|
20
|
+
import * as __WEBPACK_EXTERNAL_MODULE_html_to_text_2c51ed38__ from "html-to-text";
|
|
21
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
22
|
+
import * as __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__ from "@mdx-js/mdx";
|
|
23
|
+
import * as __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__ from "enhanced-resolve";
|
|
24
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
|
|
25
|
+
import * as __WEBPACK_EXTERNAL_MODULE_picocolors__ from "picocolors";
|
|
26
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__ from "react-helmet-async";
|
|
27
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
|
|
28
|
+
export * from "@rspress-theme-anatole/shared";
|
|
29
|
+
function _check_private_redeclaration(obj, privateCollection) {
|
|
30
|
+
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
31
|
+
}
|
|
32
|
+
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
33
|
+
if (descriptor.get) return descriptor.get.call(receiver);
|
|
34
|
+
return descriptor.value;
|
|
35
|
+
}
|
|
36
|
+
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
37
|
+
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
38
|
+
else {
|
|
39
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
40
|
+
descriptor.value = value;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
44
|
+
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
45
|
+
return privateMap.get(receiver);
|
|
46
|
+
}
|
|
47
|
+
function _class_private_field_get(receiver, privateMap) {
|
|
48
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
49
|
+
return _class_apply_descriptor_get(receiver, descriptor);
|
|
50
|
+
}
|
|
51
|
+
function _class_private_field_init(obj, privateMap, value) {
|
|
52
|
+
_check_private_redeclaration(obj, privateMap);
|
|
53
|
+
privateMap.set(obj, value);
|
|
54
|
+
}
|
|
55
|
+
function _class_private_field_set(receiver, privateMap, value) {
|
|
56
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
57
|
+
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
var _config = /*#__PURE__*/ new WeakMap(), _plugins = /*#__PURE__*/ new WeakMap(), _isProd = /*#__PURE__*/ new WeakMap();
|
|
61
|
+
class PluginDriver {
|
|
62
|
+
async init() {
|
|
63
|
+
var _themeConfig_locales, _themeConfig_locales_, _themeConfig_locales1, _themeConfig_locales_1, _themeConfig_locales2;
|
|
64
|
+
this.clearPlugins();
|
|
65
|
+
const config = _class_private_field_get(this, _config);
|
|
66
|
+
const themeConfig = (null == config ? void 0 : config.themeConfig) || {};
|
|
67
|
+
const enableLastUpdated = (null == themeConfig ? void 0 : themeConfig.lastUpdated) || (null == themeConfig ? void 0 : null === (_themeConfig_locales = themeConfig.locales) || void 0 === _themeConfig_locales ? void 0 : _themeConfig_locales.some((locale)=>locale.lastUpdated));
|
|
68
|
+
const mediumZoomConfig = (null == config ? void 0 : config.mediumZoom) ?? true;
|
|
69
|
+
const haveNavSidebarConfig = themeConfig.nav || themeConfig.sidebar || (null === (_themeConfig_locales1 = themeConfig.locales) || void 0 === _themeConfig_locales1 ? void 0 : null === (_themeConfig_locales_ = _themeConfig_locales1[0]) || void 0 === _themeConfig_locales_ ? void 0 : _themeConfig_locales_.nav) || (null === (_themeConfig_locales2 = themeConfig.locales) || void 0 === _themeConfig_locales2 ? void 0 : null === (_themeConfig_locales_1 = _themeConfig_locales2[0]) || void 0 === _themeConfig_locales_1 ? void 0 : _themeConfig_locales_1.sidebar);
|
|
70
|
+
if (enableLastUpdated) {
|
|
71
|
+
const { pluginLastUpdated } = await import("@rspress/plugin-last-updated");
|
|
72
|
+
this.addPlugin(pluginLastUpdated());
|
|
73
|
+
}
|
|
74
|
+
if (mediumZoomConfig) {
|
|
75
|
+
const { pluginMediumZoom } = await import("@rspress/plugin-medium-zoom");
|
|
76
|
+
this.addPlugin(pluginMediumZoom('object' == typeof mediumZoomConfig ? mediumZoomConfig : void 0));
|
|
77
|
+
}
|
|
78
|
+
this.addPlugin((0, __WEBPACK_EXTERNAL_MODULE__rspress_plugin_container_syntax_12d3c700__.pluginContainerSyntax)());
|
|
79
|
+
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isDevDebugMode)()) {
|
|
80
|
+
const SourceBuildPlugin = await import("@rspress-theme-anatole/theme-default/node/source-build-plugin.js").then((r)=>r.SourceBuildPlugin, ()=>null);
|
|
81
|
+
if (SourceBuildPlugin) this.addPlugin(SourceBuildPlugin());
|
|
82
|
+
}
|
|
83
|
+
(config.plugins || []).forEach((plugin)=>{
|
|
84
|
+
this.addPlugin(plugin);
|
|
85
|
+
});
|
|
86
|
+
if (!haveNavSidebarConfig) {
|
|
87
|
+
const { pluginAutoNavSidebar } = await import("@rspress/plugin-auto-nav-sidebar");
|
|
88
|
+
this.addPlugin(pluginAutoNavSidebar());
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
addPlugin(plugin) {
|
|
92
|
+
const existedIndex = _class_private_field_get(this, _plugins).findIndex((item)=>item.name === plugin.name);
|
|
93
|
+
if (-1 !== existedIndex) throw new Error(`The plugin "${plugin.name}" has been registered`);
|
|
94
|
+
_class_private_field_get(this, _plugins).push(plugin);
|
|
95
|
+
}
|
|
96
|
+
getPlugins() {
|
|
97
|
+
return _class_private_field_get(this, _plugins);
|
|
98
|
+
}
|
|
99
|
+
clearPlugins() {
|
|
100
|
+
_class_private_field_set(this, _plugins, []);
|
|
101
|
+
}
|
|
102
|
+
removePlugin(pluginName) {
|
|
103
|
+
const index = _class_private_field_get(this, _plugins).findIndex((item)=>item.name === pluginName);
|
|
104
|
+
if (-1 !== index) _class_private_field_get(this, _plugins).splice(index, 1);
|
|
105
|
+
}
|
|
106
|
+
async modifyConfig() {
|
|
107
|
+
let config = _class_private_field_get(this, _config);
|
|
108
|
+
for(let i = 0; i < _class_private_field_get(this, _plugins).length; i++){
|
|
109
|
+
const plugin = _class_private_field_get(this, _plugins)[i];
|
|
110
|
+
if ('function' == typeof plugin.config) config = await plugin.config(config || {}, {
|
|
111
|
+
addPlugin: this.addPlugin.bind(this),
|
|
112
|
+
removePlugin: (pluginName)=>{
|
|
113
|
+
const index = _class_private_field_get(this, _plugins).findIndex((item)=>item.name === pluginName);
|
|
114
|
+
this.removePlugin(pluginName);
|
|
115
|
+
if (index <= i && index > 0) i--;
|
|
116
|
+
}
|
|
117
|
+
}, _class_private_field_get(this, _isProd));
|
|
118
|
+
}
|
|
119
|
+
_class_private_field_set(this, _config, config);
|
|
120
|
+
return _class_private_field_get(this, _config);
|
|
121
|
+
}
|
|
122
|
+
async beforeBuild() {
|
|
123
|
+
return this._runParallelAsyncHook('beforeBuild', _class_private_field_get(this, _config) || {}, _class_private_field_get(this, _isProd));
|
|
124
|
+
}
|
|
125
|
+
async afterBuild() {
|
|
126
|
+
return this._runParallelAsyncHook('afterBuild', _class_private_field_get(this, _config) || {}, _class_private_field_get(this, _isProd));
|
|
127
|
+
}
|
|
128
|
+
async modifySearchIndexData(pages) {
|
|
129
|
+
return this._runParallelAsyncHook('modifySearchIndexData', pages, _class_private_field_get(this, _isProd));
|
|
130
|
+
}
|
|
131
|
+
async extendPageData(pageData) {
|
|
132
|
+
return this._runParallelAsyncHook('extendPageData', pageData, _class_private_field_get(this, _isProd));
|
|
133
|
+
}
|
|
134
|
+
async addPages() {
|
|
135
|
+
const result = await this._runParallelAsyncHook('addPages', _class_private_field_get(this, _config) || {}, _class_private_field_get(this, _isProd));
|
|
136
|
+
return result.flat();
|
|
137
|
+
}
|
|
138
|
+
async routeGenerated(routes) {
|
|
139
|
+
return this._runParallelAsyncHook('routeGenerated', routes, _class_private_field_get(this, _isProd));
|
|
140
|
+
}
|
|
141
|
+
async addRuntimeModules() {
|
|
142
|
+
const result = await this._runParallelAsyncHook('addRuntimeModules', _class_private_field_get(this, _config) || {}, _class_private_field_get(this, _isProd));
|
|
143
|
+
return result.reduce((prev, current)=>({
|
|
144
|
+
...prev,
|
|
145
|
+
...current
|
|
146
|
+
}), {});
|
|
147
|
+
}
|
|
148
|
+
async addSSGRoutes() {
|
|
149
|
+
const result = await this._runParallelAsyncHook('addSSGRoutes', _class_private_field_get(this, _config) || {}, _class_private_field_get(this, _isProd));
|
|
150
|
+
return result.flat();
|
|
151
|
+
}
|
|
152
|
+
globalUIComponents() {
|
|
153
|
+
const result = _class_private_field_get(this, _plugins).map((plugin)=>plugin.globalUIComponents || []);
|
|
154
|
+
return result.flat();
|
|
155
|
+
}
|
|
156
|
+
globalStyles() {
|
|
157
|
+
return _class_private_field_get(this, _plugins).filter((plugin)=>'string' == typeof plugin.globalStyles).map((plugin)=>plugin.globalStyles);
|
|
158
|
+
}
|
|
159
|
+
_runParallelAsyncHook(hookName, ...args) {
|
|
160
|
+
return Promise.all(_class_private_field_get(this, _plugins).filter((plugin)=>'function' == typeof plugin[hookName]).map((plugin)=>plugin[hookName](...args)));
|
|
161
|
+
}
|
|
162
|
+
_runSerialAsyncHook(hookName, ...args) {
|
|
163
|
+
return _class_private_field_get(this, _plugins).reduce(async (prev, plugin)=>{
|
|
164
|
+
if ('function' == typeof plugin[hookName]) {
|
|
165
|
+
await prev;
|
|
166
|
+
return plugin[hookName](...args);
|
|
167
|
+
}
|
|
168
|
+
return prev;
|
|
169
|
+
}, Promise.resolve());
|
|
170
|
+
}
|
|
171
|
+
constructor(config, isProd){
|
|
172
|
+
_class_private_field_init(this, _config, {
|
|
173
|
+
writable: true,
|
|
174
|
+
value: void 0
|
|
175
|
+
});
|
|
176
|
+
_class_private_field_init(this, _plugins, {
|
|
177
|
+
writable: true,
|
|
178
|
+
value: void 0
|
|
179
|
+
});
|
|
180
|
+
_class_private_field_init(this, _isProd, {
|
|
181
|
+
writable: true,
|
|
182
|
+
value: void 0
|
|
183
|
+
});
|
|
184
|
+
_class_private_field_set(this, _config, config);
|
|
185
|
+
_class_private_field_set(this, _isProd, isProd);
|
|
186
|
+
_class_private_field_set(this, _plugins, []);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const isProduction = ()=>'production' === process.env.NODE_ENV;
|
|
190
|
+
const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
|
|
191
|
+
const inlineThemeScript = `{
|
|
192
|
+
const saved = localStorage.getItem('${__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.APPEARANCE_KEY}')
|
|
193
|
+
const preferDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
194
|
+
const isDark = !saved || saved === 'auto' ? preferDark : saved === 'dark'
|
|
195
|
+
document.documentElement.classList.toggle('dark', isDark)
|
|
196
|
+
document.documentElement.style.colorScheme = isDark ? 'dark' : 'light'
|
|
197
|
+
}`.replace(/\n/g, ';').replace(/\s{2,}/g, '');
|
|
198
|
+
const dirname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(new URL(import.meta.url)));
|
|
199
|
+
const PACKAGE_ROOT = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dirname, '..');
|
|
200
|
+
const CLIENT_ENTRY = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'clientEntry.js');
|
|
201
|
+
const SSR_ENTRY = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrEntry.js');
|
|
202
|
+
const OUTPUT_DIR = 'doc_build';
|
|
203
|
+
const APP_HTML_MARKER = '<!--<?- DOC_CONTENT ?>-->';
|
|
204
|
+
const HEAD_MARKER = '<!--<?- HEAD ?>-->';
|
|
205
|
+
const META_GENERATOR = '<!--<?- GENERATOR ?>-->';
|
|
206
|
+
const HTML_START_TAG = '<html';
|
|
207
|
+
const BODY_START_TAG = '<body';
|
|
208
|
+
const DEFAULT_TITLE = 'Rspress';
|
|
209
|
+
const PUBLIC_DIR = 'public';
|
|
210
|
+
const TEMP_DIR = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), 'node_modules', __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.RSPRESS_TEMP_DIR);
|
|
211
|
+
const isWindows = 'win32' === __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__["default"].platform();
|
|
212
|
+
function slash(p) {
|
|
213
|
+
return p.replace(/\\/g, '/');
|
|
214
|
+
}
|
|
215
|
+
function normalizePath(id) {
|
|
216
|
+
return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.normalize(isWindows ? slash(id) : id);
|
|
217
|
+
}
|
|
218
|
+
function getPageKey(route) {
|
|
219
|
+
const cleanRoute = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.removeLeadingSlash)(route);
|
|
220
|
+
return cleanRoute.replace(/\//g, '_').replace(/\.[^.]+$/, '') || 'index';
|
|
221
|
+
}
|
|
222
|
+
const normalizeRoutePath = (routePath, base, lang, version, langs, versions, extensions = __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__.DEFAULT_PAGE_EXTENSIONS)=>{
|
|
223
|
+
const hasTrailSlash = routePath.endsWith('/');
|
|
224
|
+
let versionPart = '';
|
|
225
|
+
let langPart = '';
|
|
226
|
+
let purePathPart = '';
|
|
227
|
+
const parts = routePath.split('/').filter(Boolean);
|
|
228
|
+
if (version) {
|
|
229
|
+
const versionToMatch = parts[0];
|
|
230
|
+
if (versions.includes(versionToMatch)) {
|
|
231
|
+
if (versionToMatch !== version) versionPart = versionToMatch;
|
|
232
|
+
parts.shift();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (lang) {
|
|
236
|
+
const langToMatch = parts[0];
|
|
237
|
+
if (langs.includes(langToMatch)) {
|
|
238
|
+
if (langToMatch !== lang) langPart = langToMatch;
|
|
239
|
+
parts.shift();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
purePathPart = parts.join('/');
|
|
243
|
+
const extensionsWithoutDot = extensions.map((i)=>i.slice(1));
|
|
244
|
+
const cleanExtensionPattern = new RegExp(`\\.(${extensionsWithoutDot.join('|')})$`, 'i');
|
|
245
|
+
let normalizedRoutePath = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.addLeadingSlash)([
|
|
246
|
+
versionPart,
|
|
247
|
+
langPart,
|
|
248
|
+
purePathPart
|
|
249
|
+
].filter(Boolean).join('/')).replace(cleanExtensionPattern, '').replace(/\.html$/, '').replace(/\/index$/, '/');
|
|
250
|
+
if (hasTrailSlash) normalizedRoutePath = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.addTrailingSlash)(normalizedRoutePath);
|
|
251
|
+
return {
|
|
252
|
+
routePath: (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.withBase)(normalizedRoutePath, base),
|
|
253
|
+
lang: langPart || lang,
|
|
254
|
+
version: versionPart || version
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
function RouteService_check_private_redeclaration(obj, privateCollection) {
|
|
258
|
+
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
259
|
+
}
|
|
260
|
+
function RouteService_class_apply_descriptor_get(receiver, descriptor) {
|
|
261
|
+
if (descriptor.get) return descriptor.get.call(receiver);
|
|
262
|
+
return descriptor.value;
|
|
263
|
+
}
|
|
264
|
+
function RouteService_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
265
|
+
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
266
|
+
else {
|
|
267
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
268
|
+
descriptor.value = value;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function RouteService_class_extract_field_descriptor(receiver, privateMap, action) {
|
|
272
|
+
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
273
|
+
return privateMap.get(receiver);
|
|
274
|
+
}
|
|
275
|
+
function RouteService_class_private_field_get(receiver, privateMap) {
|
|
276
|
+
var descriptor = RouteService_class_extract_field_descriptor(receiver, privateMap, "get");
|
|
277
|
+
return RouteService_class_apply_descriptor_get(receiver, descriptor);
|
|
278
|
+
}
|
|
279
|
+
function RouteService_class_private_field_init(obj, privateMap, value) {
|
|
280
|
+
RouteService_check_private_redeclaration(obj, privateMap);
|
|
281
|
+
privateMap.set(obj, value);
|
|
282
|
+
}
|
|
283
|
+
function RouteService_class_private_field_set(receiver, privateMap, value) {
|
|
284
|
+
var descriptor = RouteService_class_extract_field_descriptor(receiver, privateMap, "set");
|
|
285
|
+
RouteService_class_apply_descriptor_set(receiver, descriptor, value);
|
|
286
|
+
return value;
|
|
287
|
+
}
|
|
288
|
+
function _class_private_method_get(receiver, privateSet, fn) {
|
|
289
|
+
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
290
|
+
return fn;
|
|
291
|
+
}
|
|
292
|
+
function _class_private_method_init(obj, privateSet) {
|
|
293
|
+
RouteService_check_private_redeclaration(obj, privateSet);
|
|
294
|
+
privateSet.add(obj);
|
|
295
|
+
}
|
|
296
|
+
function _define_property(obj, key, value) {
|
|
297
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
298
|
+
value: value,
|
|
299
|
+
enumerable: true,
|
|
300
|
+
configurable: true,
|
|
301
|
+
writable: true
|
|
302
|
+
});
|
|
303
|
+
else obj[key] = value;
|
|
304
|
+
return obj;
|
|
305
|
+
}
|
|
306
|
+
var _scanDir = /*#__PURE__*/ new WeakMap(), _defaultLang = /*#__PURE__*/ new WeakMap(), _defaultVersion = /*#__PURE__*/ new WeakMap(), _extensions = /*#__PURE__*/ new WeakMap(), _langs = /*#__PURE__*/ new WeakMap(), _versions = /*#__PURE__*/ new WeakMap(), _include = /*#__PURE__*/ new WeakMap(), _exclude = /*#__PURE__*/ new WeakMap(), _base = /*#__PURE__*/ new WeakMap(), _tempDir = /*#__PURE__*/ new WeakMap(), _pluginDriver = /*#__PURE__*/ new WeakMap(), _writeTempFile = /*#__PURE__*/ new WeakSet(), _generateRouteInfo = /*#__PURE__*/ new WeakSet();
|
|
307
|
+
class RouteService {
|
|
308
|
+
async init() {
|
|
309
|
+
const extensions = RouteService_class_private_field_get(this, _extensions).map((i)=>i.slice(1));
|
|
310
|
+
const files = (await (0, __WEBPACK_EXTERNAL_MODULE_tinyglobby__.glob)([
|
|
311
|
+
`**/*.{${extensions.join(',')}}`,
|
|
312
|
+
...RouteService_class_private_field_get(this, _include)
|
|
313
|
+
], {
|
|
314
|
+
cwd: RouteService_class_private_field_get(this, _scanDir),
|
|
315
|
+
absolute: true,
|
|
316
|
+
onlyFiles: true,
|
|
317
|
+
ignore: [
|
|
318
|
+
...RouteService_class_private_field_get(this, _exclude),
|
|
319
|
+
'**/node_modules/**',
|
|
320
|
+
'**/.eslintrc.js',
|
|
321
|
+
'**/.nx/**',
|
|
322
|
+
`./${PUBLIC_DIR}/**`
|
|
323
|
+
]
|
|
324
|
+
})).sort();
|
|
325
|
+
files.forEach((filePath)=>{
|
|
326
|
+
const fileRelativePath = normalizePath(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(RouteService_class_private_field_get(this, _scanDir), filePath));
|
|
327
|
+
const { routePath, lang, version } = this.normalizeRoutePath(fileRelativePath);
|
|
328
|
+
const absolutePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(RouteService_class_private_field_get(this, _scanDir), fileRelativePath);
|
|
329
|
+
const routeInfo = {
|
|
330
|
+
routePath,
|
|
331
|
+
absolutePath: normalizePath(absolutePath),
|
|
332
|
+
relativePath: fileRelativePath,
|
|
333
|
+
pageName: getPageKey(fileRelativePath),
|
|
334
|
+
lang,
|
|
335
|
+
version
|
|
336
|
+
};
|
|
337
|
+
this.addRoute(routeInfo);
|
|
338
|
+
});
|
|
339
|
+
const externalPages = await RouteService_class_private_field_get(this, _pluginDriver).addPages();
|
|
340
|
+
await Promise.all(externalPages.map(async (route, index)=>{
|
|
341
|
+
const { routePath, content, filepath } = route;
|
|
342
|
+
if (filepath) {
|
|
343
|
+
const routeInfo = _class_private_method_get(this, _generateRouteInfo, generateRouteInfo).call(this, routePath, filepath);
|
|
344
|
+
this.addRoute(routeInfo);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
if (content) {
|
|
348
|
+
const filepath = await _class_private_method_get(this, _writeTempFile, writeTempFile).call(this, index, content);
|
|
349
|
+
const routeInfo = _class_private_method_get(this, _generateRouteInfo, generateRouteInfo).call(this, routePath, filepath);
|
|
350
|
+
this.addRoute(routeInfo);
|
|
351
|
+
}
|
|
352
|
+
}));
|
|
353
|
+
await RouteService_class_private_field_get(this, _pluginDriver).routeGenerated(this.getRoutes());
|
|
354
|
+
}
|
|
355
|
+
addRoute(routeInfo) {
|
|
356
|
+
const { routePath, absolutePath } = routeInfo;
|
|
357
|
+
if (this.routeData.has(routePath)) {
|
|
358
|
+
const preRouteExtIndex = RouteService_class_private_field_get(this, _extensions).indexOf(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(this.routeData.get(routePath).absolutePath));
|
|
359
|
+
const currRouteExtIndex = RouteService_class_private_field_get(this, _extensions).indexOf(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(absolutePath));
|
|
360
|
+
if (-1 !== currRouteExtIndex && (currRouteExtIndex < preRouteExtIndex || -1 === preRouteExtIndex)) this.routeData.set(routePath, routeInfo);
|
|
361
|
+
} else this.routeData.set(routePath, routeInfo);
|
|
362
|
+
}
|
|
363
|
+
removeRoute(filePath) {
|
|
364
|
+
const fileRelativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(RouteService_class_private_field_get(this, _scanDir), filePath);
|
|
365
|
+
const { routePath } = this.normalizeRoutePath(fileRelativePath);
|
|
366
|
+
this.routeData.delete(routePath);
|
|
367
|
+
}
|
|
368
|
+
getRoutes() {
|
|
369
|
+
return Array.from(this.routeData.values());
|
|
370
|
+
}
|
|
371
|
+
isExistRoute(routePath) {
|
|
372
|
+
const { routePath: normalizedRoute } = this.normalizeRoutePath(routePath);
|
|
373
|
+
return Boolean(this.routeData.get(normalizedRoute));
|
|
374
|
+
}
|
|
375
|
+
isEmpty() {
|
|
376
|
+
return 0 === this.routeData.size;
|
|
377
|
+
}
|
|
378
|
+
generateRoutesCode(isStaticImport = false) {
|
|
379
|
+
return this.generateRoutesCodeByRouteMeta(this.getRoutes(), isStaticImport);
|
|
380
|
+
}
|
|
381
|
+
generateRoutesCodeByRouteMeta(routeMeta, isStaticImport) {
|
|
382
|
+
return `
|
|
383
|
+
import React from 'react';
|
|
384
|
+
import { lazyWithPreload } from "react-lazy-with-preload";
|
|
385
|
+
${routeMeta.map((route, index)=>isStaticImport ? `import * as Route${index} from '${route.absolutePath}';` : `const Route${index} = lazyWithPreload(() => import('${route.absolutePath}'))`).join('\n')}
|
|
386
|
+
export const routes = [
|
|
387
|
+
${routeMeta.map((route, index)=>{
|
|
388
|
+
const preload = isStaticImport ? `() => Route${index}` : `async () => {
|
|
389
|
+
await Route${index}.preload();
|
|
390
|
+
return import("${route.absolutePath}");
|
|
391
|
+
}`;
|
|
392
|
+
const component = isStaticImport ? `Route${index}.default` : `Route${index}`;
|
|
393
|
+
return `{ path: '${route.routePath}', element: React.createElement(${component}), filePath: '${route.relativePath}', preload: ${preload}, lang: '${route.lang}', version: '${route.version}' }`;
|
|
394
|
+
}).join(',\n')}
|
|
395
|
+
];
|
|
396
|
+
`;
|
|
397
|
+
}
|
|
398
|
+
normalizeRoutePath(routePath) {
|
|
399
|
+
return normalizeRoutePath(routePath, RouteService_class_private_field_get(this, _base), RouteService_class_private_field_get(this, _defaultLang), RouteService_class_private_field_get(this, _defaultVersion), RouteService_class_private_field_get(this, _langs), RouteService_class_private_field_get(this, _versions), RouteService_class_private_field_get(this, _extensions));
|
|
400
|
+
}
|
|
401
|
+
constructor(scanDir, userConfig, tempDir, pluginDriver){
|
|
402
|
+
var _userConfig_themeConfig;
|
|
403
|
+
_class_private_method_init(this, _writeTempFile);
|
|
404
|
+
_class_private_method_init(this, _generateRouteInfo);
|
|
405
|
+
_define_property(this, "routeData", new Map());
|
|
406
|
+
RouteService_class_private_field_init(this, _scanDir, {
|
|
407
|
+
writable: true,
|
|
408
|
+
value: void 0
|
|
409
|
+
});
|
|
410
|
+
RouteService_class_private_field_init(this, _defaultLang, {
|
|
411
|
+
writable: true,
|
|
412
|
+
value: void 0
|
|
413
|
+
});
|
|
414
|
+
RouteService_class_private_field_init(this, _defaultVersion, {
|
|
415
|
+
writable: true,
|
|
416
|
+
value: ''
|
|
417
|
+
});
|
|
418
|
+
RouteService_class_private_field_init(this, _extensions, {
|
|
419
|
+
writable: true,
|
|
420
|
+
value: []
|
|
421
|
+
});
|
|
422
|
+
RouteService_class_private_field_init(this, _langs, {
|
|
423
|
+
writable: true,
|
|
424
|
+
value: []
|
|
425
|
+
});
|
|
426
|
+
RouteService_class_private_field_init(this, _versions, {
|
|
427
|
+
writable: true,
|
|
428
|
+
value: []
|
|
429
|
+
});
|
|
430
|
+
RouteService_class_private_field_init(this, _include, {
|
|
431
|
+
writable: true,
|
|
432
|
+
value: []
|
|
433
|
+
});
|
|
434
|
+
RouteService_class_private_field_init(this, _exclude, {
|
|
435
|
+
writable: true,
|
|
436
|
+
value: []
|
|
437
|
+
});
|
|
438
|
+
RouteService_class_private_field_init(this, _base, {
|
|
439
|
+
writable: true,
|
|
440
|
+
value: ''
|
|
441
|
+
});
|
|
442
|
+
RouteService_class_private_field_init(this, _tempDir, {
|
|
443
|
+
writable: true,
|
|
444
|
+
value: ''
|
|
445
|
+
});
|
|
446
|
+
RouteService_class_private_field_init(this, _pluginDriver, {
|
|
447
|
+
writable: true,
|
|
448
|
+
value: void 0
|
|
449
|
+
});
|
|
450
|
+
const routeOptions = (null == userConfig ? void 0 : userConfig.route) || {};
|
|
451
|
+
RouteService_class_private_field_set(this, _scanDir, scanDir);
|
|
452
|
+
RouteService_class_private_field_set(this, _extensions, routeOptions.extensions || __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__.DEFAULT_PAGE_EXTENSIONS);
|
|
453
|
+
RouteService_class_private_field_set(this, _include, routeOptions.include || []);
|
|
454
|
+
RouteService_class_private_field_set(this, _exclude, routeOptions.exclude || []);
|
|
455
|
+
RouteService_class_private_field_set(this, _defaultLang, (null == userConfig ? void 0 : userConfig.lang) || '');
|
|
456
|
+
RouteService_class_private_field_set(this, _langs, ((null == userConfig ? void 0 : userConfig.locales) ?? (null == userConfig ? void 0 : null === (_userConfig_themeConfig = userConfig.themeConfig) || void 0 === _userConfig_themeConfig ? void 0 : _userConfig_themeConfig.locales) ?? []).map((item)=>item.lang));
|
|
457
|
+
RouteService_class_private_field_set(this, _base, (null == userConfig ? void 0 : userConfig.base) || '');
|
|
458
|
+
RouteService_class_private_field_set(this, _tempDir, tempDir);
|
|
459
|
+
RouteService_class_private_field_set(this, _pluginDriver, pluginDriver);
|
|
460
|
+
if (userConfig.multiVersion) {
|
|
461
|
+
RouteService_class_private_field_set(this, _defaultVersion, userConfig.multiVersion.default || '');
|
|
462
|
+
RouteService_class_private_field_set(this, _versions, userConfig.multiVersion.versions || []);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
async function writeTempFile(index, content) {
|
|
467
|
+
const tempFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(RouteService_class_private_field_get(this, _tempDir), `temp-${index}.mdx`);
|
|
468
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile(tempFilePath, content);
|
|
469
|
+
return tempFilePath;
|
|
470
|
+
}
|
|
471
|
+
function generateRouteInfo(routePath, filepath) {
|
|
472
|
+
const { routePath: normalizedPath, lang, version } = this.normalizeRoutePath(routePath);
|
|
473
|
+
return {
|
|
474
|
+
routePath: normalizedPath,
|
|
475
|
+
absolutePath: normalizePath(filepath),
|
|
476
|
+
relativePath: normalizePath(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(RouteService_class_private_field_get(this, _scanDir), filepath)),
|
|
477
|
+
pageName: getPageKey(routePath),
|
|
478
|
+
lang,
|
|
479
|
+
version
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
let init_routeService = null;
|
|
483
|
+
async function initRouteService(options) {
|
|
484
|
+
const { scanDir, config, runtimeTempDir, pluginDriver } = options;
|
|
485
|
+
init_routeService = new RouteService(scanDir, config, runtimeTempDir, pluginDriver);
|
|
486
|
+
await init_routeService.init();
|
|
487
|
+
return init_routeService;
|
|
488
|
+
}
|
|
489
|
+
async function globalStylesVMPlugin(context) {
|
|
490
|
+
const { config, pluginDriver } = context;
|
|
491
|
+
const globalStylesByPlugins = pluginDriver.globalStyles();
|
|
492
|
+
if (config.globalStyles) {
|
|
493
|
+
const source = config.globalStyles;
|
|
494
|
+
const styleContent = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(source, 'utf-8');
|
|
495
|
+
const patchedStyleContent = styleContent.replace(/--modern-/g, '--rp-').replace(/\.modern-doc/g, '.rspress').replace(/\.modern-/g, '.rspress-');
|
|
496
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile(source, patchedStyleContent, 'utf-8');
|
|
497
|
+
}
|
|
498
|
+
const moduleContent = (await Promise.all([
|
|
499
|
+
(null == config ? void 0 : config.globalStyles) || '',
|
|
500
|
+
...globalStylesByPlugins
|
|
501
|
+
].filter((source)=>source.length > 0).map(async (source)=>`import ${JSON.stringify(source)};`))).join('');
|
|
502
|
+
return {
|
|
503
|
+
[runtimeModule_RuntimeModuleID.GlobalStyles]: moduleContent
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
async function globalUIComponentsVMPlugin(context) {
|
|
507
|
+
const { config, pluginDriver } = context;
|
|
508
|
+
let index = 0;
|
|
509
|
+
const globalUIComponentsByPlugins = pluginDriver.globalUIComponents();
|
|
510
|
+
const globalComponents = [
|
|
511
|
+
...(null == config ? void 0 : config.globalUIComponents) || [],
|
|
512
|
+
...globalUIComponentsByPlugins
|
|
513
|
+
];
|
|
514
|
+
const moduleContent = globalComponents.map((source)=>{
|
|
515
|
+
const name = `Comp_${index}`;
|
|
516
|
+
if (Array.isArray(source)) return `import ${name} from ${JSON.stringify(source[0])};
|
|
517
|
+
const Props_${index++} = ${JSON.stringify(source[1])};\n`;
|
|
518
|
+
index++;
|
|
519
|
+
return `import ${name} from ${JSON.stringify(source)};\n`;
|
|
520
|
+
}).concat(`export default [${Array.from({
|
|
521
|
+
length: index
|
|
522
|
+
}, (_, i)=>{
|
|
523
|
+
if (Array.isArray(globalComponents[i])) return `[Comp_${i}, Props_${i}]`;
|
|
524
|
+
return `Comp_${i}`;
|
|
525
|
+
}).join(', ')}];`).join('');
|
|
526
|
+
return {
|
|
527
|
+
[runtimeModule_RuntimeModuleID.GlobalComponents]: moduleContent
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
const DEFAULT_I18N_SOURCE = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(process.cwd(), 'i18n.json');
|
|
531
|
+
function getI18nData(docConfig) {
|
|
532
|
+
const { i18nSourcePath = DEFAULT_I18N_SOURCE } = docConfig;
|
|
533
|
+
try {
|
|
534
|
+
delete require.cache[i18nSourcePath];
|
|
535
|
+
const i18nSource = require(i18nSourcePath);
|
|
536
|
+
return i18nSource;
|
|
537
|
+
} catch (e) {
|
|
538
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.debug('getI18nData Failed: \n', e);
|
|
539
|
+
return {};
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
function i18nVMPlugin(context) {
|
|
543
|
+
const { config } = context;
|
|
544
|
+
const i18nData = getI18nData(config);
|
|
545
|
+
return {
|
|
546
|
+
[runtimeModule_RuntimeModuleID.I18nText]: `export default ${JSON.stringify(i18nData, null, 2)}`
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
async function routeVMPlugin(context) {
|
|
550
|
+
const { routeService, isSSR } = context;
|
|
551
|
+
if (!isSSR) return {
|
|
552
|
+
[runtimeModule_RuntimeModuleID.RouteForClient]: routeService.generateRoutesCode(false),
|
|
553
|
+
[runtimeModule_RuntimeModuleID.RouteForSSR]: ''
|
|
554
|
+
};
|
|
555
|
+
return {
|
|
556
|
+
[runtimeModule_RuntimeModuleID.RouteForClient]: routeService.generateRoutesCode(false),
|
|
557
|
+
[runtimeModule_RuntimeModuleID.RouteForSSR]: routeService.generateRoutesCode(true)
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
async function searchHookVMPlugin(context) {
|
|
561
|
+
const { config } = context;
|
|
562
|
+
let content = 'export const onSearch = () => {};';
|
|
563
|
+
let extname = '';
|
|
564
|
+
if ('object' == typeof config.search && 'string' == typeof config.search.searchHooks) {
|
|
565
|
+
content = `export * from '${config.search.searchHooks}'`;
|
|
566
|
+
extname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(config.search.searchHooks);
|
|
567
|
+
}
|
|
568
|
+
return {
|
|
569
|
+
[`${runtimeModule_RuntimeModuleID.SearchHooks}${extname}`]: content
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
function createHash(str) {
|
|
573
|
+
return (0, __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.createHash)('sha256').update(str).digest('hex').slice(0, 8);
|
|
574
|
+
}
|
|
575
|
+
let flattenMdxContent_resolver;
|
|
576
|
+
let startFlatten = false;
|
|
577
|
+
const processor = (0, __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__.createProcessor)();
|
|
578
|
+
const { CachedInputFileSystem, ResolverFactory } = __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__["default"];
|
|
579
|
+
const fileSystem = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"];
|
|
580
|
+
async function resolveDepPath(importPath, importer, alias) {
|
|
581
|
+
if (!flattenMdxContent_resolver) flattenMdxContent_resolver = ResolverFactory.createResolver({
|
|
582
|
+
fileSystem: new CachedInputFileSystem(fileSystem, 0),
|
|
583
|
+
extensions: [
|
|
584
|
+
'.mdx',
|
|
585
|
+
'.md'
|
|
586
|
+
],
|
|
587
|
+
alias
|
|
588
|
+
});
|
|
589
|
+
const resolveResult = await new Promise((resolve, reject)=>{
|
|
590
|
+
flattenMdxContent_resolver.resolve({
|
|
591
|
+
importer
|
|
592
|
+
}, importer, importPath, {}, (err, filePath)=>{
|
|
593
|
+
if (err) return reject(err);
|
|
594
|
+
if (!filePath) return reject(new Error(`Empty result when resolving ${importPath} from ${importer}`));
|
|
595
|
+
return resolve(filePath);
|
|
596
|
+
});
|
|
597
|
+
});
|
|
598
|
+
return resolveResult;
|
|
599
|
+
}
|
|
600
|
+
async function flattenMdxContent(content, basePath, alias) {
|
|
601
|
+
const deps = [];
|
|
602
|
+
const regex = new RegExp(importStatementRegex);
|
|
603
|
+
if (!regex.test(content)) return {
|
|
604
|
+
flattenContent: content,
|
|
605
|
+
deps
|
|
606
|
+
};
|
|
607
|
+
if (!startFlatten) {
|
|
608
|
+
flattenMdxContent_resolver = ResolverFactory.createResolver({
|
|
609
|
+
fileSystem: new CachedInputFileSystem(fileSystem, 0),
|
|
610
|
+
extensions: [
|
|
611
|
+
'.mdx',
|
|
612
|
+
'.md',
|
|
613
|
+
'.js'
|
|
614
|
+
],
|
|
615
|
+
alias
|
|
616
|
+
});
|
|
617
|
+
startFlatten = true;
|
|
618
|
+
}
|
|
619
|
+
let ast;
|
|
620
|
+
let result = content;
|
|
621
|
+
try {
|
|
622
|
+
ast = processor.parse(content);
|
|
623
|
+
} catch (e) {
|
|
624
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.debug('flattenMdxContent parse failed: \n', e);
|
|
625
|
+
return {
|
|
626
|
+
flattenContent: content,
|
|
627
|
+
deps
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
const importNodes = ast.children.filter((node)=>'mdxjsEsm' === node.type).flatMap((node)=>{
|
|
631
|
+
var _node_data_estree, _node_data;
|
|
632
|
+
return (null === (_node_data = node.data) || void 0 === _node_data ? void 0 : null === (_node_data_estree = _node_data.estree) || void 0 === _node_data_estree ? void 0 : _node_data_estree.body) || [];
|
|
633
|
+
}).filter((node)=>'ImportDeclaration' === node.type);
|
|
634
|
+
for (const importNode of importNodes){
|
|
635
|
+
const id = importNode.specifiers[0].local.name;
|
|
636
|
+
const importPath = importNode.source.value;
|
|
637
|
+
let absoluteImportPath;
|
|
638
|
+
try {
|
|
639
|
+
absoluteImportPath = await resolveDepPath(importPath, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(basePath), alias);
|
|
640
|
+
} catch (_e) {
|
|
641
|
+
continue;
|
|
642
|
+
}
|
|
643
|
+
if (__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(absoluteImportPath)) {
|
|
644
|
+
const importedContent = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(absoluteImportPath, 'utf-8');
|
|
645
|
+
const { flattenContent: replacedValue, deps: subDeps } = await flattenMdxContent(importedContent, absoluteImportPath, alias);
|
|
646
|
+
result = result.replace(new RegExp(`import\\s+${id}\\s+from\\s+['"](${importPath})['"];?`), '').replace(new RegExp(`<${id}\\s*/>`, 'g'), ()=>replacedValue);
|
|
647
|
+
deps.push(...subDeps, absoluteImportPath);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return {
|
|
651
|
+
flattenContent: result,
|
|
652
|
+
deps
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
function applyReplaceRules(code = '', replaceRules = []) {
|
|
656
|
+
let result = code;
|
|
657
|
+
for (const rule of replaceRules)result = result.replace(rule.search, rule.replace);
|
|
658
|
+
return result;
|
|
659
|
+
}
|
|
660
|
+
function applyReplaceRulesToNestedObject(obj, replaceRules) {
|
|
661
|
+
for(const key in obj)if ('string' == typeof obj[key]) obj[key] = applyReplaceRules(obj[key], replaceRules);
|
|
662
|
+
else if ('object' == typeof obj[key] && null !== obj[key]) obj[key] = applyReplaceRulesToNestedObject(obj[key], replaceRules);
|
|
663
|
+
return obj;
|
|
664
|
+
}
|
|
665
|
+
async function extractPageData(replaceRules, alias, domain, root, routeService, highlighterLangs, searchCodeBlocks) {
|
|
666
|
+
const pageData = await Promise.all(routeService.getRoutes().map(async (route, index)=>{
|
|
667
|
+
const defaultIndexInfo = {
|
|
668
|
+
id: index,
|
|
669
|
+
title: '',
|
|
670
|
+
content: '',
|
|
671
|
+
_html: '',
|
|
672
|
+
routePath: route.routePath,
|
|
673
|
+
lang: route.lang,
|
|
674
|
+
toc: [],
|
|
675
|
+
domain,
|
|
676
|
+
frontmatter: {},
|
|
677
|
+
version: route.version,
|
|
678
|
+
_filepath: route.absolutePath,
|
|
679
|
+
_relativePath: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, route.absolutePath).split(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep).join('/')
|
|
680
|
+
};
|
|
681
|
+
if (!__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(route.absolutePath)) return defaultIndexInfo;
|
|
682
|
+
let content = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(route.absolutePath, 'utf8');
|
|
683
|
+
const { frontmatter, content: strippedFrontMatter } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.loadFrontMatter)(content, route.absolutePath, root);
|
|
684
|
+
applyReplaceRulesToNestedObject(frontmatter, replaceRules);
|
|
685
|
+
const { flattenContent } = await flattenMdxContent(applyReplaceRules(strippedFrontMatter, replaceRules), route.absolutePath, alias);
|
|
686
|
+
content = flattenContent.replace(importStatementRegex, '');
|
|
687
|
+
const { html: rawHtml, title, toc: rawToc, languages } = await (0, __WEBPACK_EXTERNAL_MODULE__rspress_mdx_rs_d2f3021f__.compile)({
|
|
688
|
+
value: content,
|
|
689
|
+
filepath: route.absolutePath,
|
|
690
|
+
development: 'production' !== process.env.NODE_ENV,
|
|
691
|
+
root
|
|
692
|
+
});
|
|
693
|
+
function encodeHtml(html) {
|
|
694
|
+
return html.replace(/<code>([\s\S]*?)<\/\s?code>/gm, function(_match, innerContent) {
|
|
695
|
+
return `<code>${innerContent.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>')}</code>`;
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
const html = encodeHtml(String(rawHtml));
|
|
699
|
+
content = (0, __WEBPACK_EXTERNAL_MODULE_html_to_text_2c51ed38__.htmlToText)(html, {
|
|
700
|
+
wordwrap: 80,
|
|
701
|
+
selectors: [
|
|
702
|
+
{
|
|
703
|
+
selector: 'a',
|
|
704
|
+
options: {
|
|
705
|
+
ignoreHref: true
|
|
706
|
+
}
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
selector: 'img',
|
|
710
|
+
format: 'skip'
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
selector: 'pre > code',
|
|
714
|
+
format: searchCodeBlocks ? 'block' : 'skip'
|
|
715
|
+
},
|
|
716
|
+
...[
|
|
717
|
+
'h1',
|
|
718
|
+
'h2',
|
|
719
|
+
'h3',
|
|
720
|
+
'h4',
|
|
721
|
+
'h5',
|
|
722
|
+
'h6'
|
|
723
|
+
].map((tag)=>({
|
|
724
|
+
selector: tag,
|
|
725
|
+
options: {
|
|
726
|
+
uppercase: false
|
|
727
|
+
}
|
|
728
|
+
}))
|
|
729
|
+
],
|
|
730
|
+
tables: true,
|
|
731
|
+
longWordSplit: {
|
|
732
|
+
forceWrapOnLimit: true
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
if (content.startsWith(title)) content = content.slice(title.length);
|
|
736
|
+
languages.forEach((lang)=>highlighterLangs.add(lang));
|
|
737
|
+
const toc = rawToc.map((item)=>{
|
|
738
|
+
const match = item.id.match(/-(\d+)$/);
|
|
739
|
+
let position = -1;
|
|
740
|
+
if (match) for(let i = 0; i < Number(match[1]); i++){
|
|
741
|
+
position = content.indexOf(`\n${item.text}#\n\n`, position + 1);
|
|
742
|
+
if (-1 === position) break;
|
|
743
|
+
}
|
|
744
|
+
return {
|
|
745
|
+
...item,
|
|
746
|
+
charIndex: content.indexOf(`\n${item.text}#\n\n`, position + 1)
|
|
747
|
+
};
|
|
748
|
+
});
|
|
749
|
+
return {
|
|
750
|
+
...defaultIndexInfo,
|
|
751
|
+
title: frontmatter.title || title,
|
|
752
|
+
toc,
|
|
753
|
+
content,
|
|
754
|
+
_html: html,
|
|
755
|
+
frontmatter: {
|
|
756
|
+
...frontmatter,
|
|
757
|
+
__content: void 0
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
}));
|
|
761
|
+
return pageData.filter(Boolean);
|
|
762
|
+
}
|
|
763
|
+
const highlightLanguages_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
|
|
764
|
+
let highlightLanguages_supportedLanguages;
|
|
765
|
+
function handleHighlightLanguages(highlightLanguages, defaultLanguages) {
|
|
766
|
+
const aliases = {};
|
|
767
|
+
if (highlightLanguages.size) {
|
|
768
|
+
if (!highlightLanguages_supportedLanguages) {
|
|
769
|
+
const langs = highlightLanguages_require('react-syntax-highlighter/dist/cjs/languages/prism/supported-languages').default;
|
|
770
|
+
highlightLanguages_supportedLanguages = new Set(langs);
|
|
771
|
+
}
|
|
772
|
+
let useDeprecatedTypeWarning = true;
|
|
773
|
+
const names = {};
|
|
774
|
+
[
|
|
775
|
+
...__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.DEFAULT_HIGHLIGHT_LANGUAGES,
|
|
776
|
+
...defaultLanguages
|
|
777
|
+
].forEach((lang)=>{
|
|
778
|
+
if (Array.isArray(lang)) {
|
|
779
|
+
const [alias, name] = lang;
|
|
780
|
+
names[alias] = name;
|
|
781
|
+
} else if (useDeprecatedTypeWarning) {
|
|
782
|
+
console.log(`${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellowBright('warning')} Automatic import is supported. \`highlightLanguages\` is now used only as alias, and string types will be ignored. \n`);
|
|
783
|
+
useDeprecatedTypeWarning = false;
|
|
784
|
+
}
|
|
785
|
+
});
|
|
786
|
+
[
|
|
787
|
+
...highlightLanguages.values()
|
|
788
|
+
].forEach((lang)=>{
|
|
789
|
+
const name = names[lang];
|
|
790
|
+
if (name && highlightLanguages_supportedLanguages.has(name)) {
|
|
791
|
+
const temp = aliases[name] || (aliases[name] = []);
|
|
792
|
+
if (!temp.includes(lang)) temp.push(lang);
|
|
793
|
+
highlightLanguages.delete(lang);
|
|
794
|
+
highlightLanguages.add(name);
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
if (!highlightLanguages_supportedLanguages.has(lang)) highlightLanguages.delete(lang);
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
return aliases;
|
|
801
|
+
}
|
|
802
|
+
function normalizeThemeConfig(docConfig, pages = []) {
|
|
803
|
+
const { locales: siteLocales, base = '', lang, replaceRules = [], multiVersion } = docConfig;
|
|
804
|
+
const { versions = [] } = multiVersion || {};
|
|
805
|
+
const hasMultiVersion = versions.length > 0;
|
|
806
|
+
docConfig.themeConfig = docConfig.themeConfig || {};
|
|
807
|
+
const { themeConfig } = docConfig;
|
|
808
|
+
const locales = siteLocales ?? ((null == themeConfig ? void 0 : themeConfig.locales) || []);
|
|
809
|
+
const i18nTextData = getI18nData(docConfig);
|
|
810
|
+
const normalizeLinkPrefix = (link = '', currentLang = '')=>{
|
|
811
|
+
const normalizedLink = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.slash)(link);
|
|
812
|
+
if (!currentLang || !link || (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.withoutBase)(normalizedLink, base).startsWith(`/${currentLang}`) || (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isExternalUrl)(normalizedLink) || hasMultiVersion) return normalizedLink;
|
|
813
|
+
return lang === currentLang ? normalizedLink : `/${currentLang}${(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.addLeadingSlash)(normalizedLink)}`;
|
|
814
|
+
};
|
|
815
|
+
const getI18nText = (key = '', currentLang = '')=>{
|
|
816
|
+
var _i18nTextData_key;
|
|
817
|
+
const text = null === (_i18nTextData_key = i18nTextData[key]) || void 0 === _i18nTextData_key ? void 0 : _i18nTextData_key[currentLang];
|
|
818
|
+
return text || key;
|
|
819
|
+
};
|
|
820
|
+
const normalizeSidebar = (sidebar, currentLang = '')=>{
|
|
821
|
+
const normalizedSidebar = {};
|
|
822
|
+
if (!sidebar) return {};
|
|
823
|
+
const normalizeSidebarItem = (item)=>{
|
|
824
|
+
if ('object' == typeof item && 'dividerType' in item) return item;
|
|
825
|
+
if ('object' == typeof item && 'sectionHeaderText' in item) {
|
|
826
|
+
item.sectionHeaderText = applyReplaceRules(getI18nText(item.sectionHeaderText, currentLang), replaceRules);
|
|
827
|
+
return item;
|
|
828
|
+
}
|
|
829
|
+
if ('object' == typeof item && 'items' in item) return {
|
|
830
|
+
...item,
|
|
831
|
+
text: applyReplaceRules(getI18nText(item.text, currentLang), replaceRules),
|
|
832
|
+
link: normalizeLinkPrefix(item.link),
|
|
833
|
+
collapsed: item.collapsed ?? false,
|
|
834
|
+
collapsible: item.collapsible ?? true,
|
|
835
|
+
tag: item.tag,
|
|
836
|
+
items: item.items.map((subItem)=>normalizeSidebarItem(subItem))
|
|
837
|
+
};
|
|
838
|
+
if ('string' == typeof item) {
|
|
839
|
+
const normalizedItem = normalizeLinkPrefix(item, currentLang);
|
|
840
|
+
const page = pages.find((page)=>page.routePath === (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.withBase)(normalizedItem, base));
|
|
841
|
+
return {
|
|
842
|
+
text: applyReplaceRules((null == page ? void 0 : page.title) || '', replaceRules),
|
|
843
|
+
link: normalizedItem,
|
|
844
|
+
_fileKey: null == page ? void 0 : page._relativePath.replace(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(page._relativePath), '')
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
return {
|
|
848
|
+
...item,
|
|
849
|
+
text: applyReplaceRules(getI18nText(item.text, currentLang), replaceRules),
|
|
850
|
+
link: normalizeLinkPrefix(item.link),
|
|
851
|
+
tag: item.tag
|
|
852
|
+
};
|
|
853
|
+
};
|
|
854
|
+
const normalizeSidebar = (sidebar)=>{
|
|
855
|
+
Object.keys(sidebar).forEach((key)=>{
|
|
856
|
+
const value = sidebar[key];
|
|
857
|
+
normalizedSidebar[key] = value.map(normalizeSidebarItem);
|
|
858
|
+
});
|
|
859
|
+
};
|
|
860
|
+
normalizeSidebar(sidebar);
|
|
861
|
+
return normalizedSidebar;
|
|
862
|
+
};
|
|
863
|
+
const normalizeNav = (nav, currentLang)=>{
|
|
864
|
+
if (!nav) return [];
|
|
865
|
+
const transformNavItem = (navItem)=>{
|
|
866
|
+
const text = applyReplaceRules(getI18nText(navItem.text, currentLang), replaceRules);
|
|
867
|
+
if ('link' in navItem) return {
|
|
868
|
+
...navItem,
|
|
869
|
+
text,
|
|
870
|
+
link: normalizeLinkPrefix(navItem.link, currentLang)
|
|
871
|
+
};
|
|
872
|
+
if ('items' in navItem) return {
|
|
873
|
+
...navItem,
|
|
874
|
+
text,
|
|
875
|
+
items: navItem.items.map((item)=>({
|
|
876
|
+
...item,
|
|
877
|
+
text: applyReplaceRules(getI18nText(item.text, currentLang), replaceRules),
|
|
878
|
+
link: normalizeLinkPrefix(item.link, currentLang)
|
|
879
|
+
}))
|
|
880
|
+
};
|
|
881
|
+
return navItem;
|
|
882
|
+
};
|
|
883
|
+
if (Array.isArray(nav)) return nav.map(transformNavItem);
|
|
884
|
+
return Object.entries(nav).reduce((acc, [key, value])=>{
|
|
885
|
+
acc[key] = value.map(transformNavItem);
|
|
886
|
+
return acc;
|
|
887
|
+
}, {});
|
|
888
|
+
};
|
|
889
|
+
if (locales.length) themeConfig.locales = locales.map(({ lang: currentLang, label })=>{
|
|
890
|
+
var _themeConfig_locales;
|
|
891
|
+
const localeInThemeConfig = null === (_themeConfig_locales = themeConfig.locales) || void 0 === _themeConfig_locales ? void 0 : _themeConfig_locales.find((locale)=>locale.lang === currentLang);
|
|
892
|
+
return {
|
|
893
|
+
lang: currentLang,
|
|
894
|
+
label,
|
|
895
|
+
...localeInThemeConfig || {},
|
|
896
|
+
sidebar: normalizeSidebar((null == localeInThemeConfig ? void 0 : localeInThemeConfig.sidebar) ?? themeConfig.sidebar, currentLang),
|
|
897
|
+
nav: normalizeNav((null == localeInThemeConfig ? void 0 : localeInThemeConfig.nav) ?? themeConfig.nav, currentLang)
|
|
898
|
+
};
|
|
899
|
+
});
|
|
900
|
+
else {
|
|
901
|
+
themeConfig.sidebar = normalizeSidebar(null == themeConfig ? void 0 : themeConfig.sidebar);
|
|
902
|
+
themeConfig.nav = normalizeNav(null == themeConfig ? void 0 : themeConfig.nav);
|
|
903
|
+
}
|
|
904
|
+
return themeConfig;
|
|
905
|
+
}
|
|
906
|
+
function deletePrivateField(obj) {
|
|
907
|
+
if ('object' != typeof obj || null === obj) return obj;
|
|
908
|
+
const newObj = {
|
|
909
|
+
...obj
|
|
910
|
+
};
|
|
911
|
+
for(const key in newObj)if (key.startsWith('_')) delete newObj[key];
|
|
912
|
+
return newObj;
|
|
913
|
+
}
|
|
914
|
+
async function siteDataVMPlugin(context) {
|
|
915
|
+
var _userConfig_themeConfig, _userConfig_multiVersion, _userConfig_multiVersion1, _userConfig_markdown, _userConfig_markdown1, _userConfig_markdown2, _siteData_pages_;
|
|
916
|
+
const { config, alias, userDocRoot, routeService, pluginDriver } = context;
|
|
917
|
+
const userConfig = config;
|
|
918
|
+
const tempSearchObj = Object.assign({}, userConfig.search);
|
|
919
|
+
if (tempSearchObj) tempSearchObj.searchHooks = void 0;
|
|
920
|
+
const highlightLanguages = new Set();
|
|
921
|
+
const replaceRules = (null == userConfig ? void 0 : userConfig.replaceRules) || [];
|
|
922
|
+
const searchConfig = (null == userConfig ? void 0 : userConfig.search) || {};
|
|
923
|
+
const domain = (null == searchConfig ? void 0 : searchConfig.mode) === 'remote' ? searchConfig.domain ?? '' : '';
|
|
924
|
+
const searchCodeBlocks = 'codeBlocks' in searchConfig ? Boolean(searchConfig.codeBlocks) : false;
|
|
925
|
+
const pages = await extractPageData(replaceRules, alias, domain, userDocRoot, routeService, highlightLanguages, searchCodeBlocks);
|
|
926
|
+
await pluginDriver.modifySearchIndexData(pages);
|
|
927
|
+
const versioned = userConfig.search && 'remote' !== userConfig.search.mode && userConfig.search.versioned;
|
|
928
|
+
const groupedPages = (0, __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__.groupBy)(pages, (page)=>{
|
|
929
|
+
var _page_frontmatter;
|
|
930
|
+
if ((null === (_page_frontmatter = page.frontmatter) || void 0 === _page_frontmatter ? void 0 : _page_frontmatter.pageType) === 'home') return 'noindex';
|
|
931
|
+
const version = versioned ? page.version : '';
|
|
932
|
+
const lang = page.lang || '';
|
|
933
|
+
return `${version}###${lang}`;
|
|
934
|
+
});
|
|
935
|
+
delete groupedPages.noindex;
|
|
936
|
+
const indexHashByGroup = {};
|
|
937
|
+
await Promise.all(Object.keys(groupedPages).map(async (group)=>{
|
|
938
|
+
const stringifiedIndex = JSON.stringify(groupedPages[group].map(deletePrivateField));
|
|
939
|
+
const indexHash = createHash(stringifiedIndex);
|
|
940
|
+
indexHashByGroup[group] = indexHash;
|
|
941
|
+
const [version, lang] = group.split('###');
|
|
942
|
+
const indexVersion = version ? `.${version.replace('.', '_')}` : '';
|
|
943
|
+
const indexLang = lang ? `.${lang}` : '';
|
|
944
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].mkdir(TEMP_DIR, {
|
|
945
|
+
recursive: true
|
|
946
|
+
});
|
|
947
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(TEMP_DIR, `${__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.SEARCH_INDEX_NAME}${indexVersion}${indexLang}.${indexHash}.json`), stringifiedIndex);
|
|
948
|
+
}));
|
|
949
|
+
await Promise.all(pages.map(async (pageData)=>pluginDriver.extendPageData(pageData)));
|
|
950
|
+
const siteData = {
|
|
951
|
+
title: (null == userConfig ? void 0 : userConfig.title) || '',
|
|
952
|
+
description: (null == userConfig ? void 0 : userConfig.description) || '',
|
|
953
|
+
icon: (null == userConfig ? void 0 : userConfig.icon) || '',
|
|
954
|
+
route: (null == userConfig ? void 0 : userConfig.route) || {},
|
|
955
|
+
themeConfig: normalizeThemeConfig(userConfig, pages),
|
|
956
|
+
base: (null == userConfig ? void 0 : userConfig.base) || '/',
|
|
957
|
+
lang: (null == userConfig ? void 0 : userConfig.lang) || '',
|
|
958
|
+
locales: (null == userConfig ? void 0 : userConfig.locales) || (null === (_userConfig_themeConfig = userConfig.themeConfig) || void 0 === _userConfig_themeConfig ? void 0 : _userConfig_themeConfig.locales) || [],
|
|
959
|
+
logo: (null == userConfig ? void 0 : userConfig.logo) || '',
|
|
960
|
+
logoText: (null == userConfig ? void 0 : userConfig.logoText) || '',
|
|
961
|
+
ssg: Boolean(null == userConfig ? void 0 : userConfig.ssg) ?? true,
|
|
962
|
+
apiUrl: (null == userConfig ? void 0 : userConfig.apiUrl) || '',
|
|
963
|
+
emailSupport: (null == userConfig ? void 0 : userConfig.emailSupport) || '',
|
|
964
|
+
multiVersion: {
|
|
965
|
+
default: (null == userConfig ? void 0 : null === (_userConfig_multiVersion = userConfig.multiVersion) || void 0 === _userConfig_multiVersion ? void 0 : _userConfig_multiVersion.default) || '',
|
|
966
|
+
versions: (null == userConfig ? void 0 : null === (_userConfig_multiVersion1 = userConfig.multiVersion) || void 0 === _userConfig_multiVersion1 ? void 0 : _userConfig_multiVersion1.versions) || []
|
|
967
|
+
},
|
|
968
|
+
search: tempSearchObj ?? {
|
|
969
|
+
mode: 'local'
|
|
970
|
+
},
|
|
971
|
+
pages: pages.map((page)=>{
|
|
972
|
+
const { content, id, domain, _filepath, _html, ...rest } = page;
|
|
973
|
+
return isProduction() ? rest : {
|
|
974
|
+
...rest,
|
|
975
|
+
_filepath
|
|
976
|
+
};
|
|
977
|
+
}),
|
|
978
|
+
markdown: {
|
|
979
|
+
showLineNumbers: (null == userConfig ? void 0 : null === (_userConfig_markdown = userConfig.markdown) || void 0 === _userConfig_markdown ? void 0 : _userConfig_markdown.showLineNumbers) ?? false,
|
|
980
|
+
defaultWrapCode: (null == userConfig ? void 0 : null === (_userConfig_markdown1 = userConfig.markdown) || void 0 === _userConfig_markdown1 ? void 0 : _userConfig_markdown1.defaultWrapCode) ?? false,
|
|
981
|
+
codeHighlighter: (null == userConfig ? void 0 : null === (_userConfig_markdown2 = userConfig.markdown) || void 0 === _userConfig_markdown2 ? void 0 : _userConfig_markdown2.codeHighlighter) || 'prism'
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
const { highlightLanguages: defaultLanguages = [] } = config.markdown || {};
|
|
985
|
+
if (Array.isArray(null === (_siteData_pages_ = siteData.pages[0]) || void 0 === _siteData_pages_ ? void 0 : _siteData_pages_.extraHighlightLanguages)) siteData.pages[0].extraHighlightLanguages.forEach((lang)=>highlightLanguages.add(lang));
|
|
986
|
+
const aliases = handleHighlightLanguages(highlightLanguages, defaultLanguages);
|
|
987
|
+
const sortedAliases = Object.fromEntries(Object.entries(aliases).sort());
|
|
988
|
+
const sortedHighlightLanguages = Array.from(highlightLanguages).sort();
|
|
989
|
+
return {
|
|
990
|
+
[`${runtimeModule_RuntimeModuleID.SiteData}.mjs`]: `export default ${JSON.stringify(siteData, null, 2)}`,
|
|
991
|
+
[runtimeModule_RuntimeModuleID.SearchIndexHash]: `export default ${JSON.stringify(indexHashByGroup, null, 2)}`,
|
|
992
|
+
[runtimeModule_RuntimeModuleID.PrismLanguages]: `export const aliases = ${JSON.stringify(sortedAliases, null, 2)};
|
|
993
|
+
export const languages = {
|
|
994
|
+
${sortedHighlightLanguages.map((lang)=>`"${lang}": require(
|
|
995
|
+
"react-syntax-highlighter/dist/cjs/languages/prism/${lang}"
|
|
996
|
+
).default`)}
|
|
997
|
+
}`
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
const runtimeModuleFactory = [
|
|
1001
|
+
routeVMPlugin,
|
|
1002
|
+
siteDataVMPlugin,
|
|
1003
|
+
globalUIComponentsVMPlugin,
|
|
1004
|
+
globalStylesVMPlugin,
|
|
1005
|
+
i18nVMPlugin,
|
|
1006
|
+
searchHookVMPlugin
|
|
1007
|
+
];
|
|
1008
|
+
function rsbuildPluginDocVM(factoryContext) {
|
|
1009
|
+
const { pluginDriver } = factoryContext;
|
|
1010
|
+
return {
|
|
1011
|
+
name: 'rsbuild-plugin-doc-vm',
|
|
1012
|
+
setup (api) {
|
|
1013
|
+
api.modifyBundlerChain(async (bundlerChain, { target })=>{
|
|
1014
|
+
const isServer = 'node' === target;
|
|
1015
|
+
const alias = bundlerChain.resolve.alias.entries();
|
|
1016
|
+
const runtimeModule = {};
|
|
1017
|
+
for (const factory of runtimeModuleFactory){
|
|
1018
|
+
const moduleResult = await factory({
|
|
1019
|
+
...factoryContext,
|
|
1020
|
+
isSSR: isServer,
|
|
1021
|
+
alias: alias
|
|
1022
|
+
});
|
|
1023
|
+
Object.assign(runtimeModule, moduleResult);
|
|
1024
|
+
}
|
|
1025
|
+
const modulesByPlugin = await pluginDriver.addRuntimeModules();
|
|
1026
|
+
Object.keys(modulesByPlugin).forEach((key)=>{
|
|
1027
|
+
if (runtimeModule[key]) throw new Error(`The runtime module ${key} is duplicated, please check your plugin`);
|
|
1028
|
+
runtimeModule[key] = modulesByPlugin[key];
|
|
1029
|
+
});
|
|
1030
|
+
bundlerChain.plugin('rspress-runtime-module').use(new __WEBPACK_EXTERNAL_MODULE_rspack_plugin_virtual_module_609978fd__.RspackVirtualModulePlugin(runtimeModule, factoryContext.runtimeTempDir));
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
var runtimeModule_RuntimeModuleID = /*#__PURE__*/ function(RuntimeModuleID) {
|
|
1036
|
+
RuntimeModuleID["GlobalStyles"] = "virtual-global-styles";
|
|
1037
|
+
RuntimeModuleID["GlobalComponents"] = "virtual-global-components";
|
|
1038
|
+
RuntimeModuleID["RouteForClient"] = "virtual-routes";
|
|
1039
|
+
RuntimeModuleID["RouteForSSR"] = "virtual-routes-ssr";
|
|
1040
|
+
RuntimeModuleID["SiteData"] = "virtual-site-data";
|
|
1041
|
+
RuntimeModuleID["SearchIndexHash"] = "virtual-search-index-hash";
|
|
1042
|
+
RuntimeModuleID["I18nText"] = "virtual-i18n-text";
|
|
1043
|
+
RuntimeModuleID["SearchHooks"] = "virtual-search-hooks";
|
|
1044
|
+
RuntimeModuleID["PrismLanguages"] = "virtual-prism-languages";
|
|
1045
|
+
return RuntimeModuleID;
|
|
1046
|
+
}({});
|
|
1047
|
+
async function writeSearchIndex(config) {
|
|
1048
|
+
var _config_search;
|
|
1049
|
+
if ((null == config ? void 0 : config.search) === false) return;
|
|
1050
|
+
const cwd = process.cwd();
|
|
1051
|
+
const searchIndexFiles = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readdir(TEMP_DIR);
|
|
1052
|
+
const outDir = (null == config ? void 0 : config.outDir) ?? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(cwd, OUTPUT_DIR);
|
|
1053
|
+
const targetDir = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outDir, 'static');
|
|
1054
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].mkdir(targetDir, {
|
|
1055
|
+
recursive: true
|
|
1056
|
+
});
|
|
1057
|
+
let searchIndexData = '[]';
|
|
1058
|
+
let scanning = false;
|
|
1059
|
+
for (const searchIndexFile of searchIndexFiles){
|
|
1060
|
+
if (!searchIndexFile.includes(__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.SEARCH_INDEX_NAME) || !searchIndexFile.endsWith('.json')) continue;
|
|
1061
|
+
const source = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(TEMP_DIR, searchIndexFile);
|
|
1062
|
+
const target = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(targetDir, searchIndexFile);
|
|
1063
|
+
const searchIndex = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(TEMP_DIR, searchIndexFile), 'utf-8');
|
|
1064
|
+
searchIndexData = `${searchIndexData.slice(0, -1)}${scanning ? ',' : ''}${searchIndex.slice(1)}`;
|
|
1065
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].rename(source, target);
|
|
1066
|
+
scanning = true;
|
|
1067
|
+
}
|
|
1068
|
+
if (isProduction() && (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isSCM)() && (null == config ? void 0 : null === (_config_search = config.search) || void 0 === _config_search ? void 0 : _config_search.mode) === 'remote') {
|
|
1069
|
+
const { apiUrl, indexName } = config.search;
|
|
1070
|
+
try {
|
|
1071
|
+
await fetch(`${apiUrl}?index=${indexName}`, {
|
|
1072
|
+
method: 'PUT',
|
|
1073
|
+
body: searchIndexData,
|
|
1074
|
+
headers: {
|
|
1075
|
+
'Content-Type': 'application/json'
|
|
1076
|
+
}
|
|
1077
|
+
});
|
|
1078
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info(__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].green(`[doc-tools] Search index uploaded to ${apiUrl}, indexName: ${indexName}`));
|
|
1079
|
+
} catch (e) {
|
|
1080
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info(__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].red(`[doc-tools] Upload search index \`${indexName}\` failed:\n ${e}`));
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
function serveSearchIndexMiddleware(config) {
|
|
1085
|
+
return (req, res, next)=>{
|
|
1086
|
+
var _req_url;
|
|
1087
|
+
const searchIndexRequestMatch = `/${__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.SEARCH_INDEX_NAME}.`;
|
|
1088
|
+
if (null === (_req_url = req.url) || void 0 === _req_url ? void 0 : _req_url.includes(searchIndexRequestMatch)) {
|
|
1089
|
+
res.setHeader('Content-Type', 'application/json');
|
|
1090
|
+
const outDir = (null == config ? void 0 : config.outDir) ?? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(process.cwd(), OUTPUT_DIR);
|
|
1091
|
+
const searchIndexFile = req.url.split('/').pop();
|
|
1092
|
+
(0, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.createReadStream)((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outDir, 'static', searchIndexFile), 'utf-8').pipe(res, {
|
|
1093
|
+
end: true
|
|
1094
|
+
});
|
|
1095
|
+
} else null == next || next();
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1098
|
+
async function pathExists(path) {
|
|
1099
|
+
try {
|
|
1100
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].access(path);
|
|
1101
|
+
return true;
|
|
1102
|
+
} catch {
|
|
1103
|
+
return false;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
async function readJson(path) {
|
|
1107
|
+
const raw = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(path, 'utf8');
|
|
1108
|
+
return JSON.parse(raw);
|
|
1109
|
+
}
|
|
1110
|
+
const { CachedInputFileSystem: detectReactVersion_CachedInputFileSystem, ResolverFactory: detectReactVersion_ResolverFactory } = __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__["default"];
|
|
1111
|
+
const DEFAULT_REACT_VERSION = 18;
|
|
1112
|
+
async function detectReactVersion() {
|
|
1113
|
+
const cwd = process.cwd();
|
|
1114
|
+
const reactPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(cwd, 'node_modules', 'react');
|
|
1115
|
+
if (await pathExists(reactPath)) {
|
|
1116
|
+
var _reactPkg_version;
|
|
1117
|
+
const reactPkg = await readJson(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(reactPath, 'package.json'));
|
|
1118
|
+
const version = Number(null === (_reactPkg_version = reactPkg.version) || void 0 === _reactPkg_version ? void 0 : _reactPkg_version.split('.')[0]);
|
|
1119
|
+
return version;
|
|
1120
|
+
}
|
|
1121
|
+
return DEFAULT_REACT_VERSION;
|
|
1122
|
+
}
|
|
1123
|
+
async function resolveReactAlias(reactVersion, isSSR) {
|
|
1124
|
+
const basedir = reactVersion === DEFAULT_REACT_VERSION ? PACKAGE_ROOT : process.cwd();
|
|
1125
|
+
const libPaths = [
|
|
1126
|
+
'react',
|
|
1127
|
+
'react/jsx-runtime',
|
|
1128
|
+
'react/jsx-dev-runtime',
|
|
1129
|
+
'react-dom',
|
|
1130
|
+
'react-dom/server'
|
|
1131
|
+
];
|
|
1132
|
+
if (reactVersion >= DEFAULT_REACT_VERSION) libPaths.push('react-dom/client');
|
|
1133
|
+
const alias = {};
|
|
1134
|
+
const resolver = detectReactVersion_ResolverFactory.createResolver({
|
|
1135
|
+
fileSystem: new detectReactVersion_CachedInputFileSystem(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"], 0),
|
|
1136
|
+
extensions: [
|
|
1137
|
+
'.js'
|
|
1138
|
+
],
|
|
1139
|
+
alias,
|
|
1140
|
+
conditionNames: isSSR ? [
|
|
1141
|
+
'...'
|
|
1142
|
+
] : [
|
|
1143
|
+
'browser',
|
|
1144
|
+
'...'
|
|
1145
|
+
]
|
|
1146
|
+
});
|
|
1147
|
+
await Promise.all(libPaths.map(async (lib)=>{
|
|
1148
|
+
try {
|
|
1149
|
+
alias[lib] = await new Promise((resolve, reject)=>{
|
|
1150
|
+
resolver.resolve({
|
|
1151
|
+
importer: basedir
|
|
1152
|
+
}, basedir, lib, {}, (err, filePath)=>{
|
|
1153
|
+
if (err || !filePath) return reject(err);
|
|
1154
|
+
return resolve(filePath);
|
|
1155
|
+
});
|
|
1156
|
+
});
|
|
1157
|
+
} catch (e) {
|
|
1158
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.warn(`${lib} not found: \n`, e);
|
|
1159
|
+
}
|
|
1160
|
+
}));
|
|
1161
|
+
return alias;
|
|
1162
|
+
}
|
|
1163
|
+
const detectCustomIcon = async (customThemeDir)=>{
|
|
1164
|
+
const assetsDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(customThemeDir, 'assets');
|
|
1165
|
+
const alias = {};
|
|
1166
|
+
if (!(0, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.existsSync)(assetsDir)) return alias;
|
|
1167
|
+
const files = await (0, __WEBPACK_EXTERNAL_MODULE_tinyglobby__.glob)('*.svg', {
|
|
1168
|
+
cwd: assetsDir
|
|
1169
|
+
});
|
|
1170
|
+
files.forEach((file)=>{
|
|
1171
|
+
const name = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(file, '.svg');
|
|
1172
|
+
alias[`@theme-assets/${name}`] = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(assetsDir, file);
|
|
1173
|
+
});
|
|
1174
|
+
return alias;
|
|
1175
|
+
};
|
|
1176
|
+
const presetIcons = {
|
|
1177
|
+
discord: '<path fill="currentColor" d="M20.317 4.37a19.8 19.8 0 0 0-4.885-1.515a.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.3 18.3 0 0 0-5.487 0a13 13 0 0 0-.617-1.25a.08.08 0 0 0-.079-.037A19.7 19.7 0 0 0 3.677 4.37a.1.1 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.08.08 0 0 0 .031.057a19.9 19.9 0 0 0 5.993 3.03a.08.08 0 0 0 .084-.028a14 14 0 0 0 1.226-1.994a.076.076 0 0 0-.041-.106a13 13 0 0 1-1.872-.892a.077.077 0 0 1-.008-.128a10 10 0 0 0 .372-.292a.07.07 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.07.07 0 0 1 .078.01q.181.149.373.292a.077.077 0 0 1-.006.127a12.3 12.3 0 0 1-1.873.892a.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.08.08 0 0 0 .084.028a19.8 19.8 0 0 0 6.002-3.03a.08.08 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.06.06 0 0 0-.031-.03M8.02 15.33c-1.182 0-2.157-1.085-2.157-2.419c0-1.333.956-2.419 2.157-2.419c1.21 0 2.176 1.096 2.157 2.42c0 1.333-.956 2.418-2.157 2.418m7.975 0c-1.183 0-2.157-1.085-2.157-2.419c0-1.333.955-2.419 2.157-2.419c1.21 0 2.176 1.096 2.157 2.42c0 1.333-.946 2.418-2.157 2.418"/>',
|
|
1178
|
+
facebook: '<path fill="currentColor" d="M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978c.401 0 .955.042 1.468.103a9 9 0 0 1 1.141.195v3.325a9 9 0 0 0-.653-.036a27 27 0 0 0-.733-.009c-.707 0-1.259.096-1.675.309a1.7 1.7 0 0 0-.679.622c-.258.42-.374.995-.374 1.752v1.297h3.919l-.386 2.103l-.287 1.564h-3.246v8.245C19.396 23.238 24 18.179 24 12.044c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.628 3.874 10.35 9.101 11.647"/>',
|
|
1179
|
+
github: '<path fill="currentColor" d="M12 .297c-6.63 0-12 5.373-12 12c0 5.303 3.438 9.8 8.205 11.385c.6.113.82-.258.82-.577c0-.285-.01-1.04-.015-2.04c-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729c1.205.084 1.838 1.236 1.838 1.236c1.07 1.835 2.809 1.305 3.495.998c.108-.776.417-1.305.76-1.605c-2.665-.3-5.466-1.332-5.466-5.93c0-1.31.465-2.38 1.235-3.22c-.135-.303-.54-1.523.105-3.176c0 0 1.005-.322 3.3 1.23c.96-.267 1.98-.399 3-.405c1.02.006 2.04.138 3 .405c2.28-1.552 3.285-1.23 3.285-1.23c.645 1.653.24 2.873.12 3.176c.765.84 1.23 1.91 1.23 3.22c0 4.61-2.805 5.625-5.475 5.92c.42.36.81 1.096.81 2.22c0 1.606-.015 2.896-.015 3.286c0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/>',
|
|
1180
|
+
gitlab: '<path fill="currentColor" d="m23.6 9.593l-.033-.086L20.3.98a.85.85 0 0 0-.336-.405a.875.875 0 0 0-1 .054a.9.9 0 0 0-.29.44L16.47 7.818H7.537L5.333 1.07a.86.86 0 0 0-.29-.441a.875.875 0 0 0-1-.054a.86.86 0 0 0-.336.405L.433 9.502l-.032.086a6.066 6.066 0 0 0 2.012 7.01l.01.009l.03.021l4.977 3.727l2.462 1.863l1.5 1.132a1.01 1.01 0 0 0 1.22 0l1.499-1.132l2.461-1.863l5.006-3.75l.013-.01a6.07 6.07 0 0 0 2.01-7.002"/>',
|
|
1181
|
+
instagram: '<path fill="currentColor" d="M7.03.084c-1.277.06-2.149.264-2.91.563a5.9 5.9 0 0 0-2.124 1.388a5.9 5.9 0 0 0-1.38 2.127C.321 4.926.12 5.8.064 7.076s-.069 1.688-.063 4.947s.021 3.667.083 4.947c.061 1.277.264 2.149.563 2.911c.308.789.72 1.457 1.388 2.123a5.9 5.9 0 0 0 2.129 1.38c.763.295 1.636.496 2.913.552c1.278.056 1.689.069 4.947.063s3.668-.021 4.947-.082c1.28-.06 2.147-.265 2.91-.563a5.9 5.9 0 0 0 2.123-1.388a5.9 5.9 0 0 0 1.38-2.129c.295-.763.496-1.636.551-2.912c.056-1.28.07-1.69.063-4.948c-.006-3.258-.02-3.667-.081-4.947c-.06-1.28-.264-2.148-.564-2.911a5.9 5.9 0 0 0-1.387-2.123a5.9 5.9 0 0 0-2.128-1.38c-.764-.294-1.636-.496-2.914-.55C15.647.009 15.236-.006 11.977 0S8.31.021 7.03.084m.14 21.693c-1.17-.05-1.805-.245-2.228-.408a3.7 3.7 0 0 1-1.382-.895a3.7 3.7 0 0 1-.9-1.378c-.165-.423-.363-1.058-.417-2.228c-.06-1.264-.072-1.644-.08-4.848c-.006-3.204.006-3.583.061-4.848c.05-1.169.246-1.805.408-2.228c.216-.561.477-.96.895-1.382a3.7 3.7 0 0 1 1.379-.9c.423-.165 1.057-.361 2.227-.417c1.265-.06 1.644-.072 4.848-.08c3.203-.006 3.583.006 4.85.062c1.168.05 1.804.244 2.227.408c.56.216.96.475 1.382.895s.681.817.9 1.378c.165.422.362 1.056.417 2.227c.06 1.265.074 1.645.08 4.848c.005 3.203-.006 3.583-.061 4.848c-.051 1.17-.245 1.805-.408 2.23c-.216.56-.477.96-.896 1.38a3.7 3.7 0 0 1-1.378.9c-.422.165-1.058.362-2.226.418c-1.266.06-1.645.072-4.85.079s-3.582-.006-4.848-.06m9.783-16.192a1.44 1.44 0 1 0 1.437-1.442a1.44 1.44 0 0 0-1.437 1.442M5.839 12.012a6.161 6.161 0 1 0 12.323-.024a6.162 6.162 0 0 0-12.323.024M8 12.008A4 4 0 1 1 12.008 16A4 4 0 0 1 8 12.008"/>',
|
|
1182
|
+
linkedin: '<path fill="currentColor" d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037c-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85c3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.06 2.06 0 0 1-2.063-2.065a2.064 2.064 0 1 1 2.063 2.065m1.782 13.019H3.555V9h3.564zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0z"/>',
|
|
1183
|
+
slack: '<path fill="currentColor" d="M5.042 15.165a2.53 2.53 0 0 1-2.52 2.523A2.53 2.53 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52zm1.271 0a2.527 2.527 0 0 1 2.521-2.52a2.527 2.527 0 0 1 2.521 2.52v6.313A2.53 2.53 0 0 1 8.834 24a2.53 2.53 0 0 1-2.521-2.522zM8.834 5.042a2.53 2.53 0 0 1-2.521-2.52A2.53 2.53 0 0 1 8.834 0a2.53 2.53 0 0 1 2.521 2.522v2.52zm0 1.271a2.53 2.53 0 0 1 2.521 2.521a2.53 2.53 0 0 1-2.521 2.521H2.522A2.53 2.53 0 0 1 0 8.834a2.53 2.53 0 0 1 2.522-2.521zm10.122 2.521a2.53 2.53 0 0 1 2.522-2.521A2.53 2.53 0 0 1 24 8.834a2.53 2.53 0 0 1-2.522 2.521h-2.522zm-1.268 0a2.53 2.53 0 0 1-2.523 2.521a2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.53 2.53 0 0 1 2.523 2.522zm-2.523 10.122a2.53 2.53 0 0 1 2.523 2.522A2.53 2.53 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522zm0-1.268a2.527 2.527 0 0 1-2.52-2.523a2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.53 2.53 0 0 1-2.522 2.523z"/>',
|
|
1184
|
+
youtube: '<path fill="currentColor" d="M23.498 6.186a3.02 3.02 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.02 3.02 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.02 3.02 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.02 3.02 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814M9.545 15.568V8.432L15.818 12z"/>',
|
|
1185
|
+
juejin: '<path fill="currentColor" d="m12 14.316l7.454-5.88l-2.022-1.625L12 11.1l-.004.003l-5.432-4.288l-2.02 1.624l7.452 5.88Zm0-7.247l2.89-2.298L12 2.453l-.004-.005l-2.884 2.318l2.884 2.3Zm0 11.266l-.005.002l-9.975-7.87L0 12.088l.194.156l11.803 9.308l7.463-5.885L24 12.085l-2.023-1.624Z"/>',
|
|
1186
|
+
qq: '<path fill="currentColor" d="M21.395 15.035a40 40 0 0 0-.803-2.264l-1.079-2.695c.001-.032.014-.562.014-.836C19.526 4.632 17.351 0 12 0S4.474 4.632 4.474 9.241c0 .274.013.804.014.836l-1.08 2.695a39 39 0 0 0-.802 2.264c-1.021 3.283-.69 4.643-.438 4.673c.54.065 2.103-2.472 2.103-2.472c0 1.469.756 3.387 2.394 4.771c-.612.188-1.363.479-1.845.835c-.434.32-.379.646-.301.778c.343.578 5.883.369 7.482.189c1.6.18 7.14.389 7.483-.189c.078-.132.132-.458-.301-.778c-.483-.356-1.233-.646-1.846-.836c1.637-1.384 2.393-3.302 2.393-4.771c0 0 1.563 2.537 2.103 2.472c.251-.03.581-1.39-.438-4.673"/>',
|
|
1187
|
+
wechat: '<path fill="currentColor" d="M8.691 2.188C3.891 2.188 0 5.476 0 9.53c0 2.212 1.17 4.203 3.002 5.55a.59.59 0 0 1 .213.665l-.39 1.48c-.019.07-.048.141-.048.213c0 .163.13.295.29.295a.33.33 0 0 0 .167-.054l1.903-1.114a.86.86 0 0 1 .717-.098a10.2 10.2 0 0 0 2.837.403c.276 0 .543-.027.811-.05c-.857-2.578.157-4.972 1.932-6.446c1.703-1.415 3.882-1.98 5.853-1.838c-.576-3.583-4.196-6.348-8.596-6.348M5.785 5.991c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178A1.17 1.17 0 0 1 4.623 7.17c0-.651.52-1.18 1.162-1.18zm5.813 0c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178a1.17 1.17 0 0 1-1.162-1.178c0-.651.52-1.18 1.162-1.18m5.34 2.867c-1.797-.052-3.746.512-5.28 1.786c-1.72 1.428-2.687 3.72-1.78 6.22c.942 2.453 3.666 4.229 6.884 4.229c.826 0 1.622-.12 2.361-.336a.72.72 0 0 1 .598.082l1.584.926a.3.3 0 0 0 .14.047c.134 0 .24-.111.24-.247c0-.06-.023-.12-.038-.177l-.327-1.233a.6.6 0 0 1-.023-.156a.49.49 0 0 1 .201-.398C23.024 18.48 24 16.82 24 14.98c0-3.21-2.931-5.837-6.656-6.088V8.89c-.135-.01-.27-.027-.407-.03zm-2.53 3.274c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983a.976.976 0 0 1-.969-.983c0-.542.434-.982.97-.982zm4.844 0c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983a.976.976 0 0 1-.969-.983c0-.542.434-.982.969-.982"/>',
|
|
1188
|
+
weibo: '<path fill="currentColor" d="M17.525 11.378c1.263.392 2.669 1.336 2.669 3.004c0 2.763-3.98 6.239-9.964 6.239c-4.565 0-9.23-2.213-9.23-5.852c0-1.902 1.204-4.102 3.277-6.177c2.773-2.77 6.004-4.033 7.219-2.816c.537.537.588 1.464.244 2.572c-.178.557.525.25.525.25c2.24-.938 4.196-.994 4.909.027c.38.543.343 1.306-.008 2.19c-.163.407.048.471.36.563zm-7.282 7.939c3.641-.362 6.401-2.592 6.167-4.983c-.237-2.391-3.382-4.038-7.023-3.677c-3.64.36-6.403 2.59-6.167 4.98c.237 2.394 3.382 4.039 7.023 3.68zM6.16 14.438c.754-1.527 2.712-2.39 4.446-1.94c1.793.463 2.707 2.154 1.976 3.8c-.744 1.682-2.882 2.578-4.695 1.993c-1.752-.566-2.493-2.294-1.727-3.853zm1.446 2.587c.568.257 1.325.013 1.676-.55c.346-.568.163-1.217-.407-1.459c-.563-.237-1.291.008-1.64.553c-.354.547-.189 1.202.371 1.456zm2.206-1.808c.219.092.501-.012.628-.231c.123-.22.044-.466-.178-.548c-.216-.084-.486.018-.613.232c-.123.214-.054.458.163.547zM19.873 9.5a.725.725 0 1 1-1.378-.451a1.38 1.38 0 0 0-.288-1.357a1.395 1.395 0 0 0-1.321-.425a.723.723 0 1 1-.303-1.416a2.836 2.836 0 0 1 3.29 3.649zm-3.916-6.575A5.831 5.831 0 0 1 21.5 4.72a5.836 5.836 0 0 1 1.22 5.704a.838.838 0 0 1-1.06.54a.844.844 0 0 1-.542-1.062a4.143 4.143 0 0 0-4.807-5.327a.845.845 0 0 1-.354-1.65z"/>',
|
|
1189
|
+
zhihu: '<path fill="currentColor" d="M5.721 0C2.251 0 0 2.25 0 5.719V18.28C0 21.751 2.252 24 5.721 24h12.56C21.751 24 24 21.75 24 18.281V5.72C24 2.249 21.75 0 18.281 0zm1.964 4.078q-.408 1.096-.68 2.11h4.587c.545-.006.445 1.168.445 1.171H9.384a58 58 0 0 1-.112 3.797h2.712c.388.023.393 1.251.393 1.266H9.183a9.2 9.2 0 0 1-.408 2.102l.757-.604c.452.456 1.512 1.712 1.906 2.177c.473.681.063 2.081.063 2.081l-2.794-3.382c-.653 2.518-1.845 3.607-1.845 3.607c-.523.468-1.58.82-2.64.516c2.218-1.73 3.44-3.917 3.667-6.497H4.491c0-.015.197-1.243.806-1.266h2.71c.024-.32.086-3.254.086-3.797H6.598c-.136.406-.158.447-.268.753c-.594 1.095-1.603 1.122-1.907 1.155c.906-1.821 1.416-3.6 1.591-4.064c.425-1.124 1.671-1.125 1.671-1.125M13.078 6h6.377v11.33h-2.573l-2.184 1.373l-.401-1.373h-1.219zm1.313 1.219v8.86h.623l.263.937l1.455-.938h1.456v-8.86z"/>',
|
|
1190
|
+
bilibili: '<path fill="currentColor" d="M17.813 4.653h.854q2.266.08 3.773 1.574Q23.946 7.72 24 9.987v7.36q-.054 2.266-1.56 3.773c-1.506 1.507-2.262 1.524-3.773 1.56H5.333q-2.266-.054-3.773-1.56C.053 19.614.036 18.858 0 17.347v-7.36q.054-2.267 1.56-3.76t3.773-1.574h.774l-1.174-1.12a1.23 1.23 0 0 1-.373-.906q0-.534.373-.907l.027-.027q.4-.373.92-.373t.92.373L9.653 4.44q.107.106.187.213h4.267a.8.8 0 0 1 .16-.213l2.853-2.747q.4-.373.92-.373c.347 0 .662.151.929.4s.391.551.391.907q0 .532-.373.906zM5.333 7.24q-1.12.027-1.88.773q-.76.748-.786 1.894v7.52q.026 1.146.786 1.893t1.88.773h13.334q1.12-.026 1.88-.773t.786-1.893v-7.52q-.026-1.147-.786-1.894t-1.88-.773zM8 11.107q.56 0 .933.373q.375.374.4.96v1.173q-.025.586-.4.96q-.373.375-.933.374c-.56-.001-.684-.125-.933-.374q-.375-.373-.4-.96V12.44q0-.56.386-.947q.387-.386.947-.386m8 0q.56 0 .933.373q.375.374.4.96v1.173q-.025.586-.4.96q-.373.375-.933.374c-.56-.001-.684-.125-.933-.374q-.375-.373-.4-.96V12.44q.025-.586.4-.96q.373-.373.933-.373"/>',
|
|
1191
|
+
lark: `<path d="M8.813 5.477c1.038.836 2.286 2.045 3.3 3.495.171.23.377.576.457.71l.034.056a8.803 8.803 0 0 0-.922 1.3l-.271-.494C9.655 7.53 6.3 5.477 6.137 5.377a.447.447 0 0 1-.006-.004l-.666-.393-.107-.086a.499.499 0 0 1 .306-.885L6.084 4h7.997c.159.006.318.037.47.092.174.064.317.174.458.308.134.143.272.296.403.448.622.675 1.324 1.688 1.324 1.688-.573.193-1.349.736-1.349.736a5.095 5.095 0 0 0-.348-.54 20.665 20.665 0 0 0-1.037-1.255H8.813Z" fill="currentColor"/>
|
|
1192
|
+
<path d="M18.482 7.507a5.42 5.42 0 0 1 4.04.717c.248.168.788.635.242 1.233-1.7 1.67-2.194 3.225-2.63 4.599-.278.873-.541 1.697-1.066 2.424-1.813 2.508-4.114 4-6.837 4.434-.561.089-1.132.131-1.7.131-3.958 0-7.498-2.035-8.75-2.844h.003l-.161-.107c-.534-.378-.61-.723-.623-.989V7.055a.486.486 0 0 1 .827-.317l.482.589c5.082 6.201 9.126 8.063 11.626 8.53 2.246.424 3.631-.165 4.022-.37.333-.51.534-1.143.764-1.865l.006-.021c.406-1.276.898-2.821 2.322-4.477a3.93 3.93 0 0 0-2.28-.168c-1.761.394-3.403 1.96-4.89 4.643a8.27 8.27 0 0 0-.341.671c-.724-.107-1.334-.65-1.334-.65.128-.269.22-.455.345-.672 1.718-3.125 3.714-4.962 5.933-5.441ZM2.477 16.889c1.145.744 5.341 3.232 9.532 2.563 1.56-.247 2.963-.915 4.196-1.99-2.771.254-7.557-.753-13.728-7.666v7.093Z" fill="currentColor"/>`,
|
|
1193
|
+
x: '<path fill="currentColor" d="M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584l-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z"/>',
|
|
1194
|
+
bluesky: '<path fill="currentColor" d="M12 10.8c-1.087-2.114-4.046-6.053-6.798-7.995C2.566.944 1.561 1.266.902 1.565C.139 1.908 0 3.08 0 3.768c0 .69.378 5.65.624 6.479c.815 2.736 3.713 3.66 6.383 3.364q.204-.03.415-.056q-.207.033-.415.056c-3.912.58-7.387 2.005-2.83 7.078c5.013 5.19 6.87-1.113 7.823-4.308c.953 3.195 2.05 9.271 7.733 4.308c4.267-4.308 1.172-6.498-2.74-7.078a9 9 0 0 1-.415-.056q.21.026.415.056c2.67.297 5.568-.628 6.383-3.364c.246-.828.624-5.79.624-6.478c0-.69-.139-1.861-.902-2.206c-.659-.298-1.664-.62-4.3 1.24C16.046 4.748 13.087 8.687 12 10.8"/>'
|
|
1195
|
+
};
|
|
1196
|
+
const formatIconName = (icon)=>icon.toLowerCase();
|
|
1197
|
+
function getSocialIcons(socialLinks = []) {
|
|
1198
|
+
const icons = {};
|
|
1199
|
+
for (const link of socialLinks)if ('string' == typeof link.icon) {
|
|
1200
|
+
const pathContent = presetIcons[formatIconName(link.icon)];
|
|
1201
|
+
icons[link.icon] = `<svg xmlns="http://www.w3.org/2000/svg" width="100%" viewBox="0 0 24 24">${pathContent}</svg>`;
|
|
1202
|
+
}
|
|
1203
|
+
return icons;
|
|
1204
|
+
}
|
|
1205
|
+
function isPluginIncluded(config, pluginName) {
|
|
1206
|
+
var _config_builderPlugins, _config_builderConfig_plugins, _config_builderConfig;
|
|
1207
|
+
return Boolean((null === (_config_builderPlugins = config.builderPlugins) || void 0 === _config_builderPlugins ? void 0 : _config_builderPlugins.some((plugin)=>plugin.name === pluginName)) || (null === (_config_builderConfig = config.builderConfig) || void 0 === _config_builderConfig ? void 0 : null === (_config_builderConfig_plugins = _config_builderConfig.plugins) || void 0 === _config_builderConfig_plugins ? void 0 : _config_builderConfig_plugins.some((plugin)=>plugin && plugin.name === pluginName)));
|
|
1208
|
+
}
|
|
1209
|
+
async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, runtimeTempDir) {
|
|
1210
|
+
var _config_builderConfig_output, _config_builderConfig, _config_themeConfig, _config_themeConfig1;
|
|
1211
|
+
const cwd = process.cwd();
|
|
1212
|
+
const CUSTOM_THEME_DIR = (null == config ? void 0 : config.themeDir) ?? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), 'theme');
|
|
1213
|
+
const baseOutDir = (null == config ? void 0 : config.outDir) ?? OUTPUT_DIR;
|
|
1214
|
+
const csrOutDir = baseOutDir;
|
|
1215
|
+
const ssrOutDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(baseOutDir, 'ssr');
|
|
1216
|
+
const DEFAULT_THEME = require.resolve('@rspress-theme-anatole/theme-default');
|
|
1217
|
+
const base = (null == config ? void 0 : config.base) ?? '';
|
|
1218
|
+
const assetPrefix = isProduction() ? (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.removeTrailingSlash)((null == config ? void 0 : null === (_config_builderConfig = config.builderConfig) || void 0 === _config_builderConfig ? void 0 : null === (_config_builderConfig_output = _config_builderConfig.output) || void 0 === _config_builderConfig_output ? void 0 : _config_builderConfig_output.assetPrefix) ?? base) : '';
|
|
1219
|
+
const reactVersion = await detectReactVersion();
|
|
1220
|
+
const normalizeIcon = (icon)=>{
|
|
1221
|
+
if (!icon) return;
|
|
1222
|
+
if (__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(icon)) return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(userDocRoot, PUBLIC_DIR, icon);
|
|
1223
|
+
return icon;
|
|
1224
|
+
};
|
|
1225
|
+
const [detectCustomIconAlias, reactCSRAlias, reactSSRAlias] = await Promise.all([
|
|
1226
|
+
detectCustomIcon(CUSTOM_THEME_DIR),
|
|
1227
|
+
resolveReactAlias(reactVersion, false),
|
|
1228
|
+
enableSSG ? resolveReactAlias(reactVersion, true) : Promise.resolve({})
|
|
1229
|
+
]);
|
|
1230
|
+
return {
|
|
1231
|
+
plugins: [
|
|
1232
|
+
...isPluginIncluded(config, __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__.PLUGIN_REACT_NAME) ? [] : [
|
|
1233
|
+
(0, __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__.pluginReact)()
|
|
1234
|
+
],
|
|
1235
|
+
...isPluginIncluded(config, __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_sass_b13a7d33__.PLUGIN_SASS_NAME) ? [] : [
|
|
1236
|
+
(0, __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_sass_b13a7d33__.pluginSass)()
|
|
1237
|
+
],
|
|
1238
|
+
...isPluginIncluded(config, __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_less_4c557a99__.PLUGIN_LESS_NAME) ? [] : [
|
|
1239
|
+
(0, __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_less_4c557a99__.pluginLess)()
|
|
1240
|
+
],
|
|
1241
|
+
rsbuildPluginDocVM({
|
|
1242
|
+
userDocRoot,
|
|
1243
|
+
config,
|
|
1244
|
+
runtimeTempDir,
|
|
1245
|
+
routeService,
|
|
1246
|
+
pluginDriver
|
|
1247
|
+
})
|
|
1248
|
+
],
|
|
1249
|
+
server: {
|
|
1250
|
+
port: !isProduction() && process.env.PORT ? Number(process.env.PORT) : void 0,
|
|
1251
|
+
printUrls: ({ urls })=>urls.map((url)=>`${url}/${(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.removeLeadingSlash)(base)}`),
|
|
1252
|
+
publicDir: {
|
|
1253
|
+
name: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(userDocRoot, PUBLIC_DIR)
|
|
1254
|
+
}
|
|
1255
|
+
},
|
|
1256
|
+
dev: {
|
|
1257
|
+
progressBar: false,
|
|
1258
|
+
setupMiddlewares: [
|
|
1259
|
+
(middlewares)=>{
|
|
1260
|
+
middlewares.unshift(serveSearchIndexMiddleware(config));
|
|
1261
|
+
}
|
|
1262
|
+
],
|
|
1263
|
+
cliShortcuts: {
|
|
1264
|
+
custom: (shortcuts)=>shortcuts.filter(({ key })=>'r' !== key)
|
|
1265
|
+
}
|
|
1266
|
+
},
|
|
1267
|
+
html: {
|
|
1268
|
+
title: (null == config ? void 0 : config.title) ?? DEFAULT_TITLE,
|
|
1269
|
+
favicon: normalizeIcon(null == config ? void 0 : config.icon),
|
|
1270
|
+
template: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'index.html'),
|
|
1271
|
+
tags: [
|
|
1272
|
+
(null === (_config_themeConfig = config.themeConfig) || void 0 === _config_themeConfig ? void 0 : _config_themeConfig.darkMode) !== false ? {
|
|
1273
|
+
tag: "script",
|
|
1274
|
+
children: inlineThemeScript,
|
|
1275
|
+
append: false
|
|
1276
|
+
} : null
|
|
1277
|
+
].filter(Boolean)
|
|
1278
|
+
},
|
|
1279
|
+
output: {
|
|
1280
|
+
assetPrefix,
|
|
1281
|
+
distPath: {
|
|
1282
|
+
root: csrOutDir
|
|
1283
|
+
}
|
|
1284
|
+
},
|
|
1285
|
+
resolve: {
|
|
1286
|
+
alias: {
|
|
1287
|
+
...detectCustomIconAlias,
|
|
1288
|
+
'@mdx-js/react': require.resolve('@mdx-js/react'),
|
|
1289
|
+
'@theme': [
|
|
1290
|
+
CUSTOM_THEME_DIR,
|
|
1291
|
+
DEFAULT_THEME
|
|
1292
|
+
],
|
|
1293
|
+
'@theme-assets': __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(DEFAULT_THEME, '../assets'),
|
|
1294
|
+
'@rspress-theme-anatole/core': PACKAGE_ROOT,
|
|
1295
|
+
'react-lazy-with-preload': require.resolve('react-lazy-with-preload'),
|
|
1296
|
+
'react-syntax-highlighter': __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(require.resolve('react-syntax-highlighter/package.json'))
|
|
1297
|
+
}
|
|
1298
|
+
},
|
|
1299
|
+
source: {
|
|
1300
|
+
include: [
|
|
1301
|
+
PACKAGE_ROOT,
|
|
1302
|
+
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(cwd, 'node_modules', __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.RSPRESS_TEMP_DIR)
|
|
1303
|
+
],
|
|
1304
|
+
define: {
|
|
1305
|
+
'process.env.__REACT_GTE_18__': JSON.stringify(reactVersion >= 18),
|
|
1306
|
+
'process.env.TEST': JSON.stringify(process.env.TEST),
|
|
1307
|
+
'process.env.RSPRESS_SOCIAL_ICONS': JSON.stringify(getSocialIcons(null === (_config_themeConfig1 = config.themeConfig) || void 0 === _config_themeConfig1 ? void 0 : _config_themeConfig1.socialLinks))
|
|
1308
|
+
}
|
|
1309
|
+
},
|
|
1310
|
+
performance: {
|
|
1311
|
+
chunkSplit: {
|
|
1312
|
+
override: {
|
|
1313
|
+
cacheGroups: {
|
|
1314
|
+
styles: {
|
|
1315
|
+
name: 'styles',
|
|
1316
|
+
minSize: 0,
|
|
1317
|
+
chunks: 'all',
|
|
1318
|
+
test: /\.(?:css|less|sass|scss)$/,
|
|
1319
|
+
priority: 99
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
},
|
|
1325
|
+
tools: {
|
|
1326
|
+
bundlerChain (chain, { CHAIN_ID, target }) {
|
|
1327
|
+
var _config_markdown;
|
|
1328
|
+
const isServer = 'node' === target;
|
|
1329
|
+
const jsModuleRule = chain.module.rule(CHAIN_ID.RULE.JS);
|
|
1330
|
+
const swcLoaderOptions = jsModuleRule.use(CHAIN_ID.USE.SWC).get('options');
|
|
1331
|
+
const checkDeadLinks = ((null == config ? void 0 : null === (_config_markdown = config.markdown) || void 0 === _config_markdown ? void 0 : _config_markdown.checkDeadLinks) && !isServer) ?? false;
|
|
1332
|
+
chain.module.rule('MDX').type("javascript/auto").test(__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP).resolve.merge({
|
|
1333
|
+
conditionNames: jsModuleRule.resolve.conditionNames.values(),
|
|
1334
|
+
mainFields: jsModuleRule.resolve.mainFields.values()
|
|
1335
|
+
}).end().oneOf('MDXCompile').use('builtin:swc-loader').loader('builtin:swc-loader').options(swcLoaderOptions).end().use('mdx-loader').loader(require.resolve('./loader.js')).options({
|
|
1336
|
+
config,
|
|
1337
|
+
docDirectory: userDocRoot,
|
|
1338
|
+
checkDeadLinks,
|
|
1339
|
+
routeService,
|
|
1340
|
+
pluginDriver
|
|
1341
|
+
}).end();
|
|
1342
|
+
if (chain.plugins.has(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH)) chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).tap((options)=>{
|
|
1343
|
+
options[0] ??= {};
|
|
1344
|
+
options[0].include = [
|
|
1345
|
+
/\.([cm]js|[jt]sx?|flow)$/i,
|
|
1346
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP
|
|
1347
|
+
];
|
|
1348
|
+
return options;
|
|
1349
|
+
});
|
|
1350
|
+
chain.resolve.extensions.prepend('.md').prepend('.mdx').prepend('.mjs');
|
|
1351
|
+
chain.module.rule('css-virtual-module').test(/\.rspress[\\/]runtime[\\/]virtual-global-styles/).merge({
|
|
1352
|
+
sideEffects: true
|
|
1353
|
+
});
|
|
1354
|
+
if (isServer) chain.output.filename('main.cjs');
|
|
1355
|
+
const enableIncremental = !isProduction() && !process.env.DISABLE_RSPACK_INCREMENTAL;
|
|
1356
|
+
if (enableIncremental) chain.merge({
|
|
1357
|
+
experiments: {
|
|
1358
|
+
incremental: true
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
},
|
|
1363
|
+
environments: {
|
|
1364
|
+
web: {
|
|
1365
|
+
resolve: {
|
|
1366
|
+
alias: {
|
|
1367
|
+
...reactCSRAlias,
|
|
1368
|
+
__VIRTUAL_ROUTES__: 'virtual-routes'
|
|
1369
|
+
}
|
|
1370
|
+
},
|
|
1371
|
+
source: {
|
|
1372
|
+
entry: {
|
|
1373
|
+
index: CLIENT_ENTRY
|
|
1374
|
+
},
|
|
1375
|
+
define: {
|
|
1376
|
+
'process.env.__SSR__': JSON.stringify(false)
|
|
1377
|
+
}
|
|
1378
|
+
},
|
|
1379
|
+
output: {
|
|
1380
|
+
target: 'web',
|
|
1381
|
+
distPath: {
|
|
1382
|
+
root: csrOutDir
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
},
|
|
1386
|
+
...enableSSG ? {
|
|
1387
|
+
node: {
|
|
1388
|
+
resolve: {
|
|
1389
|
+
alias: {
|
|
1390
|
+
...reactSSRAlias,
|
|
1391
|
+
__VIRTUAL_ROUTES__: 'virtual-routes-ssr'
|
|
1392
|
+
}
|
|
1393
|
+
},
|
|
1394
|
+
source: {
|
|
1395
|
+
entry: {
|
|
1396
|
+
index: SSR_ENTRY
|
|
1397
|
+
},
|
|
1398
|
+
define: {
|
|
1399
|
+
'process.env.__SSR__': JSON.stringify(true)
|
|
1400
|
+
}
|
|
1401
|
+
},
|
|
1402
|
+
performance: {
|
|
1403
|
+
printFileSize: (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isDebugMode)()
|
|
1404
|
+
},
|
|
1405
|
+
output: {
|
|
1406
|
+
emitAssets: false,
|
|
1407
|
+
target: 'node',
|
|
1408
|
+
distPath: {
|
|
1409
|
+
root: ssrOutDir
|
|
1410
|
+
},
|
|
1411
|
+
minify: false
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
} : {}
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
async function initRsbuild(rootDir, config, pluginDriver, enableSSG, extraRsbuildConfig) {
|
|
1419
|
+
var _pluginDriver_getPlugins;
|
|
1420
|
+
const cwd = process.cwd();
|
|
1421
|
+
const userDocRoot = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(rootDir || (null == config ? void 0 : config.root) || cwd);
|
|
1422
|
+
const builderPlugins = (null == config ? void 0 : config.builderPlugins) ?? [];
|
|
1423
|
+
const runtimeTempDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.RSPRESS_TEMP_DIR, 'runtime');
|
|
1424
|
+
const runtimeAbsTempDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(cwd, 'node_modules', runtimeTempDir);
|
|
1425
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].mkdir(runtimeAbsTempDir, {
|
|
1426
|
+
recursive: true
|
|
1427
|
+
});
|
|
1428
|
+
const routeService = await initRouteService({
|
|
1429
|
+
config,
|
|
1430
|
+
runtimeTempDir: runtimeAbsTempDir,
|
|
1431
|
+
scanDir: userDocRoot,
|
|
1432
|
+
pluginDriver
|
|
1433
|
+
});
|
|
1434
|
+
const { createRsbuild, mergeRsbuildConfig } = await import("@rsbuild/core");
|
|
1435
|
+
const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, runtimeTempDir);
|
|
1436
|
+
const rsbuild = await createRsbuild({
|
|
1437
|
+
rsbuildConfig: mergeRsbuildConfig(internalRsbuildConfig, ...(null === (_pluginDriver_getPlugins = pluginDriver.getPlugins()) || void 0 === _pluginDriver_getPlugins ? void 0 : _pluginDriver_getPlugins.map((plugin)=>plugin.builderConfig ?? {})) || [], (null == config ? void 0 : config.builderConfig) || {}, extraRsbuildConfig || {})
|
|
1438
|
+
});
|
|
1439
|
+
rsbuild.addPlugins(builderPlugins);
|
|
1440
|
+
return rsbuild;
|
|
1441
|
+
}
|
|
1442
|
+
function checkLanguageParity_normalizePath(filePath) {
|
|
1443
|
+
return filePath.split(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep).join('/');
|
|
1444
|
+
}
|
|
1445
|
+
async function getAllMarkdownFilesFrom(dirPath) {
|
|
1446
|
+
const files = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readdir(dirPath, {
|
|
1447
|
+
withFileTypes: true
|
|
1448
|
+
});
|
|
1449
|
+
const allFiles = [];
|
|
1450
|
+
for (const file of files){
|
|
1451
|
+
const fullPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dirPath, file.name);
|
|
1452
|
+
if (file.isDirectory()) {
|
|
1453
|
+
const nestedFiles = await getAllMarkdownFilesFrom(fullPath);
|
|
1454
|
+
allFiles.push(...nestedFiles);
|
|
1455
|
+
} else if ([
|
|
1456
|
+
'.md',
|
|
1457
|
+
'.mdx'
|
|
1458
|
+
].includes(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(file.name))) allFiles.push(fullPath);
|
|
1459
|
+
}
|
|
1460
|
+
return allFiles;
|
|
1461
|
+
}
|
|
1462
|
+
async function collectModuleFiles(contentPath, lang, includedDir, excludedDirs, fileLangMap) {
|
|
1463
|
+
const langDirPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(contentPath, lang);
|
|
1464
|
+
const langModuleDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(langDirPath, includedDir);
|
|
1465
|
+
try {
|
|
1466
|
+
const moduleDirStats = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].stat(langModuleDir);
|
|
1467
|
+
if (!moduleDirStats.isDirectory()) return fileLangMap;
|
|
1468
|
+
const files = await getAllMarkdownFilesFrom(langModuleDir);
|
|
1469
|
+
for (const file of files){
|
|
1470
|
+
const relativePath = checkLanguageParity_normalizePath(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(langDirPath, file));
|
|
1471
|
+
if (excludedDirs.some((excludedDir)=>{
|
|
1472
|
+
const isFilePath = /\.(md|mdx)$/.test(excludedDir);
|
|
1473
|
+
return relativePath.includes(excludedDir + (isFilePath ? '' : '/'));
|
|
1474
|
+
})) continue;
|
|
1475
|
+
const baseName = relativePath;
|
|
1476
|
+
if (!fileLangMap[baseName]) fileLangMap[baseName] = new Set();
|
|
1477
|
+
fileLangMap[baseName].add(lang);
|
|
1478
|
+
}
|
|
1479
|
+
} catch (e) {
|
|
1480
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(e);
|
|
1481
|
+
throw new Error(`Failed to access directory: ${checkLanguageParity_normalizePath(langModuleDir)}`);
|
|
1482
|
+
}
|
|
1483
|
+
return fileLangMap;
|
|
1484
|
+
}
|
|
1485
|
+
async function checkLanguageParity(config) {
|
|
1486
|
+
var _config_languageParity_include, _this, _config_themeConfig;
|
|
1487
|
+
if (!(null == config ? void 0 : config.languageParity) || false === config.languageParity.enabled) return;
|
|
1488
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info('Checking language parity...');
|
|
1489
|
+
const contentPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(config.root);
|
|
1490
|
+
const includedDirs = (null === (_config_languageParity_include = config.languageParity.include) || void 0 === _config_languageParity_include ? void 0 : _config_languageParity_include.length) ? config.languageParity.include : [
|
|
1491
|
+
''
|
|
1492
|
+
];
|
|
1493
|
+
const excludedDirs = config.languageParity.exclude ?? [];
|
|
1494
|
+
const supportedLanguages = (null === (_this = config.locales ?? (null === (_config_themeConfig = config.themeConfig) || void 0 === _config_themeConfig ? void 0 : _config_themeConfig.locales)) || void 0 === _this ? void 0 : _this.map((locale)=>locale.lang)) || [];
|
|
1495
|
+
if (!supportedLanguages.length) {
|
|
1496
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error('No supported languages found in the configuration.');
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
const missingLanguagesFile = [];
|
|
1500
|
+
try {
|
|
1501
|
+
for (const includedDir of includedDirs){
|
|
1502
|
+
if (excludedDirs.some((excludedDir)=>excludedDir === includedDir)) continue;
|
|
1503
|
+
const curFileLangMap = {};
|
|
1504
|
+
for (const lang of supportedLanguages)await collectModuleFiles(contentPath, lang, includedDir, excludedDirs, curFileLangMap);
|
|
1505
|
+
for (const [baseName, langs] of Object.entries(curFileLangMap)){
|
|
1506
|
+
const missingLangs = supportedLanguages.filter((lang)=>!langs.has(lang));
|
|
1507
|
+
missingLangs.forEach((lang)=>{
|
|
1508
|
+
const missingPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(lang, baseName);
|
|
1509
|
+
missingLanguagesFile.push(missingPath);
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
if (missingLanguagesFile.length > 0) throw new Error(`Check language parity failed! Missing content:\n${missingLanguagesFile.map((file)=>` - ${checkLanguageParity_normalizePath(file)}`).join('\n')}`);
|
|
1514
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.success('Language parity checked successfully.');
|
|
1515
|
+
} catch (err) {
|
|
1516
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error('Error during language parity check: \n', err);
|
|
1517
|
+
throw err;
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
async function dev(options) {
|
|
1521
|
+
const { docDirectory, config, extraBuilderConfig } = options;
|
|
1522
|
+
const isProd = false;
|
|
1523
|
+
const pluginDriver = new PluginDriver(config, isProd);
|
|
1524
|
+
await pluginDriver.init();
|
|
1525
|
+
const modifiedConfig = await pluginDriver.modifyConfig();
|
|
1526
|
+
try {
|
|
1527
|
+
await pluginDriver.beforeBuild();
|
|
1528
|
+
const builder = await initRsbuild(docDirectory, modifiedConfig, pluginDriver, false, extraBuilderConfig);
|
|
1529
|
+
builder.onDevCompileDone(async ()=>{
|
|
1530
|
+
await pluginDriver.afterBuild();
|
|
1531
|
+
});
|
|
1532
|
+
const { server } = await builder.startDevServer({
|
|
1533
|
+
getPortSilently: true
|
|
1534
|
+
});
|
|
1535
|
+
return server;
|
|
1536
|
+
} finally{
|
|
1537
|
+
await writeSearchIndex(modifiedConfig);
|
|
1538
|
+
await checkLanguageParity(modifiedConfig);
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
var package_namespaceObject = {
|
|
1542
|
+
i8: "1.43.8"
|
|
1543
|
+
};
|
|
1544
|
+
async function renderFrontmatterHead(route) {
|
|
1545
|
+
if (!isRouteMeta(route)) return '';
|
|
1546
|
+
const content = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(route.absolutePath, {
|
|
1547
|
+
encoding: 'utf-8'
|
|
1548
|
+
});
|
|
1549
|
+
const { frontmatter: { head } } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.loadFrontMatter)(content, route.absolutePath, '', true);
|
|
1550
|
+
if (!head || 0 === head.length) return '';
|
|
1551
|
+
return head.map(([tag, attrs])=>`<${tag} ${renderAttrs(attrs)}>`).join('');
|
|
1552
|
+
}
|
|
1553
|
+
async function renderConfigHead(config, route) {
|
|
1554
|
+
if (!isRouteMeta(route)) return '';
|
|
1555
|
+
if (!config.head || 0 === config.head.length) return '';
|
|
1556
|
+
return config.head.map((head)=>{
|
|
1557
|
+
if ('string' == typeof head) return head;
|
|
1558
|
+
if ('function' == typeof head) {
|
|
1559
|
+
const resultHead = head(route);
|
|
1560
|
+
if (!resultHead) return '';
|
|
1561
|
+
if ('string' == typeof resultHead) return resultHead;
|
|
1562
|
+
return `<${resultHead[0]} ${renderAttrs(resultHead[1])}>`;
|
|
1563
|
+
}
|
|
1564
|
+
return `<${head[0]} ${renderAttrs(head[1])}>`;
|
|
1565
|
+
}).join('');
|
|
1566
|
+
}
|
|
1567
|
+
function renderAttrs(attrs) {
|
|
1568
|
+
return Object.entries(attrs).map(([key, value])=>{
|
|
1569
|
+
if ('boolean' == typeof value) return key;
|
|
1570
|
+
if ('string' == typeof value || 'number' == typeof value) return `${key}="${value}"`;
|
|
1571
|
+
throw new Error(`Invalid value for attribute ${key}:${JSON.stringify(value)}`);
|
|
1572
|
+
}).join('');
|
|
1573
|
+
}
|
|
1574
|
+
function isRouteMeta(route) {
|
|
1575
|
+
return !!route && 'object' == typeof route && 'routePath' in route && 'absolutePath' in route;
|
|
1576
|
+
}
|
|
1577
|
+
async function bundle(docDirectory, config, pluginDriver, enableSSG) {
|
|
1578
|
+
try {
|
|
1579
|
+
const rsbuild = await initRsbuild(docDirectory, config, pluginDriver, enableSSG);
|
|
1580
|
+
await rsbuild.build();
|
|
1581
|
+
} finally{
|
|
1582
|
+
await writeSearchIndex(config);
|
|
1583
|
+
await checkLanguageParity(config);
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
function emptyDir(path) {
|
|
1587
|
+
return __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].rm(path, {
|
|
1588
|
+
force: true,
|
|
1589
|
+
recursive: true
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
async function renderPages(appDirectory, config, pluginDriver, ssgConfig) {
|
|
1593
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info('Rendering pages...');
|
|
1594
|
+
const startTime = Date.now();
|
|
1595
|
+
const outputPath = (null == config ? void 0 : config.outDir) ?? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(appDirectory, OUTPUT_DIR);
|
|
1596
|
+
const ssrBundlePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'ssr', 'main.cjs');
|
|
1597
|
+
try {
|
|
1598
|
+
let render;
|
|
1599
|
+
if (ssgConfig) try {
|
|
1600
|
+
const { default: ssrExports } = await import((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(ssrBundlePath).toString());
|
|
1601
|
+
({ render } = ssrExports);
|
|
1602
|
+
} catch (e) {
|
|
1603
|
+
if ('object' == typeof ssgConfig && ssgConfig.strict) {
|
|
1604
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Failed to load SSG bundle: ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(ssrBundlePath)}.`);
|
|
1605
|
+
throw e;
|
|
1606
|
+
}
|
|
1607
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(e);
|
|
1608
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.warn(`Failed to load SSG bundle: ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(ssrBundlePath)}, fallback to CSR.`);
|
|
1609
|
+
}
|
|
1610
|
+
const routes = init_routeService.getRoutes();
|
|
1611
|
+
const base = (null == config ? void 0 : config.base) ?? '';
|
|
1612
|
+
const htmlTemplatePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'index.html');
|
|
1613
|
+
const htmlTemplate = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(htmlTemplatePath, 'utf-8');
|
|
1614
|
+
const additionalRoutes = (await pluginDriver.addSSGRoutes()).map((route)=>({
|
|
1615
|
+
routePath: (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.withBase)(route.path, base)
|
|
1616
|
+
}));
|
|
1617
|
+
const allRoutes = [
|
|
1618
|
+
...routes,
|
|
1619
|
+
...additionalRoutes
|
|
1620
|
+
];
|
|
1621
|
+
const is404RouteInRoutes = allRoutes.some((route)=>'/404' === route.routePath);
|
|
1622
|
+
if (!is404RouteInRoutes) allRoutes.push({
|
|
1623
|
+
routePath: '/404'
|
|
1624
|
+
});
|
|
1625
|
+
await Promise.all(allRoutes.filter((route)=>!route.routePath.includes(':')).map(async (route)=>{
|
|
1626
|
+
const helmetContext = new __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__.HelmetData({});
|
|
1627
|
+
const { routePath } = route;
|
|
1628
|
+
let appHtml = '';
|
|
1629
|
+
if (render) try {
|
|
1630
|
+
({ appHtml } = await render(routePath, helmetContext.context));
|
|
1631
|
+
} catch (e) {
|
|
1632
|
+
if ('object' == typeof ssgConfig && ssgConfig.strict) {
|
|
1633
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Page "${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(routePath)}" SSG rendering failed.`);
|
|
1634
|
+
throw e;
|
|
1635
|
+
}
|
|
1636
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.warn(`Page "${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(routePath)}" SSG rendering error, fallback to CSR.`, e);
|
|
1637
|
+
}
|
|
1638
|
+
const { helmet } = helmetContext.context;
|
|
1639
|
+
let html = htmlTemplate.replace(/<title>(.*?)<\/title>/gi, '').replace(APP_HTML_MARKER, ()=>appHtml).replace(META_GENERATOR, ()=>`<meta name="generator" content="Rspress v${package_namespaceObject.i8}">`).replace(HEAD_MARKER, [
|
|
1640
|
+
await renderConfigHead(config, route),
|
|
1641
|
+
helmet.title.toString(),
|
|
1642
|
+
helmet.meta.toString(),
|
|
1643
|
+
helmet.link.toString(),
|
|
1644
|
+
helmet.style.toString(),
|
|
1645
|
+
helmet.script.toString(),
|
|
1646
|
+
await renderFrontmatterHead(route)
|
|
1647
|
+
].join(''));
|
|
1648
|
+
if (helmet.htmlAttributes) {
|
|
1649
|
+
var _helmet_htmlAttributes;
|
|
1650
|
+
html = html.replace(HTML_START_TAG, `${HTML_START_TAG} ${null === (_helmet_htmlAttributes = helmet.htmlAttributes) || void 0 === _helmet_htmlAttributes ? void 0 : _helmet_htmlAttributes.toString()}`);
|
|
1651
|
+
}
|
|
1652
|
+
if (helmet.bodyAttributes) {
|
|
1653
|
+
var _helmet_bodyAttributes;
|
|
1654
|
+
html = html.replace(BODY_START_TAG, `${BODY_START_TAG} ${null === (_helmet_bodyAttributes = helmet.bodyAttributes) || void 0 === _helmet_bodyAttributes ? void 0 : _helmet_bodyAttributes.toString()}`);
|
|
1655
|
+
}
|
|
1656
|
+
const normalizeHtmlFilePath = (path)=>{
|
|
1657
|
+
const normalizedBase = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeSlash)((null == config ? void 0 : config.base) || '/');
|
|
1658
|
+
if (path.endsWith('/')) return `${path}index.html`.replace(normalizedBase, '');
|
|
1659
|
+
return `${path}.html`.replace(normalizedBase, '');
|
|
1660
|
+
};
|
|
1661
|
+
const fileName = normalizeHtmlFilePath(routePath);
|
|
1662
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].mkdir((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(fileName)), {
|
|
1663
|
+
recursive: true
|
|
1664
|
+
});
|
|
1665
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, fileName), html);
|
|
1666
|
+
}));
|
|
1667
|
+
if (!(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isDebugMode)()) await emptyDir((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'ssr'));
|
|
1668
|
+
await emptyDir((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'html'));
|
|
1669
|
+
const totalTime = Date.now() - startTime;
|
|
1670
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.success(`Pages rendered in ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(totalTime)} ms.`);
|
|
1671
|
+
} catch (e) {
|
|
1672
|
+
if (e instanceof Error) __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Pages render error: ${e.stack}`);
|
|
1673
|
+
throw e;
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
async function build(options) {
|
|
1677
|
+
const { docDirectory, appDirectory, config } = options;
|
|
1678
|
+
const pluginDriver = new PluginDriver(config, true);
|
|
1679
|
+
await pluginDriver.init();
|
|
1680
|
+
const modifiedConfig = await pluginDriver.modifyConfig();
|
|
1681
|
+
await pluginDriver.beforeBuild();
|
|
1682
|
+
const ssgConfig = modifiedConfig.ssg ?? true;
|
|
1683
|
+
await emptyDir(TEMP_DIR);
|
|
1684
|
+
await bundle(docDirectory, modifiedConfig, pluginDriver, Boolean(ssgConfig));
|
|
1685
|
+
await renderPages(appDirectory, modifiedConfig, pluginDriver, ssgConfig);
|
|
1686
|
+
await pluginDriver.afterBuild();
|
|
1687
|
+
}
|
|
1688
|
+
async function serve(options) {
|
|
1689
|
+
var _builderConfig_server, _builderConfig_server1;
|
|
1690
|
+
const { config, port: userPort, host: userHost } = options;
|
|
1691
|
+
const envPort = process.env.PORT;
|
|
1692
|
+
const envHost = process.env.HOST;
|
|
1693
|
+
const { builderConfig } = config;
|
|
1694
|
+
const port = Number(envPort || userPort || (null == builderConfig ? void 0 : null === (_builderConfig_server = builderConfig.server) || void 0 === _builderConfig_server ? void 0 : _builderConfig_server.port) || 4173);
|
|
1695
|
+
const host = envHost || userHost || (null == builderConfig ? void 0 : null === (_builderConfig_server1 = builderConfig.server) || void 0 === _builderConfig_server1 ? void 0 : _builderConfig_server1.host) || 'localhost';
|
|
1696
|
+
config.builderConfig = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(builderConfig, {
|
|
1697
|
+
server: {
|
|
1698
|
+
port,
|
|
1699
|
+
host
|
|
1700
|
+
}
|
|
1701
|
+
});
|
|
1702
|
+
const pluginDriver = new PluginDriver(config, true);
|
|
1703
|
+
await pluginDriver.init();
|
|
1704
|
+
const modifiedConfig = await pluginDriver.modifyConfig();
|
|
1705
|
+
const builder = await initRsbuild(config.root, modifiedConfig, pluginDriver, false);
|
|
1706
|
+
return builder.preview();
|
|
1707
|
+
}
|
|
1708
|
+
var __webpack_exports__mergeDocConfig = __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.mergeDocConfig;
|
|
1709
|
+
export { build, dev, serve, __webpack_exports__mergeDocConfig as mergeDocConfig };
|