@docusaurus/core 2.0.0-beta.16 → 2.0.0-beta.19

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.
Files changed (171) hide show
  1. package/bin/beforeCli.mjs +14 -12
  2. package/bin/docusaurus.mjs +41 -93
  3. package/lib/babel/preset.js +2 -2
  4. package/lib/client/.eslintrc.js +2 -3
  5. package/lib/client/App.d.ts +1 -1
  6. package/lib/client/App.js +15 -7
  7. package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.d.ts → BaseUrlIssueBanner/index.d.ts} +10 -5
  8. package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.js → BaseUrlIssueBanner/index.js} +14 -9
  9. package/lib/client/{baseUrlIssueBanner → BaseUrlIssueBanner}/styles.module.css +0 -0
  10. package/lib/client/ClientLifecyclesDispatcher.d.ts +16 -0
  11. package/lib/client/ClientLifecyclesDispatcher.js +34 -0
  12. package/lib/client/LinksCollector.d.ts +1 -1
  13. package/lib/client/LinksCollector.js +4 -5
  14. package/lib/client/PendingNavigation.d.ts +8 -17
  15. package/lib/client/PendingNavigation.js +39 -70
  16. package/lib/{server/loadSetup.d.ts → client/SiteMetadataDefaults.d.ts} +2 -2
  17. package/lib/client/SiteMetadataDefaults.js +19 -0
  18. package/lib/client/{exports/browserContext.d.ts → browserContext.d.ts} +0 -0
  19. package/lib/client/{exports/browserContext.js → browserContext.js} +0 -0
  20. package/lib/client/clientEntry.js +3 -4
  21. package/lib/client/docusaurus.d.ts +5 -5
  22. package/lib/client/docusaurus.js +26 -33
  23. package/lib/client/{exports/docusaurusContext.d.ts → docusaurusContext.d.ts} +0 -0
  24. package/lib/client/{exports/docusaurusContext.js → docusaurusContext.js} +0 -0
  25. package/lib/client/exports/BrowserOnly.d.ts +3 -4
  26. package/lib/client/exports/BrowserOnly.js +2 -2
  27. package/lib/client/exports/ComponentCreator.js +65 -40
  28. package/lib/client/exports/ErrorBoundary.d.ts +2 -2
  29. package/lib/client/exports/ErrorBoundary.js +4 -5
  30. package/lib/client/exports/Interpolate.d.ts +1 -1
  31. package/lib/client/exports/Interpolate.js +18 -41
  32. package/lib/client/exports/Link.d.ts +3 -15
  33. package/lib/client/exports/Link.js +24 -30
  34. package/lib/client/exports/Translate.d.ts +2 -2
  35. package/lib/client/exports/Translate.js +3 -3
  36. package/lib/client/exports/useBaseUrl.js +8 -9
  37. package/lib/client/exports/useDocusaurusContext.js +1 -1
  38. package/lib/client/exports/useGlobalData.d.ts +4 -3
  39. package/lib/client/exports/useGlobalData.js +5 -5
  40. package/lib/client/exports/useIsBrowser.js +1 -1
  41. package/lib/{server/client-modules/index.d.ts → client/exports/useRouteContext.d.ts} +2 -2
  42. package/lib/client/exports/useRouteContext.js +15 -0
  43. package/lib/client/flat.d.ts +12 -2
  44. package/lib/client/flat.js +12 -5
  45. package/lib/client/normalizeLocation.js +13 -8
  46. package/lib/client/prefetch.js +10 -28
  47. package/lib/client/preload.d.ts +1 -3
  48. package/lib/client/preload.js +5 -11
  49. package/lib/client/routeContext.d.ts +13 -0
  50. package/lib/client/routeContext.js +31 -0
  51. package/lib/client/serverEntry.js +19 -18
  52. package/lib/client/theme-fallback/Error/index.js +7 -1
  53. package/lib/client/theme-fallback/Layout/index.d.ts +1 -1
  54. package/lib/client/theme-fallback/Layout/index.js +2 -17
  55. package/lib/client/theme-fallback/Loading/index.js +2 -0
  56. package/lib/client/theme-fallback/NotFound/index.js +13 -5
  57. package/lib/client/theme-fallback/Root/index.d.ts +4 -4
  58. package/lib/client/theme-fallback/Root/index.js +2 -1
  59. package/lib/{server/html-tags/htmlTags.d.ts → client/theme-fallback/SiteMetadata/index.d.ts} +2 -1
  60. package/lib/client/theme-fallback/SiteMetadata/index.js +10 -0
  61. package/lib/commands/build.d.ts +6 -2
  62. package/lib/commands/build.js +48 -30
  63. package/lib/commands/clear.d.ts +1 -1
  64. package/lib/commands/clear.js +6 -5
  65. package/lib/commands/deploy.d.ts +5 -5
  66. package/lib/commands/deploy.js +21 -45
  67. package/lib/commands/external.d.ts +1 -1
  68. package/lib/commands/external.js +6 -11
  69. package/lib/commands/serve.d.ts +7 -2
  70. package/lib/commands/serve.js +18 -19
  71. package/lib/commands/start.d.ts +8 -2
  72. package/lib/commands/start.js +33 -30
  73. package/lib/commands/swizzle/actions.d.ts +2 -2
  74. package/lib/commands/swizzle/actions.js +10 -10
  75. package/lib/commands/swizzle/common.d.ts +3 -3
  76. package/lib/commands/swizzle/common.js +8 -9
  77. package/lib/commands/swizzle/components.js +48 -13
  78. package/lib/commands/swizzle/config.js +21 -15
  79. package/lib/commands/swizzle/context.js +6 -12
  80. package/lib/commands/swizzle/index.d.ts +2 -2
  81. package/lib/commands/swizzle/index.js +5 -4
  82. package/lib/commands/swizzle/prompts.js +2 -2
  83. package/lib/commands/swizzle/tables.js +10 -13
  84. package/lib/commands/swizzle/themes.js +9 -8
  85. package/lib/commands/writeHeadingIds.d.ts +2 -9
  86. package/lib/commands/writeHeadingIds.js +11 -69
  87. package/lib/commands/writeTranslations.d.ts +3 -4
  88. package/lib/commands/writeTranslations.js +10 -14
  89. package/lib/index.d.ts +9 -10
  90. package/lib/index.js +18 -19
  91. package/lib/server/brokenLinks.d.ts +3 -16
  92. package/lib/server/brokenLinks.js +37 -31
  93. package/lib/server/clientModules.d.ts +12 -0
  94. package/lib/server/clientModules.js +20 -0
  95. package/lib/server/config.d.ts +5 -2
  96. package/lib/server/config.js +14 -9
  97. package/lib/server/configValidation.d.ts +1 -1
  98. package/lib/server/configValidation.js +39 -13
  99. package/lib/server/getHostPort.d.ts +14 -0
  100. package/lib/{choosePort.js → server/getHostPort.js} +24 -41
  101. package/lib/server/htmlTags.d.ts +12 -0
  102. package/lib/server/htmlTags.js +62 -0
  103. package/lib/server/i18n.d.ts +2 -11
  104. package/lib/server/i18n.js +7 -28
  105. package/lib/server/index.d.ts +28 -13
  106. package/lib/server/index.js +62 -229
  107. package/lib/server/plugins/configs.d.ts +51 -0
  108. package/lib/server/plugins/configs.js +101 -0
  109. package/lib/server/plugins/index.d.ts +9 -8
  110. package/lib/server/plugins/index.js +65 -132
  111. package/lib/server/plugins/init.d.ts +6 -15
  112. package/lib/server/plugins/init.js +25 -83
  113. package/lib/server/{moduleShorthand.d.ts → plugins/moduleShorthand.d.ts} +0 -0
  114. package/lib/server/{moduleShorthand.js → plugins/moduleShorthand.js} +0 -0
  115. package/lib/server/plugins/pluginIds.d.ts +4 -0
  116. package/lib/server/plugins/pluginIds.js +6 -4
  117. package/lib/server/plugins/presets.d.ts +12 -0
  118. package/lib/server/{presets/index.js → plugins/presets.js} +21 -20
  119. package/lib/server/plugins/{applyRouteTrailingSlash.d.ts → routeConfig.d.ts} +3 -1
  120. package/lib/server/plugins/routeConfig.js +54 -0
  121. package/lib/server/plugins/synthetic.d.ts +20 -0
  122. package/lib/server/plugins/synthetic.js +112 -0
  123. package/lib/server/routes.d.ts +39 -7
  124. package/lib/server/routes.js +169 -102
  125. package/lib/server/siteMetadata.d.ts +12 -0
  126. package/lib/server/siteMetadata.js +81 -0
  127. package/lib/server/translations/translations.d.ts +5 -14
  128. package/lib/server/translations/translations.js +23 -39
  129. package/lib/server/translations/translationsExtractor.d.ts +2 -2
  130. package/lib/server/translations/translationsExtractor.js +16 -19
  131. package/lib/server/utils.js +1 -1
  132. package/lib/webpack/aliases/index.d.ts +34 -0
  133. package/lib/webpack/aliases/index.js +106 -0
  134. package/lib/webpack/base.d.ts +0 -1
  135. package/lib/webpack/base.js +12 -30
  136. package/lib/webpack/client.js +7 -8
  137. package/lib/webpack/plugins/ChunkAssetPlugin.js +7 -7
  138. package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +2 -2
  139. package/lib/webpack/plugins/CleanWebpackPlugin.js +2 -2
  140. package/lib/webpack/plugins/LogPlugin.js +2 -2
  141. package/lib/webpack/plugins/WaitPlugin.d.ts +2 -2
  142. package/lib/webpack/plugins/WaitPlugin.js +3 -3
  143. package/lib/webpack/server.d.ts +2 -2
  144. package/lib/webpack/server.js +10 -8
  145. package/lib/webpack/utils.d.ts +9 -3
  146. package/lib/webpack/utils.js +20 -25
  147. package/package.json +38 -41
  148. package/lib/choosePort.d.ts +0 -11
  149. package/lib/client/client-lifecycles-dispatcher.d.ts +0 -9
  150. package/lib/client/client-lifecycles-dispatcher.js +0 -23
  151. package/lib/client/nprogress.css +0 -36
  152. package/lib/commands/commandUtils.d.ts +0 -9
  153. package/lib/commands/commandUtils.js +0 -21
  154. package/lib/server/client-modules/index.js +0 -12
  155. package/lib/server/duplicateRoutes.d.ts +0 -10
  156. package/lib/server/duplicateRoutes.js +0 -42
  157. package/lib/server/html-tags/htmlTags.js +0 -38
  158. package/lib/server/html-tags/index.d.ts +0 -9
  159. package/lib/server/html-tags/index.js +0 -43
  160. package/lib/server/loadSetup.js +0 -25
  161. package/lib/server/plugins/applyRouteTrailingSlash.js +0 -19
  162. package/lib/server/presets/index.d.ts +0 -11
  163. package/lib/server/themes/alias.d.ts +0 -9
  164. package/lib/server/themes/alias.js +0 -48
  165. package/lib/server/themes/index.d.ts +0 -12
  166. package/lib/server/themes/index.js +0 -47
  167. package/lib/server/versions/__fixtures__/dummy-plugin.d.ts +0 -0
  168. package/lib/server/versions/__fixtures__/dummy-plugin.js +0 -0
  169. package/lib/server/versions/__fixtures__/package.json +0 -3
  170. package/lib/server/versions/index.d.ts +0 -9
  171. package/lib/server/versions/index.js +0 -51
