@docusaurus/core 2.0.0-beta.ff31de0ff → 2.0.1

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 (222) hide show
  1. package/README.md +1 -0
  2. package/bin/beforeCli.mjs +140 -0
  3. package/bin/docusaurus.mjs +223 -0
  4. package/lib/babel/preset.d.ts +8 -3
  5. package/lib/babel/preset.js +10 -8
  6. package/lib/client/App.d.ts +2 -3
  7. package/lib/client/App.js +31 -28
  8. package/lib/client/BaseUrlIssueBanner/index.d.ts +27 -0
  9. package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.js → BaseUrlIssueBanner/index.js} +25 -14
  10. package/lib/client/{baseUrlIssueBanner → BaseUrlIssueBanner}/styles.module.css +0 -0
  11. package/lib/client/ClientLifecyclesDispatcher.d.ts +16 -0
  12. package/lib/client/ClientLifecyclesDispatcher.js +39 -0
  13. package/lib/client/LinksCollector.d.ts +3 -3
  14. package/lib/client/LinksCollector.js +8 -13
  15. package/lib/client/PendingNavigation.d.ts +17 -3
  16. package/lib/client/PendingNavigation.js +47 -72
  17. package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.d.ts → SiteMetadataDefaults.d.ts} +1 -2
  18. package/lib/client/SiteMetadataDefaults.js +21 -0
  19. package/lib/{choosePort.d.ts → client/browserContext.d.ts} +5 -5
  20. package/lib/client/browserContext.js +22 -0
  21. package/lib/client/clientEntry.js +14 -9
  22. package/lib/client/docusaurus.d.ts +12 -6
  23. package/lib/client/docusaurus.js +30 -43
  24. package/lib/client/docusaurusContext.d.ts +12 -0
  25. package/lib/client/docusaurusContext.js +25 -0
  26. package/lib/client/exports/BrowserOnly.d.ts +3 -5
  27. package/lib/client/exports/BrowserOnly.js +14 -7
  28. package/lib/client/exports/ComponentCreator.d.ts +6 -2
  29. package/lib/client/exports/ComponentCreator.js +75 -42
  30. package/lib/client/exports/ErrorBoundary.d.ts +18 -0
  31. package/lib/client/exports/ErrorBoundary.js +37 -0
  32. package/lib/client/exports/ExecutionEnvironment.js +7 -8
  33. package/lib/client/exports/Head.d.ts +2 -3
  34. package/lib/client/exports/Head.js +3 -4
  35. package/lib/client/exports/Interpolate.d.ts +2 -2
  36. package/lib/client/exports/Interpolate.js +20 -49
  37. package/lib/client/exports/Link.d.ts +4 -10
  38. package/lib/client/exports/Link.js +44 -38
  39. package/lib/client/exports/Translate.d.ts +1 -1
  40. package/lib/client/exports/Translate.js +14 -9
  41. package/lib/client/exports/constants.js +1 -11
  42. package/lib/client/exports/isInternalUrl.js +1 -1
  43. package/lib/client/exports/renderRoutes.d.ts +1 -2
  44. package/lib/client/exports/renderRoutes.js +1 -2
  45. package/lib/client/exports/router.d.ts +1 -1
  46. package/lib/client/exports/router.js +1 -1
  47. package/lib/client/exports/useBaseUrl.js +11 -14
  48. package/lib/client/exports/useDocusaurusContext.d.ts +2 -3
  49. package/lib/client/exports/useDocusaurusContext.js +3 -9
  50. package/lib/client/exports/useGlobalData.d.ts +4 -3
  51. package/lib/client/exports/useGlobalData.js +8 -15
  52. package/lib/{server/versions/__tests/index.test.d.ts → client/exports/useIsBrowser.d.ts} +1 -1
  53. package/lib/client/exports/useIsBrowser.js +11 -0
  54. package/lib/client/exports/useRouteContext.d.ts +8 -0
  55. package/lib/client/exports/useRouteContext.js +15 -0
  56. package/lib/client/flat.d.ts +12 -2
  57. package/lib/client/flat.js +19 -15
  58. package/lib/client/normalizeLocation.d.ts +2 -5
  59. package/lib/client/normalizeLocation.js +14 -10
  60. package/lib/client/prefetch.d.ts +1 -2
  61. package/lib/client/prefetch.js +12 -32
  62. package/lib/client/preload.d.ts +3 -4
  63. package/lib/client/preload.js +5 -12
  64. package/lib/client/routeContext.d.ts +13 -0
  65. package/lib/client/routeContext.js +31 -0
  66. package/lib/client/serverEntry.d.ts +10 -0
  67. package/lib/client/serverEntry.js +109 -136
  68. package/lib/client/theme-fallback/Error/index.d.ts +10 -0
  69. package/lib/client/theme-fallback/Error/index.js +45 -0
  70. package/lib/client/theme-fallback/Layout/index.d.ts +10 -0
  71. package/lib/client/theme-fallback/Layout/index.js +2 -26
  72. package/lib/client/theme-fallback/Loading/index.d.ts +9 -0
  73. package/lib/client/theme-fallback/Loading/index.js +50 -116
  74. package/lib/client/{exports/context.js → theme-fallback/NotFound/index.d.ts} +2 -2
  75. package/lib/client/theme-fallback/NotFound/index.js +19 -18
  76. package/lib/client/theme-fallback/Root/index.d.ts +10 -0
  77. package/lib/client/theme-fallback/Root/index.js +2 -6
  78. package/lib/{server/html-tags/htmlTags.d.ts → client/theme-fallback/SiteMetadata/index.d.ts} +2 -1
  79. package/lib/client/theme-fallback/SiteMetadata/index.js +10 -0
  80. package/lib/commands/build.d.ts +6 -2
  81. package/lib/commands/build.js +81 -64
  82. package/lib/commands/clear.d.ts +7 -1
  83. package/lib/commands/clear.js +34 -21
  84. package/lib/commands/deploy.d.ts +5 -2
  85. package/lib/commands/deploy.js +102 -81
  86. package/lib/commands/external.d.ts +2 -2
  87. package/lib/commands/external.js +9 -11
  88. package/lib/commands/serve.d.ts +8 -2
  89. package/lib/commands/serve.js +40 -20
  90. package/lib/commands/start.d.ts +9 -2
  91. package/lib/commands/start.js +111 -101
  92. package/lib/commands/swizzle/actions.d.ts +23 -0
  93. package/lib/commands/swizzle/actions.js +106 -0
  94. package/lib/commands/swizzle/common.d.ts +33 -0
  95. package/lib/commands/swizzle/common.js +56 -0
  96. package/lib/commands/swizzle/components.d.ts +29 -0
  97. package/lib/commands/swizzle/components.js +200 -0
  98. package/lib/commands/swizzle/config.d.ts +10 -0
  99. package/lib/commands/swizzle/config.js +84 -0
  100. package/lib/{server/client-modules/index.d.ts → commands/swizzle/context.d.ts} +2 -2
  101. package/lib/commands/swizzle/context.js +24 -0
  102. package/lib/commands/swizzle/index.d.ts +8 -0
  103. package/lib/commands/swizzle/index.js +119 -0
  104. package/lib/commands/swizzle/prompts.d.ts +12 -0
  105. package/lib/commands/swizzle/prompts.js +110 -0
  106. package/lib/{client/exports/context.d.ts → commands/swizzle/tables.d.ts} +3 -4
  107. package/lib/commands/swizzle/tables.js +113 -0
  108. package/lib/commands/swizzle/themes.d.ts +20 -0
  109. package/lib/commands/swizzle/themes.js +106 -0
  110. package/lib/commands/writeHeadingIds.d.ts +2 -6
  111. package/lib/commands/writeHeadingIds.js +22 -81
  112. package/lib/commands/writeTranslations.d.ts +4 -5
  113. package/lib/commands/writeTranslations.js +48 -28
  114. package/lib/index.d.ts +9 -9
  115. package/lib/index.js +14 -14
  116. package/lib/server/brokenLinks.d.ts +4 -17
  117. package/lib/server/brokenLinks.js +67 -56
  118. package/lib/server/clientModules.d.ts +12 -0
  119. package/lib/server/clientModules.js +20 -0
  120. package/lib/server/config.d.ts +5 -2
  121. package/lib/server/config.js +29 -6
  122. package/lib/server/configValidation.d.ts +5 -3
  123. package/lib/server/configValidation.js +105 -44
  124. package/lib/server/getHostPort.d.ts +14 -0
  125. package/lib/server/getHostPort.js +79 -0
  126. package/lib/server/htmlTags.d.ts +12 -0
  127. package/lib/server/htmlTags.js +62 -0
  128. package/lib/server/i18n.d.ts +3 -13
  129. package/lib/server/i18n.js +21 -55
  130. package/lib/server/index.d.ts +28 -6
  131. package/lib/server/index.js +86 -173
  132. package/lib/server/plugins/configs.d.ts +51 -0
  133. package/lib/server/plugins/configs.js +101 -0
  134. package/lib/server/plugins/index.d.ts +10 -10
  135. package/lib/server/plugins/index.js +76 -128
  136. package/lib/server/plugins/init.d.ts +6 -9
  137. package/lib/server/plugins/init.js +44 -109
  138. package/lib/server/plugins/moduleShorthand.d.ts +9 -0
  139. package/lib/server/plugins/moduleShorthand.js +46 -0
  140. package/lib/server/plugins/pluginIds.d.ts +6 -2
  141. package/lib/server/plugins/pluginIds.js +12 -7
  142. package/lib/server/plugins/presets.d.ts +12 -0
  143. package/lib/server/plugins/presets.js +49 -0
  144. package/lib/server/plugins/routeConfig.d.ts +11 -0
  145. package/lib/server/plugins/routeConfig.js +54 -0
  146. package/lib/server/plugins/synthetic.d.ts +20 -0
  147. package/lib/server/plugins/synthetic.js +111 -0
  148. package/lib/server/routes.d.ts +39 -7
  149. package/lib/server/routes.js +182 -95
  150. package/lib/server/siteMetadata.d.ts +12 -0
  151. package/lib/server/siteMetadata.js +81 -0
  152. package/lib/server/translations/translations.d.ts +16 -22
  153. package/lib/server/translations/translations.js +41 -73
  154. package/lib/server/translations/translationsExtractor.d.ts +10 -5
  155. package/lib/server/translations/translationsExtractor.js +158 -122
  156. package/lib/server/utils.d.ts +9 -3
  157. package/lib/server/utils.js +7 -9
  158. package/lib/webpack/aliases/index.d.ts +34 -0
  159. package/lib/webpack/aliases/index.js +106 -0
  160. package/lib/webpack/base.d.ts +3 -4
  161. package/lib/webpack/base.js +56 -58
  162. package/lib/webpack/client.d.ts +3 -3
  163. package/lib/webpack/client.js +12 -19
  164. package/lib/webpack/plugins/ChunkAssetPlugin.d.ts +13 -3
  165. package/lib/webpack/plugins/ChunkAssetPlugin.js +24 -17
  166. package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +6 -25
  167. package/lib/webpack/plugins/CleanWebpackPlugin.js +34 -18
  168. package/lib/webpack/plugins/LogPlugin.d.ts +1 -1
  169. package/lib/webpack/plugins/LogPlugin.js +4 -5
  170. package/lib/webpack/plugins/WaitPlugin.d.ts +3 -3
  171. package/lib/webpack/plugins/WaitPlugin.js +1 -1
  172. package/lib/webpack/server.d.ts +5 -5
  173. package/lib/webpack/server.js +23 -8
  174. package/lib/{client → webpack}/templates/index.html.template.ejs +0 -0
  175. package/lib/webpack/templates/ssr.html.template.d.ts +8 -0
  176. package/lib/{client → webpack}/templates/ssr.html.template.js +5 -4
  177. package/lib/webpack/utils.d.ts +16 -31
  178. package/lib/webpack/utils.js +63 -183
  179. package/package.json +83 -77
  180. package/bin/docusaurus.js +0 -326
  181. package/lib/.tsbuildinfo +0 -5682
  182. package/lib/choosePort.js +0 -105
  183. package/lib/client/.eslintrc.js +0 -29
  184. package/lib/client/.tsbuildinfo +0 -4127
  185. package/lib/client/client-lifecycles-dispatcher.d.ts +0 -12
  186. package/lib/client/client-lifecycles-dispatcher.js +0 -27
  187. package/lib/client/nprogress.css +0 -36
  188. package/lib/commands/buildRemoteBranchUrl.d.ts +0 -7
  189. package/lib/commands/buildRemoteBranchUrl.js +0 -27
  190. package/lib/commands/commandUtils.d.ts +0 -3
  191. package/lib/commands/commandUtils.js +0 -21
  192. package/lib/commands/swizzle.d.ts +0 -9
  193. package/lib/commands/swizzle.js +0 -245
  194. package/lib/constants.d.ts +0 -18
  195. package/lib/constants.js +0 -23
  196. package/lib/server/client-modules/index.js +0 -14
  197. package/lib/server/duplicateRoutes.d.ts +0 -10
  198. package/lib/server/duplicateRoutes.js +0 -38
  199. package/lib/server/html-tags/htmlTags.js +0 -39
  200. package/lib/server/html-tags/index.d.ts +0 -9
  201. package/lib/server/html-tags/index.js +0 -43
  202. package/lib/server/loadSetup.d.ts +0 -9
  203. package/lib/server/loadSetup.js +0 -25
  204. package/lib/server/presets/index.d.ts +0 -11
  205. package/lib/server/presets/index.js +0 -48
  206. package/lib/server/themes/alias.d.ts +0 -8
  207. package/lib/server/themes/alias.js +0 -39
  208. package/lib/server/themes/index.d.ts +0 -8
  209. package/lib/server/themes/index.js +0 -35
  210. package/lib/server/versions/__fixtures__/dummy-plugin.js +0 -0
  211. package/lib/server/versions/__fixtures__/package.json +0 -3
  212. package/lib/server/versions/__tests/index.test.js +0 -25
  213. package/lib/server/versions/index.d.ts +0 -10
  214. package/lib/server/versions/index.js +0 -50
  215. package/lib/webpack/react-dev-utils-webpack5/README.md +0 -11
  216. package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.js +0 -57
  217. package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +0 -138
  218. package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.js +0 -285
  219. package/lib/webpack/sharedModuleAliases.d.ts +0 -10
  220. package/lib/webpack/sharedModuleAliases.js +0 -18
  221. package/tsconfig.client.json +0 -13
  222. package/tsconfig.json +0 -13
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applyDefaultCodeTranslations = exports.getPluginsDefaultCodeTranslationMessages = exports.localizePluginTranslationFile = exports.writePluginTranslations = exports.writeCodeTranslations = exports.readCodeTranslationFileContent = exports.getCodeTranslationsFilePath = exports.getTranslationsLocaleDirPath = exports.getTranslationsDirPath = exports.writeTranslationFileContent = exports.readTranslationFileContent = exports.ensureTranslationFileContent = void 0;
4
- const tslib_1 = require("tslib");
5
2
  /**
6
3
  * Copyright (c) Facebook, Inc. and its affiliates.
7
4
  *
8
5
  * This source code is licensed under the MIT license found in the
9
6
  * LICENSE file in the root directory of this source tree.
10
7
  */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.applyDefaultCodeTranslations = exports.getPluginsDefaultCodeTranslationMessages = exports.localizePluginTranslationFile = exports.writePluginTranslations = exports.writeCodeTranslations = exports.readCodeTranslationFileContent = void 0;
