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

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 (55) hide show
  1. package/lib/babel/preset.js +2 -2
  2. package/lib/choosePort.js +4 -4
  3. package/lib/client/client-lifecycles-dispatcher.js +3 -3
  4. package/lib/client/docusaurus.js +2 -5
  5. package/lib/client/exports/ErrorBoundary.js +4 -5
  6. package/lib/client/exports/Interpolate.js +2 -2
  7. package/lib/client/exports/Link.js +2 -3
  8. package/lib/client/exports/Translate.js +1 -2
  9. package/lib/commands/build.js +12 -14
  10. package/lib/commands/clear.js +3 -3
  11. package/lib/commands/commandUtils.js +1 -1
  12. package/lib/commands/deploy.js +6 -6
  13. package/lib/commands/external.js +1 -1
  14. package/lib/commands/serve.js +7 -8
  15. package/lib/commands/start.js +13 -14
  16. package/lib/commands/swizzle/actions.js +4 -4
  17. package/lib/commands/swizzle/common.js +8 -9
  18. package/lib/commands/swizzle/components.js +7 -10
  19. package/lib/commands/swizzle/config.js +7 -4
  20. package/lib/commands/swizzle/context.js +1 -1
  21. package/lib/commands/swizzle/index.js +1 -1
  22. package/lib/commands/swizzle/prompts.js +2 -2
  23. package/lib/commands/swizzle/tables.js +3 -3
  24. package/lib/commands/swizzle/themes.js +6 -8
  25. package/lib/commands/writeHeadingIds.js +5 -5
  26. package/lib/commands/writeTranslations.js +4 -6
  27. package/lib/index.js +9 -9
  28. package/lib/server/brokenLinks.js +26 -12
  29. package/lib/server/client-modules/index.js +1 -1
  30. package/lib/server/config.js +2 -2
  31. package/lib/server/html-tags/htmlTags.js +3 -3
  32. package/lib/server/html-tags/index.js +1 -1
  33. package/lib/server/i18n.js +7 -6
  34. package/lib/server/index.js +16 -20
  35. package/lib/server/plugins/index.js +14 -19
  36. package/lib/server/plugins/init.js +12 -15
  37. package/lib/server/plugins/pluginIds.js +2 -2
  38. package/lib/server/presets/index.js +2 -3
  39. package/lib/server/routes.js +3 -5
  40. package/lib/server/themes/alias.js +3 -3
  41. package/lib/server/themes/index.js +2 -2
  42. package/lib/server/translations/translations.js +15 -22
  43. package/lib/server/translations/translationsExtractor.js +13 -15
  44. package/lib/server/utils.js +1 -1
  45. package/lib/server/versions/index.js +2 -2
  46. package/lib/webpack/base.js +4 -5
  47. package/lib/webpack/client.js +6 -7
  48. package/lib/webpack/plugins/CleanWebpackPlugin.js +1 -1
  49. package/lib/webpack/plugins/LogPlugin.js +2 -2
  50. package/lib/webpack/plugins/WaitPlugin.js +3 -3
  51. package/lib/webpack/server.js +5 -5
  52. package/lib/webpack/utils.js +16 -19
  53. package/package.json +11 -11
  54. package/lib/server/loadSetup.d.ts +0 -8
  55. package/lib/server/loadSetup.js +0 -25
