@docusaurus/core 2.0.0-beta.8bda3b2db → 2.0.0-beta.9
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/beforeCli.js +125 -0
- package/bin/docusaurus.js +36 -105
- package/lib/.tsbuildinfo +1 -1
- package/lib/babel/preset.js +1 -1
- package/lib/choosePort.js +10 -11
- package/lib/client/.tsbuildinfo +1 -1
- package/lib/client/App.js +8 -22
- package/lib/client/PendingNavigation.d.ts +24 -1
- package/lib/client/PendingNavigation.js +1 -1
- package/lib/client/baseUrlIssueBanner/BaseUrlIssueBanner.js +1 -0
- package/lib/client/docusaurus.js +0 -1
- package/lib/client/exports/BrowserOnly.js +5 -3
- package/lib/client/exports/Interpolate.js +4 -0
- package/lib/client/exports/Link.js +11 -11
- package/lib/client/exports/Translate.d.ts +2 -2
- package/lib/client/exports/Translate.js +13 -9
- package/lib/client/exports/browserContext.d.ts +11 -0
- package/lib/client/exports/browserContext.js +21 -0
- package/lib/client/exports/constants.js +1 -11
- package/lib/client/exports/{context.d.ts → docusaurusContext.d.ts} +5 -3
- package/lib/client/exports/docusaurusContext.js +25 -0
- package/lib/client/exports/useBaseUrl.js +1 -1
- package/lib/client/exports/useDocusaurusContext.js +2 -7
- package/lib/client/exports/useGlobalData.js +1 -5
- package/lib/client/exports/{context.js → useIsBrowser.d.ts} +1 -2
- package/lib/client/exports/useIsBrowser.js +11 -0
- package/lib/client/normalizeLocation.d.ts +1 -3
- package/lib/client/prefetch.js +0 -1
- package/lib/client/serverEntry.js +11 -27
- package/lib/commands/build.js +26 -23
- package/lib/commands/clear.js +2 -2
- package/lib/commands/commandUtils.js +2 -2
- package/lib/commands/deploy.js +24 -14
- package/lib/commands/external.js +4 -4
- package/lib/commands/serve.js +13 -13
- package/lib/commands/start.js +74 -72
- package/lib/commands/swizzle.js +33 -33
- package/lib/commands/writeHeadingIds.d.ts +8 -5
- package/lib/commands/writeHeadingIds.js +32 -31
- package/lib/commands/writeTranslations.js +25 -11
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +4 -1
- package/lib/server/brokenLinks.js +13 -13
- package/lib/server/config.js +4 -4
- package/lib/server/configValidation.js +4 -3
- package/lib/server/duplicateRoutes.js +2 -2
- package/lib/server/html-tags/htmlTags.js +5 -5
- package/lib/server/html-tags/index.d.ts +2 -2
- package/lib/server/html-tags/index.js +3 -3
- package/lib/server/i18n.js +4 -4
- package/lib/server/index.js +99 -62
- package/lib/server/loadSetup.js +3 -3
- package/lib/server/plugins/applyRouteTrailingSlash.d.ts +2 -1
- package/lib/server/plugins/applyRouteTrailingSlash.js +3 -3
- package/lib/server/plugins/index.d.ts +3 -4
- package/lib/server/plugins/index.js +41 -27
- package/lib/server/plugins/init.d.ts +2 -6
- package/lib/server/plugins/init.js +7 -10
- package/lib/server/plugins/pluginIds.d.ts +2 -2
- package/lib/server/plugins/pluginIds.js +2 -2
- package/lib/server/presets/index.js +4 -7
- package/lib/server/routes.js +41 -23
- package/lib/server/themes/alias.d.ts +3 -2
- package/lib/server/themes/alias.js +24 -12
- package/lib/server/themes/index.d.ts +6 -2
- package/lib/server/themes/index.js +19 -9
- package/lib/server/translations/translations.d.ts +4 -5
- package/lib/server/translations/translations.js +9 -9
- package/lib/server/translations/translationsExtractor.d.ts +2 -3
- package/lib/server/translations/translationsExtractor.js +58 -47
- package/lib/server/utils.d.ts +8 -2
- package/lib/server/utils.js +8 -10
- package/lib/server/versions/__fixtures__/dummy-plugin.d.ts +0 -0
- package/lib/server/versions/__tests/index.test.js +5 -5
- package/lib/server/versions/index.js +6 -6
- package/lib/webpack/base.js +28 -19
- package/lib/webpack/client.js +8 -17
- package/lib/webpack/plugins/CleanWebpackPlugin.js +2 -5
- package/lib/webpack/plugins/LogPlugin.js +3 -4
- package/lib/webpack/plugins/WaitPlugin.js +4 -4
- package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.d.ts +2 -0
- package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.d.ts +5 -0
- package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +1 -1
- package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.d.ts +1 -0
- package/lib/webpack/server.js +11 -7
- package/lib/webpack/sharedModuleAliases.js +1 -1
- package/lib/webpack/utils.d.ts +2 -1
- package/lib/webpack/utils.js +28 -25
- package/package.json +45 -39
- package/tsconfig.client.json +1 -2
- package/tsconfig.json +5 -4
|
@@ -9,18 +9,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.loadPlugins = exports.sortConfig = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const utils_1 = require("@docusaurus/utils");
|
|
12
|
-
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
13
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
14
|
-
const init_1 = tslib_1.__importDefault(require("./init"));
|
|
15
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
12
|
+
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
13
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
14
|
+
const init_1 = (0, tslib_1.__importDefault)(require("./init"));
|
|
15
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
16
16
|
const constants_1 = require("../../constants");
|
|
17
17
|
const lodash_1 = require("lodash");
|
|
18
18
|
const translations_1 = require("../translations/translations");
|
|
19
|
-
const applyRouteTrailingSlash_1 = tslib_1.__importDefault(require("./applyRouteTrailingSlash"));
|
|
20
|
-
function sortConfig(routeConfigs) {
|
|
19
|
+
const applyRouteTrailingSlash_1 = (0, tslib_1.__importDefault)(require("./applyRouteTrailingSlash"));
|
|
20
|
+
function sortConfig(routeConfigs, baseUrl = '/') {
|
|
21
21
|
// Sort the route config. This ensures that route with nested
|
|
22
22
|
// routes is always placed last.
|
|
23
23
|
routeConfigs.sort((a, b) => {
|
|
24
|
+
// Root route should get placed last.
|
|
25
|
+
if (a.path === baseUrl && b.path !== baseUrl) {
|
|
26
|
+
return 1;
|
|
27
|
+
}
|
|
28
|
+
if (a.path !== baseUrl && b.path === baseUrl) {
|
|
29
|
+
return -1;
|
|
30
|
+
}
|
|
24
31
|
if (a.routes && !b.routes) {
|
|
25
32
|
return 1;
|
|
26
33
|
}
|
|
@@ -46,35 +53,39 @@ function sortConfig(routeConfigs) {
|
|
|
46
53
|
exports.sortConfig = sortConfig;
|
|
47
54
|
async function loadPlugins({ pluginConfigs, context, }) {
|
|
48
55
|
// 1. Plugin Lifecycle - Initialization/Constructor.
|
|
49
|
-
const plugins = init_1.default({
|
|
56
|
+
const plugins = (0, init_1.default)({
|
|
50
57
|
pluginConfigs,
|
|
51
58
|
context,
|
|
52
59
|
});
|
|
53
|
-
|
|
60
|
+
// 2. Plugin Lifecycle - loadContent.
|
|
61
|
+
// Currently plugins run lifecycle methods in parallel and are not order-dependent.
|
|
62
|
+
// We could change this in future if there are plugins which need to
|
|
63
|
+
// run in certain order or depend on others for data.
|
|
64
|
+
const loadedPlugins = await Promise.all(plugins.map(async (plugin) => {
|
|
54
65
|
const content = plugin.loadContent ? await plugin.loadContent() : null;
|
|
55
|
-
return { plugin, content };
|
|
66
|
+
return { ...plugin, content };
|
|
56
67
|
}));
|
|
57
|
-
const contentLoadedTranslatedPlugins = await Promise.all(
|
|
58
|
-
var _a, _b
|
|
59
|
-
const translationFiles = (
|
|
68
|
+
const contentLoadedTranslatedPlugins = await Promise.all(loadedPlugins.map(async (contentLoadedPlugin) => {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
const translationFiles = (_b = (await ((_a = contentLoadedPlugin === null || contentLoadedPlugin === void 0 ? void 0 : contentLoadedPlugin.getTranslationFiles) === null || _a === void 0 ? void 0 : _a.call(contentLoadedPlugin, {
|
|
60
71
|
content: contentLoadedPlugin.content,
|
|
61
|
-
})))) !== null &&
|
|
62
|
-
const localizedTranslationFiles = await Promise.all(translationFiles.map((translationFile) => translations_1.localizePluginTranslationFile({
|
|
72
|
+
})))) !== null && _b !== void 0 ? _b : [];
|
|
73
|
+
const localizedTranslationFiles = await Promise.all(translationFiles.map((translationFile) => (0, translations_1.localizePluginTranslationFile)({
|
|
63
74
|
locale: context.i18n.currentLocale,
|
|
64
75
|
siteDir: context.siteDir,
|
|
65
76
|
translationFile,
|
|
66
|
-
plugin: contentLoadedPlugin
|
|
77
|
+
plugin: contentLoadedPlugin,
|
|
67
78
|
})));
|
|
68
79
|
return {
|
|
69
80
|
...contentLoadedPlugin,
|
|
70
81
|
translationFiles: localizedTranslationFiles,
|
|
71
82
|
};
|
|
72
83
|
}));
|
|
73
|
-
const allContent = lodash_1.chain(
|
|
74
|
-
.groupBy((item) => item.
|
|
84
|
+
const allContent = (0, lodash_1.chain)(loadedPlugins)
|
|
85
|
+
.groupBy((item) => item.name)
|
|
75
86
|
.mapValues((nameItems) => {
|
|
76
|
-
return lodash_1.chain(nameItems)
|
|
77
|
-
.groupBy((item) => { var _a; return (_a = item.
|
|
87
|
+
return (0, lodash_1.chain)(nameItems)
|
|
88
|
+
.groupBy((item) => { var _a; return (_a = item.options.id) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_PLUGIN_ID; })
|
|
78
89
|
.mapValues((idItems) => idItems[0].content)
|
|
79
90
|
.value();
|
|
80
91
|
})
|
|
@@ -82,7 +93,7 @@ async function loadPlugins({ pluginConfigs, context, }) {
|
|
|
82
93
|
// 3. Plugin Lifecycle - contentLoaded.
|
|
83
94
|
const pluginsRouteConfigs = [];
|
|
84
95
|
const globalData = {};
|
|
85
|
-
await Promise.all(contentLoadedTranslatedPlugins.map(async ({
|
|
96
|
+
await Promise.all(contentLoadedTranslatedPlugins.map(async ({ content, translationFiles, ...plugin }) => {
|
|
86
97
|
var _a, _b, _c;
|
|
87
98
|
if (!plugin.contentLoaded) {
|
|
88
99
|
return;
|
|
@@ -93,13 +104,16 @@ async function loadPlugins({ pluginConfigs, context, }) {
|
|
|
93
104
|
const dataDir = path_1.default.join(dataDirRoot, pluginId);
|
|
94
105
|
const addRoute = (initialRouteConfig) => {
|
|
95
106
|
// Trailing slash behavior is handled in a generic way for all plugins
|
|
96
|
-
const finalRouteConfig = applyRouteTrailingSlash_1.default(initialRouteConfig,
|
|
107
|
+
const finalRouteConfig = (0, applyRouteTrailingSlash_1.default)(initialRouteConfig, {
|
|
108
|
+
trailingSlash: context.siteConfig.trailingSlash,
|
|
109
|
+
baseUrl: context.siteConfig.baseUrl,
|
|
110
|
+
});
|
|
97
111
|
pluginsRouteConfigs.push(finalRouteConfig);
|
|
98
112
|
};
|
|
99
113
|
const createData = async (name, data) => {
|
|
100
114
|
const modulePath = path_1.default.join(dataDir, name);
|
|
101
115
|
await fs_extra_1.default.ensureDir(path_1.default.dirname(modulePath));
|
|
102
|
-
await utils_1.generate(dataDir, name, data);
|
|
116
|
+
await (0, utils_1.generate)(dataDir, name, data);
|
|
103
117
|
return modulePath;
|
|
104
118
|
};
|
|
105
119
|
// the plugins global data are namespaced to avoid data conflicts:
|
|
@@ -126,7 +140,7 @@ async function loadPlugins({ pluginConfigs, context, }) {
|
|
|
126
140
|
// Currently plugins run lifecycle methods in parallel and are not order-dependent.
|
|
127
141
|
// We could change this in future if there are plugins which need to
|
|
128
142
|
// run in certain order or depend on others for data.
|
|
129
|
-
await Promise.all(contentLoadedTranslatedPlugins.map(async (
|
|
143
|
+
await Promise.all(contentLoadedTranslatedPlugins.map(async (plugin) => {
|
|
130
144
|
if (!plugin.routesLoaded) {
|
|
131
145
|
return null;
|
|
132
146
|
}
|
|
@@ -138,14 +152,14 @@ async function loadPlugins({ pluginConfigs, context, }) {
|
|
|
138
152
|
}));
|
|
139
153
|
// Sort the route config. This ensures that route with nested
|
|
140
154
|
// routes are always placed last.
|
|
141
|
-
sortConfig(pluginsRouteConfigs);
|
|
155
|
+
sortConfig(pluginsRouteConfigs, context.siteConfig.baseUrl);
|
|
142
156
|
// Apply each plugin one after the other to translate the theme config
|
|
143
157
|
function translateThemeConfig(untranslatedThemeConfig) {
|
|
144
|
-
return contentLoadedTranslatedPlugins.reduce((currentThemeConfig,
|
|
158
|
+
return contentLoadedTranslatedPlugins.reduce((currentThemeConfig, plugin) => {
|
|
145
159
|
var _a;
|
|
146
160
|
const translatedThemeConfigSlice = (_a = plugin.translateThemeConfig) === null || _a === void 0 ? void 0 : _a.call(plugin, {
|
|
147
161
|
themeConfig: currentThemeConfig,
|
|
148
|
-
translationFiles,
|
|
162
|
+
translationFiles: plugin.translationFiles,
|
|
149
163
|
});
|
|
150
164
|
return {
|
|
151
165
|
...currentThemeConfig,
|
|
@@ -154,7 +168,7 @@ async function loadPlugins({ pluginConfigs, context, }) {
|
|
|
154
168
|
}, untranslatedThemeConfig);
|
|
155
169
|
}
|
|
156
170
|
return {
|
|
157
|
-
plugins,
|
|
171
|
+
plugins: loadedPlugins,
|
|
158
172
|
pluginsRouteConfigs,
|
|
159
173
|
globalData,
|
|
160
174
|
themeConfigTranslated: translateThemeConfig(context.siteConfig.themeConfig),
|
|
@@ -4,12 +4,8 @@
|
|
|
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 {
|
|
8
|
-
export declare type InitPlugin = Plugin<unknown> & {
|
|
9
|
-
readonly options: PluginOptions;
|
|
10
|
-
readonly version: DocusaurusPluginVersionInformation;
|
|
11
|
-
};
|
|
7
|
+
import { LoadContext, PluginConfig, InitializedPlugin } from '@docusaurus/types';
|
|
12
8
|
export default function initPlugins({ pluginConfigs, context, }: {
|
|
13
9
|
pluginConfigs: PluginConfig[];
|
|
14
10
|
context: LoadContext;
|
|
15
|
-
}):
|
|
11
|
+
}): InitializedPlugin[];
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
|
-
const module_1 =
|
|
11
|
-
const import_fresh_1 = tslib_1.__importDefault(require("import-fresh"));
|
|
10
|
+
const module_1 = require("module");
|
|
11
|
+
const import_fresh_1 = (0, tslib_1.__importDefault)(require("import-fresh"));
|
|
12
12
|
const constants_1 = require("../../constants");
|
|
13
13
|
const versions_1 = require("../versions");
|
|
14
14
|
const pluginIds_1 = require("./pluginIds");
|
|
@@ -19,7 +19,7 @@ function normalizePluginConfig(pluginConfig, pluginRequire) {
|
|
|
19
19
|
if (typeof pluginConfig === 'string') {
|
|
20
20
|
const pluginModuleImport = pluginConfig;
|
|
21
21
|
const pluginPath = pluginRequire.resolve(pluginModuleImport);
|
|
22
|
-
const pluginModule = import_fresh_1.default(pluginPath);
|
|
22
|
+
const pluginModule = (0, import_fresh_1.default)(pluginPath);
|
|
23
23
|
return {
|
|
24
24
|
plugin: (_a = pluginModule === null || pluginModule === void 0 ? void 0 : pluginModule.default) !== null && _a !== void 0 ? _a : pluginModule,
|
|
25
25
|
options: {},
|
|
@@ -43,7 +43,7 @@ function normalizePluginConfig(pluginConfig, pluginRequire) {
|
|
|
43
43
|
if (typeof pluginConfig[0] === 'string') {
|
|
44
44
|
const pluginModuleImport = pluginConfig[0];
|
|
45
45
|
const pluginPath = pluginRequire.resolve(pluginModuleImport);
|
|
46
|
-
const pluginModule = import_fresh_1.default(pluginPath);
|
|
46
|
+
const pluginModule = (0, import_fresh_1.default)(pluginPath);
|
|
47
47
|
return {
|
|
48
48
|
plugin: (_b = pluginModule === null || pluginModule === void 0 ? void 0 : pluginModule.default) !== null && _b !== void 0 ? _b : pluginModule,
|
|
49
49
|
options: (_c = pluginConfig[1]) !== null && _c !== void 0 ? _c : {},
|
|
@@ -88,16 +88,13 @@ function getThemeValidationFunction(normalizedPluginConfig) {
|
|
|
88
88
|
function initPlugins({ pluginConfigs, context, }) {
|
|
89
89
|
// We need to resolve plugins from the perspective of the siteDir, since the siteDir's package.json
|
|
90
90
|
// declares the dependency on these plugins.
|
|
91
|
-
|
|
92
|
-
// See: https://nodejs.org/api/modules.html#modules_module_createrequire_filename
|
|
93
|
-
const createRequire = module_1.default.createRequire || module_1.default.createRequireFromPath;
|
|
94
|
-
const pluginRequire = createRequire(context.siteConfigPath);
|
|
91
|
+
const pluginRequire = (0, module_1.createRequire)(context.siteConfigPath);
|
|
95
92
|
function doGetPluginVersion(normalizedPluginConfig) {
|
|
96
93
|
var _a, _b;
|
|
97
94
|
// get plugin version
|
|
98
95
|
if ((_a = normalizedPluginConfig.pluginModule) === null || _a === void 0 ? void 0 : _a.path) {
|
|
99
96
|
const pluginPath = pluginRequire.resolve((_b = normalizedPluginConfig.pluginModule) === null || _b === void 0 ? void 0 : _b.path);
|
|
100
|
-
return versions_1.getPluginVersion(pluginPath, context.siteDir);
|
|
97
|
+
return (0, versions_1.getPluginVersion)(pluginPath, context.siteDir);
|
|
101
98
|
}
|
|
102
99
|
else {
|
|
103
100
|
return { type: 'local' };
|
|
@@ -154,7 +151,7 @@ function initPlugins({ pluginConfigs, context, }) {
|
|
|
154
151
|
};
|
|
155
152
|
})
|
|
156
153
|
.filter((item) => Boolean(item));
|
|
157
|
-
pluginIds_1.ensureUniquePluginInstanceIds(plugins);
|
|
154
|
+
(0, pluginIds_1.ensureUniquePluginInstanceIds)(plugins);
|
|
158
155
|
return plugins;
|
|
159
156
|
}
|
|
160
157
|
exports.default = initPlugins;
|
|
@@ -4,5 +4,5 @@
|
|
|
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 {
|
|
8
|
-
export declare function ensureUniquePluginInstanceIds(plugins:
|
|
7
|
+
import { InitializedPlugin } from '@docusaurus/types';
|
|
8
|
+
export declare function ensureUniquePluginInstanceIds(plugins: InitializedPlugin[]): void;
|
|
@@ -12,9 +12,9 @@ const constants_1 = require("../../constants");
|
|
|
12
12
|
// It is forbidden to have 2 plugins of the same name sharing the same id
|
|
13
13
|
// this is required to support multi-instance plugins without conflict
|
|
14
14
|
function ensureUniquePluginInstanceIds(plugins) {
|
|
15
|
-
const pluginsByName = lodash_1.groupBy(plugins, (p) => p.name);
|
|
15
|
+
const pluginsByName = (0, lodash_1.groupBy)(plugins, (p) => p.name);
|
|
16
16
|
Object.entries(pluginsByName).forEach(([pluginName, pluginInstances]) => {
|
|
17
|
-
const pluginInstancesById = lodash_1.groupBy(pluginInstances, (p) => { var _a; return (_a = p.options.id) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_PLUGIN_ID; });
|
|
17
|
+
const pluginInstancesById = (0, lodash_1.groupBy)(pluginInstances, (p) => { var _a; return (_a = p.options.id) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_PLUGIN_ID; });
|
|
18
18
|
Object.entries(pluginInstancesById).forEach(([pluginId, pluginInstancesWithId]) => {
|
|
19
19
|
if (pluginInstancesWithId.length !== 1) {
|
|
20
20
|
throw new Error(`Plugin "${pluginName}" is used ${pluginInstancesWithId.length} times with id ${pluginId}.\nTo use the same plugin multiple times on a Docusaurus site, you need to assign a unique id to each plugin instance.`);
|
|
@@ -7,15 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
|
-
const module_1 =
|
|
11
|
-
const import_fresh_1 = tslib_1.__importDefault(require("import-fresh"));
|
|
10
|
+
const module_1 = require("module");
|
|
11
|
+
const import_fresh_1 = (0, tslib_1.__importDefault)(require("import-fresh"));
|
|
12
12
|
function loadPresets(context) {
|
|
13
13
|
// We need to resolve plugins from the perspective of the siteDir, since the siteDir's package.json
|
|
14
14
|
// declares the dependency on these plugins.
|
|
15
|
-
|
|
16
|
-
// See: https://nodejs.org/api/modules.html#modules_module_createrequire_filename
|
|
17
|
-
const createRequire = module_1.default.createRequire || module_1.default.createRequireFromPath;
|
|
18
|
-
const pluginRequire = createRequire(context.siteConfigPath);
|
|
15
|
+
const pluginRequire = (0, module_1.createRequire)(context.siteConfigPath);
|
|
19
16
|
const presets = (context.siteConfig || {}).presets || [];
|
|
20
17
|
const unflatPlugins = [];
|
|
21
18
|
const unflatThemes = [];
|
|
@@ -31,7 +28,7 @@ function loadPresets(context) {
|
|
|
31
28
|
else {
|
|
32
29
|
throw new Error('Invalid presets format detected in config.');
|
|
33
30
|
}
|
|
34
|
-
const presetModule = import_fresh_1.default(pluginRequire.resolve(presetModuleImport));
|
|
31
|
+
const presetModule = (0, import_fresh_1.default)(pluginRequire.resolve(presetModuleImport));
|
|
35
32
|
const preset = (presetModule.default || presetModule)(context, presetOptions);
|
|
36
33
|
if (preset.plugins) {
|
|
37
34
|
unflatPlugins.push(preset.plugins);
|
package/lib/server/routes.js
CHANGED
|
@@ -9,18 +9,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
const utils_1 = require("@docusaurus/utils");
|
|
10
10
|
const lodash_1 = require("lodash");
|
|
11
11
|
const querystring_1 = require("querystring");
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
${
|
|
20
|
-
]
|
|
21
|
-
|
|
22
|
-
:
|
|
23
|
-
|
|
12
|
+
function indent(str) {
|
|
13
|
+
const spaces = ' ';
|
|
14
|
+
return `${spaces}${str.replace(/(\n)/g, `\n${spaces}`)}`;
|
|
15
|
+
}
|
|
16
|
+
const createRouteCodeString = ({ routePath, routeHash, exact, subroutesCodeStrings, props, }) => {
|
|
17
|
+
const parts = [
|
|
18
|
+
`path: '${routePath}'`,
|
|
19
|
+
`component: ComponentCreator('${routePath}','${routeHash}')`,
|
|
20
|
+
];
|
|
21
|
+
if (exact) {
|
|
22
|
+
parts.push(`exact: true`);
|
|
23
|
+
}
|
|
24
|
+
if (subroutesCodeStrings) {
|
|
25
|
+
parts.push(`routes: [
|
|
26
|
+
${indent((0, utils_1.removeSuffix)(subroutesCodeStrings.join(',\n'), ',\n'))}
|
|
27
|
+
]`);
|
|
28
|
+
}
|
|
29
|
+
Object.entries(props).forEach(([propName, propValue]) => {
|
|
30
|
+
// Figure out how to "unquote" JS attributes that don't need to be quoted
|
|
31
|
+
// Is this lib reliable? https://github.com/armanozak/should-quote
|
|
32
|
+
const shouldQuote = true; // TODO
|
|
33
|
+
const key = shouldQuote ? `'${propName}'` : propName;
|
|
34
|
+
parts.push(`${key}: ${JSON.stringify(propValue)}`);
|
|
35
|
+
});
|
|
36
|
+
return `{
|
|
37
|
+
${indent(parts.join(',\n'))}
|
|
38
|
+
}`;
|
|
24
39
|
};
|
|
25
40
|
const NotFoundRouteCode = `{
|
|
26
41
|
path: '*',
|
|
@@ -31,10 +46,10 @@ const RoutesImportsCode = [
|
|
|
31
46
|
`import ComponentCreator from '@docusaurus/ComponentCreator';`,
|
|
32
47
|
].join('\n');
|
|
33
48
|
function isModule(value) {
|
|
34
|
-
if (lodash_1.isString(value)) {
|
|
49
|
+
if ((0, lodash_1.isString)(value)) {
|
|
35
50
|
return true;
|
|
36
51
|
}
|
|
37
|
-
if (lodash_1.isPlainObject(value) && lodash_1.has(value, '__import') && lodash_1.has(value, 'path')) {
|
|
52
|
+
if ((0, lodash_1.isPlainObject)(value) && (0, lodash_1.has)(value, '__import') && (0, lodash_1.has)(value, 'path')) {
|
|
38
53
|
return true;
|
|
39
54
|
}
|
|
40
55
|
return false;
|
|
@@ -43,17 +58,17 @@ function getModulePath(target) {
|
|
|
43
58
|
if (typeof target === 'string') {
|
|
44
59
|
return target;
|
|
45
60
|
}
|
|
46
|
-
const queryStr = target.query ? `?${querystring_1.stringify(target.query)}` : '';
|
|
61
|
+
const queryStr = target.query ? `?${(0, querystring_1.stringify)(target.query)}` : '';
|
|
47
62
|
return `${target.path}${queryStr}`;
|
|
48
63
|
}
|
|
49
64
|
async function loadRoutes(pluginsRouteConfigs, baseUrl) {
|
|
50
65
|
const registry = {};
|
|
51
|
-
const routesPaths = [utils_1.normalizeUrl([baseUrl, '404.html'])];
|
|
66
|
+
const routesPaths = [(0, utils_1.normalizeUrl)([baseUrl, '404.html'])];
|
|
52
67
|
const routesChunkNames = {};
|
|
53
68
|
// This is the higher level overview of route code generation.
|
|
54
69
|
function generateRouteCode(routeConfig) {
|
|
55
|
-
const { path: routePath, component, modules = {}, routes: subroutes, exact, } = routeConfig;
|
|
56
|
-
if (!lodash_1.isString(routePath) || !component) {
|
|
70
|
+
const { path: routePath, component, modules = {}, routes: subroutes, exact, priority, ...props } = routeConfig;
|
|
71
|
+
if (!(0, lodash_1.isString)(routePath) || !component) {
|
|
57
72
|
throw new Error(`Invalid route config: path must be a string and component is required.\n${JSON.stringify(routeConfig)}`);
|
|
58
73
|
}
|
|
59
74
|
// Collect all page paths for injecting it later in the plugin lifecycle
|
|
@@ -65,7 +80,7 @@ async function loadRoutes(pluginsRouteConfigs, baseUrl) {
|
|
|
65
80
|
// We hash the route to generate the key, because 2 routes can conflict with
|
|
66
81
|
// each others if they have the same path, ex: parent=/docs, child=/docs
|
|
67
82
|
// see https://github.com/facebook/docusaurus/issues/2917
|
|
68
|
-
const routeHash = utils_1.simpleHash(JSON.stringify(routeConfig), 3);
|
|
83
|
+
const routeHash = (0, utils_1.simpleHash)(JSON.stringify(routeConfig), 3);
|
|
69
84
|
const chunkNamesKey = `${routePath}-${routeHash}`;
|
|
70
85
|
routesChunkNames[chunkNamesKey] = {
|
|
71
86
|
...genRouteChunkNames(registry, { component }, 'component', component),
|
|
@@ -76,14 +91,17 @@ async function loadRoutes(pluginsRouteConfigs, baseUrl) {
|
|
|
76
91
|
routeHash,
|
|
77
92
|
exact,
|
|
78
93
|
subroutesCodeStrings: subroutes === null || subroutes === void 0 ? void 0 : subroutes.map(generateRouteCode),
|
|
94
|
+
props,
|
|
79
95
|
});
|
|
80
96
|
}
|
|
81
97
|
const routesConfig = `
|
|
82
98
|
${RoutesImportsCode}
|
|
99
|
+
|
|
83
100
|
export default [
|
|
84
|
-
${pluginsRouteConfigs.map(generateRouteCode).join(',\n')}
|
|
85
|
-
${NotFoundRouteCode}
|
|
86
|
-
]
|
|
101
|
+
${indent(`${pluginsRouteConfigs.map(generateRouteCode).join(',\n')},`)}
|
|
102
|
+
${indent(NotFoundRouteCode)}
|
|
103
|
+
];
|
|
104
|
+
`;
|
|
87
105
|
return {
|
|
88
106
|
registry,
|
|
89
107
|
routesConfig,
|
|
@@ -103,7 +121,7 @@ registry, value, prefix, name) {
|
|
|
103
121
|
}
|
|
104
122
|
if (isModule(value)) {
|
|
105
123
|
const modulePath = getModulePath(value);
|
|
106
|
-
const chunkName = utils_1.genChunkName(modulePath, prefix, name);
|
|
124
|
+
const chunkName = (0, utils_1.genChunkName)(modulePath, prefix, name);
|
|
107
125
|
// We need to JSON.stringify so that if its on windows, backslashes are escaped.
|
|
108
126
|
const loader = `() => import(/* webpackChunkName: '${chunkName}' */ ${JSON.stringify(modulePath)})`;
|
|
109
127
|
registry[chunkName] = {
|
|
@@ -4,5 +4,6 @@
|
|
|
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 {
|
|
8
|
-
export
|
|
7
|
+
import { ThemeAliases } from '@docusaurus/types';
|
|
8
|
+
export declare function sortAliases(aliases: ThemeAliases): ThemeAliases;
|
|
9
|
+
export default function themeAlias(themePath: string, addOriginalAlias: boolean): ThemeAliases;
|
|
@@ -6,34 +6,46 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.sortAliases = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
+
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
12
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
13
13
|
const utils_1 = require("@docusaurus/utils");
|
|
14
14
|
const lodash_1 = require("lodash");
|
|
15
|
+
// Order of Webpack aliases is important because one alias can shadow another
|
|
16
|
+
// This ensure @theme/NavbarItem alias is after @theme/NavbarItem/LocaleDropdown
|
|
17
|
+
// See https://github.com/facebook/docusaurus/pull/3922
|
|
18
|
+
// See https://github.com/facebook/docusaurus/issues/5382
|
|
19
|
+
function sortAliases(aliases) {
|
|
20
|
+
// Alphabetical order by default
|
|
21
|
+
const entries = (0, lodash_1.sortBy)(Object.entries(aliases), ([alias]) => alias);
|
|
22
|
+
// @theme/NavbarItem should be after @theme/NavbarItem/LocaleDropdown
|
|
23
|
+
entries.sort(([alias1], [alias2]) => {
|
|
24
|
+
return alias1.includes(`${alias2}/`) ? -1 : 0;
|
|
25
|
+
});
|
|
26
|
+
return Object.fromEntries(entries);
|
|
27
|
+
}
|
|
28
|
+
exports.sortAliases = sortAliases;
|
|
29
|
+
// TODO make async
|
|
15
30
|
function themeAlias(themePath, addOriginalAlias) {
|
|
16
31
|
if (!fs_extra_1.default.pathExistsSync(themePath)) {
|
|
17
32
|
return {};
|
|
18
33
|
}
|
|
19
|
-
const themeComponentFiles =
|
|
34
|
+
const themeComponentFiles = utils_1.Globby.sync(['**/*.{js,jsx,ts,tsx}'], {
|
|
20
35
|
cwd: themePath,
|
|
21
36
|
});
|
|
22
|
-
// See https://github.com/facebook/docusaurus/pull/3922
|
|
23
|
-
// ensure @theme/NavbarItem alias is created after @theme/NavbarItem/LocaleDropdown
|
|
24
|
-
const sortedThemeComponentFiles = lodash_1.sortBy(themeComponentFiles, (file) => file.endsWith('/index.js'));
|
|
25
37
|
const aliases = {};
|
|
26
|
-
|
|
38
|
+
themeComponentFiles.forEach((relativeSource) => {
|
|
27
39
|
const filePath = path_1.default.join(themePath, relativeSource);
|
|
28
|
-
const fileName = utils_1.fileToPath(relativeSource);
|
|
29
|
-
const aliasName = utils_1.posixPath(utils_1.normalizeUrl(['@theme', fileName]).replace(/\/$/, ''));
|
|
40
|
+
const fileName = (0, utils_1.fileToPath)(relativeSource);
|
|
41
|
+
const aliasName = (0, utils_1.posixPath)((0, utils_1.normalizeUrl)(['@theme', fileName]).replace(/\/$/, ''));
|
|
30
42
|
aliases[aliasName] = filePath;
|
|
31
43
|
if (addOriginalAlias) {
|
|
32
44
|
// For swizzled components to access the original.
|
|
33
|
-
const originalAliasName = utils_1.posixPath(utils_1.normalizeUrl(['@theme-original', fileName]).replace(/\/$/, ''));
|
|
45
|
+
const originalAliasName = (0, utils_1.posixPath)((0, utils_1.normalizeUrl)(['@theme-original', fileName]).replace(/\/$/, ''));
|
|
34
46
|
aliases[originalAliasName] = filePath;
|
|
35
47
|
}
|
|
36
48
|
});
|
|
37
|
-
return aliases;
|
|
49
|
+
return sortAliases(aliases);
|
|
38
50
|
}
|
|
39
51
|
exports.default = themeAlias;
|
|
@@ -4,5 +4,9 @@
|
|
|
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 {
|
|
8
|
-
export
|
|
7
|
+
import { ThemeAliases, LoadedPlugin } from '@docusaurus/types';
|
|
8
|
+
export declare function loadThemeAliases(themePaths: string[], userThemePaths?: string[]): ThemeAliases;
|
|
9
|
+
export declare function loadPluginsThemeAliases({ siteDir, plugins, }: {
|
|
10
|
+
siteDir: string;
|
|
11
|
+
plugins: LoadedPlugin[];
|
|
12
|
+
}): ThemeAliases;
|
|
@@ -6,30 +6,40 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.loadPluginsThemeAliases = exports.loadThemeAliases = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
|
-
const
|
|
11
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
12
|
+
const constants_1 = require("../../constants");
|
|
13
|
+
const alias_1 = (0, tslib_1.__importStar)(require("./alias"));
|
|
14
|
+
const ThemeFallbackDir = path_1.default.resolve(__dirname, '../../client/theme-fallback');
|
|
11
15
|
function buildThemeAliases(themeAliases, aliases = {}) {
|
|
12
16
|
Object.keys(themeAliases).forEach((aliasKey) => {
|
|
13
17
|
if (aliasKey in aliases) {
|
|
14
18
|
const componentName = aliasKey.substring(aliasKey.indexOf('/') + 1);
|
|
15
|
-
// eslint-disable-next-line no-param-reassign
|
|
16
19
|
aliases[`@theme-init/${componentName}`] = aliases[aliasKey];
|
|
17
20
|
}
|
|
18
|
-
// eslint-disable-next-line no-param-reassign
|
|
19
21
|
aliases[aliasKey] = themeAliases[aliasKey];
|
|
20
22
|
});
|
|
21
23
|
return aliases;
|
|
22
24
|
}
|
|
23
|
-
function
|
|
24
|
-
let aliases = {};
|
|
25
|
+
function loadThemeAliases(themePaths, userThemePaths = []) {
|
|
26
|
+
let aliases = {}; // TODO refactor, inelegant side-effect
|
|
25
27
|
themePaths.forEach((themePath) => {
|
|
26
|
-
const themeAliases = alias_1.default(themePath, true);
|
|
28
|
+
const themeAliases = (0, alias_1.default)(themePath, true);
|
|
27
29
|
aliases = { ...aliases, ...buildThemeAliases(themeAliases, aliases) };
|
|
28
30
|
});
|
|
29
31
|
userThemePaths.forEach((themePath) => {
|
|
30
|
-
const userThemeAliases = alias_1.default(themePath, false);
|
|
32
|
+
const userThemeAliases = (0, alias_1.default)(themePath, false);
|
|
31
33
|
aliases = { ...aliases, ...buildThemeAliases(userThemeAliases, aliases) };
|
|
32
34
|
});
|
|
33
|
-
return aliases;
|
|
35
|
+
return (0, alias_1.sortAliases)(aliases);
|
|
36
|
+
}
|
|
37
|
+
exports.loadThemeAliases = loadThemeAliases;
|
|
38
|
+
function loadPluginsThemeAliases({ siteDir, plugins, }) {
|
|
39
|
+
const pluginThemes = plugins
|
|
40
|
+
.map((plugin) => (plugin.getThemePath ? plugin.getThemePath() : undefined))
|
|
41
|
+
.filter((x) => Boolean(x));
|
|
42
|
+
const userTheme = path_1.default.resolve(siteDir, constants_1.THEME_PATH);
|
|
43
|
+
return loadThemeAliases([ThemeFallbackDir, ...pluginThemes], [userTheme]);
|
|
34
44
|
}
|
|
35
|
-
exports.
|
|
45
|
+
exports.loadPluginsThemeAliases = loadPluginsThemeAliases;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TranslationFileContent, TranslationFile, TranslationMessage } from '@docusaurus/types';
|
|
1
|
+
import { TranslationFileContent, TranslationFile, TranslationMessage, InitializedPlugin } from '@docusaurus/types';
|
|
3
2
|
export declare type WriteTranslationsOptions = {
|
|
4
3
|
override?: boolean;
|
|
5
4
|
messagePrefix?: string;
|
|
@@ -21,15 +20,15 @@ export declare function getCodeTranslationsFilePath(context: TranslationContext)
|
|
|
21
20
|
export declare function readCodeTranslationFileContent(context: TranslationContext): Promise<TranslationFileContent | undefined>;
|
|
22
21
|
export declare function writeCodeTranslations(context: TranslationContext, content: TranslationFileContent, options: WriteTranslationsOptions): Promise<void>;
|
|
23
22
|
export declare function writePluginTranslations({ siteDir, plugin, locale, translationFile, options, }: TranslationContext & {
|
|
24
|
-
plugin:
|
|
23
|
+
plugin: InitializedPlugin;
|
|
25
24
|
translationFile: TranslationFile;
|
|
26
25
|
options?: WriteTranslationsOptions;
|
|
27
26
|
}): Promise<void>;
|
|
28
27
|
export declare function localizePluginTranslationFile({ siteDir, plugin, locale, translationFile, }: TranslationContext & {
|
|
29
|
-
plugin:
|
|
28
|
+
plugin: InitializedPlugin;
|
|
30
29
|
translationFile: TranslationFile;
|
|
31
30
|
}): Promise<TranslationFile>;
|
|
32
|
-
export declare function getPluginsDefaultCodeTranslationMessages(plugins:
|
|
31
|
+
export declare function getPluginsDefaultCodeTranslationMessages(plugins: InitializedPlugin[]): Promise<Record<string, string>>;
|
|
33
32
|
export declare function applyDefaultCodeTranslations({ extractedCodeTranslations, defaultCodeMessages, }: {
|
|
34
33
|
extractedCodeTranslations: Record<string, TranslationMessage>;
|
|
35
34
|
defaultCodeMessages: Record<string, string>;
|
|
@@ -8,12 +8,12 @@ const tslib_1 = require("tslib");
|
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
10
|
*/
|
|
11
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
-
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
11
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
12
|
+
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
13
13
|
const lodash_1 = require("lodash");
|
|
14
14
|
const utils_1 = require("@docusaurus/utils");
|
|
15
15
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
16
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
16
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
17
17
|
const TranslationFileContentSchema = utils_validation_1.Joi.object()
|
|
18
18
|
.pattern(utils_validation_1.Joi.string(), utils_validation_1.Joi.object({
|
|
19
19
|
message: utils_validation_1.Joi.string().allow('').required(),
|
|
@@ -44,7 +44,7 @@ async function readTranslationFileContent(filePath) {
|
|
|
44
44
|
exports.readTranslationFileContent = readTranslationFileContent;
|
|
45
45
|
function mergeTranslationFileContent({ existingContent = {}, newContent, options, }) {
|
|
46
46
|
// Apply messagePrefix to all messages
|
|
47
|
-
const newContentTransformed = lodash_1.mapValues(newContent, (value) => {
|
|
47
|
+
const newContentTransformed = (0, lodash_1.mapValues)(newContent, (value) => {
|
|
48
48
|
var _a;
|
|
49
49
|
return ({
|
|
50
50
|
...value,
|
|
@@ -68,7 +68,7 @@ function mergeTranslationFileContent({ existingContent = {}, newContent, options
|
|
|
68
68
|
async function writeTranslationFileContent({ filePath, content: newContent, options = {}, }) {
|
|
69
69
|
const existingContent = await readTranslationFileContent(filePath);
|
|
70
70
|
// Warn about potential legacy keys
|
|
71
|
-
const unknownKeys = lodash_1.difference(Object.keys(existingContent !== null && existingContent !== void 0 ? existingContent : {}), Object.keys(newContent));
|
|
71
|
+
const unknownKeys = (0, lodash_1.difference)(Object.keys(existingContent !== null && existingContent !== void 0 ? existingContent : {}), Object.keys(newContent));
|
|
72
72
|
if (unknownKeys.length > 0) {
|
|
73
73
|
console.warn(chalk_1.default.yellow(`Some translation keys looks unknown to us in file ${filePath}
|
|
74
74
|
Maybe you should remove them?
|
|
@@ -83,7 +83,7 @@ Maybe you should remove them?
|
|
|
83
83
|
if (Object.keys(mergedContent).length > 0) {
|
|
84
84
|
console.log(`${Object.keys(mergedContent)
|
|
85
85
|
.length.toString()
|
|
86
|
-
.padStart(3, ' ')} translations will be written at "${utils_1.toMessageRelativeFilePath(filePath)}".`);
|
|
86
|
+
.padStart(3, ' ')} translations will be written at "${(0, utils_1.toMessageRelativeFilePath)(filePath)}".`);
|
|
87
87
|
await fs_extra_1.default.ensureDir(path_1.default.dirname(filePath));
|
|
88
88
|
await fs_extra_1.default.writeFile(filePath, JSON.stringify(mergedContent, null, 2));
|
|
89
89
|
}
|
|
@@ -124,7 +124,7 @@ function addTranslationFileExtension(translationFilePath) {
|
|
|
124
124
|
return `${translationFilePath}.json`;
|
|
125
125
|
}
|
|
126
126
|
function getPluginTranslationFilePath({ siteDir, plugin, locale, translationFilePath, }) {
|
|
127
|
-
const dirPath = utils_1.getPluginI18nPath({
|
|
127
|
+
const dirPath = (0, utils_1.getPluginI18nPath)({
|
|
128
128
|
siteDir,
|
|
129
129
|
locale,
|
|
130
130
|
pluginName: plugin.name,
|
|
@@ -178,14 +178,14 @@ async function getPluginsDefaultCodeTranslationMessages(plugins) {
|
|
|
178
178
|
}
|
|
179
179
|
exports.getPluginsDefaultCodeTranslationMessages = getPluginsDefaultCodeTranslationMessages;
|
|
180
180
|
function applyDefaultCodeTranslations({ extractedCodeTranslations, defaultCodeMessages, }) {
|
|
181
|
-
const unusedDefaultCodeMessages = lodash_1.difference(Object.keys(defaultCodeMessages), Object.keys(extractedCodeTranslations));
|
|
181
|
+
const unusedDefaultCodeMessages = (0, lodash_1.difference)(Object.keys(defaultCodeMessages), Object.keys(extractedCodeTranslations));
|
|
182
182
|
if (unusedDefaultCodeMessages.length > 0) {
|
|
183
183
|
console.warn(chalk_1.default.yellow(`Unused default message codes found.
|
|
184
184
|
Please report this Docusaurus issue.
|
|
185
185
|
- ${unusedDefaultCodeMessages.join('\n- ')}
|
|
186
186
|
`));
|
|
187
187
|
}
|
|
188
|
-
return lodash_1.mapValues(extractedCodeTranslations, (messageTranslation, messageId) => {
|
|
188
|
+
return (0, lodash_1.mapValues)(extractedCodeTranslations, (messageTranslation, messageId) => {
|
|
189
189
|
var _a;
|
|
190
190
|
return {
|
|
191
191
|
...messageTranslation,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { TransformOptions } from '@babel/core';
|
|
2
|
-
import { TranslationFileContent, TranslationMessage } from '@docusaurus/types';
|
|
3
|
-
import { InitPlugin } from '../plugins/init';
|
|
2
|
+
import { InitializedPlugin, TranslationFileContent, TranslationMessage } from '@docusaurus/types';
|
|
4
3
|
export declare function globSourceCodeFilePaths(dirPaths: string[]): Promise<string[]>;
|
|
5
|
-
export declare function extractSiteSourceCodeTranslations(siteDir: string, plugins:
|
|
4
|
+
export declare function extractSiteSourceCodeTranslations(siteDir: string, plugins: InitializedPlugin[], babelOptions: TransformOptions, extraSourceCodeFilePaths?: string[]): Promise<TranslationFileContent>;
|
|
6
5
|
declare type SourceCodeFileTranslations = {
|
|
7
6
|
sourceCodeFilePath: string;
|
|
8
7
|
translations: Record<string, TranslationMessage>;
|