@docusaurus/core 0.0.0-4680 → 0.0.0-4682

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.
@@ -33,7 +33,9 @@ exports.DEFAULT_CONFIG = {
33
33
  };
34
34
  function createPluginSchema(theme = false) {
35
35
  return (utils_validation_1.Joi.alternatives()
36
- .try(utils_validation_1.Joi.function(), utils_validation_1.Joi.array().ordered(utils_validation_1.Joi.function().required(), utils_validation_1.Joi.object().required()), utils_validation_1.Joi.string(), utils_validation_1.Joi.array()
36
+ .try(utils_validation_1.Joi.function(), utils_validation_1.Joi.array()
37
+ .ordered(utils_validation_1.Joi.function().required(), utils_validation_1.Joi.object().required())
38
+ .length(2), utils_validation_1.Joi.string(), utils_validation_1.Joi.array()
37
39
  .ordered(utils_validation_1.Joi.string().required(), utils_validation_1.Joi.object().required())
38
40
  .length(2), utils_validation_1.Joi.bool().equal(false))
39
41
  // @ts-expect-error: bad lib def, doesn't recognize an array of reports
@@ -60,7 +60,7 @@ async function loadPlugins({ pluginConfigs, context, }) {
60
60
  // order-dependent. We could change this in future if there are plugins which
61
61
  // need to run in certain order or depend on others for data.
62
62
  const loadedPlugins = await Promise.all(plugins.map(async (plugin) => {
63
- const content = plugin.loadContent ? await plugin.loadContent() : null;
63
+ const content = await plugin.loadContent?.();
64
64
  return { ...plugin, content };
65
65
  }));
66
66
  const contentLoadedTranslatedPlugins = await Promise.all(loadedPlugins.map(async (contentLoadedPlugin) => {
@@ -135,13 +135,13 @@ async function loadPlugins({ pluginConfigs, context, }) {
135
135
  // need to run in certain order or depend on others for data.
136
136
  await Promise.all(contentLoadedTranslatedPlugins.map(async (plugin) => {
137
137
  if (!plugin.routesLoaded) {
138
- return null;
138
+ return;
139
139
  }
140
140
  // TODO remove this deprecated lifecycle soon
141
141
  // deprecated since alpha-60
142
142
  // TODO, 1 user reported usage of this lifecycle! https://github.com/facebook/docusaurus/issues/3918
143
143
  logger_1.default.error `Plugin code=${'routesLoaded'} lifecycle is deprecated. If you think we should keep this lifecycle, please report here: path=${'https://github.com/facebook/docusaurus/issues/3918'}`;
144
- return plugin.routesLoaded(pluginsRouteConfigs);
144
+ await plugin.routesLoaded(pluginsRouteConfigs);
145
145
  }));
146
146
  // Sort the route config. This ensures that route with nested
147
147
  // routes are always placed last.
@@ -36,34 +36,29 @@ async function normalizePluginConfig(pluginConfig, pluginRequire) {
36
36
  options: {},
37
37
  };
38
38
  }
39
- if (Array.isArray(pluginConfig)) {
40
- // plugins: [
41
- // ['./plugin',options],
42
- // ]
43
- if (typeof pluginConfig[0] === 'string') {
44
- const pluginModuleImport = pluginConfig[0];
45
- const pluginPath = pluginRequire.resolve(pluginModuleImport);
46
- const pluginModule = (0, import_fresh_1.default)(pluginPath);
47
- return {
48
- plugin: pluginModule?.default ?? pluginModule,
49
- options: pluginConfig[1] ?? {},
50
- pluginModule: {
51
- path: pluginModuleImport,
52
- module: pluginModule,
53
- },
54
- };
55
- }
56
- // plugins: [
57
- // [function plugin() { },options],
58
- // ]
59
- if (typeof pluginConfig[0] === 'function') {
60
- return {
61
- plugin: pluginConfig[0],
62
- options: pluginConfig[1] ?? {},
63
- };
64
- }
39
+ // plugins: [
40
+ // ['./plugin',options],
41
+ // ]
42
+ if (typeof pluginConfig[0] === 'string') {
43
+ const pluginModuleImport = pluginConfig[0];
44
+ const pluginPath = pluginRequire.resolve(pluginModuleImport);
45
+ const pluginModule = (0, import_fresh_1.default)(pluginPath);
46
+ return {
47
+ plugin: pluginModule?.default ?? pluginModule,
48
+ options: pluginConfig[1],
49
+ pluginModule: {
50
+ path: pluginModuleImport,
51
+ module: pluginModule,
52
+ },
53
+ };
65
54
  }
66
- throw new Error(`Unexpected: can't load plugin for following plugin config.\n${JSON.stringify(pluginConfig)}`);
55
+ // plugins: [
56
+ // [function plugin() { },options],
57
+ // ]
58
+ return {
59
+ plugin: pluginConfig[0],
60
+ options: pluginConfig[1],
61
+ };
67
62
  }
68
63
  async function normalizePluginConfigs(pluginConfigs, pluginRequire) {
69
64
  return Promise.all(pluginConfigs.map((pluginConfig) => normalizePluginConfig(pluginConfig, pluginRequire)));
@@ -138,12 +133,7 @@ async function initPlugins({ pluginConfigs, context, }) {
138
133
  version: pluginVersion,
139
134
  };
140
135
  }
141
- const plugins = (await Promise.all(pluginConfigsNormalized.map((pluginConfig) => {
142
- if (!pluginConfig) {
143
- return null;
144
- }
145
- return initializePlugin(pluginConfig);
146
- }))).filter((item) => Boolean(item));
136
+ const plugins = await Promise.all(pluginConfigsNormalized.map(initializePlugin));
147
137
  (0, pluginIds_1.ensureUniquePluginInstanceIds)(plugins);
148
138
  return plugins;
149
139
  }
@@ -23,11 +23,8 @@ async function loadPresets(context) {
23
23
  if (typeof presetItem === 'string') {
24
24
  presetModuleImport = presetItem;
25
25
  }
26
- else if (Array.isArray(presetItem)) {
27
- [presetModuleImport, presetOptions = {}] = presetItem;
28
- }
29
26
  else {
30
- throw new Error('Invalid presets format detected in config.');
27
+ [presetModuleImport, presetOptions] = presetItem;
31
28
  }
32
29
  const presetName = (0, moduleShorthand_1.resolveModuleName)(presetModuleImport, presetRequire, 'preset');
33
30
  const presetModule = (0, import_fresh_1.default)(presetRequire.resolve(presetName));
@@ -19,11 +19,8 @@ async function getPackageJsonVersion(packageJsonPath) {
19
19
  }
20
20
  exports.getPackageJsonVersion = getPackageJsonVersion;
21
21
  async function getPackageJsonName(packageJsonPath) {
22
- if (await fs_extra_1.default.pathExists(packageJsonPath)) {
23
- // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require, global-require
24
- return require(packageJsonPath).name;
25
- }
26
- return undefined;
22
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require, global-require
23
+ return require(packageJsonPath).name;
27
24
  }
28
25
  async function getPluginVersion(pluginPath, siteDir) {
29
26
  let potentialPluginPackageJsonDirectory = path_1.default.dirname(pluginPath);
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-4680",
4
+ "version": "0.0.0-4682",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -41,13 +41,13 @@
41
41
  "@babel/runtime": "^7.17.2",
42
42
  "@babel/runtime-corejs3": "^7.17.2",
43
43
  "@babel/traverse": "^7.17.3",
44
- "@docusaurus/cssnano-preset": "0.0.0-4680",
45
- "@docusaurus/logger": "0.0.0-4680",
46
- "@docusaurus/mdx-loader": "0.0.0-4680",
44
+ "@docusaurus/cssnano-preset": "0.0.0-4682",
45
+ "@docusaurus/logger": "0.0.0-4682",
46
+ "@docusaurus/mdx-loader": "0.0.0-4682",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "0.0.0-4680",
49
- "@docusaurus/utils-common": "0.0.0-4680",
50
- "@docusaurus/utils-validation": "0.0.0-4680",
48
+ "@docusaurus/utils": "0.0.0-4682",
49
+ "@docusaurus/utils-common": "0.0.0-4682",
50
+ "@docusaurus/utils-validation": "0.0.0-4682",
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-4680",
110
- "@docusaurus/types": "0.0.0-4680",
109
+ "@docusaurus/module-type-aliases": "0.0.0-4682",
110
+ "@docusaurus/types": "0.0.0-4682",
111
111
  "@types/detect-port": "^1.3.2",
112
112
  "@types/nprogress": "^0.2.0",
113
113
  "@types/react-dom": "^17.0.11",
@@ -128,5 +128,5 @@
128
128
  "engines": {
129
129
  "node": ">=14"
130
130
  },
131
- "gitHead": "367835b86a28dea97e2addba03291438a5f813f8"
131
+ "gitHead": "143b48a54a5604d348ff1ad02fd024c8cf9d33a2"
132
132
  }
File without changes
@@ -1,3 +0,0 @@
1
- {
2
- "version": "random-version"
3
- }