@docusaurus/core 3.3.2 → 3.5.0

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 (96) hide show
  1. package/bin/docusaurus.mjs +13 -12
  2. package/lib/babel/preset.js +1 -1
  3. package/lib/client/App.d.ts +0 -2
  4. package/lib/client/BaseUrlIssueBanner/index.d.ts +0 -1
  5. package/lib/client/BrokenLinksContext.d.ts +0 -1
  6. package/lib/client/SiteMetadataDefaults.d.ts +0 -1
  7. package/lib/client/clientEntry.js +7 -3
  8. package/lib/client/exports/BrowserOnly.d.ts +0 -2
  9. package/lib/client/exports/ErrorBoundary.d.ts +0 -1
  10. package/lib/client/exports/Head.d.ts +0 -2
  11. package/lib/client/exports/Interpolate.d.ts +0 -1
  12. package/lib/client/exports/Link.d.ts +0 -1
  13. package/lib/client/exports/Link.js +26 -5
  14. package/lib/client/exports/Translate.d.ts +0 -2
  15. package/lib/client/exports/useBaseUrl.d.ts +8 -1
  16. package/lib/client/exports/useBaseUrl.js +11 -3
  17. package/lib/client/exports/useBrokenLinks.d.ts +0 -1
  18. package/lib/client/hasHydratedDataAttribute.d.ts +0 -1
  19. package/lib/client/theme-fallback/Error/index.d.ts +0 -2
  20. package/lib/client/theme-fallback/Layout/index.d.ts +0 -2
  21. package/lib/client/theme-fallback/Loading/index.d.ts +0 -1
  22. package/lib/client/theme-fallback/NotFound/index.d.ts +0 -1
  23. package/lib/client/theme-fallback/Root/index.d.ts +0 -2
  24. package/lib/client/theme-fallback/SiteMetadata/index.d.ts +0 -1
  25. package/lib/commands/build.js +36 -23
  26. package/lib/commands/clear.js +1 -2
  27. package/lib/commands/deploy.js +1 -2
  28. package/lib/commands/external.js +1 -2
  29. package/lib/commands/serve.js +16 -6
  30. package/lib/commands/start/start.js +1 -2
  31. package/lib/commands/start/utils.d.ts +3 -2
  32. package/lib/commands/start/utils.js +9 -5
  33. package/lib/commands/start/watcher.js +5 -6
  34. package/lib/commands/start/webpack.js +4 -5
  35. package/lib/commands/swizzle/actions.js +4 -4
  36. package/lib/commands/swizzle/common.js +7 -7
  37. package/lib/commands/swizzle/components.js +5 -6
  38. package/lib/commands/swizzle/config.js +2 -3
  39. package/lib/commands/swizzle/context.js +19 -8
  40. package/lib/commands/swizzle/index.js +1 -2
  41. package/lib/commands/swizzle/prompts.js +4 -5
  42. package/lib/commands/swizzle/tables.js +2 -3
  43. package/lib/commands/swizzle/themes.js +5 -6
  44. package/lib/commands/writeHeadingIds.js +1 -2
  45. package/lib/commands/writeTranslations.js +1 -2
  46. package/lib/server/brokenLinks.js +10 -3
  47. package/lib/server/clientModules.js +1 -2
  48. package/lib/server/codegen/codegen.d.ts +2 -1
  49. package/lib/server/codegen/codegen.js +5 -2
  50. package/lib/server/codegen/codegenRoutes.d.ts +1 -0
  51. package/lib/server/codegen/codegenRoutes.js +22 -9
  52. package/lib/server/config.js +1 -2
  53. package/lib/server/configValidation.d.ts +4 -1
  54. package/lib/server/configValidation.js +30 -2
  55. package/lib/server/getHostPort.js +1 -2
  56. package/lib/server/htmlTags.d.ts +5 -2
  57. package/lib/server/htmlTags.js +16 -8
  58. package/lib/server/i18n.js +39 -11
  59. package/lib/server/plugins/actions.js +1 -2
  60. package/lib/server/plugins/configs.js +1 -2
  61. package/lib/server/plugins/init.d.ts +11 -0
  62. package/lib/server/plugins/init.js +42 -7
  63. package/lib/server/plugins/moduleShorthand.d.ts +0 -1
  64. package/lib/server/plugins/moduleShorthand.js +2 -3
  65. package/lib/server/plugins/pluginIds.js +1 -2
  66. package/lib/server/plugins/plugins.js +2 -3
  67. package/lib/server/plugins/pluginsUtils.js +7 -8
  68. package/lib/server/plugins/presets.js +1 -2
  69. package/lib/server/plugins/routeConfig.js +2 -3
  70. package/lib/server/plugins/synthetic.js +2 -3
  71. package/lib/server/routes.js +2 -3
  72. package/lib/server/site.js +17 -10
  73. package/lib/server/siteMetadata.js +3 -4
  74. package/lib/server/storage.d.ts +13 -0
  75. package/lib/server/storage.js +35 -0
  76. package/lib/server/translations/translations.js +9 -10
  77. package/lib/server/translations/translationsExtractor.js +4 -5
  78. package/lib/server/utils.js +1 -2
  79. package/lib/ssg.d.ts +4 -1
  80. package/lib/ssg.js +10 -3
  81. package/lib/templates/templates.d.ts +3 -0
  82. package/lib/templates/templates.js +27 -3
  83. package/lib/webpack/aliases/index.js +4 -5
  84. package/lib/webpack/base.js +4 -4
  85. package/lib/webpack/client.js +13 -22
  86. package/lib/webpack/configure.d.ts +25 -0
  87. package/lib/webpack/configure.js +99 -0
  88. package/lib/webpack/minification.js +1 -2
  89. package/lib/webpack/plugins/ForceTerminatePlugin.d.ts +10 -0
  90. package/lib/webpack/plugins/ForceTerminatePlugin.js +25 -0
  91. package/lib/webpack/plugins/StaticDirectoriesCopyPlugin.d.ts +11 -0
  92. package/lib/webpack/plugins/StaticDirectoriesCopyPlugin.js +38 -0
  93. package/lib/webpack/server.js +1 -29
  94. package/lib/webpack/utils.d.ts +1 -24
  95. package/lib/webpack/utils.js +8 -87
  96. package/package.json +10 -10