10
+ const tslib_1 = require("tslib");
11
11
  const path_1 = tslib_1.__importDefault(require("path"));
12
12
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
- const lodash_1 = require("lodash");
13
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
14
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
15
  const utils_1 = require("@docusaurus/utils");
15
16
  const utils_validation_1 = require("@docusaurus/utils-validation");
16
- const chalk_1 = 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(),
@@ -27,40 +27,35 @@ function ensureTranslationFileContent(content) {
27
27
  convert: false,
28
28
  });
29
29
  }
30
- exports.ensureTranslationFileContent = ensureTranslationFileContent;
31
30
  async function readTranslationFileContent(filePath) {
32
31
  if (await fs_extra_1.default.pathExists(filePath)) {
33
32
  try {
34
- const content = JSON.parse(await fs_extra_1.default.readFile(filePath, 'utf8'));
33
+ const content = await fs_extra_1.default.readJSON(filePath);
35
34
  ensureTranslationFileContent(content);
36
35
  return content;
37
36
  }
38
- catch (e) {
39
- throw new Error(`Invalid translation file at path=${filePath}.\n${e.message}`);
37
+ catch (err) {
38
+ logger_1.default.error `Invalid translation file at path=${filePath}.`;
39
+ throw err;
40
40
  }
41
41
  }
42
42
  return undefined;
43
43
  }
44
- exports.readTranslationFileContent = readTranslationFileContent;
45
44
  function mergeTranslationFileContent({ existingContent = {}, newContent, options, }) {
46
45
  // Apply messagePrefix to all messages
47
- const newContentTransformed = lodash_1.mapValues(newContent, (value) => {
48
- var _a;
49
- return ({
50
- ...value,
51
- message: `${(_a = options.messagePrefix) !== null && _a !== void 0 ? _a : ''}${value.message}`,
52
- });
53
- });
46
+ const newContentTransformed = lodash_1.default.mapValues(newContent, (value) => ({
47
+ ...value,
48
+ message: `${options.messagePrefix ?? ''}${value.message}`,
49
+ }));
54
50
  const result = { ...existingContent };
55
51
  // We only add missing keys here, we don't delete existing ones
56
52
  Object.entries(newContentTransformed).forEach(([key, { message, description }]) => {
57
- var _a, _b;
58
53
  result[key] = {
59
- // If the messages already exist, we don't override them (unless requested)
54
+ // If messages already exist, we don't override them (unless requested)
60
55
  message: options.override
61
56
  ? message
62
- : (_b = (_a = existingContent[key]) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : message,
63
- description, // description
57
+ : existingContent[key]?.message ?? message,
58
+ description,
64
59
  };
65
60
  });
66
61
  return result;
@@ -68,11 +63,10 @@ function mergeTranslationFileContent({ existingContent = {}, newContent, options
68
63
  async function writeTranslationFileContent({ filePath, content: newContent, options = {}, }) {
69
64
  const existingContent = await readTranslationFileContent(filePath);
70
65
  // Warn about potential legacy keys
71
- const unknownKeys = lodash_1.difference(Object.keys(existingContent !== null && existingContent !== void 0 ? existingContent : {}), Object.keys(newContent));
66
+ const unknownKeys = lodash_1.default.difference(Object.keys(existingContent ?? {}), Object.keys(newContent));
72
67
  if (unknownKeys.length > 0) {
73
- console.warn(chalk_1.default.yellow(`Some translation keys looks unknown to us in file ${filePath}
74
- Maybe you should remove them?
75
- - ${unknownKeys.join('\n- ')}`));
68
+ logger_1.default.warn `Some translation keys looks unknown to us in file path=${filePath}.
69
+ Maybe you should remove them? ${unknownKeys}`;
76
70
  }
77
71
  const mergedContent = mergeTranslationFileContent({
78
72
  existingContent,
@@ -81,27 +75,13 @@ Maybe you should remove them?
81
75
  });
82
76
  // Avoid creating empty translation files
83
77
  if (Object.keys(mergedContent).length > 0) {
84
- console.log(`${Object.keys(mergedContent)
85
- .length.toString()
86
- .padStart(3, ' ')} translations will be written at ${utils_1.toMessageRelativeFilePath(filePath)}`);
87
- await fs_extra_1.default.ensureDir(path_1.default.dirname(filePath));
88
- await fs_extra_1.default.writeFile(filePath, JSON.stringify(mergedContent, null, 2));
78
+ logger_1.default.info `number=${Object.keys(mergedContent).length} translations will be written at path=${(0, utils_1.toMessageRelativeFilePath)(filePath)}.`;
79
+ await fs_extra_1.default.outputFile(filePath, `${JSON.stringify(mergedContent, null, 2)}\n`);
89
80
  }
90
81
  }
91
- exports.writeTranslationFileContent = writeTranslationFileContent;
92
- // should we make this configurable?
93
- function getTranslationsDirPath(context) {
94
- return path_1.default.resolve(path_1.default.join(context.siteDir, `i18n`));
95
- }
96
- exports.getTranslationsDirPath = getTranslationsDirPath;
97
- function getTranslationsLocaleDirPath(context) {
98
- return path_1.default.join(getTranslationsDirPath(context), context.locale);
99
- }
100
- exports.getTranslationsLocaleDirPath = getTranslationsLocaleDirPath;
101
82
  function getCodeTranslationsFilePath(context) {
102
- return path_1.default.join(getTranslationsLocaleDirPath(context), 'code.json');
83
+ return path_1.default.join(context.localizationDir, utils_1.CODE_TRANSLATIONS_FILE_NAME);
103
84
  }
104
- exports.getCodeTranslationsFilePath = getCodeTranslationsFilePath;
105
85
  async function readCodeTranslationFileContent(context) {
106
86
  return readTranslationFileContent(getCodeTranslationsFilePath(context));
107
87
  }
@@ -119,25 +99,23 @@ exports.writeCodeTranslations = writeCodeTranslations;
119
99
  // (json/yaml/toml/xml...)
120
100
  function addTranslationFileExtension(translationFilePath) {
121
101
  if (translationFilePath.endsWith('.json')) {
122
- throw new Error(`Translation file path does not need to end with .json, we addt the extension automatically. translationFilePath=${translationFilePath}`);
102
+ throw new Error(`Translation file path at "${translationFilePath}" does not need to end with ".json", we add the extension automatically.`);
123
103
  }
124
104
  return `${translationFilePath}.json`;
125
105
  }
126
- function getPluginTranslationFilePath({ siteDir, plugin, locale, translationFilePath, }) {
127
- const dirPath = utils_1.getPluginI18nPath({
128
- siteDir,
129
- locale,
106
+ function getPluginTranslationFilePath({ localizationDir, plugin, translationFilePath, }) {
107
+ const dirPath = (0, utils_1.getPluginI18nPath)({
108
+ localizationDir,
130
109
  pluginName: plugin.name,
131
110
  pluginId: plugin.options.id,
132
111
  });
133
112
  const filePath = addTranslationFileExtension(translationFilePath);
134
113
  return path_1.default.join(dirPath, filePath);
135
114
  }
136
- async function writePluginTranslations({ siteDir, plugin, locale, translationFile, options, }) {
115
+ async function writePluginTranslations({ localizationDir, plugin, translationFile, options, }) {
137
116
  const filePath = getPluginTranslationFilePath({
138
117
  plugin,
139
- siteDir,
140
- locale,
118
+ localizationDir,
141
119
  translationFilePath: translationFile.path,
142
120
  });
143
121
  await writeTranslationFileContent({
@@ -147,16 +125,15 @@ async function writePluginTranslations({ siteDir, plugin, locale, translationFil
147
125
  });
148
126
  }
149
127
  exports.writePluginTranslations = writePluginTranslations;
150
- async function localizePluginTranslationFile({ siteDir, plugin, locale, translationFile, }) {
128
+ async function localizePluginTranslationFile({ localizationDir, plugin, translationFile, }) {
151
129
  const filePath = getPluginTranslationFilePath({
152
130
  plugin,
153
- siteDir,
154
- locale,
131
+ localizationDir,
155
132
  translationFilePath: translationFile.path,
156
133
  });
157
134
  const localizedContent = await readTranslationFileContent(filePath);
158
135
  if (localizedContent) {
159
- // localized messages "override" default unlocalized messages
136
+ // Localized messages "override" default unlocalized messages
160
137
  return {
161
138
  path: translationFile.path,
162
139
  content: {
@@ -165,32 +142,23 @@ async function localizePluginTranslationFile({ siteDir, plugin, locale, translat
165
142
  },
166
143
  };
167
144
  }
168
- else {
169
- return translationFile;
170
- }
145
+ return translationFile;
171
146
  }
172
147
  exports.localizePluginTranslationFile = localizePluginTranslationFile;
173
148
  async function getPluginsDefaultCodeTranslationMessages(plugins) {
174
- const pluginsMessages = await Promise.all(plugins.map((plugin) => { var _a, _b; return (_b = (_a = plugin.getDefaultCodeTranslationMessages) === null || _a === void 0 ? void 0 : _a.call(plugin)) !== null && _b !== void 0 ? _b : {}; }));
175
- return pluginsMessages.reduce((allMessages, pluginMessages) => {
176
- return { ...allMessages, ...pluginMessages };
177
- }, {});
149
+ const pluginsMessages = await Promise.all(plugins.map((plugin) => plugin.getDefaultCodeTranslationMessages?.() ?? {}));
150
+ return pluginsMessages.reduce((allMessages, pluginMessages) => ({ ...allMessages, ...pluginMessages }), {});
178
151
  }
179
152
  exports.getPluginsDefaultCodeTranslationMessages = getPluginsDefaultCodeTranslationMessages;
180
153
  function applyDefaultCodeTranslations({ extractedCodeTranslations, defaultCodeMessages, }) {
181
- const unusedDefaultCodeMessages = lodash_1.difference(Object.keys(defaultCodeMessages), Object.keys(extractedCodeTranslations));
154
+ const unusedDefaultCodeMessages = lodash_1.default.difference(Object.keys(defaultCodeMessages), Object.keys(extractedCodeTranslations));
182
155
  if (unusedDefaultCodeMessages.length > 0) {
183
- console.warn(chalk_1.default.yellow(`Unused default message codes found.
184
- Please report this Docusaurus issue.
185
- - ${unusedDefaultCodeMessages.join('\n- ')}
186
- `));
156
+ logger_1.default.warn `Unused default message codes found.
157
+ Please report this Docusaurus issue. name=${unusedDefaultCodeMessages}`;
187
158
  }
188
- return lodash_1.mapValues(extractedCodeTranslations, (messageTranslation, messageId) => {
189
- var _a;
190
- return {
191
- ...messageTranslation,
192
- message: (_a = defaultCodeMessages[messageId]) !== null && _a !== void 0 ? _a : messageTranslation.message,
193
- };
194
- });
159
+ return lodash_1.default.mapValues(extractedCodeTranslations, (messageTranslation, messageId) => ({
160
+ ...messageTranslation,
161
+ message: defaultCodeMessages[messageId] ?? messageTranslation.message,
162
+ }));
195
163
  }
196
164
  exports.applyDefaultCodeTranslations = applyDefaultCodeTranslations;
@@ -1,11 +1,16 @@
1
- import { TransformOptions } from '@babel/core';
2
- import { TranslationFileContent, TranslationMessage } from '@docusaurus/types';
3
- import { InitPlugin } from '../plugins/init';
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 TransformOptions } from '@babel/core';
8
+ import type { InitializedPlugin, TranslationFileContent } from '@docusaurus/types';
4
9
  export declare function globSourceCodeFilePaths(dirPaths: string[]): Promise<string[]>;
5
- export declare function extractSiteSourceCodeTranslations(siteDir: string, plugins: InitPlugin[], babelOptions: TransformOptions): Promise<TranslationFileContent>;
10
+ export declare function extractSiteSourceCodeTranslations(siteDir: string, plugins: InitializedPlugin[], babelOptions: TransformOptions, extraSourceCodeFilePaths?: string[]): Promise<TranslationFileContent>;
6
11
  declare type SourceCodeFileTranslations = {
7
12
  sourceCodeFilePath: string;
8
- translations: Record<string, TranslationMessage>;
13
+ translations: TranslationFileContent;
9
14
  warnings: string[];
10
15
  };
11
16
  export declare function extractAllSourceCodeFileTranslations(sourceCodeFilePaths: string[], babelOptions: TransformOptions): Promise<SourceCodeFileTranslations[]>;
@@ -1,22 +1,21 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractSourceCodeFileTranslations = exports.extractAllSourceCodeFileTranslations = exports.extractSiteSourceCodeTranslations = exports.globSourceCodeFilePaths = void 0;
4
- const tslib_1 = require("tslib");
5
2
  /**
6
3
  * Copyright (c) Facebook, Inc. and its affiliates.
7
4
  *
8
5
  * This source code is licensed under the MIT license found in the
9
6
  * LICENSE file in the root directory of this source tree.
10
7
  */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.extractSourceCodeFileTranslations = exports.extractAllSourceCodeFileTranslations = exports.extractSiteSourceCodeTranslations = exports.globSourceCodeFilePaths = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const path_1 = tslib_1.__importDefault(require("path"));
11
12
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
14
  const traverse_1 = tslib_1.__importDefault(require("@babel/traverse"));
13
15
  const generator_1 = tslib_1.__importDefault(require("@babel/generator"));
14
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
15
16
  const core_1 = require("@babel/core");
16
- const lodash_1 = require("lodash");
17
- const path_1 = tslib_1.__importDefault(require("path"));
18
- const constants_1 = require("../../constants");
19
- const utils_1 = require("../utils");
17
+ const utils_1 = require("@docusaurus/utils");
18
+ const utils_2 = require("../utils");
20
19
  // We only support extracting source code translations from these kind of files
21
20
  const TranslatableSourceCodeExtension = new Set([
22
21
  '.js',
@@ -24,7 +23,7 @@ const TranslatableSourceCodeExtension = new Set([
24
23
  '.ts',
25
24
  '.tsx',
26
25
  // TODO support md/mdx too? (may be overkill)
27
- // need to compile the MDX to JSX first and remove frontmatter
26
+ // need to compile the MDX to JSX first and remove front matter
28
27
  // '.md',
29
28
  // '.mdx',
30
29
  ]);
@@ -32,44 +31,48 @@ function isTranslatableSourceCodePath(filePath) {
32
31
  return TranslatableSourceCodeExtension.has(path_1.default.extname(filePath));
33
32
  }
34
33
  function getSiteSourceCodeFilePaths(siteDir) {
35
- return [path_1.default.join(siteDir, constants_1.SRC_DIR_NAME)];
34
+ return [path_1.default.join(siteDir, utils_1.SRC_DIR_NAME)];
36
35
  }
37
36
  function getPluginSourceCodeFilePaths(plugin) {
38
- var _a, _b, _c;
39
37
  // The getPathsToWatch() generally returns the js/jsx/ts/tsx/md/mdx file paths
40
- // We can use this method as well to know which folders we should try to extract translations from
41
- // Hacky/implicit, but do we want to introduce a new lifecycle method just for that???
42
- const codePaths = (_b = (_a = plugin.getPathsToWatch) === null || _a === void 0 ? void 0 : _a.call(plugin)) !== null && _b !== void 0 ? _b : [];
38
+ // We can use this method as well to know which folders we should try to
39
+ // extract translations from. Hacky/implicit, but do we want to introduce a
40
+ // new lifecycle method just for that???
41
+ const codePaths = plugin.getPathsToWatch?.() ?? [];
43
42
  // We also include theme code
44
- const themePath = (_c = plugin.getThemePath) === null || _c === void 0 ? void 0 : _c.call(plugin);
43
+ const themePath = plugin.getThemePath?.();
45
44
  if (themePath) {
46
45
  codePaths.push(themePath);
47
46
  }
48
- return codePaths;
47
+ return codePaths.map((p) => path_1.default.resolve(plugin.path, p));
49
48
  }
50
49
  async function globSourceCodeFilePaths(dirPaths) {
51
- const filePaths = await utils_1.safeGlobby(dirPaths);
50
+ const filePaths = await (0, utils_2.safeGlobby)(dirPaths);
52
51
  return filePaths.filter(isTranslatableSourceCodePath);
53
52
  }
54
53
  exports.globSourceCodeFilePaths = globSourceCodeFilePaths;
55
54
  async function getSourceCodeFilePaths(siteDir, plugins) {
56
55
  const sitePaths = getSiteSourceCodeFilePaths(siteDir);
57
56
  // The getPathsToWatch() generally returns the js/jsx/ts/tsx/md/mdx file paths
58
- // We can use this method as well to know which folders we should try to extract translations from
59
- // Hacky/implicit, but do we want to introduce a new lifecycle method for that???
60
- const pluginsPaths = lodash_1.flatten(plugins.map(getPluginSourceCodeFilePaths));
57
+ // We can use this method as well to know which folders we should try to
58
+ // extract translations from. Hacky/implicit, but do we want to introduce a
59
+ // new lifecycle method for that???
60
+ const pluginsPaths = plugins.flatMap(getPluginSourceCodeFilePaths);
61
61
  const allPaths = [...sitePaths, ...pluginsPaths];
62
62
  return globSourceCodeFilePaths(allPaths);
63
63
  }
64
- async function extractSiteSourceCodeTranslations(siteDir, plugins, babelOptions) {
65
- // Should we warn here if the same translation "key" is found in multiple source code files?
64
+ async function extractSiteSourceCodeTranslations(siteDir, plugins, babelOptions, extraSourceCodeFilePaths = []) {
65
+ // Should we warn here if the same translation "key" is found in multiple
66
+ // source code files?
66
67
  function toTranslationFileContent(sourceCodeFileTranslations) {
67
- return sourceCodeFileTranslations.reduce((acc, item) => {
68
- return { ...acc, ...item.translations };
69
- }, {});
68
+ return sourceCodeFileTranslations.reduce((acc, item) => ({ ...acc, ...item.translations }), {});
70
69
  }
71
70
  const sourceCodeFilePaths = await getSourceCodeFilePaths(siteDir, plugins);
72
- const sourceCodeFilesTranslations = await extractAllSourceCodeFileTranslations(sourceCodeFilePaths, babelOptions);
71
+ const allSourceCodeFilePaths = [
72
+ ...sourceCodeFilePaths,
73
+ ...extraSourceCodeFilePaths,
74
+ ];
75
+ const sourceCodeFilesTranslations = await extractAllSourceCodeFileTranslations(allSourceCodeFilePaths, babelOptions);
73
76
  logSourceCodeFileTranslationsWarnings(sourceCodeFilesTranslations);
74
77
  return toTranslationFileContent(sourceCodeFilesTranslations);
75
78
  }
@@ -77,29 +80,31 @@ exports.extractSiteSourceCodeTranslations = extractSiteSourceCodeTranslations;
77
80
  function logSourceCodeFileTranslationsWarnings(sourceCodeFilesTranslations) {
78
81
  sourceCodeFilesTranslations.forEach(({ sourceCodeFilePath, warnings }) => {
79
82
  if (warnings.length > 0) {
80
- console.warn(`Translation extraction warnings for file path=${sourceCodeFilePath}:\n- ${chalk_1.default.yellow(warnings.join('\n\n- '))}`);
83
+ logger_1.default.warn `Translation extraction warnings for file path=${sourceCodeFilePath}: ${warnings}`;
81
84
  }
82
85
  });
83
86
  }
84
87
  async function extractAllSourceCodeFileTranslations(sourceCodeFilePaths, babelOptions) {
85
- return lodash_1.flatten(await Promise.all(sourceCodeFilePaths.map((sourceFilePath) => extractSourceCodeFileTranslations(sourceFilePath, babelOptions))));
88
+ return Promise.all(sourceCodeFilePaths.flatMap((sourceFilePath) => extractSourceCodeFileTranslations(sourceFilePath, babelOptions)));
86
89
  }
87
90
  exports.extractAllSourceCodeFileTranslations = extractAllSourceCodeFileTranslations;
88
91
  async function extractSourceCodeFileTranslations(sourceCodeFilePath, babelOptions) {
89
92
  try {
90
93
  const code = await fs_extra_1.default.readFile(sourceCodeFilePath, 'utf8');
91
- const ast = core_1.parse(code, {
94
+ const ast = (0, core_1.parse)(code, {
92
95
  ...babelOptions,
93
96
  ast: true,
94
- // filename is important, because babel does not process the same files according to their js/ts extensions
95
- // see see https://twitter.com/NicoloRibaudo/status/1321130735605002243
97
+ // filename is important, because babel does not process the same files
98
+ // according to their js/ts extensions.
99
+ // See https://twitter.com/NicoloRibaudo/status/1321130735605002243
96
100
  filename: sourceCodeFilePath,
97
101
  });
98
- return await extractSourceCodeAstTranslations(ast, sourceCodeFilePath);
102
+ const translations = extractSourceCodeAstTranslations(ast, sourceCodeFilePath);
103
+ return translations;
99
104
  }
100
- catch (e) {
101
- e.message = `Error while attempting to extract Docusaurus translations from source code file at path=${sourceCodeFilePath}\n${e.message}`;
102
- throw e;
105
+ catch (err) {
106
+ logger_1.default.error `Error while attempting to extract Docusaurus translations from source code file at path=${sourceCodeFilePath}.`;
107
+ throw err;
103
108
  }
104
109
  }
105
110
  exports.extractSourceCodeFileTranslations = extractSourceCodeFileTranslations;
@@ -112,108 +117,139 @@ https://github.com/formatjs/formatjs/blob/main/packages/babel-plugin-formatjs/in
112
117
  https://github.com/pugjs/babel-walk
113
118
  */
114
119
  function extractSourceCodeAstTranslations(ast, sourceCodeFilePath) {
115
- function staticTranslateJSXWarningPart() {
116
- return 'Translate content could not be extracted.\nIt has to be a static string and use optional but static props, like <Translate id="my-id" description="my-description">text</Translate>.';
117
- }
118
- function sourceFileWarningPart(node) {
119
- var _a;
120
- return `File=${sourceCodeFilePath} at line=${(_a = node.loc) === null || _a === void 0 ? void 0 : _a.start.line}`;
121
- }
122
- function generateCode(node) {
123
- return generator_1.default(node).code;
120
+ function sourceWarningPart(node) {
121
+ return `File: ${sourceCodeFilePath} at line ${node.loc?.start.line ?? '?'}
122
+ Full code: ${(0, generator_1.default)(node).code}`;
124
123
  }
125
124
  const translations = {};
126
125
  const warnings = [];
127
- // TODO we should check the presence of the correct @docusaurus imports here!
128
- traverse_1.default(ast, {
129
- JSXElement(path) {
130
- if (!path
131
- .get('openingElement')
132
- .get('name')
133
- .isJSXIdentifier({ name: 'Translate' })) {
126
+ let translateComponentName;
127
+ let translateFunctionName;
128
+ // First pass: find import declarations of Translate / translate.
129
+ // If not found, don't process the rest to avoid false positives
130
+ (0, traverse_1.default)(ast, {
131
+ ImportDeclaration(path) {
132
+ if (path.node.importKind === 'type' ||
133
+ path.get('source').node.value !== '@docusaurus/Translate') {
134
134
  return;
135
135
  }
136
- function evaluateJSXProp(propName) {
137
- const attributePath = path
138
- .get('openingElement.attributes')
139
- .find((attr) => attr.isJSXAttribute() &&
140
- attr
141
- .get('name')
142
- .isJSXIdentifier({ name: propName }));
143
- if (attributePath) {
144
- const attributeValue = attributePath.get('value');
145
- const attributeValueEvaluated = attributeValue.isJSXExpressionContainer()
146
- ? attributeValue.get('expression').evaluate()
147
- : attributeValue.evaluate();
148
- if (attributeValueEvaluated.confident &&
149
- typeof attributeValueEvaluated.value === 'string') {
150
- return attributeValueEvaluated.value;
151
- }
152
- else {
153
- warnings.push(`<Translate> prop=${propName} should be a statically evaluable object.\nExample: <Translate id="optional.id" description="optional description">Message</Translate>\nDynamically constructed values are not allowed, because they prevent translations to be extracted.\n${sourceFileWarningPart(path.node)}\n${generateCode(path.node)}`);
136
+ const importSpecifiers = path.get('specifiers');
137
+ const defaultImport = importSpecifiers.find((specifier) => specifier.node.type === 'ImportDefaultSpecifier');
138
+ const callbackImport = importSpecifiers.find((specifier) => specifier.node.type === 'ImportSpecifier' &&
139
+ (specifier.get('imported')
140
+ .node.name === 'translate' ||
141
+ specifier.get('imported')
142
+ .node.value === 'translate'));
143
+ translateComponentName = defaultImport?.get('local').node.name;
144
+ translateFunctionName = callbackImport?.get('local').node.name;
145
+ },
146
+ });
147
+ (0, traverse_1.default)(ast, {
148
+ ...(translateComponentName && {
149
+ JSXElement(path) {
150
+ if (!path
151
+ .get('openingElement')
152
+ .get('name')
153
+ .isJSXIdentifier({ name: translateComponentName })) {
154
+ return;
155
+ }
156
+ function evaluateJSXProp(propName) {
157
+ const attributePath = path
158
+ .get('openingElement.attributes')
159
+ .find((attr) => attr.isJSXAttribute() &&
160
+ attr.get('name').isJSXIdentifier({ name: propName }));
161
+ if (attributePath) {
162
+ const attributeValue = attributePath.get('value');
163
+ const attributeValueEvaluated = attributeValue.isJSXExpressionContainer()
164
+ ? attributeValue.get('expression').evaluate()
165
+ : attributeValue.evaluate();
166
+ if (attributeValueEvaluated.confident &&
167
+ typeof attributeValueEvaluated.value === 'string') {
168
+ return attributeValueEvaluated.value;
169
+ }
170
+ warnings.push(`<Translate> prop=${propName} should be a statically evaluable object.
171
+ Example: <Translate id="optional id" description="optional description">Message</Translate>
172
+ Dynamically constructed values are not allowed, because they prevent translations to be extracted.
173
+ ${sourceWarningPart(path.node)}`);
154
174
  }
175
+ return undefined;
155
176
  }
156
- return undefined;
157
- }
158
- // We only handle the optimistic case where we have a single non-empty content
159
- const singleChildren = path
160
- .get('children')
161
- // Remove empty/useless text nodes that might be around our translation!
162
- // Makes the translation system more reliable to JSX formatting issues
163
- .filter((childrenPath) => !(childrenPath.isJSXText() &&
164
- childrenPath.node.value.replace('\n', '').trim() === ''))
165
- .pop();
166
- if (singleChildren && singleChildren.isJSXText()) {
167
- const message = singleChildren.node.value.trim().replace(/\s+/g, ' ');
168
- const id = evaluateJSXProp('id');
169
- const description = evaluateJSXProp('description');
170
- translations[id !== null && id !== void 0 ? id : message] = {
171
- message,
172
- ...(description && { description }),
173
- };
174
- }
175
- else if (singleChildren &&
176
- singleChildren.isJSXExpressionContainer() &&
177
- singleChildren.get('expression').evaluate().confident) {
178
- const message = singleChildren.get('expression').evaluate().value;
179
177
  const id = evaluateJSXProp('id');
180
178
  const description = evaluateJSXProp('description');
181
- translations[id !== null && id !== void 0 ? id : message] = {
182
- message,
183
- ...(description && { description }),
184
- };
185
- }
186
- else {
187
- warnings.push(`${staticTranslateJSXWarningPart()}\n${sourceFileWarningPart(path.node)}\n${generateCode(path.node)}`);
188
- }
189
- },
190
- CallExpression(path) {
191
- if (!path.get('callee').isIdentifier({ name: 'translate' })) {
192
- return;
193
- }
194
- // console.log('CallExpression', path.node);
195
- const args = path.get('arguments');
196
- if (args.length === 1 || args.length === 2) {
197
- const firstArgPath = args[0];
198
- // evaluation allows translate("x" + "y"); to be considered as translate("xy");
199
- const firstArgEvaluated = firstArgPath.evaluate();
200
- // console.log('firstArgEvaluated', firstArgEvaluated);
201
- if (firstArgEvaluated.confident &&
202
- typeof firstArgEvaluated.value === 'object') {
203
- const { message, id, description } = firstArgEvaluated.value;
204
- translations[id !== null && id !== void 0 ? id : message] = {
179
+ let message;
180
+ const childrenPath = path.get('children');
181
+ // Handle empty content
182
+ if (!childrenPath.length) {
183
+ if (!id) {
184
+ warnings.push(`<Translate> without children must have id prop.
185
+ Example: <Translate id="my-id" />
186
+ ${sourceWarningPart(path.node)}`);
187
+ }
188
+ else {
189
+ translations[id] = {
190
+ message: id,
191
+ ...(description && { description }),
192
+ };
193
+ }
194
+ return;
195
+ }
196
+ // Handle single non-empty content
197
+ const singleChildren = childrenPath
198
+ // Remove empty/useless text nodes that might be around our
199
+ // translation! Makes the translation system more reliable to JSX
200
+ // formatting issues
201
+ .filter((children) => !(children.isJSXText() &&
202
+ children.node.value.replace('\n', '').trim() === ''))
203
+ .pop();
204
+ const isJSXText = singleChildren?.isJSXText();
205
+ const isJSXExpressionContainer = singleChildren?.isJSXExpressionContainer() &&
206
+ singleChildren.get('expression').evaluate().confident;
207
+ if (isJSXText || isJSXExpressionContainer) {
208
+ message = isJSXText
209
+ ? singleChildren.node.value.trim().replace(/\s+/g, ' ')
210
+ : String(singleChildren.get('expression').evaluate().value);
211
+ translations[id ?? message] = {
205
212
  message,
206
213
  ...(description && { description }),
207
214
  };
208
215
  }
209
216
  else {
210
- warnings.push(`translate() first arg should be a statically evaluable object.\nExample: translate({message: "text",id: "optional.id",description: "optional description"}\nDynamically constructed values are not allowed, because they prevent translations to be extracted.\n${sourceFileWarningPart(path.node)}\n${generateCode(path.node)}`);
217
+ warnings.push(`Translate content could not be extracted. It has to be a static string and use optional but static props, like <Translate id="my-id" description="my-description">text</Translate>.
218
+ ${sourceWarningPart(path.node)}`);
211
219
  }
212
- }
213
- else {
214
- warnings.push(`translate() function only takes 1 or 2 args\n${sourceFileWarningPart(path.node)}\n${generateCode(path.node)}`);
215
- }
216
- },
220
+ },
221
+ }),
222
+ ...(translateFunctionName && {
223
+ CallExpression(path) {
224
+ if (!path.get('callee').isIdentifier({ name: translateFunctionName })) {
225
+ return;
226
+ }
227
+ const args = path.get('arguments');
228
+ if (args.length === 1 || args.length === 2) {
229
+ const firstArgPath = args[0];
230
+ // translate("x" + "y"); => translate("xy");
231
+ const firstArgEvaluated = firstArgPath.evaluate();
232
+ if (firstArgEvaluated.confident &&
233
+ typeof firstArgEvaluated.value === 'object') {
234
+ const { message, id, description } = firstArgEvaluated.value;
235
+ translations[String(id ?? message)] = {
236
+ message: String(message ?? id),
237
+ ...(Boolean(description) && { description: String(description) }),
238
+ };
239
+ }
240
+ else {
241
+ warnings.push(`translate() first arg should be a statically evaluable object.
242
+ Example: translate({message: "text",id: "optional.id",description: "optional description"}
243
+ Dynamically constructed values are not allowed, because they prevent translations to be extracted.
244
+ ${sourceWarningPart(path.node)}`);
245
+ }
246
+ }
247
+ else {
248
+ warnings.push(`translate() function only takes 1 or 2 args
249
+ ${sourceWarningPart(path.node)}`);
250
+ }
251
+ },
252
+ }),
217
253
  });
218
254
  return { sourceCodeFilePath, translations, warnings };
219
255
  }
@@ -1,4 +1,10 @@
1
- import { RouteConfig } from '@docusaurus/types';
2
- import globby from 'globby';
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 { Globby } from '@docusaurus/utils';
8
+ import type { RouteConfig } from '@docusaurus/types';
3
9
  export declare function getAllFinalRoutes(routeConfig: RouteConfig[]): RouteConfig[];
4
- export declare function safeGlobby(patterns: string[], options?: globby.GlobbyOptions): Promise<string[]>;
10
+ export declare function safeGlobby(patterns: string[], options?: Globby.GlobbyOptions): Promise<string[]>;