@docusaurus/core 0.0.0-4797 → 0.0.0-4800

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 (74) hide show
  1. package/lib/commands/build.d.ts +1 -1
  2. package/lib/commands/build.js +6 -3
  3. package/lib/commands/clear.d.ts +1 -1
  4. package/lib/commands/clear.js +2 -1
  5. package/lib/commands/commandUtils.js +2 -3
  6. package/lib/commands/deploy.d.ts +1 -1
  7. package/lib/commands/deploy.js +6 -4
  8. package/lib/commands/external.d.ts +1 -1
  9. package/lib/commands/external.js +5 -6
  10. package/lib/commands/serve.d.ts +1 -1
  11. package/lib/commands/serve.js +6 -5
  12. package/lib/commands/start.d.ts +1 -1
  13. package/lib/commands/start.js +4 -2
  14. package/lib/commands/swizzle/common.d.ts +1 -2
  15. package/lib/commands/swizzle/context.js +6 -10
  16. package/lib/commands/swizzle/index.d.ts +1 -1
  17. package/lib/commands/swizzle/index.js +2 -1
  18. package/lib/commands/writeHeadingIds.d.ts +1 -1
  19. package/lib/commands/writeHeadingIds.js +5 -8
  20. package/lib/commands/writeTranslations.d.ts +1 -1
  21. package/lib/commands/writeTranslations.js +6 -8
  22. package/lib/index.d.ts +9 -10
  23. package/lib/index.js +18 -19
  24. package/lib/server/choosePort.d.ts +12 -0
  25. package/lib/{choosePort.js → server/choosePort.js} +8 -10
  26. package/lib/server/{client-modules/index.d.ts → clientModules.d.ts} +5 -1
  27. package/lib/server/{client-modules/index.js → clientModules.js} +6 -1
  28. package/lib/server/config.d.ts +5 -2
  29. package/lib/server/config.js +11 -6
  30. package/lib/server/htmlTags.d.ts +12 -0
  31. package/lib/server/htmlTags.js +62 -0
  32. package/lib/server/i18n.d.ts +2 -11
  33. package/lib/server/i18n.js +1 -18
  34. package/lib/server/index.d.ts +26 -11
  35. package/lib/server/index.js +40 -201
  36. package/lib/server/plugins/configs.d.ts +14 -0
  37. package/lib/server/plugins/configs.js +101 -0
  38. package/lib/server/plugins/index.d.ts +6 -6
  39. package/lib/server/plugins/index.js +29 -64
  40. package/lib/server/plugins/init.d.ts +6 -19
  41. package/lib/server/plugins/init.js +14 -65
  42. package/lib/server/{moduleShorthand.d.ts → plugins/moduleShorthand.d.ts} +0 -0
  43. package/lib/server/{moduleShorthand.js → plugins/moduleShorthand.js} +0 -0
  44. package/lib/server/plugins/pluginIds.d.ts +4 -0
  45. package/lib/server/plugins/pluginIds.js +4 -2
  46. package/lib/server/plugins/presets.d.ts +12 -0
  47. package/lib/server/{presets/index.js → plugins/presets.js} +9 -4
  48. package/lib/server/plugins/{applyRouteTrailingSlash.d.ts → routeConfig.d.ts} +2 -1
  49. package/lib/server/plugins/routeConfig.js +53 -0
  50. package/lib/server/plugins/synthetic.d.ts +20 -0
  51. package/lib/server/plugins/synthetic.js +112 -0
  52. package/lib/server/routes.d.ts +3 -2
  53. package/lib/server/routes.js +50 -24
  54. package/lib/server/{versions/index.d.ts → siteMetadata.d.ts} +5 -2
  55. package/lib/server/{versions/index.js → siteMetadata.js} +36 -3
  56. package/lib/server/translations/translations.js +1 -4
  57. package/lib/webpack/aliases/index.d.ts +29 -0
  58. package/lib/webpack/aliases/index.js +106 -0
  59. package/lib/webpack/base.d.ts +0 -3
  60. package/lib/webpack/base.js +4 -21
  61. package/package.json +10 -11
  62. package/lib/choosePort.d.ts +0 -11
  63. package/lib/server/duplicateRoutes.d.ts +0 -8
  64. package/lib/server/duplicateRoutes.js +0 -42
  65. package/lib/server/html-tags/htmlTags.d.ts +0 -7
  66. package/lib/server/html-tags/htmlTags.js +0 -38
  67. package/lib/server/html-tags/index.d.ts +0 -8
  68. package/lib/server/html-tags/index.js +0 -42
  69. package/lib/server/plugins/applyRouteTrailingSlash.js +0 -19
  70. package/lib/server/presets/index.d.ts +0 -11
  71. package/lib/server/themes/alias.d.ts +0 -9
  72. package/lib/server/themes/alias.js +0 -50
  73. package/lib/server/themes/index.d.ts +0 -12
  74. package/lib/server/themes/index.js +0 -47
