@docusaurus/core 0.0.0-4724 → 0.0.0-4727
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/commands/swizzle/context.js +1 -3
- package/lib/commands/swizzle/themes.js +5 -2
- package/lib/server/client-modules/index.d.ts +2 -2
- package/lib/server/client-modules/index.js +4 -1
- package/lib/server/index.js +5 -2
- package/lib/server/plugins/init.d.ts +6 -2
- package/lib/server/plugins/init.js +11 -4
- package/lib/server/themes/index.js +1 -1
- package/lib/server/translations/translationsExtractor.js +1 -1
- package/package.json +10 -10
|
@@ -8,18 +8,16 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.initSwizzleContext = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const module_1 = require("module");
|
|
12
11
|
const server_1 = require("../../server");
|
|
13
12
|
const init_1 = tslib_1.__importStar(require("../../server/plugins/init"));
|
|
14
13
|
async function initSwizzleContext(siteDir) {
|
|
15
14
|
const context = await (0, server_1.loadContext)(siteDir);
|
|
16
|
-
const pluginRequire = (0, module_1.createRequire)(context.siteConfigPath);
|
|
17
15
|
const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
|
|
18
16
|
const plugins = await (0, init_1.default)({
|
|
19
17
|
pluginConfigs,
|
|
20
18
|
context,
|
|
21
19
|
});
|
|
22
|
-
const pluginsNormalized = await (0, init_1.normalizePluginConfigs)(pluginConfigs,
|
|
20
|
+
const pluginsNormalized = await (0, init_1.normalizePluginConfigs)(pluginConfigs, context.siteConfigPath);
|
|
23
21
|
return {
|
|
24
22
|
plugins: plugins.map((plugin, pluginIndex) => ({
|
|
25
23
|
plugin: pluginsNormalized[pluginIndex],
|
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.getThemePath = exports.getThemeName = exports.getThemeNames = exports.getPluginByThemeName = exports.pluginToThemeName = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
12
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
13
|
const leven_1 = tslib_1.__importDefault(require("leven"));
|
|
13
14
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
14
15
|
const prompts_1 = require("./prompts");
|
|
@@ -87,8 +88,10 @@ exports.getThemeName = getThemeName;
|
|
|
87
88
|
function getThemePath({ plugins, themeName, typescript, }) {
|
|
88
89
|
const pluginInstance = getPluginByThemeName(plugins, themeName);
|
|
89
90
|
const themePath = typescript
|
|
90
|
-
? pluginInstance.instance.getTypeScriptThemePath
|
|
91
|
-
|
|
91
|
+
? pluginInstance.instance.getTypeScriptThemePath &&
|
|
92
|
+
path_1.default.resolve(pluginInstance.instance.path, pluginInstance.instance.getTypeScriptThemePath())
|
|
93
|
+
: pluginInstance.instance.getThemePath &&
|
|
94
|
+
path_1.default.resolve(pluginInstance.instance.path, pluginInstance.instance.getThemePath());
|
|
92
95
|
if (!themePath) {
|
|
93
96
|
logger_1.default.warn(typescript
|
|
94
97
|
? logger_1.default.interpolate `name=${themeName} does not provide TypeScript theme code via ${'getTypeScriptThemePath()'}.`
|
|
@@ -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 type {
|
|
8
|
-
export default function loadClientModules(plugins:
|
|
7
|
+
import type { LoadedPlugin } from '@docusaurus/types';
|
|
8
|
+
export default function loadClientModules(plugins: LoadedPlugin<unknown>[]): string[];
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
11
|
function loadClientModules(plugins) {
|
|
10
|
-
return plugins.flatMap((plugin) => plugin.getClientModules?.()
|
|
12
|
+
return plugins.flatMap((plugin) => plugin.getClientModules?.().map((p) => path_1.default.resolve(plugin.path, p)) ??
|
|
13
|
+
[]);
|
|
11
14
|
}
|
|
12
15
|
exports.default = loadClientModules;
|
package/lib/server/index.js
CHANGED
|
@@ -107,7 +107,7 @@ exports.loadPluginConfigs = loadPluginConfigs;
|
|
|
107
107
|
// Make a fake plugin to:
|
|
108
108
|
// - Resolve aliased theme components
|
|
109
109
|
// - Inject scripts/stylesheets
|
|
110
|
-
function createBootstrapPlugin({ siteConfig, }) {
|
|
110
|
+
function createBootstrapPlugin({ siteDir, siteConfig, }) {
|
|
111
111
|
const { stylesheets, scripts, clientModules: siteConfigClientModules, } = siteConfig;
|
|
112
112
|
return {
|
|
113
113
|
name: 'docusaurus-bootstrap-plugin',
|
|
@@ -116,6 +116,7 @@ function createBootstrapPlugin({ siteConfig, }) {
|
|
|
116
116
|
id: 'default',
|
|
117
117
|
},
|
|
118
118
|
version: { type: 'synthetic' },
|
|
119
|
+
path: siteDir,
|
|
119
120
|
getClientModules() {
|
|
120
121
|
return siteConfigClientModules;
|
|
121
122
|
},
|
|
@@ -157,6 +158,8 @@ function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
|
|
|
157
158
|
id: 'default',
|
|
158
159
|
},
|
|
159
160
|
version: { type: 'synthetic' },
|
|
161
|
+
// Synthetic, the path doesn't matter much
|
|
162
|
+
path: '.',
|
|
160
163
|
configureWebpack(config, isServer, { getJSLoader }) {
|
|
161
164
|
// We need the mdx fallback loader to exclude files that were already
|
|
162
165
|
// processed by content plugins mdx loaders. This works, but a bit
|
|
@@ -219,7 +222,7 @@ next build. You can clear all build artifacts (including this folder) with the
|
|
|
219
222
|
*/
|
|
220
223
|
export default ${JSON.stringify(siteConfig, null, 2)};
|
|
221
224
|
`);
|
|
222
|
-
plugins.push(createBootstrapPlugin({ siteConfig }));
|
|
225
|
+
plugins.push(createBootstrapPlugin({ siteDir, siteConfig }));
|
|
223
226
|
plugins.push(createMDXFallbackPlugin({ siteDir, siteConfig }));
|
|
224
227
|
// Load client modules.
|
|
225
228
|
const clientModules = (0, client_modules_1.default)(plugins);
|
|
@@ -4,7 +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
|
-
/// <reference types="node" />
|
|
8
7
|
import type { ImportedPluginModule, LoadContext, PluginModule, PluginConfig, PluginOptions, InitializedPlugin } from '@docusaurus/types';
|
|
9
8
|
export declare type NormalizedPluginConfig = {
|
|
10
9
|
plugin: PluginModule;
|
|
@@ -13,8 +12,13 @@ export declare type NormalizedPluginConfig = {
|
|
|
13
12
|
path: string;
|
|
14
13
|
module: ImportedPluginModule;
|
|
15
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Different from pluginModule.path, this one is always an absolute path used
|
|
17
|
+
* to resolve relative paths returned from lifecycles
|
|
18
|
+
*/
|
|
19
|
+
entryPath: string;
|
|
16
20
|
};
|
|
17
|
-
export declare function normalizePluginConfigs(pluginConfigs: PluginConfig[],
|
|
21
|
+
export declare function normalizePluginConfigs(pluginConfigs: PluginConfig[], configPath: string): Promise<NormalizedPluginConfig[]>;
|
|
18
22
|
export default function initPlugins({ pluginConfigs, context, }: {
|
|
19
23
|
pluginConfigs: PluginConfig[];
|
|
20
24
|
context: LoadContext;
|
|
@@ -9,12 +9,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.normalizePluginConfigs = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const module_1 = require("module");
|
|
12
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
13
|
const import_fresh_1 = tslib_1.__importDefault(require("import-fresh"));
|
|
13
14
|
const utils_1 = require("@docusaurus/utils");
|
|
14
15
|
const versions_1 = require("../versions");
|
|
15
16
|
const pluginIds_1 = require("./pluginIds");
|
|
16
17
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
17
|
-
async function normalizePluginConfig(pluginConfig,
|
|
18
|
+
async function normalizePluginConfig(pluginConfig, configPath) {
|
|
19
|
+
const pluginRequire = (0, module_1.createRequire)(configPath);
|
|
18
20
|
// plugins: ['./plugin']
|
|
19
21
|
if (typeof pluginConfig === 'string') {
|
|
20
22
|
const pluginModuleImport = pluginConfig;
|
|
@@ -27,6 +29,7 @@ async function normalizePluginConfig(pluginConfig, pluginRequire) {
|
|
|
27
29
|
path: pluginModuleImport,
|
|
28
30
|
module: pluginModule,
|
|
29
31
|
},
|
|
32
|
+
entryPath: pluginPath,
|
|
30
33
|
};
|
|
31
34
|
}
|
|
32
35
|
// plugins: [function plugin() { }]
|
|
@@ -34,6 +37,7 @@ async function normalizePluginConfig(pluginConfig, pluginRequire) {
|
|
|
34
37
|
return {
|
|
35
38
|
plugin: pluginConfig,
|
|
36
39
|
options: {},
|
|
40
|
+
entryPath: configPath,
|
|
37
41
|
};
|
|
38
42
|
}
|
|
39
43
|
// plugins: [
|
|
@@ -50,6 +54,7 @@ async function normalizePluginConfig(pluginConfig, pluginRequire) {
|
|
|
50
54
|
path: pluginModuleImport,
|
|
51
55
|
module: pluginModule,
|
|
52
56
|
},
|
|
57
|
+
entryPath: pluginPath,
|
|
53
58
|
};
|
|
54
59
|
}
|
|
55
60
|
// plugins: [
|
|
@@ -58,10 +63,11 @@ async function normalizePluginConfig(pluginConfig, pluginRequire) {
|
|
|
58
63
|
return {
|
|
59
64
|
plugin: pluginConfig[0],
|
|
60
65
|
options: pluginConfig[1],
|
|
66
|
+
entryPath: configPath,
|
|
61
67
|
};
|
|
62
68
|
}
|
|
63
|
-
async function normalizePluginConfigs(pluginConfigs,
|
|
64
|
-
return Promise.all(pluginConfigs.map((pluginConfig) => normalizePluginConfig(pluginConfig,
|
|
69
|
+
async function normalizePluginConfigs(pluginConfigs, configPath) {
|
|
70
|
+
return Promise.all(pluginConfigs.map((pluginConfig) => normalizePluginConfig(pluginConfig, configPath)));
|
|
65
71
|
}
|
|
66
72
|
exports.normalizePluginConfigs = normalizePluginConfigs;
|
|
67
73
|
function getOptionValidationFunction(normalizedPluginConfig) {
|
|
@@ -84,7 +90,7 @@ async function initPlugins({ pluginConfigs, context, }) {
|
|
|
84
90
|
// We need to resolve plugins from the perspective of the siteDir, since the
|
|
85
91
|
// siteDir's package.json declares the dependency on these plugins.
|
|
86
92
|
const pluginRequire = (0, module_1.createRequire)(context.siteConfigPath);
|
|
87
|
-
const pluginConfigsNormalized = await normalizePluginConfigs(pluginConfigs,
|
|
93
|
+
const pluginConfigsNormalized = await normalizePluginConfigs(pluginConfigs, context.siteConfigPath);
|
|
88
94
|
async function doGetPluginVersion(normalizedPluginConfig) {
|
|
89
95
|
// get plugin version
|
|
90
96
|
if (normalizedPluginConfig.pluginModule?.path) {
|
|
@@ -131,6 +137,7 @@ async function initPlugins({ pluginConfigs, context, }) {
|
|
|
131
137
|
...pluginInstance,
|
|
132
138
|
options: pluginOptions,
|
|
133
139
|
version: pluginVersion,
|
|
140
|
+
path: path_1.default.dirname(normalizedPluginConfig.entryPath),
|
|
134
141
|
};
|
|
135
142
|
}
|
|
136
143
|
const plugins = await Promise.all(pluginConfigsNormalized.map(initializePlugin));
|
|
@@ -39,7 +39,7 @@ async function loadThemeAliases(themePaths, userThemePaths) {
|
|
|
39
39
|
exports.loadThemeAliases = loadThemeAliases;
|
|
40
40
|
function loadPluginsThemeAliases({ siteDir, plugins, }) {
|
|
41
41
|
const pluginThemes = plugins
|
|
42
|
-
.map((plugin) => plugin.getThemePath
|
|
42
|
+
.map((plugin) => plugin.getThemePath && path_1.default.resolve(plugin.path, plugin.getThemePath()))
|
|
43
43
|
.filter((x) => Boolean(x));
|
|
44
44
|
const userTheme = path_1.default.resolve(siteDir, utils_1.THEME_PATH);
|
|
45
45
|
return loadThemeAliases([ThemeFallbackDir, ...pluginThemes], [userTheme]);
|
|
@@ -44,7 +44,7 @@ function getPluginSourceCodeFilePaths(plugin) {
|
|
|
44
44
|
if (themePath) {
|
|
45
45
|
codePaths.push(themePath);
|
|
46
46
|
}
|
|
47
|
-
return codePaths;
|
|
47
|
+
return codePaths.map((p) => path_1.default.resolve(plugin.path, p));
|
|
48
48
|
}
|
|
49
49
|
async function globSourceCodeFilePaths(dirPaths) {
|
|
50
50
|
const filePaths = await (0, utils_2.safeGlobby)(dirPaths);
|
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-4727",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"@babel/runtime": "^7.17.7",
|
|
42
42
|
"@babel/runtime-corejs3": "^7.17.7",
|
|
43
43
|
"@babel/traverse": "^7.17.3",
|
|
44
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
45
|
-
"@docusaurus/logger": "0.0.0-
|
|
46
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
44
|
+
"@docusaurus/cssnano-preset": "0.0.0-4727",
|
|
45
|
+
"@docusaurus/logger": "0.0.0-4727",
|
|
46
|
+
"@docusaurus/mdx-loader": "0.0.0-4727",
|
|
47
47
|
"@docusaurus/react-loadable": "5.5.2",
|
|
48
|
-
"@docusaurus/utils": "0.0.0-
|
|
49
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
50
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
48
|
+
"@docusaurus/utils": "0.0.0-4727",
|
|
49
|
+
"@docusaurus/utils-common": "0.0.0-4727",
|
|
50
|
+
"@docusaurus/utils-validation": "0.0.0-4727",
|
|
51
51
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.1",
|
|
52
52
|
"@svgr/webpack": "^6.2.1",
|
|
53
53
|
"autoprefixer": "^10.4.2",
|
|
@@ -106,8 +106,8 @@
|
|
|
106
106
|
"webpackbar": "^5.0.2"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
110
|
-
"@docusaurus/types": "0.0.0-
|
|
109
|
+
"@docusaurus/module-type-aliases": "0.0.0-4727",
|
|
110
|
+
"@docusaurus/types": "0.0.0-4727",
|
|
111
111
|
"@types/detect-port": "^1.3.2",
|
|
112
112
|
"@types/nprogress": "^0.2.0",
|
|
113
113
|
"@types/react-dom": "^17.0.13",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"engines": {
|
|
129
129
|
"node": ">=14"
|
|
130
130
|
},
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "967bfff81002933a1c68980300233e0320398e04"
|
|
132
132
|
}
|