@@ -7,7 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
10
+ const path_1 = tslib_1.__importDefault(require("path"));
11
11
  function getTransformOptions(isServer) {
12
12
  const absoluteRuntimePath = path_1.default.dirname(require.resolve(`@babel/runtime/package.json`));
13
13
  return {
@@ -68,7 +68,7 @@ function getTransformOptions(isServer) {
68
68
  };
69
69
  }
70
70
  function babelPresets(api) {
71
- const callerName = api.caller((caller) => caller === null || caller === void 0 ? void 0 : caller.name);
71
+ const callerName = api.caller((caller) => caller?.name);
72
72
  return getTransformOptions(callerName === 'server');
73
73
  }
74
74
  exports.default = babelPresets;
package/lib/choosePort.js CHANGED
@@ -12,10 +12,10 @@ const tslib_1 = require("tslib");
12
12
  * uses many of the same utility functions to implement it.
13
13
  */
14
14
  const child_process_1 = require("child_process");
15
- const detect_port_1 = (0, tslib_1.__importDefault)(require("detect-port"));
16
- const is_root_1 = (0, tslib_1.__importDefault)(require("is-root"));
17
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
18
- const prompts_1 = (0, tslib_1.__importDefault)(require("prompts"));
15
+ const detect_port_1 = tslib_1.__importDefault(require("detect-port"));
16
+ const is_root_1 = tslib_1.__importDefault(require("is-root"));
17
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
18
+ const prompts_1 = tslib_1.__importDefault(require("prompts"));
19
19
  const isInteractive = process.stdout.isTTY;
20
20
  const execOptions = {
21
21
  encoding: 'utf8',
@@ -7,9 +7,9 @@
7
7
  import clientModules from '@generated/client-modules';
8
8
  function dispatchLifecycleAction(lifecycleAction, args) {
9
9
  clientModules.forEach((clientModule) => {
10
- var _a, _b;
11
- const lifecycleFunction = ((_b = (_a = clientModule === null || clientModule === void 0 ? void 0 : clientModule.default) === null || _a === void 0 ? void 0 : _a[lifecycleAction]) !== null && _b !== void 0 ? _b : clientModule[lifecycleAction]);
12
- lifecycleFunction === null || lifecycleFunction === void 0 ? void 0 : lifecycleFunction(...args);
10
+ const lifecycleFunction = (clientModule?.default?.[lifecycleAction] ??
11
+ clientModule[lifecycleAction]);
12
+ lifecycleFunction?.(...args);
13
13
  });
14
14
  }
15
15
  const clientLifecyclesDispatchers = {
@@ -13,11 +13,8 @@ import flat from './flat';
13
13
  const fetched = {};
14
14
  const loaded = {};
15
15
  // If user is on slow or constrained connection.
16
- const isSlowConnection = () => {
17
- var _a, _b;
18
- return ((_a = navigator.connection) === null || _a === void 0 ? void 0 : _a.effectiveType.includes('2g')) &&
19
- ((_b = navigator.connection) === null || _b === void 0 ? void 0 : _b.saveData);
20
- };
16
+ const isSlowConnection = () => navigator.connection?.effectiveType.includes('2g') &&
17
+ navigator.connection?.saveData;
21
18
  const canPrefetch = (routePath) => !isSlowConnection() && !loaded[routePath] && !fetched[routePath];
22
19
  const canPreload = (routePath) => !isSlowConnection() && !loaded[routePath];
23
20
  // Remove the last part containing the route hash
@@ -19,18 +19,17 @@ export default class ErrorBoundary extends React.Component {
19
19
  }
20
20
  }
21
21
  render() {
22
- var _a;
23
22
  const { children } = this.props;
24
23
  const { error } = this.state;
25
24
  if (error) {
26
- const fallback = (_a = this.props.fallback) !== null && _a !== void 0 ? _a : DefaultFallback;
25
+ const fallback = this.props.fallback ?? DefaultFallback;
27
26
  return fallback({
28
27
  error,
29
28
  tryAgain: () => this.setState({ error: null }),
30
29
  });
31
30
  }
32
- return (children !== null && children !== void 0 ? children :
33
- // See https://github.com/facebook/docusaurus/issues/6337#issuecomment-1012913647
34
- null);
31
+ return (children ??
32
+ // See https://github.com/facebook/docusaurus/issues/6337#issuecomment-1012913647
33
+ null);
35
34
  }
36
35
  }
@@ -17,7 +17,7 @@ export function interpolate(text, values) {
17
17
  const processedText = text.replace(ValueRegexp, (match) => {
18
18
  // remove {{ and }} around the placeholder
19
19
  const key = match.substring(1, match.length - 1);
20
- const value = values === null || values === void 0 ? void 0 : values[key];
20
+ const value = values?.[key];
21
21
  if (typeof value !== 'undefined') {
22
22
  const element = React.isValidElement(value)
23
23
  ? value
@@ -36,7 +36,7 @@ export function interpolate(text, values) {
36
36
  if (elements.every((el) => typeof el === 'string')) {
37
37
  return processedText
38
38
  .split(ValueFoundMarker)
39
- .reduce((str, value, index) => { var _a; return str.concat(value).concat((_a = elements[index]) !== null && _a !== void 0 ? _a : ''); }, '');
39
+ .reduce((str, value, index) => str.concat(value).concat(elements[index] ?? ''), '');
40
40
  }
41
41
  // JSX interpolation: returns ReactNode
42
42
  return processedText.split(ValueFoundMarker).reduce((array, value, index) => [
@@ -19,7 +19,6 @@ import { applyTrailingSlash } from '@docusaurus/utils-common';
19
19
  // like "introduction" to "/baseUrl/introduction" => bad behavior to fix
20
20
  const shouldAddBaseUrlAutomatically = (to) => to.startsWith('/');
21
21
  function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLinkCheck': noBrokenLinkCheck, autoAddBaseUrl = true, ...props }, forwardedRef) {
22
- var _a;
23
22
  const { siteConfig: { trailingSlash, baseUrl }, } = useDocusaurusContext();
24
23
  const { withBaseUrl } = useBaseUrlUtils();
25
24
  const linksCollector = useLinksCollector();
@@ -42,7 +41,7 @@ function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLi
42
41
  // see https://github.com/facebook/docusaurus/issues/3309
43
42
  // note: we want baseUrl to be appended (see issue for details)
44
43
  // TODO read routes and automatically detect internal/external links?
45
- const targetLinkWithoutPathnameProtocol = targetLinkUnprefixed === null || targetLinkUnprefixed === void 0 ? void 0 : targetLinkUnprefixed.replace('pathname://', '');
44
+ const targetLinkWithoutPathnameProtocol = targetLinkUnprefixed?.replace('pathname://', '');
46
45
  // TODO we should use ReactRouter basename feature instead!
47
46
  // Automatically apply base url in links that start with /
48
47
  let targetLink = typeof targetLinkWithoutPathnameProtocol !== 'undefined'
@@ -103,7 +102,7 @@ function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLi
103
102
  }
104
103
  };
105
104
  }, [ioRef, targetLink, IOSupported, isInternal]);
106
- const isAnchorLink = (_a = targetLink === null || targetLink === void 0 ? void 0 : targetLink.startsWith('#')) !== null && _a !== void 0 ? _a : false;
105
+ const isAnchorLink = targetLink?.startsWith('#') ?? false;
107
106
  const isRegularHtmlLink = !targetLink || !isInternal || isAnchorLink;
108
107
  if (targetLink && isInternal && !isAnchorLink && !noBrokenLinkCheck) {
109
108
  linksCollector.collectLink(targetLink);
@@ -8,11 +8,10 @@ import { interpolate } from '@docusaurus/Interpolate';
8
8
  // Can't read it from context, due to exposing imperative API
9
9
  import codeTranslations from '@generated/codeTranslations';
10
10
  function getLocalizedMessage({ id, message, }) {
11
- var _a, _b;
12
11
  if (typeof id === 'undefined' && typeof message === 'undefined') {
13
12
  throw new Error('Docusaurus translation declarations must have at least a translation id or a default translation message');
14
13
  }
15
- return (_b = (_a = codeTranslations[(id !== null && id !== void 0 ? id : message)]) !== null && _a !== void 0 ? _a : message) !== null && _b !== void 0 ? _b : id;
14
+ return codeTranslations[(id ?? message)] ?? message ?? id;
16
15
  }
17
16
  // Imperative translation API is useful for some edge-cases:
18
17
  // - translating page titles (meta)
@@ -7,19 +7,19 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
11
- const copy_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("copy-webpack-plugin"));
12
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
14
- const react_loadable_ssr_addon_v5_slorber_1 = (0, tslib_1.__importDefault)(require("react-loadable-ssr-addon-v5-slorber"));
10
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
11
+ const copy_webpack_plugin_1 = tslib_1.__importDefault(require("copy-webpack-plugin"));
12
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
+ const path_1 = tslib_1.__importDefault(require("path"));
14
+ const react_loadable_ssr_addon_v5_slorber_1 = tslib_1.__importDefault(require("react-loadable-ssr-addon-v5-slorber"));
15
15
  const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
16
- const webpack_merge_1 = (0, tslib_1.__importDefault)(require("webpack-merge"));
16
+ const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
17
17
  const server_1 = require("../server");
18
18
  const brokenLinks_1 = require("../server/brokenLinks");
19
- const client_1 = (0, tslib_1.__importDefault)(require("../webpack/client"));
20
- const server_2 = (0, tslib_1.__importDefault)(require("../webpack/server"));
19
+ const client_1 = tslib_1.__importDefault(require("../webpack/client"));
20
+ const server_2 = tslib_1.__importDefault(require("../webpack/server"));
21
21
  const utils_1 = require("../webpack/utils");
22
- const CleanWebpackPlugin_1 = (0, tslib_1.__importDefault)(require("../webpack/plugins/CleanWebpackPlugin"));
22
+ const CleanWebpackPlugin_1 = tslib_1.__importDefault(require("../webpack/plugins/CleanWebpackPlugin"));
23
23
  const i18n_1 = require("../server/i18n");
24
24
  const utils_2 = require("@docusaurus/utils");
25
25
  async function build(siteDir, cliOptions = {},
@@ -75,7 +75,6 @@ forceTerminate = true) {
75
75
  }
76
76
  exports.default = build;
77
77
  async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLastLocale, }) {
78
- var _a;
79
78
  process.env.BABEL_ENV = 'production';
80
79
  process.env.NODE_ENV = 'production';
81
80
  logger_1.default.info `name=${`[${locale}]`} Creating an optimized production build...`;
@@ -122,16 +121,15 @@ async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLast
122
121
  }
123
122
  // Plugin Lifecycle - configureWebpack and configurePostCss.
124
123
  plugins.forEach((plugin) => {
125
- var _a, _b;
126
124
  const { configureWebpack, configurePostCss } = plugin;
127
125
  if (configurePostCss) {
128
126
  clientConfig = (0, utils_1.applyConfigurePostCss)(configurePostCss, clientConfig);
129
127
  }
130
128
  if (configureWebpack) {
131
129
  clientConfig = (0, utils_1.applyConfigureWebpack)(configureWebpack.bind(plugin), // The plugin lifecycle may reference `this`.
132
- clientConfig, false, (_a = props.siteConfig.webpack) === null || _a === void 0 ? void 0 : _a.jsLoader, plugin.content);
130
+ clientConfig, false, props.siteConfig.webpack?.jsLoader, plugin.content);
133
131
  serverConfig = (0, utils_1.applyConfigureWebpack)(configureWebpack.bind(plugin), // The plugin lifecycle may reference `this`.
134
- serverConfig, true, (_b = props.siteConfig.webpack) === null || _b === void 0 ? void 0 : _b.jsLoader, plugin.content);
132
+ serverConfig, true, props.siteConfig.webpack?.jsLoader, plugin.content);
135
133
  }
136
134
  });