@@ -4,6 +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 type { PluginVersionInformation } from '@docusaurus/types';
8
- export declare function getPackageJsonVersion(packageJsonPath: string): Promise<string | undefined>;
7
+ import type { LoadedPlugin, PluginVersionInformation, SiteMetadata } from '@docusaurus/types';
9
8
  export declare function getPluginVersion(pluginPath: string, siteDir: string): Promise<PluginVersionInformation>;
9
+ export declare function loadSiteMetadata({ plugins, siteDir, }: {
10
+ plugins: LoadedPlugin[];
11
+ siteDir: string;
12
+ }): Promise<SiteMetadata>;
@@ -6,10 +6,11 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getPluginVersion = exports.getPackageJsonVersion = void 0;
9
+ exports.loadSiteMetadata = exports.getPluginVersion = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
12
  const path_1 = tslib_1.__importDefault(require("path"));
13
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
13
14
  async function getPackageJsonVersion(packageJsonPath) {
14
15
  if (await fs_extra_1.default.pathExists(packageJsonPath)) {
15
16
  // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require, global-require
@@ -17,7 +18,6 @@ async function getPackageJsonVersion(packageJsonPath) {
17
18
  }
18
19
  return undefined;
19
20
  }
20
- exports.getPackageJsonVersion = getPackageJsonVersion;
21
21
  async function getPackageJsonName(packageJsonPath) {
22
22
  // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require, global-require
23
23
  return require(packageJsonPath).name;
@@ -42,7 +42,40 @@ async function getPluginVersion(pluginPath, siteDir) {
42
42
  potentialPluginPackageJsonDirectory = path_1.default.dirname(potentialPluginPackageJsonDirectory);
43
43
  }
44
44
  // In the case where a plugin is a path where no parent directory contains
45
- // package.json (e.g. inline plugin), we can only classify it as local.
45
+ // package.json, we can only classify it as local. Could happen if one puts a
46
+ // script in the parent directory of the site.
46
47
  return { type: 'local' };
47
48
  }
48
49
  exports.getPluginVersion = getPluginVersion;
50
+ /**
51
+ * We want all `@docusaurus/*` packages to have the exact same version!
52
+ * @see https://github.com/facebook/docusaurus/issues/3371
53
+ * @see https://github.com/facebook/docusaurus/pull/3386
54
+ */
55
+ function checkDocusaurusPackagesVersion(siteMetadata) {
56
+ const { docusaurusVersion } = siteMetadata;
57
+ Object.entries(siteMetadata.pluginVersions).forEach(([plugin, versionInfo]) => {
58
+ if (versionInfo.type === 'package' &&
59
+ versionInfo.name?.startsWith('@docusaurus/') &&
60
+ versionInfo.version &&
61
+ versionInfo.version !== docusaurusVersion) {
62
+ // should we throw instead?
63
+ // It still could work with different versions
64
+ logger_1.default.error `Invalid name=${plugin} version number=${versionInfo.version}.
65
+ All official @docusaurus/* packages should have the exact same version as @docusaurus/core (number=${docusaurusVersion}).
66
+ Maybe you want to check, or regenerate your yarn.lock or package-lock.json file?`;
67
+ }
68
+ });
69
+ }
70
+ async function loadSiteMetadata({ plugins, siteDir, }) {
71
+ const siteMetadata = {
72
+ docusaurusVersion: (await getPackageJsonVersion(path_1.default.join(__dirname, '../../package.json'))),
73
+ siteVersion: await getPackageJsonVersion(path_1.default.join(siteDir, 'package.json')),
74
+ pluginVersions: Object.fromEntries(plugins
75
+ .filter(({ version: { type } }) => type !== 'synthetic')
76
+ .map(({ name, version }) => [name, version])),
77
+ };
78
+ checkDocusaurusPackagesVersion(siteMetadata);
79
+ return siteMetadata;
80
+ }
81
+ exports.loadSiteMetadata = loadSiteMetadata;
@@ -80,11 +80,8 @@ Maybe you should remove them? ${unknownKeys}`;
80
80
  }
81
81
  }
82
82
  // should we make this configurable?
83
- function getTranslationsDirPath(context) {
84
- return path_1.default.join(context.siteDir, utils_1.I18N_DIR_NAME);
85
- }
86
83
  function getTranslationsLocaleDirPath(context) {
87
- return path_1.default.join(getTranslationsDirPath(context), context.locale);
84
+ return path_1.default.join(context.siteDir, utils_1.I18N_DIR_NAME, context.locale);
88
85
  }
89
86
  exports.getTranslationsLocaleDirPath = getTranslationsLocaleDirPath;
90
87
  function getCodeTranslationsFilePath(context) {
@@ -0,0 +1,29 @@
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
+ /**
9
+ * Order of Webpack aliases is important because one alias can shadow another.
10
+ * This ensures `@theme/NavbarItem` alias is after
11
+ * `@theme/NavbarItem/LocaleDropdown`.
12
+ *
13
+ * @see https://github.com/facebook/docusaurus/pull/3922
14
+ * @see https://github.com/facebook/docusaurus/issues/5382
15
+ */
16
+ export declare function sortAliases(aliases: ThemeAliases): ThemeAliases;
17
+ export declare function createAliasesForTheme(themePath: string, addOriginalAlias: boolean): Promise<ThemeAliases>;
18
+ export declare function loadThemeAliases({ siteDir, plugins, }: {
19
+ siteDir: string;
20
+ plugins: LoadedPlugin[];
21
+ }): Promise<ThemeAliases>;
22
+ /**
23
+ * Note: a `@docusaurus` alias would also catch `@docusaurus/theme-common`, so
24
+ * instead of naively aliasing this to `client/exports`, we use fine-grained
25
+ * aliases instead.
26
+ */
27
+ export declare function loadDocusaurusAliases(): Promise<{
28
+ [aliasName: string]: string;
29
+ }>;
@@ -0,0 +1,106 @@
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.loadDocusaurusAliases = exports.loadThemeAliases = exports.createAliasesForTheme = exports.sortAliases = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
+ const path_1 = tslib_1.__importDefault(require("path"));
13
+ const utils_1 = require("@docusaurus/utils");
14
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
15
+ const ThemeFallbackDir = path_1.default.join(__dirname, '../../client/theme-fallback');
16
+ /**
17
+ * Order of Webpack aliases is important because one alias can shadow another.
18
+ * This ensures `@theme/NavbarItem` alias is after
19
+ * `@theme/NavbarItem/LocaleDropdown`.
20
+ *
21
+ * @see https://github.com/facebook/docusaurus/pull/3922
22
+ * @see https://github.com/facebook/docusaurus/issues/5382
23
+ */
24
+ function sortAliases(aliases) {
25
+ // Alphabetical order by default
26
+ const entries = lodash_1.default.sortBy(Object.entries(aliases), ([alias]) => alias);
27
+ // @theme/NavbarItem should be after @theme/NavbarItem/LocaleDropdown
28
+ entries.sort(([alias1], [alias2]) =>
29
+ // eslint-disable-next-line no-nested-ternary
30
+ alias1.includes(`${alias2}/`) ? -1 : alias2.includes(`${alias1}/`) ? 1 : 0);
31
+ return Object.fromEntries(entries);
32
+ }
33
+ exports.sortAliases = sortAliases;
34
+ async function createAliasesForTheme(themePath, addOriginalAlias) {
35
+ if (!(await fs_extra_1.default.pathExists(themePath))) {
36
+ return {};
37
+ }
38
+ const themeComponentFiles = await (0, utils_1.Globby)(['**/*.{js,jsx,ts,tsx}'], {
39
+ cwd: themePath,
40
+ });
41
+ const aliases = {};
42
+ themeComponentFiles.forEach((relativeSource) => {
43
+ const filePath = path_1.default.join(themePath, relativeSource);
44
+ const fileName = (0, utils_1.fileToPath)(relativeSource);
45
+ const aliasName = (0, utils_1.posixPath)((0, utils_1.normalizeUrl)(['@theme', fileName]).replace(/\/$/, ''));
46
+ aliases[aliasName] = filePath;
47
+ if (addOriginalAlias) {
48
+ // For swizzled components to access the original.
49
+ const originalAliasName = (0, utils_1.posixPath)((0, utils_1.normalizeUrl)(['@theme-original', fileName]).replace(/\/$/, ''));
50
+ aliases[originalAliasName] = filePath;
51
+ }
52
+ });
53
+ return sortAliases(aliases);
54
+ }
55
+ exports.createAliasesForTheme = createAliasesForTheme;
56
+ async function createThemeAliases(themePaths, userThemePaths) {
57
+ const aliases = {};
58
+ for (const themePath of themePaths) {
59
+ const themeAliases = await createAliasesForTheme(themePath, true);
60
+ Object.entries(themeAliases).forEach(([aliasKey, alias]) => {
61
+ // If this alias shadows a previous one, use @theme-init to preserve the
62
+ // initial one. @theme-init is only applied once: to the initial theme
63
+ // that provided this component
64
+ if (aliasKey in aliases) {
65
+ const componentName = aliasKey.substring(aliasKey.indexOf('/') + 1);
66
+ const initAlias = `@theme-init/${componentName}`;
67
+ if (!(initAlias in aliases)) {
68
+ aliases[initAlias] = aliases[aliasKey];
69
+ }
70
+ }
71
+ aliases[aliasKey] = alias;
72
+ });
73
+ }
74
+ for (const themePath of userThemePaths) {
75
+ const userThemeAliases = await createAliasesForTheme(themePath, false);
76
+ Object.assign(aliases, userThemeAliases);
77
+ }
78
+ return sortAliases(aliases);
79
+ }
80
+ function loadThemeAliases({ siteDir, plugins, }) {
81
+ const pluginThemes = plugins
82
+ .map((plugin) => plugin.getThemePath && path_1.default.resolve(plugin.path, plugin.getThemePath()))
83
+ .filter((x) => Boolean(x));
84
+ const userTheme = path_1.default.resolve(siteDir, utils_1.THEME_PATH);
85
+ return createThemeAliases([ThemeFallbackDir, ...pluginThemes], [userTheme]);
86
+ }
87
+ exports.loadThemeAliases = loadThemeAliases;
88
+ /**
89
+ * Note: a `@docusaurus` alias would also catch `@docusaurus/theme-common`, so
90
+ * instead of naively aliasing this to `client/exports`, we use fine-grained
91
+ * aliases instead.
92
+ */
93
+ async function loadDocusaurusAliases() {
94
+ const dirPath = path_1.default.resolve(__dirname, '../../client/exports');
95
+ const extensions = ['.js', '.ts', '.tsx'];
96
+ const aliases = {};
97
+ (await fs_extra_1.default.readdir(dirPath))
98
+ .filter((fileName) => extensions.includes(path_1.default.extname(fileName)))
99
+ .forEach((fileName) => {
100
+ const fileNameWithoutExtension = path_1.default.basename(fileName, path_1.default.extname(fileName));
101
+ const aliasName = `@docusaurus/${fileNameWithoutExtension}`;
102
+ aliases[aliasName] = path_1.default.resolve(dirPath, fileName);
103
+ });
104
+ return aliases;
105
+ }
106
+ exports.loadDocusaurusAliases = loadDocusaurusAliases;
@@ -8,7 +8,4 @@ import type { Configuration } from 'webpack';
8
8
  import type { Props } from '@docusaurus/types';
9
9
  export declare const clientDir: string;
10
10
  export declare function excludeJS(modulePath: string): boolean;
11
- export declare function getDocusaurusAliases(): Promise<{
12
- [aliasName: string]: string;
13
- }>;
14
11
  export declare function createBaseConfig(props: Props, isServer: boolean, minify?: boolean): Promise<Configuration>;
@@ -6,13 +6,13 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.createBaseConfig = exports.getDocusaurusAliases = exports.excludeJS = exports.clientDir = void 0;
9
+ exports.createBaseConfig = exports.excludeJS = exports.clientDir = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
12
  const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
13
13
  const path_1 = tslib_1.__importDefault(require("path"));
14
14
  const utils_1 = require("./utils");
15
- const themes_1 = require("../server/themes");
15
+ const aliases_1 = require("./aliases");
16
16
  const utils_2 = require("@docusaurus/utils");
17
17
  const CSS_REGEX = /\.css$/i;
18
18
  const CSS_MODULE_REGEX = /\.module\.css$/i;
@@ -32,20 +32,6 @@ function excludeJS(modulePath) {
32
32
  !LibrariesToTranspileRegex.test(modulePath));
33
33
  }
34
34
  exports.excludeJS = excludeJS;
35
- async function getDocusaurusAliases() {
36
- const dirPath = path_1.default.resolve(__dirname, '../client/exports');
37
- const extensions = ['.js', '.ts', '.tsx'];
38
- const aliases = {};
39
- (await fs_extra_1.default.readdir(dirPath))
40
- .filter((fileName) => extensions.includes(path_1.default.extname(fileName)))
41
- .forEach((fileName) => {
42
- const fileNameWithoutExtension = path_1.default.basename(fileName, path_1.default.extname(fileName));
43
- const aliasName = `@docusaurus/${fileNameWithoutExtension}`;
44
- aliases[aliasName] = path_1.default.resolve(dirPath, fileName);
45
- });
46
- return aliases;
47
- }
48
- exports.getDocusaurusAliases = getDocusaurusAliases;
49
35
  async function createBaseConfig(props, isServer, minify = true) {
50
36
  const { outDir, siteDir, siteConfig, siteConfigPath, baseUrl, generatedFilesDir, routesPaths, siteMetadata, plugins, } = props;
51
37
  const totalPages = routesPaths.length;
@@ -55,7 +41,7 @@ async function createBaseConfig(props, isServer, minify = true) {
55
41
  const fileLoaderUtils = (0, utils_2.getFileLoaderUtils)();
56
42
  const name = isServer ? 'server' : 'client';
57
43
  const mode = isProd ? 'production' : 'development';
58
- const themeAliases = await (0, themes_1.loadPluginsThemeAliases)({ siteDir, plugins });
44
+ const themeAliases = await (0, aliases_1.loadThemeAliases)({ siteDir, plugins });
59
45
  return {
60
46
  mode,
61
47
  name,
@@ -116,10 +102,7 @@ async function createBaseConfig(props, isServer, minify = true) {
116
102
  alias: {
117
103
  '@site': siteDir,
118
104
  '@generated': generatedFilesDir,
119
- // Note: a @docusaurus alias would also catch @docusaurus/theme-common,
120
- // so we use fine-grained aliases instead
121
- // '@docusaurus': path.resolve(__dirname, '../client/exports'),
122
- ...(await getDocusaurusAliases()),
105
+ ...(await (0, aliases_1.loadDocusaurusAliases)()),
123
106
  ...themeAliases,
124
107
  },
125
108
  // This allows you to set a fallback for where Webpack should look for
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-4797",
4
+ "version": "0.0.0-4800",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -41,13 +41,13 @@
41
41
  "@babel/runtime": "^7.17.8",
42
42
  "@babel/runtime-corejs3": "^7.17.8",
43
43
  "@babel/traverse": "^7.17.3",
44
- "@docusaurus/cssnano-preset": "0.0.0-4797",
45
- "@docusaurus/logger": "0.0.0-4797",
46
- "@docusaurus/mdx-loader": "0.0.0-4797",
44
+ "@docusaurus/cssnano-preset": "0.0.0-4800",
45
+ "@docusaurus/logger": "0.0.0-4800",
46
+ "@docusaurus/mdx-loader": "0.0.0-4800",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "0.0.0-4797",
49
- "@docusaurus/utils-common": "0.0.0-4797",
50
- "@docusaurus/utils-validation": "0.0.0-4797",
48
+ "@docusaurus/utils": "0.0.0-4800",
49
+ "@docusaurus/utils-common": "0.0.0-4800",
50
+ "@docusaurus/utils-validation": "0.0.0-4800",
51
51
  "@slorber/static-site-generator-webpack-plugin": "^4.0.4",
52
52
  "@svgr/webpack": "^6.2.1",
53
53
  "autoprefixer": "^10.4.4",
@@ -74,7 +74,6 @@
74
74
  "html-tags": "^3.1.0",
75
75
  "html-webpack-plugin": "^5.5.0",
76
76
  "import-fresh": "^3.3.0",
77
- "is-root": "^2.1.0",
78
77
  "leven": "^3.1.0",
79
78
  "lodash": "^4.17.21",
80
79
  "mini-css-extract-plugin": "^2.6.0",
@@ -106,8 +105,8 @@
106
105
  "webpackbar": "^5.0.2"
107
106
  },
108
107
  "devDependencies": {
109
- "@docusaurus/module-type-aliases": "0.0.0-4797",
110
- "@docusaurus/types": "0.0.0-4797",
108
+ "@docusaurus/module-type-aliases": "0.0.0-4800",
109
+ "@docusaurus/types": "0.0.0-4800",
111
110
  "@types/detect-port": "^1.3.2",
112
111
  "@types/nprogress": "^0.2.0",
113
112
  "@types/react-dom": "^17.0.14",
@@ -128,5 +127,5 @@
128
127
  "engines": {
129
128
  "node": ">=14"
130
129
  },
131
- "gitHead": "8d1a82878ecdba1749d1383d97238a7cb391a130"
130
+ "gitHead": "d38da3dea586e001b552facb59e41f2547a38cac"
132
131
  }
@@ -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
- /**
8
- * Detects if program is running on port and prompts user
9
- * to choose another if port is already being used
10
- */
11
- export default function choosePort(host: string, defaultPort: number): Promise<number | null>;
@@ -1,8 +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 { ReportingSeverity, RouteConfig } from '@docusaurus/types';
8
- export declare function handleDuplicateRoutes(pluginsRouteConfigs: RouteConfig[], onDuplicateRoutes: ReportingSeverity): void;
@@ -1,42 +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.handleDuplicateRoutes = void 0;
10
- const utils_1 = require("@docusaurus/utils");
11
- const utils_2 = require("./utils");
12
- function getAllDuplicateRoutes(pluginsRouteConfigs) {
13
- const allRoutes = (0, utils_2.getAllFinalRoutes)(pluginsRouteConfigs).map((routeConfig) => routeConfig.path);
14
- const seenRoutes = new Set();
15
- return allRoutes.filter((route) => {
16
- if (seenRoutes.has(route)) {
17
- return true;
18
- }
19
- seenRoutes.add(route);
20
- return false;
21
- });
22
- }
23
- function getDuplicateRoutesMessage(allDuplicateRoutes) {
24
- const message = allDuplicateRoutes
25
- .map((duplicateRoute) => `- Attempting to create page at ${duplicateRoute}, but a page already exists at this route.`)
26
- .join('\n');
27
- return message;
28
- }
29
- function handleDuplicateRoutes(pluginsRouteConfigs, onDuplicateRoutes) {
30
- if (onDuplicateRoutes === 'ignore') {
31
- return;
32
- }
33
- const duplicatePaths = getAllDuplicateRoutes(pluginsRouteConfigs);
34
- const message = getDuplicateRoutesMessage(duplicatePaths);
35
- if (message) {
36
- const finalMessage = `Duplicate routes found!
37
- ${message}
38
- This could lead to non-deterministic routing behavior.`;
39
- (0, utils_1.reportMessage)(finalMessage, onDuplicateRoutes);
40
- }
41
- }
42
- exports.handleDuplicateRoutes = handleDuplicateRoutes;
@@ -1,7 +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
- export default function htmlTagObjectToString(tagDefinition: unknown): string;
@@ -1,38 +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 tslib_1 = require("tslib");
10
- const html_tags_1 = tslib_1.__importDefault(require("html-tags"));
11
- const void_1 = tslib_1.__importDefault(require("html-tags/void"));
12
- const escape_html_1 = tslib_1.__importDefault(require("escape-html"));
13
- function assertIsHtmlTagObject(val) {
14
- if (typeof val !== 'object' || !val) {
15
- throw new Error(`"${val}" is not a valid HTML tag object.`);
16
- }
17
- if (typeof val.tagName !== 'string') {
18
- throw new Error(`${JSON.stringify(val)} is not a valid HTML tag object. "tagName" must be defined as a string.`);
19
- }
20
- }
21
- function htmlTagObjectToString(tagDefinition) {
22
- assertIsHtmlTagObject(tagDefinition);
23
- if (html_tags_1.default.indexOf(tagDefinition.tagName) === -1) {
24
- throw new Error(`Error loading ${JSON.stringify(tagDefinition)}, "${tagDefinition.tagName}" is not a valid HTML tags.`);
25
- }
26
- const isVoidTag = void_1.default.indexOf(tagDefinition.tagName) !== -1;
27
- const tagAttributes = tagDefinition.attributes ?? {};
28
- const attributes = Object.keys(tagAttributes)
29
- .filter((attributeName) => tagAttributes[attributeName] !== false)
30
- .map((attributeName) => {
31
- if (tagAttributes[attributeName] === true) {
32
- return attributeName;
33
- }
34
- return `${attributeName}="${(0, escape_html_1.default)(tagAttributes[attributeName])}"`;
35
- });
36
- return `<${[tagDefinition.tagName].concat(attributes).join(' ')}>${(!isVoidTag && tagDefinition.innerHTML) || ''}${isVoidTag ? '' : `</${tagDefinition.tagName}>`}`;
37
- }
38
- exports.default = htmlTagObjectToString;
@@ -1,8 +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 { InjectedHtmlTags, LoadedPlugin } from '@docusaurus/types';
8
- export declare function loadHtmlTags(plugins: LoadedPlugin[]): InjectedHtmlTags;
@@ -1,42 +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.loadHtmlTags = void 0;
10
- const tslib_1 = require("tslib");
11
- const htmlTags_1 = tslib_1.__importDefault(require("./htmlTags"));
12
- function toString(val) {
13
- return typeof val === 'string' ? val : (0, htmlTags_1.default)(val);
14
- }
15
- function createHtmlTagsString(tags) {
16
- return Array.isArray(tags) ? tags.map(toString).join('\n') : toString(tags);
17
- }
18
- function loadHtmlTags(plugins) {
19
- const htmlTags = plugins.reduce((acc, plugin) => {
20
- if (!plugin.injectHtmlTags) {
21
- return acc;
22
- }
23
- const { headTags, preBodyTags, postBodyTags } = plugin.injectHtmlTags({ content: plugin.content }) ?? {};
24
- return {
25
- headTags: headTags
26
- ? `${acc.headTags}\n${createHtmlTagsString(headTags)}`
27
- : acc.headTags,
28
- preBodyTags: preBodyTags
29
- ? `${acc.preBodyTags}\n${createHtmlTagsString(preBodyTags)}`
30
- : acc.preBodyTags,
31
- postBodyTags: postBodyTags
32
- ? `${acc.postBodyTags}\n${createHtmlTagsString(postBodyTags)}`
33
- : acc.postBodyTags,
34
- };
35
- }, { headTags: '', preBodyTags: '', postBodyTags: '' });
36
- return {
37
- headTags: htmlTags.headTags.trim(),
38
- preBodyTags: htmlTags.preBodyTags.trim(),
39
- postBodyTags: htmlTags.postBodyTags.trim(),
40
- };
41
- }
42
- exports.loadHtmlTags = loadHtmlTags;
@@ -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,50 +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 = tslib_1.__importDefault(require("fs-extra"));
12
- const path_1 = tslib_1.__importDefault(require("path"));
13
- const utils_1 = require("@docusaurus/utils");
14
- const lodash_1 = 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]) =>
24
- // eslint-disable-next-line no-nested-ternary
25
- alias1.includes(`${alias2}/`) ? -1 : alias2.includes(`${alias1}/`) ? 1 : 0);
26
- return Object.fromEntries(entries);
27
- }
28
- exports.sortAliases = sortAliases;
29
- async function themeAlias(themePath, addOriginalAlias) {
30
- if (!(await fs_extra_1.default.pathExists(themePath))) {
31
- return {};
32
- }
33
- const themeComponentFiles = await (0, utils_1.Globby)(['**/*.{js,jsx,ts,tsx}'], {
34
- cwd: themePath,
35
- });
36
- const aliases = {};
37
- themeComponentFiles.forEach((relativeSource) => {
38
- const filePath = path_1.default.join(themePath, relativeSource);
39
- const fileName = (0, utils_1.fileToPath)(relativeSource);
40
- const aliasName = (0, utils_1.posixPath)((0, utils_1.normalizeUrl)(['@theme', fileName]).replace(/\/$/, ''));
41
- aliases[aliasName] = filePath;
42
- if (addOriginalAlias) {
43
- // For swizzled components to access the original.
44
- const originalAliasName = (0, utils_1.posixPath)((0, utils_1.normalizeUrl)(['@theme-original', fileName]).replace(/\/$/, ''));
45
- aliases[originalAliasName] = filePath;
46
- }
47
- });
48
- return sortAliases(aliases);
49
- }
50
- 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>;