@docusaurus/core 0.0.0-4730 → 0.0.0-4733

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.
package/bin/beforeCli.mjs CHANGED
@@ -72,8 +72,7 @@ export default async function beforeCli() {
72
72
  * @param {import('update-notifier').UpdateInfo} update
73
73
  */
74
74
  function ignoreUpdate(update) {
75
- const isCanaryRelease =
76
- update && update.current && update.current.startsWith('0.0.0');
75
+ const isCanaryRelease = update?.current?.startsWith('0.0.0');
77
76
  return isCanaryRelease;
78
77
  }
79
78
 
@@ -43,8 +43,7 @@ export default function ComponentCreator(path, hash) {
43
43
  if (chunkRegistry) {
44
44
  // eslint-disable-next-line prefer-destructuring
45
45
  optsLoader[key] = chunkRegistry[0];
46
- optsModules.push(chunkRegistry[1]);
47
- optsWebpack.push(chunkRegistry[2]);
46
+ optsModules.push(chunkRegistry[1], chunkRegistry[2]);
48
47
  }
49
48
  });
50
49
  return Loadable.Map({
@@ -63,7 +62,7 @@ export default function ComponentCreator(path, hash) {
63
62
  });
64
63
  val[keyPath[keyPath.length - 1]] = loaded[key].default;
65
64
  const nonDefaultKeys = Object.keys(loaded[key]).filter((k) => k !== 'default');
66
- if (nonDefaultKeys && nonDefaultKeys.length) {
65
+ if (nonDefaultKeys?.length) {
67
66
  nonDefaultKeys.forEach((nonDefaultKey) => {
68
67
  val[keyPath[keyPath.length - 1]][nonDefaultKey] =
69
68
  loaded[key][nonDefaultKey];
@@ -31,8 +31,7 @@ This component is safe to swizzle and was designed for this purpose.
31
31
  The swizzled component is retro-compatible with minor version upgrades.
32
32
  `,
33
33
  ],
34
- });
35
- table.push({
34
+ }, {
36
35
  [tableStatusLabel('unsafe')]: [
37
36
  logger_1.default.code('--danger'),
38
37
  `
@@ -44,8 +43,7 @@ ${logger_1.default.green('Tip')}: your customization can't be done in a ${tableS
44
43
  Report it here: https://github.com/facebook/docusaurus/discussions/5468
45
44
  `,
46
45
  ],
47
- });
48
- table.push({
46
+ }, {
49
47
  [tableStatusLabel('forbidden')]: [
50
48
  '',
51
49
  `
@@ -69,8 +67,7 @@ Allows rendering other components before/after the original theme component.
69
67
  ${logger_1.default.green('Tip')}: prefer ${logger_1.default.code('--wrap')} whenever possible to reduce the amount of code to maintain.
70
68
  `,
71
69
  ],
72
- });
73
- table.push({
70
+ }, {
74
71
  [logger_1.default.bold('Eject')]: [
75
72
  logger_1.default.code('--eject'),
76
73
  `
@@ -16,26 +16,24 @@ const utils_2 = require("./utils");
16
16
  const path_1 = tslib_1.__importDefault(require("path"));
17
17
  const combine_promises_1 = tslib_1.__importDefault(require("combine-promises"));
18
18
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
19
- function toReactRouterRoutes(routes) {
20
- // @ts-expect-error: types incompatible???
21
- return routes;
22
- }
23
19
  // matchRoutes does not support qs/anchors, so we remove it!
24
20
  function onlyPathname(link) {
25
21
  return link.split('#')[0].split('?')[0];
26
22
  }
27
23
  function getPageBrokenLinks({ pagePath, pageLinks, routes, }) {
28
- // ReactRouter is able to support links like ./../somePath
29
- // but matchRoutes does not do this resolving internally
30
- // we must resolve the links before using matchRoutes
31
- // resolvePathname is used internally by ReactRouter
24
+ // ReactRouter is able to support links like ./../somePath but `matchRoutes`
25
+ // does not do this resolution internally. We must resolve the links before
26
+ // using `matchRoutes`. `resolvePathname` is used internally by React Router
32
27
  function resolveLink(link) {
33
28
  const resolvedLink = (0, utils_1.resolvePathname)(onlyPathname(link), pagePath);
34
29
  return { link, resolvedLink };
35
30
  }
36
31
  function isBrokenLink(link) {
37
32
  const matchedRoutes = [link, decodeURI(link)]
38
- .map((l) => (0, react_router_config_1.matchRoutes)(toReactRouterRoutes(routes), l))
33
+ // @ts-expect-error: React router types RouteConfig with an actual React
34
+ // component, but we load route components with string paths.
35
+ // We don't actually access component here, so it's fine.
36
+ .map((l) => (0, react_router_config_1.matchRoutes)(routes, l))
39
37
  .reduce((prev, cur) => prev.concat(cur));
40
38
  return matchedRoutes.length === 0;
41
39
  }
@@ -44,8 +42,8 @@ function getPageBrokenLinks({ pagePath, pageLinks, routes, }) {
44
42
  /**
45
43
  * The route defs can be recursive, and have a parent match-all route. We don't
46
44
  * want to match broken links like /docs/brokenLink against /docs/*. For this
47
- * reason, we only consider the "final routes", that do not have subroutes.
48
- * We also need to remove the match all 404 route
45
+ * reason, we only consider the "final routes" that do not have subroutes.
46
+ * We also need to remove the match-all 404 route
49
47
  */
50
48
  function filterIntermediateRoutes(routesInput) {
51
49
  const routesWithout404 = routesInput.filter((route) => route.path !== '*');
@@ -124,8 +122,7 @@ async function filterExistingFileLinks({ baseUrl, outDir, allCollectedLinks, })
124
122
  // -> /outDir/javadoc/index.html
125
123
  const filePathsToTry = [baseFilePath];
126
124
  if (!path_1.default.extname(baseFilePath)) {
127
- filePathsToTry.push(`${baseFilePath}.html`);
128
- filePathsToTry.push(path_1.default.join(baseFilePath, 'index.html'));
125
+ filePathsToTry.push(`${baseFilePath}.html`, path_1.default.join(baseFilePath, 'index.html'));
129
126
  }
130
127
  for (const file of filePathsToTry) {
131
128
  if (await isExistingFile(file)) {
@@ -184,7 +184,7 @@ function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
184
184
  options: {
185
185
  staticDirs: siteConfig.staticDirectories.map((dir) => path_1.default.resolve(siteDir, dir)),
186
186
  siteDir,
187
- isMDXPartial: (_filename) => true,
187
+ isMDXPartial: () => true,
188
188
  isMDXPartialFrontMatterWarningDisabled: true,
189
189
  remarkPlugins: [remark_admonitions_1.default],
190
190
  },
@@ -222,8 +222,7 @@ next build. You can clear all build artifacts (including this folder) with the
222
222
  */
223
223
  export default ${JSON.stringify(siteConfig, null, 2)};
224
224
  `);
225
- plugins.push(createBootstrapPlugin({ siteDir, siteConfig }));
226
- plugins.push(createMDXFallbackPlugin({ siteDir, siteConfig }));
225
+ plugins.push(createBootstrapPlugin({ siteDir, siteConfig }), createMDXFallbackPlugin({ siteDir, siteConfig }));
227
226
  // Load client modules.
228
227
  const clientModules = (0, client_modules_1.default)(plugins);
229
228
  const genClientModules = (0, utils_1.generate)(generatedFilesDir, 'client-modules.js', `export default [
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { ChunkRegistry, RouteConfig, ChunkNames } from '@docusaurus/types';
8
- declare type LoadedRoutes = {
8
+ export default function loadRoutes(pluginsRouteConfigs: RouteConfig[], baseUrl: string): Promise<{
9
9
  registry: {
10
10
  [chunkName: string]: ChunkRegistry;
11
11
  };
@@ -14,6 +14,4 @@ declare type LoadedRoutes = {
14
14
  [routePath: string]: ChunkNames;
15
15
  };
16
16
  routesPaths: string[];
17
- };
18
- export default function loadRoutes(pluginsRouteConfigs: RouteConfig[], baseUrl: string): Promise<LoadedRoutes>;
19
- export {};
17
+ }>;
@@ -141,10 +141,7 @@ registry, value, prefix, name) {
141
141
  const modulePath = getModulePath(value);
142
142
  const chunkName = (0, utils_1.genChunkName)(modulePath, prefix, name);
143
143
  const loader = `() => import(/* webpackChunkName: '${chunkName}' */ '${(0, utils_1.escapePath)(modulePath)}')`;
144
- registry[chunkName] = {
145
- loader,
146
- modulePath,
147
- };
144
+ registry[chunkName] = { loader, modulePath };
148
145
  return chunkName;
149
146
  }
150
147
  const newValue = {};
@@ -203,9 +203,8 @@ ${sourceWarningPart(path.node)}`);
203
203
  .filter((children) => !(children.isJSXText() &&
204
204
  children.node.value.replace('\n', '').trim() === ''))
205
205
  .pop();
206
- const isJSXText = singleChildren && singleChildren.isJSXText();
207
- const isJSXExpressionContainer = singleChildren &&
208
- singleChildren.isJSXExpressionContainer() &&
206
+ const isJSXText = singleChildren?.isJSXText();
207
+ const isJSXExpressionContainer = singleChildren?.isJSXExpressionContainer() &&
209
208
  singleChildren.get('expression').evaluate().confident;
210
209
  if (isJSXText || isJSXExpressionContainer) {
211
210
  message = isJSXText
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docusaurus/core",
3
3
  "description": "Easy to Maintain Open Source Documentation Websites",
4
- "version": "0.0.0-4730",
4
+ "version": "0.0.0-4733",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -41,13 +41,13 @@
41
41
  "@babel/runtime": "^7.17.7",
42
42
  "@babel/runtime-corejs3": "^7.17.7",
43
43
  "@babel/traverse": "^7.17.3",
44
- "@docusaurus/cssnano-preset": "0.0.0-4730",
45
- "@docusaurus/logger": "0.0.0-4730",
46
- "@docusaurus/mdx-loader": "0.0.0-4730",
44
+ "@docusaurus/cssnano-preset": "0.0.0-4733",
45
+ "@docusaurus/logger": "0.0.0-4733",
46
+ "@docusaurus/mdx-loader": "0.0.0-4733",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "0.0.0-4730",
49
- "@docusaurus/utils-common": "0.0.0-4730",
50
- "@docusaurus/utils-validation": "0.0.0-4730",
48
+ "@docusaurus/utils": "0.0.0-4733",
49
+ "@docusaurus/utils-common": "0.0.0-4733",
50
+ "@docusaurus/utils-validation": "0.0.0-4733",
51
51
  "@slorber/static-site-generator-webpack-plugin": "^4.0.1",
52
52
  "@svgr/webpack": "^6.2.1",
53
53
  "autoprefixer": "^10.4.2",
@@ -106,8 +106,8 @@
106
106
  "webpackbar": "^5.0.2"
107
107
  },
108
108
  "devDependencies": {
109
- "@docusaurus/module-type-aliases": "0.0.0-4730",
110
- "@docusaurus/types": "0.0.0-4730",
109
+ "@docusaurus/module-type-aliases": "0.0.0-4733",
110
+ "@docusaurus/types": "0.0.0-4733",
111
111
  "@types/detect-port": "^1.3.2",
112
112
  "@types/nprogress": "^0.2.0",
113
113
  "@types/react-dom": "^17.0.13",
@@ -128,5 +128,5 @@
128
128
  "engines": {
129
129
  "node": ">=14"
130
130
  },
131
- "gitHead": "65b87b9d9f21c7904877ed1fade98e0b9fb61b56"
131
+ "gitHead": "b3f9b5a5da00e86eaaba2220c340d4ed81c3baea"
132
132
  }