@@ -6,7 +6,8 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.createReloadableSite = exports.createOpenUrlContext = void 0;
9
+ exports.createOpenUrlContext = createOpenUrlContext;
10
+ exports.createReloadableSite = createReloadableSite;
10
11
  const tslib_1 = require("tslib");
11
12
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
13
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
@@ -23,13 +24,16 @@ async function createOpenUrlContext({ cliOptions, }) {
23
24
  if (port === null) {
24
25
  return process.exit();
25
26
  }
26
- const getOpenUrl = ({ baseUrl }) => {
27
+ const getOpenUrl = ({ baseUrl, router }) => {
27
28
  const urls = (0, WebpackDevServerUtils_1.prepareUrls)(protocol, host, port);
28
- return (0, utils_1.normalizeUrl)([urls.localUrlForBrowser, baseUrl]);
29
+ return (0, utils_1.normalizeUrl)([
30
+ urls.localUrlForBrowser,
31
+ router === 'hash' ? '/#/' : '',
32
+ baseUrl,
33
+ ]);
29
34
  };
30
35
  return { host, port, getOpenUrl };
31
36
  }
32
- exports.createOpenUrlContext = createOpenUrlContext;
33
37
  async function createLoadSiteParams({ siteDirParam, cliOptions, }) {
34
38
  const siteDir = await fs_extra_1.default.realpath(siteDirParam);
35
39
  return {
@@ -47,6 +51,7 @@ async function createReloadableSite(startParams) {
47
51
  const get = () => site;
48
52
  const getOpenUrl = () => openUrlContext.getOpenUrl({
49
53
  baseUrl: site.props.baseUrl,
54
+ router: site.props.siteConfig.future.experimental_router,
50
55
  });
51
56
  const printOpenUrlMessage = () => {
52
57
  logger_1.default.success `Docusaurus website is running at: url=${getOpenUrl()}`;
@@ -84,4 +89,3 @@ async function createReloadableSite(startParams) {
84
89
  };
85
90
  return { get, getOpenUrl, reload, reloadPlugin, openUrlContext };
86
91
  }
87
- exports.createReloadableSite = createReloadableSite;
@@ -6,7 +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.setupSiteFileWatchers = exports.getPluginPathsToWatch = exports.getSitePathsToWatch = exports.watch = exports.createPollingOptions = void 0;
9
+ exports.createPollingOptions = createPollingOptions;
10
+ exports.watch = watch;
11
+ exports.getSitePathsToWatch = getSitePathsToWatch;
12
+ exports.getPluginPathsToWatch = getPluginPathsToWatch;
13
+ exports.setupSiteFileWatchers = setupSiteFileWatchers;
10
14
  const tslib_1 = require("tslib");
11
15
  const path_1 = tslib_1.__importDefault(require("path"));
12
16
  const chokidar_1 = tslib_1.__importDefault(require("chokidar"));
@@ -19,7 +23,6 @@ function createPollingOptions(cliOptions) {
19
23
  : undefined,
20
24
  };
21
25
  }
22
- exports.createPollingOptions = createPollingOptions;
23
26
  /**
24
27
  * Watch file system paths for changes and emit events
25
28
  * Returns an async handle to stop watching
@@ -34,7 +37,6 @@ function watch(params, callback) {
34
37
  fsWatcher.on('all', (name, eventPath) => callback({ name, path: eventPath }));
35
38
  return () => fsWatcher.close();
36
39
  }
37
- exports.watch = watch;
38
40
  function getSitePathsToWatch({ props }) {
39
41
  return [
40
42
  // TODO we should also watch all imported modules!
@@ -43,7 +45,6 @@ function getSitePathsToWatch({ props }) {
43
45
  props.localizationDir,
44
46
  ];
45
47
  }
46
- exports.getSitePathsToWatch = getSitePathsToWatch;
47
48
  function getPluginPathsToWatch({ siteDir, plugin, }) {
48
49
  const normalizeToSiteDir = (filepath) => {
49
50
  if (filepath && path_1.default.isAbsolute(filepath)) {
@@ -55,7 +56,6 @@ function getPluginPathsToWatch({ siteDir, plugin, }) {
55
56
  .filter(Boolean)
56
57
  .map(normalizeToSiteDir);
57
58
  }
58
- exports.getPluginPathsToWatch = getPluginPathsToWatch;
59
59
  function setupSiteFileWatchers({ props, cliOptions, }, callback) {
60
60
  const { siteDir } = props;
61
61
  const pollingOptions = createPollingOptions(cliOptions);
@@ -75,4 +75,3 @@ function setupSiteFileWatchers({ props, cliOptions, }, callback) {
75
75
  }, (event) => callback({ plugin, event }));
76
76
  });
77
77
  }
78
- exports.setupSiteFileWatchers = setupSiteFileWatchers;
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.createWebpackDevServer = void 0;
9
+ exports.createWebpackDevServer = createWebpackDevServer;
10
10
  const tslib_1 = require("tslib");
11
11
  const path_1 = tslib_1.__importDefault(require("path"));
12
12
  const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
@@ -16,6 +16,7 @@ const webpack_dev_server_1 = tslib_1.__importDefault(require("webpack-dev-server
16
16
  const evalSourceMapMiddleware_1 = tslib_1.__importDefault(require("react-dev-utils/evalSourceMapMiddleware"));
17
17
  const watcher_1 = require("./watcher");
18
18
  const utils_1 = require("../../webpack/utils");
19
+ const configure_1 = require("../../webpack/configure");
19
20
  const client_1 = require("../../webpack/client");
20
21
  // E2E_TEST=true docusaurus start
21
22
  // Makes "docusaurus start" exit immediately on success/error, for E2E test
@@ -60,7 +61,7 @@ async function createDevServerConfig({ cliOptions, props, host, port, }) {
60
61
  'access-control-allow-origin': '*',
61
62
  },
62
63
  devMiddleware: {
63
- publicPath: baseUrl,
64
+ publicPath: siteConfig.future.experimental_router === 'hash' ? 'auto' : baseUrl,
64
65
  // Reduce log verbosity, see https://github.com/facebook/docusaurus/pull/5420#issuecomment-906613105
65
66
  stats: 'summary',
66
67
  },
@@ -103,8 +104,7 @@ async function getStartClientConfig({ props, minify, poll, }) {
103
104
  minify,
104
105
  poll,
105
106
  });
106
- config = (0, utils_1.executePluginsConfigurePostCss)({ plugins, config });
107
- config = (0, utils_1.executePluginsConfigureWebpack)({
107
+ config = (0, configure_1.executePluginsConfigureWebpack)({
108
108
  plugins,
109
109
  config,
110
110
  isServer: false,
@@ -130,4 +130,3 @@ async function createWebpackDevServer({ props, cliOptions, openUrlContext, }) {
130
130
  const devServerConfig = (0, webpack_merge_1.default)([defaultDevServerConfig, config.devServer].filter(Boolean));
131
131
  return new webpack_dev_server_1.default(devServerConfig, compiler);
132
132
  }
133
- exports.createWebpackDevServer = createWebpackDevServer;
@@ -6,7 +6,10 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.wrap = exports.eject = exports.getAction = exports.SwizzleActions = void 0;
9
+ exports.SwizzleActions = void 0;
10
+ exports.getAction = getAction;
11
+ exports.eject = eject;
12
+ exports.wrap = wrap;
10
13
  const tslib_1 = require("tslib");
11
14
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
15
  const path_1 = tslib_1.__importDefault(require("path"));
@@ -24,7 +27,6 @@ async function getAction(componentConfig, options) {
24
27
  }
25
28
  return (0, prompts_1.askSwizzleAction)(componentConfig);
26
29
  }
27
- exports.getAction = getAction;
28
30
  async function isDir(dirPath) {
29
31
  return ((await fs_extra_1.default.pathExists(dirPath)) && (await fs_extra_1.default.stat(dirPath)).isDirectory());
30
32
  }
@@ -65,7 +67,6 @@ async function eject({ siteDir, themePath, componentName, typescript, }) {
65
67
  }));
66
68
  return { createdFiles };
67
69
  }
68
- exports.eject = eject;
69
70
  async function wrap({ siteDir, themePath, componentName: themeComponentName, typescript, importType = 'original', }) {
70
71
  const isDirectory = await isDir(path_1.default.join(themePath, themeComponentName));
71
72
  // Top/Parent/ComponentName => ComponentName
@@ -104,4 +105,3 @@ export default function ${wrapperComponentName}(props) {
104
105
  await fs_extra_1.default.outputFile(toPath, content);
105
106
  return { createdFiles: [toPath] };
106
107
  }
107
- exports.wrap = wrap;
@@ -6,7 +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.findClosestValue = exports.findStringIgnoringCase = exports.normalizeOptions = exports.actionStatusSuffix = exports.actionStatusColor = exports.actionStatusLabel = exports.PartiallySafeHint = exports.SwizzleActionsStatuses = exports.SwizzleActions = void 0;
9
+ exports.PartiallySafeHint = exports.SwizzleActionsStatuses = exports.SwizzleActions = void 0;
10
+ exports.actionStatusLabel = actionStatusLabel;
11
+ exports.actionStatusColor = actionStatusColor;
12
+ exports.actionStatusSuffix = actionStatusSuffix;
13
+ exports.normalizeOptions = normalizeOptions;
14
+ exports.findStringIgnoringCase = findStringIgnoringCase;
15
+ exports.findClosestValue = findClosestValue;
10
16
  const tslib_1 = require("tslib");
11
17
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
12
18
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
@@ -21,7 +27,6 @@ exports.PartiallySafeHint = logger_1.default.red('*');
21
27
  function actionStatusLabel(status) {
22
28
  return lodash_1.default.capitalize(status);
23
29
  }
24
- exports.actionStatusLabel = actionStatusLabel;
25
30
  const SwizzleActionStatusColors = {
26
31
  safe: logger_1.default.green,
27
32
  unsafe: logger_1.default.yellow,
@@ -31,11 +36,9 @@ function actionStatusColor(status, str) {
31
36
  const colorFn = SwizzleActionStatusColors[status];
32
37
  return colorFn(str);
33
38
  }
34
- exports.actionStatusColor = actionStatusColor;
35
39
  function actionStatusSuffix(status, options = {}) {
36
40
  return ` (${actionStatusColor(status, actionStatusLabel(status))}${options.partiallySafe ? exports.PartiallySafeHint : ''})`;
37
41
  }
38
- exports.actionStatusSuffix = actionStatusSuffix;
39
42
  function normalizeOptions(options) {
40
43
  return {
41
44
  typescript: options.typescript ?? false,
@@ -47,12 +50,9 @@ function normalizeOptions(options) {
47
50
  config: options.config ?? undefined,
48
51
  };
49
52
  }
50
- exports.normalizeOptions = normalizeOptions;
51
53
  function findStringIgnoringCase(str, values) {
52
54
  return values.find((v) => v.toLowerCase() === str.toLowerCase());
53
55
  }
54
- exports.findStringIgnoringCase = findStringIgnoringCase;
55
56
  function findClosestValue(str, values, maxLevenshtein = 3) {
56
57
  return values.find((v) => (0, leven_1.default)(v, str) <= maxLevenshtein);
57
58
  }
58
- exports.findClosestValue = findClosestValue;
@@ -6,7 +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.getComponentName = exports.getThemeComponents = exports.listComponentNames = exports.readComponentNames = exports.getMissingIntermediateComponentFolderNames = void 0;
9
+ exports.getMissingIntermediateComponentFolderNames = getMissingIntermediateComponentFolderNames;
10
+ exports.readComponentNames = readComponentNames;
11
+ exports.listComponentNames = listComponentNames;
12
+ exports.getThemeComponents = getThemeComponents;
13
+ exports.getComponentName = getComponentName;
10
14
  const tslib_1 = require("tslib");
11
15
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
16
  const path_1 = tslib_1.__importDefault(require("path"));
@@ -37,7 +41,6 @@ function getMissingIntermediateComponentFolderNames(componentNames) {
37
41
  const expandedComponentNames = lodash_1.default.uniq(componentNames.flatMap((componentName) => getAllIntermediatePaths(componentName)));
38
42
  return lodash_1.default.difference(expandedComponentNames, componentNames);
39
43
  }
40
- exports.getMissingIntermediateComponentFolderNames = getMissingIntermediateComponentFolderNames;
41
44
  const skipReadDirNames = ['__test__', '__tests__', '__mocks__', '__fixtures__'];
42
45
  async function readComponentNames(themePath) {
43
46
  if (!(await fs_extra_1.default.pathExists(themePath))) {
@@ -71,7 +74,6 @@ async function readComponentNames(themePath) {
71
74
  const componentNames = componentFiles.map((f) => f.componentName);
72
75
  return sortComponentNames(componentNames);
73
76
  }
74
- exports.readComponentNames = readComponentNames;
75
77
  function listComponentNames(themeComponents) {
76
78
  if (themeComponents.all.length === 0) {
77
79
  return 'No component to swizzle.';
@@ -81,7 +83,6 @@ function listComponentNames(themeComponents) {
81
83
  ${(0, tables_1.helpTables)()}
82
84
  `;
83
85
  }
84
- exports.listComponentNames = listComponentNames;
85
86
  async function getThemeComponents({ themeName, themePath, swizzleConfig, }) {
86
87
  const FallbackSwizzleActionStatus = 'unsafe';
87
88
  const FallbackSwizzleComponentDescription = 'N/A';
@@ -151,7 +152,6 @@ async function getThemeComponents({ themeName, themePath, swizzleConfig, }) {
151
152
  hasAllSafeAction,
152
153
  };
153
154
  }
154
- exports.getThemeComponents = getThemeComponents;
155
155
  // Returns a valid value if recovering is possible
156
156
  function handleInvalidComponentNameParam({ componentNameParam, themeComponents, }) {
157
157
  // Trying to recover invalid value
@@ -198,4 +198,3 @@ async function getComponentName({ componentNameParam, themeComponents, list, })
198
198
  : await (0, prompts_1.askComponentName)(themeComponents);
199
199
  return componentName;
200
200
  }
201
- exports.getComponentName = getComponentName;
@@ -6,7 +6,8 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getThemeSwizzleConfig = exports.normalizeSwizzleConfig = void 0;
9
+ exports.normalizeSwizzleConfig = normalizeSwizzleConfig;
10
+ exports.getThemeSwizzleConfig = getThemeSwizzleConfig;
10
11
  const tslib_1 = require("tslib");
11
12
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
13
  const utils_validation_1 = require("@docusaurus/utils-validation");
@@ -63,7 +64,6 @@ function normalizeSwizzleConfig(unsafeSwizzleConfig) {
63
64
  });
64
65
  return swizzleConfig;
65
66
  }
66
- exports.normalizeSwizzleConfig = normalizeSwizzleConfig;
67
67
  const FallbackSwizzleConfig = {
68
68
  components: {},
69
69
  };
@@ -81,4 +81,3 @@ function getThemeSwizzleConfig(themeName, plugins) {
81
81
  }
82
82
  return FallbackSwizzleConfig;
83
83
  }
84
- exports.getThemeSwizzleConfig = getThemeSwizzleConfig;
@@ -6,19 +6,30 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.initSwizzleContext = void 0;
9
+ exports.initSwizzleContext = initSwizzleContext;
10
10
  const site_1 = require("../../server/site");
11
11
  const init_1 = require("../../server/plugins/init");
12
12
  const configs_1 = require("../../server/plugins/configs");
13
+ async function getSwizzlePlugins(context) {
14
+ const pluginConfigs = await (0, configs_1.loadPluginConfigs)(context);
15
+ const pluginConfigInitResults = await (0, init_1.initPluginsConfigs)(context, pluginConfigs);
16
+ return pluginConfigInitResults.flatMap((initResult) => {
17
+ // Ignore self-disabling plugins returning null
18
+ if (initResult.plugin === null) {
19
+ return [];
20
+ }
21
+ return [
22
+ // TODO this is a bit confusing, need refactor
23
+ {
24
+ plugin: initResult.config,
25
+ instance: initResult.plugin,
26
+ },
27
+ ];
28
+ });
29
+ }
13
30
  async function initSwizzleContext(siteDir, options) {
14
31
  const context = await (0, site_1.loadContext)({ siteDir, config: options.config });
15
- const plugins = await (0, init_1.initPlugins)(context);
16
- const pluginConfigs = await (0, configs_1.loadPluginConfigs)(context);
17
32
  return {
18
- plugins: plugins.map((plugin, pluginIndex) => ({
19
- plugin: pluginConfigs[pluginIndex],
20
- instance: plugin,
21
- })),
33
+ plugins: await getSwizzlePlugins(context),
22
34
  };
23
35
  }
24
- exports.initSwizzleContext = initSwizzleContext;
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.swizzle = void 0;
9
+ exports.swizzle = swizzle;
10
10
  const tslib_1 = require("tslib");
11
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
12
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
@@ -145,4 +145,3 @@ Ejected name=${componentName} from name=${themeName} to path=${result.createdFil
145
145
  await executeAction();
146
146
  return process.exit(0);
147
147
  }
148
- exports.swizzle = swizzle;
@@ -6,7 +6,10 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.askSwizzleAction = exports.askSwizzleDangerousComponent = exports.askComponentName = exports.askThemeName = void 0;
9
+ exports.askThemeName = askThemeName;
10
+ exports.askComponentName = askComponentName;
11
+ exports.askSwizzleDangerousComponent = askSwizzleDangerousComponent;
12
+ exports.askSwizzleAction = askSwizzleAction;
10
13
  const tslib_1 = require("tslib");
11
14
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
15
  const prompts_1 = tslib_1.__importDefault(require("prompts"));
@@ -26,7 +29,6 @@ async function askThemeName(themeNames) {
26
29
  }
27
30
  return themeName;
28
31
  }
29
- exports.askThemeName = askThemeName;
30
32
  async function askComponentName(themeComponents) {
31
33
  function formatComponentName(componentName) {
32
34
  const anySafe = themeComponents.hasAnySafeAction(componentName);
@@ -64,7 +66,6 @@ ${common_1.PartiallySafeHint} = not safe for all swizzle actions
64
66
  }
65
67
  return componentName;
66
68
  }
67
- exports.askComponentName = askComponentName;
68
69
  async function askSwizzleDangerousComponent() {
69
70
  const { switchToDanger } = (await (0, prompts_1.default)({
70
71
  type: 'select',
@@ -84,7 +85,6 @@ async function askSwizzleDangerousComponent() {
84
85
  }
85
86
  return !!switchToDanger;
86
87
  }
87
- exports.askSwizzleDangerousComponent = askSwizzleDangerousComponent;
88
88
  async function askSwizzleAction(componentConfig) {
89
89
  const { action } = (await (0, prompts_1.default)({
90
90
  type: 'select',
@@ -107,4 +107,3 @@ async function askSwizzleAction(componentConfig) {
107
107
  }
108
108
  return action;
109
109
  }
110
- exports.askSwizzleAction = askSwizzleAction;
@@ -6,7 +6,8 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.themeComponentsTable = exports.helpTables = void 0;
9
+ exports.helpTables = helpTables;
10
+ exports.themeComponentsTable = themeComponentsTable;
10
11
  const tslib_1 = require("tslib");
11
12
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
12
13
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
@@ -89,7 +90,6 @@ ${statusTable()}
89
90
 
90
91
  ${logger_1.default.bold('Swizzle guide')}: https://docusaurus.io/docs/swizzling`;
91
92
  }
92
- exports.helpTables = helpTables;
93
93
  function themeComponentsTable(themeComponents) {
94
94
  const table = new cli_table3_1.default({
95
95
  head: [
@@ -110,4 +110,3 @@ function themeComponentsTable(themeComponents) {
110
110
  ${table.toString()}
111
111
  `;
112
112
  }
113
- exports.themeComponentsTable = themeComponentsTable;
@@ -6,7 +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.getThemePath = exports.getThemeName = exports.getThemeNames = exports.getPluginByThemeName = exports.pluginToThemeName = void 0;
9
+ exports.pluginToThemeName = pluginToThemeName;
10
+ exports.getPluginByThemeName = getPluginByThemeName;
11
+ exports.getThemeNames = getThemeNames;
12
+ exports.getThemeName = getThemeName;
13
+ exports.getThemePath = getThemePath;
10
14
  const tslib_1 = require("tslib");
11
15
  const path_1 = tslib_1.__importDefault(require("path"));
12
16
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
@@ -20,7 +24,6 @@ function pluginToThemeName(plugin) {
20
24
  }
21
25
  return undefined;
22
26
  }
23
- exports.pluginToThemeName = pluginToThemeName;
24
27
  function getPluginByThemeName(plugins, themeName) {
25
28
  const plugin = plugins.find((p) => pluginToThemeName(p) === themeName);
26
29
  if (!plugin) {
@@ -28,7 +31,6 @@ function getPluginByThemeName(plugins, themeName) {
28
31
  }
29
32
  return plugin;
30
33
  }
31
- exports.getPluginByThemeName = getPluginByThemeName;
32
34
  function getThemeNames(plugins) {
33
35
  const themeNames = lodash_1.default.uniq(
34
36
  // The fact that getThemePath is attached to the plugin instance makes
@@ -46,7 +48,6 @@ function getThemeNames(plugins) {
46
48
  (t) => t.includes('@docusaurus'),
47
49
  ], ['desc', 'desc', 'desc']);
48
50
  }
49
- exports.getThemeNames = getThemeNames;
50
51
  // Returns a valid value if recovering is possible
51
52
  function handleInvalidThemeName({ themeNameParam, themeNames, }) {
52
53
  // Trying to recover invalid value
@@ -84,7 +85,6 @@ async function getThemeName({ themeNameParam, themeNames, list, }) {
84
85
  ? validateThemeName({ themeNameParam, themeNames })
85
86
  : (0, prompts_1.askThemeName)(themeNames);
86
87
  }
87
- exports.getThemeName = getThemeName;
88
88
  function getThemePath({ plugins, themeName, typescript, }) {
89
89
  const pluginInstance = getPluginByThemeName(plugins, themeName);
90
90
  const themePath = typescript
@@ -103,4 +103,3 @@ function getThemePath({ plugins, themeName, typescript, }) {
103
103
  }
104
104
  return themePath;
105
105
  }
106
- exports.getThemePath = getThemePath;
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.writeHeadingIds = void 0;
9
+ exports.writeHeadingIds = writeHeadingIds;
10
10
  const tslib_1 = require("tslib");
11
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
12
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
@@ -48,4 +48,3 @@ async function writeHeadingIds(siteDirParam = '.', files = [], options = {}) {
48
48
  logger_1.default.warn `number=${markdownFiles.length} Markdown files already have explicit heading IDs. If you intend to overwrite the existing heading IDs, use the code=${'--overwrite'} option.`;
49
49
  }
50
50
  }
51
- exports.writeHeadingIds = writeHeadingIds;
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.writeTranslations = void 0;
9
+ exports.writeTranslations = writeTranslations;
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"));
@@ -82,4 +82,3 @@ Available locales are: ${context.i18n.locales.join(',')}.`);
82
82
  await writePluginTranslationFiles({ localizationDir, plugin, options });
83
83
  }));
84
84
  }
85
- exports.writeTranslations = writeTranslations;
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.handleBrokenLinks = void 0;
9
+ exports.handleBrokenLinks = handleBrokenLinks;
10
10
  const tslib_1 = require("tslib");
11
11
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
12
12
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
@@ -78,7 +78,15 @@ function createBrokenLinksHelper({ collectedLinks, routes, }) {
78
78
  if (hash === '') {
79
79
  return false;
80
80
  }
81
- const targetPage = collectedLinks.get(pathname) || collectedLinks.get(decodeURI(pathname));
81
+ const targetPage = collectedLinks.get(pathname) ??
82
+ collectedLinks.get(decodeURI(pathname)) ??
83
+ // The broken link checker should not care about a trailing slash
84
+ // Those are already covered by the broken pathname checker
85
+ // See https://github.com/facebook/docusaurus/issues/10116
86
+ collectedLinks.get((0, utils_common_1.addTrailingSlash)(pathname)) ??
87
+ collectedLinks.get((0, utils_common_1.addTrailingSlash)(decodeURI(pathname))) ??
88
+ collectedLinks.get((0, utils_common_1.removeTrailingSlash)(pathname)) ??
89
+ collectedLinks.get((0, utils_common_1.removeTrailingSlash)(decodeURI(pathname)));
82
90
  // link with anchor to a page that does not exist (or did not collect any
83
91
  // link/anchor) is considered as a broken anchor
84
92
  if (!targetPage) {
@@ -273,4 +281,3 @@ async function handleBrokenLinks({ collectedLinks, onBrokenLinks, onBrokenAnchor
273
281
  });
274
282
  reportBrokenLinks({ brokenLinks, onBrokenLinks, onBrokenAnchors });
275
283
  }
276
- exports.handleBrokenLinks = handleBrokenLinks;
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getAllClientModules = void 0;
9
+ exports.getAllClientModules = getAllClientModules;
10
10
  const tslib_1 = require("tslib");
11
11
  const path_1 = tslib_1.__importDefault(require("path"));
12
12
  /**
@@ -17,4 +17,3 @@ function getAllClientModules(plugins) {
17
17
  return plugins.flatMap((plugin) => plugin.getClientModules?.().map((p) => path_1.default.resolve(plugin.path, p)) ??
18
18
  []);
19
19
  }
20
- exports.getAllClientModules = getAllClientModules;
@@ -4,7 +4,7 @@
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 { CodeTranslations, DocusaurusConfig, GlobalData, I18n, PluginRouteConfig, SiteMetadata } from '@docusaurus/types';
7
+ import type { CodeTranslations, DocusaurusConfig, GlobalData, I18n, PluginRouteConfig, SiteMetadata, SiteStorage } from '@docusaurus/types';
8
8
  type CodegenParams = {
9
9
  generatedFilesDir: string;
10
10
  siteConfig: DocusaurusConfig;
@@ -14,6 +14,7 @@ type CodegenParams = {
14
14
  i18n: I18n;
15
15
  codeTranslations: CodeTranslations;
16
16
  siteMetadata: SiteMetadata;
17
+ siteStorage: SiteStorage;
17
18
  routes: PluginRouteConfig[];
18
19
  };
19
20
  export declare function generateSiteFiles(params: CodegenParams): Promise<void>;
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.generateSiteFiles = void 0;
9
+ exports.generateSiteFiles = generateSiteFiles;
10
10
  const utils_1 = require("@docusaurus/utils");
11
11
  const codegenRoutes_1 = require("./codegenRoutes");
12
12
  function genWarning({ generatedFilesDir }) {
@@ -50,6 +50,9 @@ function genCodeTranslations({ generatedFilesDir, codeTranslations, }) {
50
50
  function genSiteMetadata({ generatedFilesDir, siteMetadata, }) {
51
51
  return (0, utils_1.generate)(generatedFilesDir, 'site-metadata.json', JSON.stringify(siteMetadata, null, 2));
52
52
  }
53
+ function genSiteStorage({ generatedFilesDir, siteStorage, }) {
54
+ return (0, utils_1.generate)(generatedFilesDir, 'site-storage.json', JSON.stringify(siteStorage, null, 2));
55
+ }
53
56
  async function generateSiteFiles(params) {
54
57
  await Promise.all([
55
58
  genWarning(params),
@@ -58,8 +61,8 @@ async function generateSiteFiles(params) {
58
61
  (0, codegenRoutes_1.generateRouteFiles)(params),
59
62
  genGlobalData(params),
60
63
  genSiteMetadata(params),
64
+ genSiteStorage(params),
61
65
  genI18n(params),
62
66
  genCodeTranslations(params),
63
67
  ]);
64
68
  }
65
- exports.generateSiteFiles = generateSiteFiles;
@@ -45,5 +45,6 @@ type GenerateRouteFilesParams = {
45
45
  routes: PluginRouteConfig[];
46
46
  baseUrl: string;
47
47
  };
48
+ export declare function generateRoutePropFilename(route: RouteConfig): string;
48
49
  export declare function generateRouteFiles({ generatedFilesDir, routes: initialRoutes, }: GenerateRouteFilesParams): Promise<void>;
49
50
  export {};