@@ -1,19 +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
- const utils_common_1 = require("@docusaurus/utils-common");
10
- function applyRouteTrailingSlash(route, params) {
11
- return {
12
- ...route,
13
- path: (0, utils_common_1.applyTrailingSlash)(route.path, params),
14
- ...(route.routes && {
15
- routes: route.routes.map((subroute) => applyRouteTrailingSlash(subroute, params)),
16
- }),
17
- };
18
- }
19
- exports.default = applyRouteTrailingSlash;
@@ -1,11 +0,0 @@
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 { LoadContext, PluginConfig } from '@docusaurus/types';
8
- export default function loadPresets(context: LoadContext): Promise<{
9
- plugins: PluginConfig[];
10
- themes: PluginConfig[];
11
- }>;
@@ -1,9 +0,0 @@
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 { ThemeAliases } from '@docusaurus/types';
8
- export declare function sortAliases(aliases: ThemeAliases): ThemeAliases;
9
- export default function themeAlias(themePath: string, addOriginalAlias: boolean): Promise<ThemeAliases>;
@@ -1,48 +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.sortAliases = void 0;
10
- const tslib_1 = require("tslib");
11
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
13
- const utils_1 = require("@docusaurus/utils");
14
- const lodash_1 = (0, tslib_1.__importDefault)(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 = lodash_1.default.sortBy(Object.entries(aliases), ([alias]) => alias);
22
- // @theme/NavbarItem should be after @theme/NavbarItem/LocaleDropdown
23
- entries.sort(([alias1], [alias2]) => alias1.includes(`${alias2}/`) ? -1 : 0);
24
- return Object.fromEntries(entries);
25
- }
26
- exports.sortAliases = sortAliases;
27
- async function themeAlias(themePath, addOriginalAlias) {
28
- if (!(await fs_extra_1.default.pathExists(themePath))) {
29
- return {};
30
- }
31
- const themeComponentFiles = await (0, utils_1.Globby)(['**/*.{js,jsx,ts,tsx}'], {
32
- cwd: themePath,
33
- });
34
- const aliases = {};
35
- themeComponentFiles.forEach((relativeSource) => {
36
- const filePath = path_1.default.join(themePath, relativeSource);
37
- const fileName = (0, utils_1.fileToPath)(relativeSource);
38
- const aliasName = (0, utils_1.posixPath)((0, utils_1.normalizeUrl)(['@theme', fileName]).replace(/\/$/, ''));
39
- aliases[aliasName] = filePath;
40
- if (addOriginalAlias) {
41
- // For swizzled components to access the original.
42
- const originalAliasName = (0, utils_1.posixPath)((0, utils_1.normalizeUrl)(['@theme-original', fileName]).replace(/\/$/, ''));
43
- aliases[originalAliasName] = filePath;
44
- }
45
- });
46
- return sortAliases(aliases);
47
- }
48
- exports.default = themeAlias;
@@ -1,12 +0,0 @@
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 { ThemeAliases, LoadedPlugin } from '@docusaurus/types';
8
- export declare function loadThemeAliases(themePaths: string[], userThemePaths: string[]): Promise<ThemeAliases>;
9
- export declare function loadPluginsThemeAliases({ siteDir, plugins, }: {
10
- siteDir: string;
11
- plugins: LoadedPlugin[];
12
- }): Promise<ThemeAliases>;
@@ -1,47 +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.loadPluginsThemeAliases = exports.loadThemeAliases = void 0;
10
- const tslib_1 = require("tslib");
11
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
12
- const utils_1 = require("@docusaurus/utils");
13
- const alias_1 = (0, tslib_1.__importStar)(require("./alias"));
14
- const ThemeFallbackDir = path_1.default.resolve(__dirname, '../../client/theme-fallback');
15
- async function loadThemeAliases(themePaths, userThemePaths) {
16
- const aliases = {};
17
- for (const themePath of themePaths) {
18
- const themeAliases = await (0, alias_1.default)(themePath, true);
19
- Object.keys(themeAliases).forEach((aliasKey) => {
20
- // If this alias shadows a previous one, use @theme-init to preserve the
21
- // initial one. @theme-init is only applied once: to the initial theme
22
- // that provided this component
23
- if (aliasKey in aliases) {
24
- const componentName = aliasKey.substring(aliasKey.indexOf('/') + 1);
25
- const initAlias = `@theme-init/${componentName}`;
26
- if (!(initAlias in aliases)) {
27
- aliases[initAlias] = aliases[aliasKey];
28
- }
29
- }
30
- aliases[aliasKey] = themeAliases[aliasKey];
31
- });
32
- }
33
- for (const themePath of userThemePaths) {
34
- const userThemeAliases = await (0, alias_1.default)(themePath, false);
35
- Object.assign(aliases, userThemeAliases);
36
- }
37
- return (0, alias_1.sortAliases)(aliases);
38
- }
39
- exports.loadThemeAliases = loadThemeAliases;
40
- function loadPluginsThemeAliases({ siteDir, plugins, }) {
41
- const pluginThemes = plugins
42
- .map((plugin) => (plugin.getThemePath ? plugin.getThemePath() : undefined))
43
- .filter((x) => Boolean(x));
44
- const userTheme = path_1.default.resolve(siteDir, utils_1.THEME_PATH);
45
- return loadThemeAliases([ThemeFallbackDir, ...pluginThemes], [userTheme]);
46
- }
47
- exports.loadPluginsThemeAliases = loadPluginsThemeAliases;
File without changes
@@ -1,3 +0,0 @@
1
- {
2
- "version": "random-version"
3
- }
@@ -1,9 +0,0 @@
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 { DocusaurusPluginVersionInformation } from '@docusaurus/types';
8
- export declare function getPackageJsonVersion(packageJsonPath: string): Promise<string | undefined>;
9
- export declare function getPluginVersion(pluginPath: string, siteDir: string): Promise<DocusaurusPluginVersionInformation>;
@@ -1,51 +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.getPluginVersion = exports.getPackageJsonVersion = void 0;
10
- const tslib_1 = require("tslib");
11
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
13
- async function getPackageJsonVersion(packageJsonPath) {
14
- if (await fs_extra_1.default.pathExists(packageJsonPath)) {
15
- // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require, global-require
16
- return require(packageJsonPath).version;
17
- }
18
- return undefined;
19
- }
20
- exports.getPackageJsonVersion = getPackageJsonVersion;
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;
27
- }
28
- async function getPluginVersion(pluginPath, siteDir) {
29
- let potentialPluginPackageJsonDirectory = path_1.default.dirname(pluginPath);
30
- while (potentialPluginPackageJsonDirectory !== '/') {
31
- const packageJsonPath = path_1.default.join(potentialPluginPackageJsonDirectory, 'package.json');
32
- if ((await fs_extra_1.default.pathExists(packageJsonPath)) &&
33
- (await fs_extra_1.default.lstat(packageJsonPath)).isFile()) {
34
- if (potentialPluginPackageJsonDirectory === siteDir) {
35
- // If the plugin belongs to the same docusaurus project, we classify it
36
- // as local plugin.
37
- return { type: 'project' };
38
- }
39
- return {
40
- type: 'package',
41
- name: await getPackageJsonName(packageJsonPath),
42
- version: await getPackageJsonVersion(packageJsonPath),
43
- };
44
- }
45
- potentialPluginPackageJsonDirectory = path_1.default.dirname(potentialPluginPackageJsonDirectory);
46
- }
47
- // In the case where a plugin is a path where no parent directory contains
48
- // package.json (e.g. inline plugin), we can only classify it as local.
49
- return { type: 'local' };
50
- }
51
- exports.getPluginVersion = getPluginVersion;