137
135
  // Make sure generated client-manifest is cleaned first so we don't reuse
@@ -142,7 +140,7 @@ async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLast
142
140
  // Run webpack to build JS bundle (client) and static html files (server).
143
141
  await (0, utils_1.compile)([clientConfig, serverConfig]);
144
142
  // Remove server.bundle.js because it is not needed.
145
- if (typeof ((_a = serverConfig.output) === null || _a === void 0 ? void 0 : _a.filename) === 'string') {
143
+ if (typeof serverConfig.output?.filename === 'string') {
146
144
  const serverBundle = path_1.default.join(outDir, serverConfig.output.filename);
147
145
  if (await fs_extra_1.default.pathExists(serverBundle)) {
148
146
  await fs_extra_1.default.unlink(serverBundle);
@@ -7,9 +7,9 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
11
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
12
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
10
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
11
+ const path_1 = tslib_1.__importDefault(require("path"));
12
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
13
13
  const utils_1 = require("@docusaurus/utils");
14
14
  async function removePath(entry) {
15
15
  if (!(await fs_extra_1.default.pathExists(entry.path))) {
@@ -8,7 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getCLIOptionPort = exports.getCLIOptionHost = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const choosePort_1 = (0, tslib_1.__importDefault)(require("../choosePort"));
11
+ const choosePort_1 = tslib_1.__importDefault(require("../choosePort"));
12
12
  const utils_1 = require("@docusaurus/utils");
13
13
  function getCLIOptionHost(hostOption) {
14
14
  return hostOption || 'localhost';
@@ -8,13 +8,13 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.hasSSHProtocol = exports.buildHttpsUrl = exports.buildSshUrl = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
- const shelljs_1 = (0, tslib_1.__importDefault)(require("shelljs"));
13
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
11
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
+ const shelljs_1 = tslib_1.__importDefault(require("shelljs"));
13
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
14
  const server_1 = require("../server");
15
- const build_1 = (0, tslib_1.__importDefault)(require("./build"));
16
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
17
- const os_1 = (0, tslib_1.__importDefault)(require("os"));
15
+ const build_1 = tslib_1.__importDefault(require("./build"));
16
+ const path_1 = tslib_1.__importDefault(require("path"));
17
+ const os_1 = tslib_1.__importDefault(require("os"));
18
18
  // GIT_PASS env variable should not appear in logs
19
19
  function obfuscateGitPass(str) {
20
20
  const gitPass = process.env.GIT_PASS;
@@ -8,7 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
10
  const server_1 = require("../server");
11
- const init_1 = (0, tslib_1.__importDefault)(require("../server/plugins/init"));
11
+ const init_1 = tslib_1.__importDefault(require("../server/plugins/init"));
12
12
  async function externalCommand(cli, siteDir) {
13
13
  const context = await (0, server_1.loadContext)(siteDir);
14
14
  const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
@@ -7,12 +7,12 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const http_1 = (0, tslib_1.__importDefault)(require("http"));
11
- const serve_handler_1 = (0, tslib_1.__importDefault)(require("serve-handler"));
12
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
13
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
10
+ const http_1 = tslib_1.__importDefault(require("http"));
11
+ const serve_handler_1 = tslib_1.__importDefault(require("serve-handler"));
12
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
13
+ const path_1 = tslib_1.__importDefault(require("path"));
14
14
  const server_1 = require("../server");
15
- const build_1 = (0, tslib_1.__importDefault)(require("./build"));
15
+ const build_1 = tslib_1.__importDefault(require("./build"));
16
16
  const commandUtils_1 = require("./commandUtils");
17
17
  async function serve(siteDir, cliOptions) {
18
18
  let dir = path_1.default.isAbsolute(cliOptions.dir)
@@ -35,9 +35,8 @@ async function serve(siteDir, cliOptions) {
35
35
  });
36
36
  const servingUrl = `http://${host}:${port}`;
37
37
  const server = http_1.default.createServer((req, res) => {
38
- var _a, _b;
39
38
  // Automatically redirect requests to /baseUrl/
40
- if (!((_a = req.url) === null || _a === void 0 ? void 0 : _a.startsWith(baseUrl))) {
39
+ if (!req.url?.startsWith(baseUrl)) {
41
40
  res.writeHead(302, {
42
41
  Location: baseUrl,
43
42
  });
@@ -46,7 +45,7 @@ async function serve(siteDir, cliOptions) {
46
45
  }
47
46
  // Remove baseUrl before calling serveHandler, because /baseUrl/ should
48
47
  // serve /build/index.html, not /build/baseUrl/index.html (does not exist)
49
- req.url = (_b = req.url) === null || _b === void 0 ? void 0 : _b.replace(baseUrl, '/');
48
+ req.url = req.url?.replace(baseUrl, '/');
50
49
  (0, serve_handler_1.default)(req, res, {
51
50
  cleanUrls: true,
52
51
  public: dir,
@@ -8,19 +8,19 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
10
  const utils_1 = require("@docusaurus/utils");
11
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
- const chokidar_1 = (0, tslib_1.__importDefault)(require("chokidar"));
13
- const html_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("html-webpack-plugin"));
14
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
15
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
16
- const openBrowser_1 = (0, tslib_1.__importDefault)(require("react-dev-utils/openBrowser"));
11
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
+ const chokidar_1 = tslib_1.__importDefault(require("chokidar"));
13
+ const html_webpack_plugin_1 = tslib_1.__importDefault(require("html-webpack-plugin"));
14
+ const path_1 = tslib_1.__importDefault(require("path"));
15
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
16
+ const openBrowser_1 = tslib_1.__importDefault(require("react-dev-utils/openBrowser"));
17
17
  const WebpackDevServerUtils_1 = require("react-dev-utils/WebpackDevServerUtils");
18
- const evalSourceMapMiddleware_1 = (0, tslib_1.__importDefault)(require("react-dev-utils/evalSourceMapMiddleware"));
19
- const webpack_1 = (0, tslib_1.__importDefault)(require("webpack"));
20
- const webpack_dev_server_1 = (0, tslib_1.__importDefault)(require("webpack-dev-server"));
21
- const webpack_merge_1 = (0, tslib_1.__importDefault)(require("webpack-merge"));
18
+ const evalSourceMapMiddleware_1 = tslib_1.__importDefault(require("react-dev-utils/evalSourceMapMiddleware"));
19
+ const webpack_1 = tslib_1.__importDefault(require("webpack"));
20
+ const webpack_dev_server_1 = tslib_1.__importDefault(require("webpack-dev-server"));
21
+ const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
22
22
  const server_1 = require("../server");
23
- const client_1 = (0, tslib_1.__importDefault)(require("../webpack/client"));
23
+ const client_1 = tslib_1.__importDefault(require("../webpack/client"));
24
24
  const utils_2 = require("../webpack/utils");
25
25
  const commandUtils_1 = require("./commandUtils");
26
26
  const translations_1 = require("../server/translations/translations");
@@ -69,7 +69,7 @@ async function start(siteDir, cliOptions) {
69
69
  };
70
70
  const pluginPaths = []
71
71
  .concat(...plugins
72
- .map((plugin) => { var _a, _b; return (_b = (_a = plugin.getPathsToWatch) === null || _a === void 0 ? void 0 : _a.call(plugin)) !== null && _b !== void 0 ? _b : []; })
72
+ .map((plugin) => plugin.getPathsToWatch?.() ?? [])
73
73
  .filter(Boolean))
74
74
  .map(normalizeToSiteDir);
75
75
  const pathsToWatch = [
@@ -114,14 +114,13 @@ async function start(siteDir, cliOptions) {
114
114
  });
115
115
  // Plugin Lifecycle - configureWebpack and configurePostCss.
116
116
  plugins.forEach((plugin) => {
117
- var _a;
118
117
  const { configureWebpack, configurePostCss } = plugin;
119
118
  if (configurePostCss) {
120
119
  config = (0, utils_2.applyConfigurePostCss)(configurePostCss, config);
121
120
  }
122
121
  if (configureWebpack) {
123
122
  config = (0, utils_2.applyConfigureWebpack)(configureWebpack.bind(plugin), // The plugin lifecycle may reference `this`. // TODO remove this implicit api: inject in callback instead
124
- config, false, (_a = props.siteConfig.webpack) === null || _a === void 0 ? void 0 : _a.jsLoader, plugin.content);
123
+ config, false, props.siteConfig.webpack?.jsLoader, plugin.content);
125
124
  }
126
125
  });
127
126
  const compiler = (0, webpack_1.default)(config);
@@ -8,10 +8,10 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.wrap = exports.eject = exports.getAction = exports.SwizzleActions = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
14
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
11
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
+ const path_1 = tslib_1.__importDefault(require("path"));
14
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
15
15
  const utils_1 = require("@docusaurus/utils");
16
16
  const prompts_1 = require("./prompts");
17
17
  exports.SwizzleActions = ['wrap', 'eject'];
@@ -8,9 +8,9 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.findClosestValue = exports.findStringIgnoringCase = exports.normalizeOptions = exports.actionStatusSuffix = exports.actionStatusColor = exports.actionStatusLabel = exports.PartiallySafeHint = exports.SwizzleActionsStatuses = exports.SwizzleActions = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const leven_1 = (0, tslib_1.__importDefault)(require("leven"));
12
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
13
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
11
+ const leven_1 = tslib_1.__importDefault(require("leven"));
12
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
13
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
14
  exports.SwizzleActions = ['wrap', 'eject'];
15
15
  exports.SwizzleActionsStatuses = [
16
16
  'safe',
@@ -37,13 +37,12 @@ function actionStatusSuffix(status, options = {}) {
37
37
  }
38
38
  exports.actionStatusSuffix = actionStatusSuffix;
39
39
  function normalizeOptions(options) {
40
- var _a, _b, _c, _d, _e;
41
40
  return {
42
- typescript: (_a = options.typescript) !== null && _a !== void 0 ? _a : false,
43
- danger: (_b = options.danger) !== null && _b !== void 0 ? _b : false,
44
- list: (_c = options.list) !== null && _c !== void 0 ? _c : false,
45
- wrap: (_d = options.wrap) !== null && _d !== void 0 ? _d : false,
46
- eject: (_e = options.eject) !== null && _e !== void 0 ? _e : false,
41
+ typescript: options.typescript ?? false,
42
+ danger: options.danger ?? false,
43
+ list: options.list ?? false,
44
+ wrap: options.wrap ?? false,
45
+ eject: options.eject ?? false,
47
46
  };
48
47
  }
49
48
  exports.normalizeOptions = normalizeOptions;
@@ -8,10 +8,10 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getComponentName = exports.getThemeComponents = exports.listComponentNames = exports.readComponentNames = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
14
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
11
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
+ const path_1 = tslib_1.__importDefault(require("path"));
14
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
15
15
  const utils_1 = require("@docusaurus/utils");
16
16
  const prompts_1 = require("./prompts");
17
17
  const common_1 = require("./common");
@@ -74,19 +74,16 @@ async function getThemeComponents({ themeName, themePath, swizzleConfig, }) {
74
74
  };
75
75
  const allComponents = await readComponentNames(themePath);
76
76
  function getConfig(component) {
77
- var _a;
78
77
  if (!allComponents.includes(component)) {
79
78
  throw new Error(`Can't get component config: component doesn't exist: ${component}`);
80
79
  }
81
- return ((_a = swizzleConfig.components[component]) !== null && _a !== void 0 ? _a : FallbackSwizzleComponentConfig);
80
+ return (swizzleConfig.components[component] ?? FallbackSwizzleComponentConfig);
82
81
  }
83
82
  function getDescription(component) {
84
- var _a;
85
- return ((_a = getConfig(component).description) !== null && _a !== void 0 ? _a : FallbackSwizzleComponentDescription);
83
+ return (getConfig(component).description ?? FallbackSwizzleComponentDescription);
86
84
  }
87
85
  function getActionStatus(component, action) {
88
- var _a;
89
- return (_a = getConfig(component).actions[action]) !== null && _a !== void 0 ? _a : FallbackSwizzleActionStatus;
86
+ return getConfig(component).actions[action] ?? FallbackSwizzleActionStatus;
90
87
  }
91
88
  function isSafeAction(component, action) {
92
89
  return getActionStatus(component, action) === 'safe';
@@ -11,15 +11,18 @@ const utils_validation_1 = require("@docusaurus/utils-validation");
11
11
  const common_1 = require("./common");
12
12
  const themes_1 = require("./themes");
13
13
  function getModuleSwizzleConfig(swizzlePlugin) {
14
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
15
- const getSwizzleConfig = (_d = (_b = (_a = swizzlePlugin.plugin.plugin) === null || _a === void 0 ? void 0 : _a.getSwizzleConfig) !== null && _b !== void 0 ? _b : (_c = swizzlePlugin.plugin.pluginModule) === null || _c === void 0 ? void 0 : _c.module.getSwizzleConfig) !== null && _d !== void 0 ? _d : (_f = (_e = swizzlePlugin.plugin.pluginModule) === null || _e === void 0 ? void 0 : _e.module) === null || _f === void 0 ? void 0 : _f.getSwizzleConfig;
14
+ const getSwizzleConfig = swizzlePlugin.plugin.plugin?.getSwizzleConfig ??
15
+ swizzlePlugin.plugin.pluginModule?.module.getSwizzleConfig ??
16
+ swizzlePlugin.plugin.pluginModule?.module?.getSwizzleConfig;
16
17
  if (getSwizzleConfig) {
17
18
  return getSwizzleConfig();
18
19
  }
19
20
  // TODO deprecate getSwizzleComponentList later
20
- const getSwizzleComponentList = (_k = (_h = (_g = swizzlePlugin.plugin.plugin) === null || _g === void 0 ? void 0 : _g.getSwizzleComponentList) !== null && _h !== void 0 ? _h : (_j = swizzlePlugin.plugin.pluginModule) === null || _j === void 0 ? void 0 : _j.module.getSwizzleComponentList) !== null && _k !== void 0 ? _k : (_m = (_l = swizzlePlugin.plugin.pluginModule) === null || _l === void 0 ? void 0 : _l.module) === null || _m === void 0 ? void 0 : _m.getSwizzleComponentList;
21
+ const getSwizzleComponentList = swizzlePlugin.plugin.plugin?.getSwizzleComponentList ??
22
+ swizzlePlugin.plugin.pluginModule?.module.getSwizzleComponentList ??
23
+ swizzlePlugin.plugin.pluginModule?.module?.getSwizzleComponentList;
21
24
  if (getSwizzleComponentList) {
22
- const safeComponents = (_o = getSwizzleComponentList()) !== null && _o !== void 0 ? _o : [];
25
+ const safeComponents = getSwizzleComponentList() ?? [];
23
26
  const safeComponentConfig = {
24
27
  actions: {
25
28
  eject: 'safe',
@@ -10,7 +10,7 @@ exports.initSwizzleContext = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const module_1 = require("module");
12
12
  const server_1 = require("../../server");
13
- const init_1 = (0, tslib_1.__importStar)(require("../../server/plugins/init"));
13
+ const init_1 = tslib_1.__importStar(require("../../server/plugins/init"));
14
14
  async function initSwizzleContext(siteDir) {
15
15
  const context = await (0, server_1.loadContext)(siteDir);
16
16
  const pluginRequire = (0, module_1.createRequire)(context.siteConfigPath);
@@ -7,7 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
10
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
11
11
  const themes_1 = require("./themes");
12
12
  const components_1 = require("./components");
13
13
  const tables_1 = require("./tables");
@@ -8,8 +8,8 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.askSwizzleAction = exports.askSwizzleDangerousComponent = exports.askComponentName = exports.askThemeName = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
- const prompts_1 = (0, tslib_1.__importDefault)(require("prompts"));
11
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
+ const prompts_1 = tslib_1.__importDefault(require("prompts"));
13
13
  const common_1 = require("./common");
14
14
  const ExitTitle = logger_1.default.yellow('[Exit]');
15
15
  async function askThemeName(themeNames) {
@@ -8,9 +8,9 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.themeComponentsTable = exports.helpTables = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
- const cli_table3_1 = (0, tslib_1.__importDefault)(require("cli-table3"));
13
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
11
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
+ const cli_table3_1 = tslib_1.__importDefault(require("cli-table3"));
13
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
14
14
  const actions_1 = require("./actions");
15
15
  const common_1 = require("./common");
16
16
  function tableStatusLabel(status) {
@@ -8,15 +8,14 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getThemePath = exports.getThemeName = exports.getThemeNames = exports.getPluginByThemeName = exports.pluginToThemeName = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
- const leven_1 = (0, tslib_1.__importDefault)(require("leven"));
13
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
11
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
+ const leven_1 = tslib_1.__importDefault(require("leven"));
13
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
14
14
  const prompts_1 = require("./prompts");
15
15
  const common_1 = require("./common");
16
16
  function pluginToThemeName(plugin) {
17
- var _a;
18
17
  if (plugin.instance.getThemePath) {
19
- return ((_a = plugin.instance.version.name) !== null && _a !== void 0 ? _a : plugin.instance.name);
18
+ return (plugin.instance.version.name ?? plugin.instance.name);
20
19
  }
21
20
  return undefined;
22
21
  }
@@ -86,11 +85,10 @@ async function getThemeName({ themeNameParam, themeNames, list, }) {
86
85
  }
87
86
  exports.getThemeName = getThemeName;
88
87
  function getThemePath({ plugins, themeName, typescript, }) {
89
- var _a, _b, _c, _d;
90
88
  const pluginInstance = getPluginByThemeName(plugins, themeName);
91
89
  const themePath = typescript
92
- ? (_b = (_a = pluginInstance.instance).getTypeScriptThemePath) === null || _b === void 0 ? void 0 : _b.call(_a)
93
- : (_d = (_c = pluginInstance.instance).getThemePath) === null || _d === void 0 ? void 0 : _d.call(_c);
90
+ ? pluginInstance.instance.getTypeScriptThemePath?.()
91
+ : pluginInstance.instance.getThemePath?.();
94
92
  if (!themePath) {
95
93
  logger_1.default.warn(typescript
96
94
  ? logger_1.default.interpolate `name=${themeName} does not provide TypeScript theme code via ${'getTypeScriptThemePath()'}.`
@@ -8,10 +8,10 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.transformMarkdownContent = exports.transformMarkdownHeadingLine = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
11
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
13
13
  const server_1 = require("../server");
14
- const init_1 = (0, tslib_1.__importDefault)(require("../server/plugins/init"));
14
+ const init_1 = tslib_1.__importDefault(require("../server/plugins/init"));
15
15
  const utils_1 = require("@docusaurus/utils");
16
16
  const utils_2 = require("../server/utils");
17
17
  function unwrapMarkdownLinks(line) {
@@ -90,10 +90,10 @@ async function getPathsToWatch(siteDir) {
90
90
  pluginConfigs,
91
91
  context,
92
92
  });
93
- return plugins.flatMap((plugin) => { var _a, _b; return (_b = (_a = plugin === null || plugin === void 0 ? void 0 : plugin.getPathsToWatch) === null || _a === void 0 ? void 0 : _a.call(plugin)) !== null && _b !== void 0 ? _b : []; });
93
+ return plugins.flatMap((plugin) => plugin?.getPathsToWatch?.() ?? []);
94
94
  }
95
95
  async function writeHeadingIds(siteDir, files, options) {
96
- const markdownFiles = await (0, utils_2.safeGlobby)(files !== null && files !== void 0 ? files : (await getPathsToWatch(siteDir)), {
96
+ const markdownFiles = await (0, utils_2.safeGlobby)(files ?? (await getPathsToWatch(siteDir)), {
97
97
  expandDirectories: ['**/*.{md,mdx}'],
98
98
  });
99
99
  const result = await Promise.all(markdownFiles.map((p) => transformMarkdownFile(p, options)));