@docusaurus/core 0.0.0-4678 → 0.0.0-4682

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.
@@ -38,8 +38,8 @@ export default function ComponentCreator(path, hash) {
38
38
  ]
39
39
  */
40
40
  const flatChunkNames = flat(chunkNames);
41
- Object.keys(flatChunkNames).forEach((key) => {
42
- const chunkRegistry = registry[flatChunkNames[key]];
41
+ Object.entries(flatChunkNames).forEach(([key, chunkName]) => {
42
+ const chunkRegistry = registry[chunkName];
43
43
  if (chunkRegistry) {
44
44
  // eslint-disable-next-line prefer-destructuring
45
45
  optsLoader[key] = chunkRegistry[0];
@@ -58,9 +58,9 @@ export default function ComponentCreator(path, hash) {
58
58
  Object.keys(loaded).forEach((key) => {
59
59
  let val = loadedModules;
60
60
  const keyPath = key.split('.');
61
- for (let i = 0; i < keyPath.length - 1; i += 1) {
62
- val = val[keyPath[i]];
63
- }
61
+ keyPath.slice(0, -1).forEach((k) => {
62
+ val = val[k];
63
+ });
64
64
  val[keyPath[keyPath.length - 1]] = loaded[key].default;
65
65
  const nonDefaultKeys = Object.keys(loaded[key]).filter((k) => k !== 'default');
66
66
  if (nonDefaultKeys && nonDefaultKeys.length) {
@@ -19,5 +19,5 @@ declare const _default: React.ForwardRefExoticComponent<Pick<Partial<import("rea
19
19
  readonly href?: string | undefined;
20
20
  readonly autoAddBaseUrl?: boolean | undefined;
21
21
  readonly 'data-noBrokenLinkCheck'?: boolean | undefined;
22
- }, "children" | "replace" | "slot" | "style" | "title" | "component" | "location" | "exact" | "sensitive" | "strict" | "id" | "dir" | "rel" | "href" | "type" | "key" | "isNavLink" | "className" | "to" | "innerRef" | "download" | "hrefLang" | "media" | "ping" | "target" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "activeClassName" | "activeStyle" | "isActive" | "data-noBrokenLinkCheck" | "autoAddBaseUrl"> & React.RefAttributes<HTMLAnchorElement>>;
22
+ }, "children" | "replace" | "slot" | "style" | "title" | "component" | "location" | "exact" | "sensitive" | "strict" | "id" | "dir" | "rel" | "href" | "key" | "type" | "isNavLink" | "className" | "to" | "innerRef" | "download" | "hrefLang" | "media" | "ping" | "target" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "activeClassName" | "activeStyle" | "isActive" | "data-noBrokenLinkCheck" | "autoAddBaseUrl"> & React.RefAttributes<HTMLAnchorElement>>;
23
23
  export default _default;
@@ -9,8 +9,7 @@ export default function flat(target) {
9
9
  const delimiter = '.';
10
10
  const output = {};
11
11
  function step(object, prefix) {
12
- Object.keys(object).forEach((key) => {
13
- const value = object[key];
12
+ Object.entries(object).forEach(([key, value]) => {
14
13
  const newKey = prefix ? `${prefix}${delimiter}${key}` : key;
15
14
  if (isTree(value)) {
16
15
  step(value, newKey);
@@ -30,9 +30,9 @@ function linkPrefetchStrategy(url) {
30
30
  link.setAttribute('href', url);
31
31
  link.onload = resolve;
32
32
  link.onerror = reject;
33
- const parentElement = document.getElementsByTagName('head')[0] ||
34
- document.getElementsByName('script')[0].parentNode;
35
- parentElement.appendChild(link);
33
+ const parentElement = document.getElementsByTagName('head')[0] ??
34
+ document.getElementsByName('script')[0]?.parentNode;
35
+ parentElement?.appendChild(link);
36
36
  });
37
37
  }
38
38
  function xhrPrefetchStrategy(url) {
@@ -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 { ReactNode } from 'react';
7
+ import { type ReactNode } from 'react';
8
8
  export default function Root({ children }: {
9
9
  children: ReactNode;
10
- }): ReactNode;
10
+ }): JSX.Element;
@@ -4,6 +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 React from 'react';
7
8
  // Wrapper at the very top of the app, that is applied constantly
8
9
  // and does not depend on current route (unlike the layout)
9
10
  //
@@ -12,5 +13,5 @@
12
13
  //
13
14
  // See https://github.com/facebook/docusaurus/issues/3919
14
15
  export default function Root({ children }) {
15
- return children;
16
+ return <>{children}</>;
16
17
  }
@@ -49,7 +49,7 @@ Report it here: https://github.com/facebook/docusaurus/discussions/5468
49
49
  [tableStatusLabel('forbidden')]: [
50
50
  '',
51
51
  `
52
- This component should not meant to be swizzled.
52
+ This component is not meant to be swizzled.
53
53
  `,
54
54
  ],
55
55
  });
@@ -66,7 +66,7 @@ function actionsTable() {
66
66
  Creates a wrapper around the original theme component.
67
67
  Allows rendering other components before/after the original theme component.
68
68
 
69
- ${logger_1.default.green('Tip')}: prefer ${logger_1.default.code('--wrap')} whenever possible to reduces the amount of code to maintain.
69
+ ${logger_1.default.green('Tip')}: prefer ${logger_1.default.code('--wrap')} whenever possible to reduce the amount of code to maintain.
70
70
  `,
71
71
  ],
72
72
  });
@@ -75,9 +75,9 @@ ${logger_1.default.green('Tip')}: prefer ${logger_1.default.code('--wrap')} when
75
75
  logger_1.default.code('--eject'),
76
76
  `
77
77
  Ejects the full source code of the original theme component.
78
- Allows overriding the original component entirely with your own UI and logic.
78
+ Allows overriding of the original component entirely with your own UI and logic.
79
79
 
80
- ${logger_1.default.green('Tip')}: ${logger_1.default.code('--eject')} can be useful to completely redesign a component.
80
+ ${logger_1.default.green('Tip')}: ${logger_1.default.code('--eject')} can be useful for completely redesigning a component.
81
81
  `,
82
82
  ],
83
83
  });
@@ -33,7 +33,9 @@ exports.DEFAULT_CONFIG = {
33
33
  };
34
34
  function createPluginSchema(theme = false) {
35
35
  return (utils_validation_1.Joi.alternatives()
36
- .try(utils_validation_1.Joi.function(), utils_validation_1.Joi.array().ordered(utils_validation_1.Joi.function().required(), utils_validation_1.Joi.object().required()), utils_validation_1.Joi.string(), utils_validation_1.Joi.array()
36
+ .try(utils_validation_1.Joi.function(), utils_validation_1.Joi.array()
37
+ .ordered(utils_validation_1.Joi.function().required(), utils_validation_1.Joi.object().required())
38
+ .length(2), utils_validation_1.Joi.string(), utils_validation_1.Joi.array()
37
39
  .ordered(utils_validation_1.Joi.string().required(), utils_validation_1.Joi.object().required())
38
40
  .length(2), utils_validation_1.Joi.bool().equal(false))
39
41
  // @ts-expect-error: bad lib def, doesn't recognize an array of reports
@@ -234,9 +234,9 @@ export default ${JSON.stringify(siteConfig, null, 2)};`);
234
234
  // Routing.
235
235
  const { registry, routesChunkNames, routesConfig, routesPaths } = await (0, routes_1.default)(pluginsRouteConfigs, baseUrl);
236
236
  const genRegistry = (0, utils_1.generate)(generatedFilesDir, 'registry.js', `export default {
237
- ${Object.keys(registry)
238
- .sort()
239
- .map((key) => ` '${key}': [${registry[key].loader}, '${(0, utils_1.escapePath)(registry[key].modulePath)}', require.resolveWeak('${(0, utils_1.escapePath)(registry[key].modulePath)}')],`)
237
+ ${Object.entries(registry)
238
+ .sort((a, b) => a[0].localeCompare(b[0]))
239
+ .map(([key, chunk]) => ` '${key}': [${chunk.loader}, '${(0, utils_1.escapePath)(chunk.modulePath)}', require.resolveWeak('${(0, utils_1.escapePath)(chunk.modulePath)}')],`)
240
240
  .join('\n')}};\n`);
241
241
  const genRoutesChunkNames = (0, utils_1.generate)(generatedFilesDir, 'routesChunkNames.json', JSON.stringify(routesChunkNames, null, 2));
242
242
  const genRoutes = (0, utils_1.generate)(generatedFilesDir, 'routes.js', routesConfig);
@@ -60,7 +60,7 @@ async function loadPlugins({ pluginConfigs, context, }) {
60
60
  // order-dependent. We could change this in future if there are plugins which
61
61
  // need to run in certain order or depend on others for data.
62
62
  const loadedPlugins = await Promise.all(plugins.map(async (plugin) => {
63
- const content = plugin.loadContent ? await plugin.loadContent() : null;
63
+ const content = await plugin.loadContent?.();
64
64
  return { ...plugin, content };
65
65
  }));
66
66
  const contentLoadedTranslatedPlugins = await Promise.all(loadedPlugins.map(async (contentLoadedPlugin) => {
@@ -135,13 +135,13 @@ async function loadPlugins({ pluginConfigs, context, }) {
135
135
  // need to run in certain order or depend on others for data.
136
136
  await Promise.all(contentLoadedTranslatedPlugins.map(async (plugin) => {
137
137
  if (!plugin.routesLoaded) {
138
- return null;
138
+ return;
139
139
  }
140
140
  // TODO remove this deprecated lifecycle soon
141
141
  // deprecated since alpha-60
142
142
  // TODO, 1 user reported usage of this lifecycle! https://github.com/facebook/docusaurus/issues/3918
143
143
  logger_1.default.error `Plugin code=${'routesLoaded'} lifecycle is deprecated. If you think we should keep this lifecycle, please report here: path=${'https://github.com/facebook/docusaurus/issues/3918'}`;
144
- return plugin.routesLoaded(pluginsRouteConfigs);
144
+ await plugin.routesLoaded(pluginsRouteConfigs);
145
145
  }));
146
146
  // Sort the route config. This ensures that route with nested
147
147
  // routes are always placed last.
@@ -36,34 +36,29 @@ async function normalizePluginConfig(pluginConfig, pluginRequire) {
36
36
  options: {},
37
37
  };
38
38
  }
39
- if (Array.isArray(pluginConfig)) {
40
- // plugins: [
41
- // ['./plugin',options],
42
- // ]
43
- if (typeof pluginConfig[0] === 'string') {
44
- const pluginModuleImport = pluginConfig[0];
45
- const pluginPath = pluginRequire.resolve(pluginModuleImport);
46
- const pluginModule = (0, import_fresh_1.default)(pluginPath);
47
- return {
48
- plugin: pluginModule?.default ?? pluginModule,
49
- options: pluginConfig[1] ?? {},
50
- pluginModule: {
51
- path: pluginModuleImport,
52
- module: pluginModule,
53
- },
54
- };
55
- }
56
- // plugins: [
57
- // [function plugin() { },options],
58
- // ]
59
- if (typeof pluginConfig[0] === 'function') {
60
- return {
61
- plugin: pluginConfig[0],
62
- options: pluginConfig[1] ?? {},
63
- };
64
- }
39
+ // plugins: [
40
+ // ['./plugin',options],
41
+ // ]
42
+ if (typeof pluginConfig[0] === 'string') {
43
+ const pluginModuleImport = pluginConfig[0];
44
+ const pluginPath = pluginRequire.resolve(pluginModuleImport);
45
+ const pluginModule = (0, import_fresh_1.default)(pluginPath);
46
+ return {
47
+ plugin: pluginModule?.default ?? pluginModule,
48
+ options: pluginConfig[1],
49
+ pluginModule: {
50
+ path: pluginModuleImport,
51
+ module: pluginModule,
52
+ },
53
+ };
65
54
  }
66
- throw new Error(`Unexpected: can't load plugin for following plugin config.\n${JSON.stringify(pluginConfig)}`);
55
+ // plugins: [
56
+ // [function plugin() { },options],
57
+ // ]
58
+ return {
59
+ plugin: pluginConfig[0],
60
+ options: pluginConfig[1],
61
+ };
67
62
  }
68
63
  async function normalizePluginConfigs(pluginConfigs, pluginRequire) {
69
64
  return Promise.all(pluginConfigs.map((pluginConfig) => normalizePluginConfig(pluginConfig, pluginRequire)));
@@ -138,12 +133,7 @@ async function initPlugins({ pluginConfigs, context, }) {
138
133
  version: pluginVersion,
139
134
  };
140
135
  }
141
- const plugins = (await Promise.all(pluginConfigsNormalized.map((pluginConfig) => {
142
- if (!pluginConfig) {
143
- return null;
144
- }
145
- return initializePlugin(pluginConfig);
146
- }))).filter((item) => Boolean(item));
136
+ const plugins = await Promise.all(pluginConfigsNormalized.map(initializePlugin));
147
137
  (0, pluginIds_1.ensureUniquePluginInstanceIds)(plugins);
148
138
  return plugins;
149
139
  }
@@ -23,11 +23,8 @@ async function loadPresets(context) {
23
23
  if (typeof presetItem === 'string') {
24
24
  presetModuleImport = presetItem;
25
25
  }
26
- else if (Array.isArray(presetItem)) {
27
- [presetModuleImport, presetOptions = {}] = presetItem;
28
- }
29
26
  else {
30
- throw new Error('Invalid presets format detected in config.');
27
+ [presetModuleImport, presetOptions] = presetItem;
31
28
  }
32
29
  const presetName = (0, moduleShorthand_1.resolveModuleName)(presetModuleImport, presetRequire, 'preset');
33
30
  const presetModule = (0, import_fresh_1.default)(presetRequire.resolve(presetName));
@@ -134,8 +134,8 @@ registry, value, prefix, name) {
134
134
  return chunkName;
135
135
  }
136
136
  const newValue = {};
137
- Object.keys(value).forEach((key) => {
138
- newValue[key] = genRouteChunkNames(registry, value[key], key, name);
137
+ Object.entries(value).forEach(([key, v]) => {
138
+ newValue[key] = genRouteChunkNames(registry, v, key, name);
139
139
  });
140
140
  return newValue;
141
141
  }
@@ -16,7 +16,7 @@ async function loadThemeAliases(themePaths, userThemePaths) {
16
16
  const aliases = {};
17
17
  for (const themePath of themePaths) {
18
18
  const themeAliases = await (0, alias_1.default)(themePath, true);
19
- Object.keys(themeAliases).forEach((aliasKey) => {
19
+ Object.entries(themeAliases).forEach(([aliasKey, alias]) => {
20
20
  // If this alias shadows a previous one, use @theme-init to preserve the
21
21
  // initial one. @theme-init is only applied once: to the initial theme
22
22
  // that provided this component
@@ -27,7 +27,7 @@ async function loadThemeAliases(themePaths, userThemePaths) {
27
27
  aliases[initAlias] = aliases[aliasKey];
28
28
  }
29
29
  }
30
- aliases[aliasKey] = themeAliases[aliasKey];
30
+ aliases[aliasKey] = alias;
31
31
  });
32
32
  }
33
33
  for (const themePath of userThemePaths) {
@@ -19,11 +19,8 @@ async function getPackageJsonVersion(packageJsonPath) {
19
19
  }
20
20
  exports.getPackageJsonVersion = getPackageJsonVersion;
21
21
  async function getPackageJsonName(packageJsonPath) {
22
- if (await fs_extra_1.default.pathExists(packageJsonPath)) {
23
- // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require, global-require
24
- return require(packageJsonPath).name;
25
- }
26
- return undefined;
22
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require, global-require
23
+ return require(packageJsonPath).name;
27
24
  }
28
25
  async function getPluginVersion(pluginPath, siteDir) {
29
26
  let potentialPluginPackageJsonDirectory = path_1.default.dirname(pluginPath);
@@ -24,11 +24,10 @@ class ChunkAssetPlugin {
24
24
  compiler.hooks.thisCompilation.tap(pluginName, ({ mainTemplate }) => {
25
25
  mainTemplate.hooks.requireExtensions.tap(pluginName, (source, chunk) => {
26
26
  const chunkIdToName = chunk.getChunkMaps(false).name;
27
- const chunkNameToId = Object.create(null);
28
- Object.keys(chunkIdToName).forEach((chunkId) => {
29
- const chunkName = chunkIdToName[chunkId];
30
- chunkNameToId[chunkName] = chunkId;
31
- });
27
+ const chunkNameToId = Object.fromEntries(Object.entries(chunkIdToName).map(([chunkId, chunkName]) => [
28
+ chunkName,
29
+ chunkId,
30
+ ]));
32
31
  const buf = [source];
33
32
  buf.push('// function to get chunk asset');
34
33
  buf.push(
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-4678",
4
+ "version": "0.0.0-4682",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -41,13 +41,13 @@
41
41
  "@babel/runtime": "^7.17.2",
42
42
  "@babel/runtime-corejs3": "^7.17.2",
43
43
  "@babel/traverse": "^7.17.3",
44
- "@docusaurus/cssnano-preset": "0.0.0-4678",
45
- "@docusaurus/logger": "0.0.0-4678",
46
- "@docusaurus/mdx-loader": "0.0.0-4678",
44
+ "@docusaurus/cssnano-preset": "0.0.0-4682",
45
+ "@docusaurus/logger": "0.0.0-4682",
46
+ "@docusaurus/mdx-loader": "0.0.0-4682",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "0.0.0-4678",
49
- "@docusaurus/utils-common": "0.0.0-4678",
50
- "@docusaurus/utils-validation": "0.0.0-4678",
48
+ "@docusaurus/utils": "0.0.0-4682",
49
+ "@docusaurus/utils-common": "0.0.0-4682",
50
+ "@docusaurus/utils-validation": "0.0.0-4682",
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-4678",
110
- "@docusaurus/types": "0.0.0-4678",
109
+ "@docusaurus/module-type-aliases": "0.0.0-4682",
110
+ "@docusaurus/types": "0.0.0-4682",
111
111
  "@types/detect-port": "^1.3.2",
112
112
  "@types/nprogress": "^0.2.0",
113
113
  "@types/react-dom": "^17.0.11",
@@ -128,5 +128,5 @@
128
128
  "engines": {
129
129
  "node": ">=14"
130
130
  },
131
- "gitHead": "553449a1da416365f1980133f6059baa57e9df50"
131
+ "gitHead": "143b48a54a5604d348ff1ad02fd024c8cf9d33a2"
132
132
  }
File without changes
@@ -1,3 +0,0 @@
1
- {
2
- "version": "random-version"
3
- }