@docusaurus/core 3.1.1 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/docusaurus.mjs +10 -5
- package/lib/client/{serverRenderer.d.ts → renderToHtml.d.ts} +1 -1
- package/lib/client/{serverRenderer.js → renderToHtml.js} +1 -1
- package/lib/client/serverEntry.d.ts +3 -4
- package/lib/client/serverEntry.js +12 -113
- package/lib/client/theme-fallback/Error/index.js +22 -8
- package/lib/commands/build.d.ts +3 -3
- package/lib/commands/build.js +133 -112
- package/lib/commands/deploy.d.ts +2 -2
- package/lib/commands/deploy.js +3 -3
- package/lib/commands/external.js +2 -2
- package/lib/commands/serve.d.ts +2 -2
- package/lib/commands/serve.js +4 -4
- package/lib/commands/{start.d.ts → start/start.d.ts} +3 -3
- package/lib/commands/start/start.js +47 -0
- package/lib/commands/start/utils.d.ts +31 -0
- package/lib/commands/start/utils.js +87 -0
- package/lib/commands/start/watcher.d.ts +42 -0
- package/lib/commands/start/watcher.js +78 -0
- package/lib/commands/start/webpack.d.ts +15 -0
- package/lib/commands/start/webpack.js +133 -0
- package/lib/commands/swizzle/common.d.ts +1 -0
- package/lib/commands/swizzle/common.js +1 -0
- package/lib/commands/swizzle/context.js +2 -2
- package/lib/commands/swizzle/index.js +32 -3
- package/lib/commands/writeHeadingIds.js +2 -2
- package/lib/commands/writeTranslations.d.ts +2 -2
- package/lib/commands/writeTranslations.js +3 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/server/brokenLinks.js +4 -4
- package/lib/server/clientModules.d.ts +1 -1
- package/lib/server/clientModules.js +3 -3
- package/lib/server/codegen/codegen.d.ts +20 -0
- package/lib/server/codegen/codegen.js +65 -0
- package/lib/server/codegen/codegenRoutes.d.ts +49 -0
- package/lib/server/codegen/codegenRoutes.js +190 -0
- package/lib/server/configValidation.js +6 -4
- package/lib/server/i18n.d.ts +2 -2
- package/lib/server/i18n.js +20 -2
- package/lib/server/plugins/actions.d.ts +19 -0
- package/lib/server/plugins/actions.js +62 -0
- package/lib/server/plugins/init.js +3 -3
- package/lib/server/plugins/plugins.d.ts +21 -0
- package/lib/server/plugins/plugins.js +188 -0
- package/lib/server/plugins/pluginsUtils.d.ts +16 -0
- package/lib/server/plugins/pluginsUtils.js +75 -0
- package/lib/server/plugins/routeConfig.d.ts +1 -1
- package/lib/server/plugins/routeConfig.js +4 -4
- package/lib/server/plugins/synthetic.d.ts +3 -3
- package/lib/server/plugins/synthetic.js +0 -2
- package/lib/server/routes.d.ts +3 -45
- package/lib/server/routes.js +16 -168
- package/lib/server/{index.d.ts → site.d.ts} +12 -5
- package/lib/server/site.js +164 -0
- package/lib/server/siteMetadata.d.ts +5 -4
- package/lib/server/siteMetadata.js +14 -10
- package/lib/server/translations/translations.d.ts +9 -2
- package/lib/server/translations/translations.js +21 -4
- package/lib/server/utils.d.ts +0 -2
- package/lib/server/utils.js +1 -9
- package/lib/ssg.d.ts +31 -0
- package/lib/ssg.js +167 -0
- package/lib/templates/templates.d.ts +28 -0
- package/lib/templates/templates.js +63 -0
- package/lib/utils.d.ts +9 -0
- package/lib/utils.js +78 -0
- package/lib/webpack/base.d.ts +5 -1
- package/lib/webpack/base.js +4 -6
- package/lib/webpack/client.d.ts +15 -1
- package/lib/webpack/client.js +78 -23
- package/lib/webpack/minification.d.ts +8 -0
- package/lib/webpack/minification.js +97 -0
- package/lib/webpack/server.d.ts +5 -3
- package/lib/webpack/server.js +41 -50
- package/lib/webpack/utils.d.ts +13 -4
- package/lib/webpack/utils.js +27 -83
- package/package.json +13 -11
- package/lib/commands/start.js +0 -212
- package/lib/server/index.js +0 -154
- package/lib/server/plugins/index.d.ts +0 -18
- package/lib/server/plugins/index.js +0 -106
- /package/lib/{webpack/templates/index.html.template.ejs → templates/dev.html.template.ejs} +0 -0
- /package/lib/{webpack/templates → templates}/ssr.html.template.d.ts +0 -0
- /package/lib/{webpack/templates → templates}/ssr.html.template.js +0 -0
|
@@ -1,106 +0,0 @@
|
|
|
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.loadPlugins = void 0;
|
|
10
|
-
const tslib_1 = require("tslib");
|
|
11
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
13
|
-
const utils_1 = require("@docusaurus/utils");
|
|
14
|
-
const init_1 = require("./init");
|
|
15
|
-
const synthetic_1 = require("./synthetic");
|
|
16
|
-
const translations_1 = require("../translations/translations");
|
|
17
|
-
const routeConfig_1 = require("./routeConfig");
|
|
18
|
-
/**
|
|
19
|
-
* Initializes the plugins, runs `loadContent`, `translateContent`,
|
|
20
|
-
* `contentLoaded`, and `translateThemeConfig`. Because `contentLoaded` is
|
|
21
|
-
* side-effect-ful (it generates temp files), so is this function. This function
|
|
22
|
-
* would also mutate `context.siteConfig.themeConfig` to translate it.
|
|
23
|
-
*/
|
|
24
|
-
async function loadPlugins(context) {
|
|
25
|
-
// 1. Plugin Lifecycle - Initialization/Constructor.
|
|
26
|
-
const plugins = await (0, init_1.initPlugins)(context);
|
|
27
|
-
plugins.push((0, synthetic_1.createBootstrapPlugin)(context), (0, synthetic_1.createMDXFallbackPlugin)(context));
|
|
28
|
-
// 2. Plugin Lifecycle - loadContent.
|
|
29
|
-
// Currently plugins run lifecycle methods in parallel and are not
|
|
30
|
-
// order-dependent. We could change this in future if there are plugins which
|
|
31
|
-
// need to run in certain order or depend on others for data.
|
|
32
|
-
// This would also translate theme config and content upfront, given the
|
|
33
|
-
// translation files that the plugin declares.
|
|
34
|
-
const loadedPlugins = await Promise.all(plugins.map(async (plugin) => {
|
|
35
|
-
const content = await plugin.loadContent?.();
|
|
36
|
-
const rawTranslationFiles = (await plugin.getTranslationFiles?.({ content })) ?? [];
|
|
37
|
-
const translationFiles = await Promise.all(rawTranslationFiles.map((translationFile) => (0, translations_1.localizePluginTranslationFile)({
|
|
38
|
-
localizationDir: context.localizationDir,
|
|
39
|
-
translationFile,
|
|
40
|
-
plugin,
|
|
41
|
-
})));
|
|
42
|
-
const translatedContent = plugin.translateContent?.({ content, translationFiles }) ?? content;
|
|
43
|
-
const translatedThemeConfigSlice = plugin.translateThemeConfig?.({
|
|
44
|
-
themeConfig: context.siteConfig.themeConfig,
|
|
45
|
-
translationFiles,
|
|
46
|
-
});
|
|
47
|
-
// Side-effect to merge theme config translations. A plugin should only
|
|
48
|
-
// translate its own slice of theme config and should make no assumptions
|
|
49
|
-
// about other plugins' keys, so this is safe to run in parallel.
|
|
50
|
-
Object.assign(context.siteConfig.themeConfig, translatedThemeConfigSlice);
|
|
51
|
-
return { ...plugin, content: translatedContent };
|
|
52
|
-
}));
|
|
53
|
-
const allContent = lodash_1.default.chain(loadedPlugins)
|
|
54
|
-
.groupBy((item) => item.name)
|
|
55
|
-
.mapValues((nameItems) => lodash_1.default.chain(nameItems)
|
|
56
|
-
.groupBy((item) => item.options.id)
|
|
57
|
-
.mapValues((idItems) => idItems[0].content)
|
|
58
|
-
.value())
|
|
59
|
-
.value();
|
|
60
|
-
// 3. Plugin Lifecycle - contentLoaded.
|
|
61
|
-
const pluginsRouteConfigs = [];
|
|
62
|
-
const globalData = {};
|
|
63
|
-
await Promise.all(loadedPlugins.map(async ({ content, ...plugin }) => {
|
|
64
|
-
if (!plugin.contentLoaded) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const pluginId = plugin.options.id;
|
|
68
|
-
// Plugins data files are namespaced by pluginName/pluginId
|
|
69
|
-
const dataDir = path_1.default.join(context.generatedFilesDir, plugin.name, pluginId);
|
|
70
|
-
const pluginRouteContextModulePath = path_1.default.join(dataDir, `${(0, utils_1.docuHash)('pluginRouteContextModule')}.json`);
|
|
71
|
-
const pluginRouteContext = {
|
|
72
|
-
name: plugin.name,
|
|
73
|
-
id: pluginId,
|
|
74
|
-
};
|
|
75
|
-
await (0, utils_1.generate)('/', pluginRouteContextModulePath, JSON.stringify(pluginRouteContext, null, 2));
|
|
76
|
-
const actions = {
|
|
77
|
-
addRoute(initialRouteConfig) {
|
|
78
|
-
// Trailing slash behavior is handled generically for all plugins
|
|
79
|
-
const finalRouteConfig = (0, routeConfig_1.applyRouteTrailingSlash)(initialRouteConfig, context.siteConfig);
|
|
80
|
-
pluginsRouteConfigs.push({
|
|
81
|
-
...finalRouteConfig,
|
|
82
|
-
context: {
|
|
83
|
-
...(finalRouteConfig.context && { data: finalRouteConfig.context }),
|
|
84
|
-
plugin: pluginRouteContextModulePath,
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
async createData(name, data) {
|
|
89
|
-
const modulePath = path_1.default.join(dataDir, name);
|
|
90
|
-
await (0, utils_1.generate)(dataDir, name, data);
|
|
91
|
-
return modulePath;
|
|
92
|
-
},
|
|
93
|
-
setGlobalData(data) {
|
|
94
|
-
var _a;
|
|
95
|
-
globalData[_a = plugin.name] ?? (globalData[_a] = {});
|
|
96
|
-
globalData[plugin.name][pluginId] = data;
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
await plugin.contentLoaded({ content, actions, allContent });
|
|
100
|
-
}));
|
|
101
|
-
// Sort the route config. This ensures that route with nested
|
|
102
|
-
// routes are always placed last.
|
|
103
|
-
(0, routeConfig_1.sortConfig)(pluginsRouteConfigs, context.siteConfig.baseUrl);
|
|
104
|
-
return { plugins: loadedPlugins, pluginsRouteConfigs, globalData };
|
|
105
|
-
}
|
|
106
|
-
exports.loadPlugins = loadPlugins;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|