@docusaurus/core 0.0.0-5869 → 0.0.0-5872
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/lib/server/plugins/actions.d.ts +2 -2
- package/lib/server/plugins/plugins.d.ts +0 -5
- package/lib/server/plugins/plugins.js +50 -98
- package/lib/server/plugins/pluginsUtils.d.ts +15 -0
- package/lib/server/plugins/pluginsUtils.js +60 -0
- package/lib/server/plugins/synthetic.d.ts +3 -3
- package/lib/server/plugins/synthetic.js +0 -2
- package/lib/server/site.js +0 -1
- package/lib/utils.js +31 -3
- package/package.json +10 -10
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { InitializedPlugin, PluginContentLoadedActions, RouteConfig } from '@docusaurus/types';
|
|
8
8
|
type PluginActionUtils = {
|
|
9
9
|
getRoutes: () => RouteConfig[];
|
|
10
10
|
getGlobalData: () => unknown;
|
|
11
11
|
getActions: () => PluginContentLoadedActions;
|
|
12
12
|
};
|
|
13
13
|
export declare function createPluginActionsUtils({ plugin, generatedFilesDir, baseUrl, trailingSlash, }: {
|
|
14
|
-
plugin:
|
|
14
|
+
plugin: InitializedPlugin;
|
|
15
15
|
generatedFilesDir: string;
|
|
16
16
|
baseUrl: string;
|
|
17
17
|
trailingSlash: boolean | undefined;
|
|
@@ -10,15 +10,10 @@ export type LoadPluginsResult = {
|
|
|
10
10
|
routes: RouteConfig[];
|
|
11
11
|
globalData: GlobalData;
|
|
12
12
|
};
|
|
13
|
-
export declare function mergeGlobalData(...globalDataList: GlobalData[]): GlobalData;
|
|
14
13
|
/**
|
|
15
14
|
* Initializes the plugins and run their lifecycle functions.
|
|
16
15
|
*/
|
|
17
16
|
export declare function loadPlugins(context: LoadContext): Promise<LoadPluginsResult>;
|
|
18
|
-
export declare function getPluginByIdentifier({ plugins, pluginIdentifier, }: {
|
|
19
|
-
pluginIdentifier: PluginIdentifier;
|
|
20
|
-
plugins: LoadedPlugin[];
|
|
21
|
-
}): LoadedPlugin;
|
|
22
17
|
export declare function reloadPlugin({ pluginIdentifier, plugins: previousPlugins, context, }: {
|
|
23
18
|
pluginIdentifier: PluginIdentifier;
|
|
24
19
|
plugins: LoadedPlugin[];
|
|
@@ -6,19 +6,16 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.reloadPlugin = exports.
|
|
10
|
-
const tslib_1 = require("tslib");
|
|
11
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
|
-
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
9
|
+
exports.reloadPlugin = exports.loadPlugins = void 0;
|
|
13
10
|
const init_1 = require("./init");
|
|
14
11
|
const synthetic_1 = require("./synthetic");
|
|
15
12
|
const translations_1 = require("../translations/translations");
|
|
16
13
|
const routeConfig_1 = require("./routeConfig");
|
|
17
14
|
const utils_1 = require("../../utils");
|
|
18
15
|
const actions_1 = require("./actions");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const rawTranslationFiles = (await plugin.getTranslationFiles?.({ content
|
|
16
|
+
const pluginsUtils_1 = require("./pluginsUtils");
|
|
17
|
+
async function translatePluginContent({ plugin, content, context, }) {
|
|
18
|
+
const rawTranslationFiles = (await plugin.getTranslationFiles?.({ content })) ?? [];
|
|
22
19
|
const translationFiles = await Promise.all(rawTranslationFiles.map((translationFile) => (0, translations_1.localizePluginTranslationFile)({
|
|
23
20
|
localizationDir: context.localizationDir,
|
|
24
21
|
translationFile,
|
|
@@ -34,31 +31,23 @@ async function translatePlugin({ plugin, context, }) {
|
|
|
34
31
|
// translate its own slice of theme config and should make no assumptions
|
|
35
32
|
// about other plugins' keys, so this is safe to run in parallel.
|
|
36
33
|
Object.assign(context.siteConfig.themeConfig, translatedThemeConfigSlice);
|
|
37
|
-
return
|
|
34
|
+
return translatedContent;
|
|
38
35
|
}
|
|
39
|
-
async function
|
|
40
|
-
return utils_1.PerfLogger.async(`
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return utils_1.PerfLogger.async(`Plugins - loadContent`, () => Promise.all(plugins.map((plugin) => executePluginLoadContent({ plugin, context }))));
|
|
48
|
-
}
|
|
49
|
-
function aggregateAllContent(loadedPlugins) {
|
|
50
|
-
return lodash_1.default.chain(loadedPlugins)
|
|
51
|
-
.groupBy((item) => item.name)
|
|
52
|
-
.mapValues((nameItems) => lodash_1.default.chain(nameItems)
|
|
53
|
-
.groupBy((item) => item.options.id)
|
|
54
|
-
.mapValues((idItems) => idItems[0].content)
|
|
55
|
-
.value())
|
|
56
|
-
.value();
|
|
57
|
-
}
|
|
58
|
-
async function executePluginContentLoaded({ plugin, context, }) {
|
|
59
|
-
return utils_1.PerfLogger.async(`Plugins - contentLoaded - ${plugin.name}@${plugin.options.id}`, async () => {
|
|
36
|
+
async function executePluginContentLoading({ plugin, context, }) {
|
|
37
|
+
return utils_1.PerfLogger.async(`Plugins - single plugin content loading - ${plugin.name}@${plugin.options.id}`, async () => {
|
|
38
|
+
let content = await plugin.loadContent?.();
|
|
39
|
+
content = await translatePluginContent({
|
|
40
|
+
plugin,
|
|
41
|
+
content,
|
|
42
|
+
context,
|
|
43
|
+
});
|
|
60
44
|
if (!plugin.contentLoaded) {
|
|
61
|
-
return {
|
|
45
|
+
return {
|
|
46
|
+
...plugin,
|
|
47
|
+
content,
|
|
48
|
+
routes: [],
|
|
49
|
+
globalData: undefined,
|
|
50
|
+
};
|
|
62
51
|
}
|
|
63
52
|
const pluginActionsUtils = await (0, actions_1.createPluginActionsUtils)({
|
|
64
53
|
plugin,
|
|
@@ -67,15 +56,22 @@ async function executePluginContentLoaded({ plugin, context, }) {
|
|
|
67
56
|
trailingSlash: context.siteConfig.trailingSlash,
|
|
68
57
|
});
|
|
69
58
|
await plugin.contentLoaded({
|
|
70
|
-
content
|
|
59
|
+
content,
|
|
71
60
|
actions: pluginActionsUtils.getActions(),
|
|
72
61
|
});
|
|
73
62
|
return {
|
|
63
|
+
...plugin,
|
|
64
|
+
content,
|
|
74
65
|
routes: pluginActionsUtils.getRoutes(),
|
|
75
66
|
globalData: pluginActionsUtils.getGlobalData(),
|
|
76
67
|
};
|
|
77
68
|
});
|
|
78
69
|
}
|
|
70
|
+
async function executeAllPluginsContentLoading({ plugins, context, }) {
|
|
71
|
+
return utils_1.PerfLogger.async(`Plugins - all plugins content loading`, () => {
|
|
72
|
+
return Promise.all(plugins.map((plugin) => executePluginContentLoading({ plugin, context })));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
79
75
|
async function executePluginAllContentLoaded({ plugin, context, allContent, }) {
|
|
80
76
|
return utils_1.PerfLogger.async(`Plugins - allContentLoaded - ${plugin.name}@${plugin.options.id}`, async () => {
|
|
81
77
|
if (!plugin.allContentLoaded) {
|
|
@@ -97,31 +93,9 @@ async function executePluginAllContentLoaded({ plugin, context, allContent, }) {
|
|
|
97
93
|
};
|
|
98
94
|
});
|
|
99
95
|
}
|
|
100
|
-
async function
|
|
101
|
-
return utils_1.PerfLogger.async(`Plugins - contentLoaded`, async () => {
|
|
102
|
-
const routes = [];
|
|
103
|
-
const globalData = {};
|
|
104
|
-
await Promise.all(plugins.map(async (plugin) => {
|
|
105
|
-
var _a;
|
|
106
|
-
const { routes: pluginRoutes, globalData: pluginGlobalData } = await executePluginContentLoaded({
|
|
107
|
-
plugin,
|
|
108
|
-
context,
|
|
109
|
-
});
|
|
110
|
-
routes.push(...pluginRoutes);
|
|
111
|
-
if (pluginGlobalData !== undefined) {
|
|
112
|
-
globalData[_a = plugin.name] ?? (globalData[_a] = {});
|
|
113
|
-
globalData[plugin.name][plugin.options.id] = pluginGlobalData;
|
|
114
|
-
}
|
|
115
|
-
}));
|
|
116
|
-
// Sort the route config.
|
|
117
|
-
// This ensures that route with sub routes are always placed last.
|
|
118
|
-
(0, routeConfig_1.sortRoutes)(routes, context.siteConfig.baseUrl);
|
|
119
|
-
return { routes, globalData };
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
async function executePluginsAllContentLoaded({ plugins, context, }) {
|
|
96
|
+
async function executeAllPluginsAllContentLoaded({ plugins, context, }) {
|
|
123
97
|
return utils_1.PerfLogger.async(`Plugins - allContentLoaded`, async () => {
|
|
124
|
-
const allContent = aggregateAllContent(plugins);
|
|
98
|
+
const allContent = (0, pluginsUtils_1.aggregateAllContent)(plugins);
|
|
125
99
|
const routes = [];
|
|
126
100
|
const globalData = {};
|
|
127
101
|
await Promise.all(plugins.map(async (plugin) => {
|
|
@@ -137,33 +111,16 @@ async function executePluginsAllContentLoaded({ plugins, context, }) {
|
|
|
137
111
|
globalData[plugin.name][plugin.options.id] = pluginGlobalData;
|
|
138
112
|
}
|
|
139
113
|
}));
|
|
140
|
-
// Sort the route config.
|
|
141
|
-
// This ensures that route with sub routes are always placed last.
|
|
142
|
-
(0, routeConfig_1.sortRoutes)(routes, context.siteConfig.baseUrl);
|
|
143
114
|
return { routes, globalData };
|
|
144
115
|
});
|
|
145
116
|
}
|
|
146
|
-
function
|
|
147
|
-
const result = {};
|
|
148
|
-
const allPluginIdentifiers = globalDataList.flatMap((gd) => Object.keys(gd).flatMap((name) => Object.keys(gd[name]).map((id) => ({ name, id }))));
|
|
149
|
-
allPluginIdentifiers.forEach(({ name, id }) => {
|
|
150
|
-
const allData = globalDataList
|
|
151
|
-
.map((gd) => gd?.[name]?.[id])
|
|
152
|
-
.filter((d) => typeof d !== 'undefined');
|
|
153
|
-
const mergedData = allData.length === 1 ? allData[0] : Object.assign({}, ...allData);
|
|
154
|
-
result[name] ?? (result[name] = {});
|
|
155
|
-
result[name][id] = mergedData;
|
|
156
|
-
});
|
|
157
|
-
return result;
|
|
158
|
-
}
|
|
159
|
-
exports.mergeGlobalData = mergeGlobalData;
|
|
160
|
-
function mergeResults({ contentLoadedResult, allContentLoadedResult, }) {
|
|
117
|
+
function mergeResults({ plugins, allContentLoadedResult, }) {
|
|
161
118
|
const routes = [
|
|
162
|
-
...
|
|
119
|
+
...(0, pluginsUtils_1.aggregateRoutes)(plugins),
|
|
163
120
|
...allContentLoadedResult.routes,
|
|
164
121
|
];
|
|
165
122
|
(0, routeConfig_1.sortRoutes)(routes);
|
|
166
|
-
const globalData = mergeGlobalData(
|
|
123
|
+
const globalData = (0, pluginsUtils_1.mergeGlobalData)((0, pluginsUtils_1.aggregateGlobalData)(plugins), allContentLoadedResult.globalData);
|
|
167
124
|
return { routes, globalData };
|
|
168
125
|
}
|
|
169
126
|
/**
|
|
@@ -172,54 +129,49 @@ function mergeResults({ contentLoadedResult, allContentLoadedResult, }) {
|
|
|
172
129
|
async function loadPlugins(context) {
|
|
173
130
|
return utils_1.PerfLogger.async('Plugins - loadPlugins', async () => {
|
|
174
131
|
const initializedPlugins = await utils_1.PerfLogger.async('Plugins - initPlugins', () => (0, init_1.initPlugins)(context));
|
|
132
|
+
// TODO probably not the ideal place to hardcode those plugins
|
|
175
133
|
initializedPlugins.push((0, synthetic_1.createBootstrapPlugin)(context), (0, synthetic_1.createMDXFallbackPlugin)(context));
|
|
176
|
-
const plugins = await
|
|
134
|
+
const plugins = await executeAllPluginsContentLoading({
|
|
177
135
|
plugins: initializedPlugins,
|
|
178
136
|
context,
|
|
179
137
|
});
|
|
180
|
-
const
|
|
181
|
-
plugins,
|
|
182
|
-
context,
|
|
183
|
-
});
|
|
184
|
-
const allContentLoadedResult = await executePluginsAllContentLoaded({
|
|
138
|
+
const allContentLoadedResult = await executeAllPluginsAllContentLoaded({
|
|
185
139
|
plugins,
|
|
186
140
|
context,
|
|
187
141
|
});
|
|
188
142
|
const { routes, globalData } = mergeResults({
|
|
189
|
-
|
|
143
|
+
plugins,
|
|
190
144
|
allContentLoadedResult,
|
|
191
145
|
});
|
|
192
146
|
return { plugins, routes, globalData };
|
|
193
147
|
});
|
|
194
148
|
}
|
|
195
149
|
exports.loadPlugins = loadPlugins;
|
|
196
|
-
function getPluginByIdentifier({ plugins, pluginIdentifier, }) {
|
|
197
|
-
const plugin = plugins.find((p) => p.name === pluginIdentifier.name && p.options.id === pluginIdentifier.id);
|
|
198
|
-
if (!plugin) {
|
|
199
|
-
throw new Error(logger_1.default.interpolate `Plugin not found for identifier ${pluginIdentifier.name}@${pluginIdentifier.id}`);
|
|
200
|
-
}
|
|
201
|
-
return plugin;
|
|
202
|
-
}
|
|
203
|
-
exports.getPluginByIdentifier = getPluginByIdentifier;
|
|
204
150
|
async function reloadPlugin({ pluginIdentifier, plugins: previousPlugins, context, }) {
|
|
205
151
|
return utils_1.PerfLogger.async('Plugins - reloadPlugin', async () => {
|
|
206
|
-
const
|
|
152
|
+
const previousPlugin = (0, pluginsUtils_1.getPluginByIdentifier)({
|
|
207
153
|
plugins: previousPlugins,
|
|
208
154
|
pluginIdentifier,
|
|
209
155
|
});
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
// TODO optimize this, we shouldn't need to re-run this lifecycle
|
|
213
|
-
const contentLoadedResult = await executePluginsContentLoaded({
|
|
214
|
-
plugins,
|
|
156
|
+
const plugin = await executePluginContentLoading({
|
|
157
|
+
plugin: previousPlugin,
|
|
215
158
|
context,
|
|
216
159
|
});
|
|
217
|
-
|
|
160
|
+
/*
|
|
161
|
+
// TODO Docusaurus v4 - upgrade to Node 20, use array.with()
|
|
162
|
+
const plugins = previousPlugins.with(
|
|
163
|
+
previousPlugins.indexOf(previousPlugin),
|
|
164
|
+
plugin,
|
|
165
|
+
);
|
|
166
|
+
*/
|
|
167
|
+
const plugins = [...previousPlugins];
|
|
168
|
+
plugins[previousPlugins.indexOf(previousPlugin)] = plugin;
|
|
169
|
+
const allContentLoadedResult = await executeAllPluginsAllContentLoaded({
|
|
218
170
|
plugins,
|
|
219
171
|
context,
|
|
220
172
|
});
|
|
221
173
|
const { routes, globalData } = mergeResults({
|
|
222
|
-
|
|
174
|
+
plugins,
|
|
223
175
|
allContentLoadedResult,
|
|
224
176
|
});
|
|
225
177
|
return { plugins, routes, globalData };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type { AllContent, GlobalData, InitializedPlugin, LoadedPlugin, PluginIdentifier, RouteConfig } from '@docusaurus/types';
|
|
8
|
+
export declare function getPluginByIdentifier<P extends InitializedPlugin>({ plugins, pluginIdentifier, }: {
|
|
9
|
+
pluginIdentifier: PluginIdentifier;
|
|
10
|
+
plugins: P[];
|
|
11
|
+
}): P;
|
|
12
|
+
export declare function aggregateAllContent(loadedPlugins: LoadedPlugin[]): AllContent;
|
|
13
|
+
export declare function aggregateRoutes(loadedPlugins: LoadedPlugin[]): RouteConfig[];
|
|
14
|
+
export declare function aggregateGlobalData(loadedPlugins: LoadedPlugin[]): GlobalData;
|
|
15
|
+
export declare function mergeGlobalData(...globalDataList: GlobalData[]): GlobalData;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.mergeGlobalData = exports.aggregateGlobalData = exports.aggregateRoutes = exports.aggregateAllContent = exports.getPluginByIdentifier = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
13
|
+
function getPluginByIdentifier({ plugins, pluginIdentifier, }) {
|
|
14
|
+
const plugin = plugins.find((p) => p.name === pluginIdentifier.name && p.options.id === pluginIdentifier.id);
|
|
15
|
+
if (!plugin) {
|
|
16
|
+
throw new Error(logger_1.default.interpolate `Plugin not found for identifier ${pluginIdentifier.name}@${pluginIdentifier.id}`);
|
|
17
|
+
}
|
|
18
|
+
return plugin;
|
|
19
|
+
}
|
|
20
|
+
exports.getPluginByIdentifier = getPluginByIdentifier;
|
|
21
|
+
function aggregateAllContent(loadedPlugins) {
|
|
22
|
+
return lodash_1.default.chain(loadedPlugins)
|
|
23
|
+
.groupBy((item) => item.name)
|
|
24
|
+
.mapValues((nameItems) => lodash_1.default.chain(nameItems)
|
|
25
|
+
.groupBy((item) => item.options.id)
|
|
26
|
+
.mapValues((idItems) => idItems[0].content)
|
|
27
|
+
.value())
|
|
28
|
+
.value();
|
|
29
|
+
}
|
|
30
|
+
exports.aggregateAllContent = aggregateAllContent;
|
|
31
|
+
function aggregateRoutes(loadedPlugins) {
|
|
32
|
+
return loadedPlugins.flatMap((p) => p.routes);
|
|
33
|
+
}
|
|
34
|
+
exports.aggregateRoutes = aggregateRoutes;
|
|
35
|
+
function aggregateGlobalData(loadedPlugins) {
|
|
36
|
+
const globalData = {};
|
|
37
|
+
loadedPlugins.forEach((plugin) => {
|
|
38
|
+
var _a;
|
|
39
|
+
if (plugin.globalData !== undefined) {
|
|
40
|
+
globalData[_a = plugin.name] ?? (globalData[_a] = {});
|
|
41
|
+
globalData[plugin.name][plugin.options.id] = plugin.globalData;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return globalData;
|
|
45
|
+
}
|
|
46
|
+
exports.aggregateGlobalData = aggregateGlobalData;
|
|
47
|
+
function mergeGlobalData(...globalDataList) {
|
|
48
|
+
const result = {};
|
|
49
|
+
const allPluginIdentifiers = globalDataList.flatMap((gd) => Object.keys(gd).flatMap((name) => Object.keys(gd[name]).map((id) => ({ name, id }))));
|
|
50
|
+
allPluginIdentifiers.forEach(({ name, id }) => {
|
|
51
|
+
const allData = globalDataList
|
|
52
|
+
.map((gd) => gd?.[name]?.[id])
|
|
53
|
+
.filter((d) => typeof d !== 'undefined');
|
|
54
|
+
const mergedData = allData.length === 1 ? allData[0] : Object.assign({}, ...allData);
|
|
55
|
+
result[name] ?? (result[name] = {});
|
|
56
|
+
result[name][id] = mergedData;
|
|
57
|
+
});
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
exports.mergeGlobalData = mergeGlobalData;
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { LoadContext, InitializedPlugin } from '@docusaurus/types';
|
|
8
8
|
/**
|
|
9
9
|
* Make a synthetic plugin to:
|
|
10
10
|
* - Inject site client modules
|
|
11
11
|
* - Inject scripts/stylesheets
|
|
12
12
|
*/
|
|
13
|
-
export declare function createBootstrapPlugin({ siteDir, siteConfig, }: LoadContext):
|
|
13
|
+
export declare function createBootstrapPlugin({ siteDir, siteConfig, }: LoadContext): InitializedPlugin;
|
|
14
14
|
/**
|
|
15
15
|
* Configure Webpack fallback mdx loader for md/mdx files out of content-plugin
|
|
16
16
|
* folders. Adds a "fallback" mdx loader for mdx files that are not processed by
|
|
17
17
|
* content plugins. This allows to do things such as importing repo/README.md as
|
|
18
18
|
* a partial from another doc. Not ideal solution, but good enough for now
|
|
19
19
|
*/
|
|
20
|
-
export declare function createMDXFallbackPlugin({ siteDir, siteConfig, }: LoadContext):
|
|
20
|
+
export declare function createMDXFallbackPlugin({ siteDir, siteConfig, }: LoadContext): InitializedPlugin;
|
|
@@ -18,7 +18,6 @@ function createBootstrapPlugin({ siteDir, siteConfig, }) {
|
|
|
18
18
|
const { stylesheets, scripts, headTags, clientModules: siteConfigClientModules, } = siteConfig;
|
|
19
19
|
return {
|
|
20
20
|
name: 'docusaurus-bootstrap-plugin',
|
|
21
|
-
content: null,
|
|
22
21
|
options: {
|
|
23
22
|
id: 'default',
|
|
24
23
|
},
|
|
@@ -61,7 +60,6 @@ exports.createBootstrapPlugin = createBootstrapPlugin;
|
|
|
61
60
|
function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
|
|
62
61
|
return {
|
|
63
62
|
name: 'docusaurus-mdx-fallback-plugin',
|
|
64
|
-
content: null,
|
|
65
63
|
options: {
|
|
66
64
|
id: 'default',
|
|
67
65
|
},
|
package/lib/server/site.js
CHANGED
|
@@ -144,7 +144,6 @@ async function reloadSite(site) {
|
|
|
144
144
|
}
|
|
145
145
|
exports.reloadSite = reloadSite;
|
|
146
146
|
async function reloadSitePlugin(site, pluginIdentifier) {
|
|
147
|
-
console.log(`reloadSitePlugin ${pluginIdentifier.name}@${pluginIdentifier.id}`);
|
|
148
147
|
const { plugins, routes, globalData } = await (0, plugins_1.reloadPlugin)({
|
|
149
148
|
pluginIdentifier,
|
|
150
149
|
plugins: site.props.plugins,
|
package/lib/utils.js
CHANGED
|
@@ -12,6 +12,11 @@ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
|
12
12
|
// For now this is a private env variable we use internally
|
|
13
13
|
// But we'll want to expose this feature officially some day
|
|
14
14
|
exports.PerfDebuggingEnabled = !!process.env.DOCUSAURUS_PERF_LOGGER;
|
|
15
|
+
const Thresholds = {
|
|
16
|
+
min: 5,
|
|
17
|
+
yellow: 100,
|
|
18
|
+
red: 1000,
|
|
19
|
+
};
|
|
15
20
|
function createPerfLogger() {
|
|
16
21
|
if (!exports.PerfDebuggingEnabled) {
|
|
17
22
|
const noop = () => { };
|
|
@@ -23,13 +28,36 @@ function createPerfLogger() {
|
|
|
23
28
|
};
|
|
24
29
|
}
|
|
25
30
|
const prefix = logger_1.default.yellow(`[PERF] `);
|
|
26
|
-
const
|
|
27
|
-
|
|
31
|
+
const formatDuration = (duration) => {
|
|
32
|
+
if (duration > Thresholds.red) {
|
|
33
|
+
return logger_1.default.red(`${(duration / 1000).toFixed(2)} seconds!`);
|
|
34
|
+
}
|
|
35
|
+
else if (duration > Thresholds.yellow) {
|
|
36
|
+
return logger_1.default.yellow(`${duration.toFixed(2)} ms`);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return logger_1.default.green(`${duration.toFixed(2)} ms`);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const logDuration = (label, duration) => {
|
|
43
|
+
if (duration < Thresholds.min) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
console.log(`${prefix + label} - ${formatDuration(duration)}`);
|
|
47
|
+
};
|
|
48
|
+
const start = (label) => performance.mark(label);
|
|
49
|
+
const end = (label) => {
|
|
50
|
+
const { duration } = performance.measure(label);
|
|
51
|
+
performance.clearMarks(label);
|
|
52
|
+
logDuration(label, duration);
|
|
53
|
+
};
|
|
28
54
|
const log = (label) => console.log(prefix + label);
|
|
29
55
|
const async = async (label, asyncFn) => {
|
|
30
56
|
start(label);
|
|
57
|
+
const before = performance.now();
|
|
31
58
|
const result = await asyncFn();
|
|
32
|
-
|
|
59
|
+
const duration = performance.now() - before;
|
|
60
|
+
logDuration(label, duration);
|
|
33
61
|
return result;
|
|
34
62
|
};
|
|
35
63
|
return {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/core",
|
|
3
3
|
"description": "Easy to Maintain Open Source Documentation Websites",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-5872",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"@babel/runtime": "^7.22.6",
|
|
44
44
|
"@babel/runtime-corejs3": "^7.22.6",
|
|
45
45
|
"@babel/traverse": "^7.22.8",
|
|
46
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
47
|
-
"@docusaurus/logger": "0.0.0-
|
|
48
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
46
|
+
"@docusaurus/cssnano-preset": "0.0.0-5872",
|
|
47
|
+
"@docusaurus/logger": "0.0.0-5872",
|
|
48
|
+
"@docusaurus/mdx-loader": "0.0.0-5872",
|
|
49
49
|
"@docusaurus/react-loadable": "5.5.2",
|
|
50
|
-
"@docusaurus/utils": "0.0.0-
|
|
51
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
52
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
50
|
+
"@docusaurus/utils": "0.0.0-5872",
|
|
51
|
+
"@docusaurus/utils-common": "0.0.0-5872",
|
|
52
|
+
"@docusaurus/utils-validation": "0.0.0-5872",
|
|
53
53
|
"@svgr/webpack": "^6.5.1",
|
|
54
54
|
"autoprefixer": "^10.4.14",
|
|
55
55
|
"babel-loader": "^9.1.3",
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"webpackbar": "^5.0.2"
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
109
|
-
"@docusaurus/types": "0.0.0-
|
|
108
|
+
"@docusaurus/module-type-aliases": "0.0.0-5872",
|
|
109
|
+
"@docusaurus/types": "0.0.0-5872",
|
|
110
110
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
111
111
|
"@types/detect-port": "^1.3.3",
|
|
112
112
|
"@types/react-dom": "^18.2.7",
|
|
@@ -126,5 +126,5 @@
|
|
|
126
126
|
"engines": {
|
|
127
127
|
"node": ">=18.0"
|
|
128
128
|
},
|
|
129
|
-
"gitHead": "
|
|
129
|
+
"gitHead": "b059cfb578e4a80cdd8b5cf9a3c8978fb41693e3"
|
|
130
130
|
}
|