@docusaurus/core 0.0.0-4685 → 0.0.0-4693

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.
@@ -18,5 +18,5 @@ Current type: ${isValidElement(children) ? 'React element' : typeof children}`);
18
18
  }
19
19
  return <>{children()}</>;
20
20
  }
21
- return fallback || null;
21
+ return fallback ?? null;
22
22
  }
@@ -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" | "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>>;
22
+ }, "children" | "replace" | "slot" | "style" | "title" | "location" | "component" | "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;
@@ -110,7 +110,7 @@ function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLi
110
110
  return isRegularHtmlLink ? (
111
111
  // eslint-disable-next-line jsx-a11y/anchor-has-content
112
112
  <a ref={innerRef} href={targetLink} {...(targetLinkUnprefixed &&
113
- !isInternal && { target: '_blank', rel: 'noopener noreferrer' })} {...props}/>) : (<LinkComponent {...props} onMouseEnter={onMouseEnter} innerRef={handleRef} to={targetLink || ''}
113
+ !isInternal && { target: '_blank', rel: 'noopener noreferrer' })} {...props}/>) : (<LinkComponent {...props} onMouseEnter={onMouseEnter} innerRef={handleRef} to={targetLink}
114
114
  // avoid "React does not recognize the `activeClassName` prop on a DOM
115
115
  // element"
116
116
  {...(isNavLink && { isActive, activeClassName })}/>);
@@ -16,13 +16,7 @@ import { matchRoutes } from 'react-router-config';
16
16
  */
17
17
  export default function preload(routes, pathname) {
18
18
  const matches = matchRoutes(routes, pathname);
19
- return Promise.all(matches.map((match) => {
20
- const { component } = match.route;
21
- // @ts-expect-error: ComponentCreator injected this method.
22
- if (component && component.preload) {
23
- // @ts-expect-error: checked above.
24
- return component.preload();
25
- }
26
- return undefined;
27
- }));
19
+ return Promise.all(
20
+ // @ts-expect-error: ComponentCreator injected this method.
21
+ matches.map((match) => match.route.component?.preload?.()));
28
22
  }
@@ -81,13 +81,13 @@ async function doRender(locals) {
81
81
  // manifest information.
82
82
  const modulesToBeLoaded = [...manifest.entrypoints, ...Array.from(modules)];
83
83
  const bundles = getBundles(manifest, modulesToBeLoaded);
84
- const stylesheets = (bundles.css || []).map((b) => b.file);
85
- const scripts = (bundles.js || []).map((b) => b.file);
84
+ const stylesheets = (bundles.css ?? []).map((b) => b.file);
85
+ const scripts = (bundles.js ?? []).map((b) => b.file);
86
86
  const renderedHtml = renderSSRTemplate(ssrTemplate, {
87
87
  appHtml,
88
88
  baseUrl,
89
- htmlAttributes: htmlAttributes || '',
90
- bodyAttributes: bodyAttributes || '',
89
+ htmlAttributes,
90
+ bodyAttributes,
91
91
  headTags,
92
92
  preBodyTags,
93
93
  postBodyTags,
@@ -11,7 +11,7 @@ const tslib_1 = require("tslib");
11
11
  const choosePort_1 = tslib_1.__importDefault(require("../choosePort"));
12
12
  const utils_1 = require("@docusaurus/utils");
13
13
  function getCLIOptionHost(hostOption) {
14
- return hostOption || 'localhost';
14
+ return hostOption ?? 'localhost';
15
15
  }
16
16
  exports.getCLIOptionHost = getCLIOptionHost;
17
17
  async function getCLIOptionPort(portOption, host) {
@@ -60,17 +60,16 @@ async function start(siteDir, cliOptions) {
60
60
  logger_1.default.error(err.stack);
61
61
  });
62
62
  }, 500);
63
- const { siteConfig, plugins = [] } = props;
63
+ const { siteConfig, plugins } = props;
64
64
  const normalizeToSiteDir = (filepath) => {
65
65
  if (filepath && path_1.default.isAbsolute(filepath)) {
66
66
  return (0, utils_1.posixPath)(path_1.default.relative(siteDir, filepath));
67
67
  }
68
68
  return (0, utils_1.posixPath)(filepath);
69
69
  };
70
- const pluginPaths = []
71
- .concat(...plugins
72
- .map((plugin) => plugin.getPathsToWatch?.() ?? [])
73
- .filter(Boolean))
70
+ const pluginPaths = plugins
71
+ .flatMap((plugin) => plugin.getPathsToWatch?.() ?? [])
72
+ .filter(Boolean)
74
73
  .map(normalizeToSiteDir);
75
74
  const pathsToWatch = [
76
75
  ...pluginPaths,
@@ -5,20 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { RouteConfig, ReportingSeverity } from '@docusaurus/types';
8
- declare type BrokenLink = {
9
- link: string;
10
- resolvedLink: string;
11
- };
12
- export declare function getAllBrokenLinks({ allCollectedLinks, routes, }: {
13
- allCollectedLinks: Record<string, string[]>;
14
- routes: RouteConfig[];
15
- }): Record<string, BrokenLink[]>;
16
- export declare function getBrokenLinksErrorMessage(allBrokenLinks: Record<string, BrokenLink[]>): string | undefined;
17
- export declare function filterExistingFileLinks({ baseUrl, outDir, allCollectedLinks, }: {
18
- baseUrl: string;
19
- outDir: string;
20
- allCollectedLinks: Record<string, string[]>;
21
- }): Promise<Record<string, string[]>>;
22
8
  export declare function handleBrokenLinks({ allCollectedLinks, onBrokenLinks, routes, baseUrl, outDir, }: {
23
9
  allCollectedLinks: Record<string, string[]>;
24
10
  onBrokenLinks: ReportingSeverity;
@@ -26,4 +12,3 @@ export declare function handleBrokenLinks({ allCollectedLinks, onBrokenLinks, ro
26
12
  baseUrl: string;
27
13
  outDir: string;
28
14
  }): Promise<void>;
29
- export {};
@@ -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 = exports.filterExistingFileLinks = exports.getBrokenLinksErrorMessage = exports.getAllBrokenLinks = void 0;
9
+ exports.handleBrokenLinks = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const react_router_config_1 = require("react-router-config");
12
12
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
@@ -57,7 +57,6 @@ function getAllBrokenLinks({ allCollectedLinks, routes, }) {
57
57
  // remove pages without any broken link
58
58
  return lodash_1.default.pickBy(allBrokenLinks, (brokenLinks) => brokenLinks.length > 0);
59
59
  }
60
- exports.getAllBrokenLinks = getAllBrokenLinks;
61
60
  function getBrokenLinksErrorMessage(allBrokenLinks) {
62
61
  if (Object.keys(allBrokenLinks).length === 0) {
63
62
  return undefined;
@@ -93,8 +92,7 @@ function getBrokenLinksErrorMessage(allBrokenLinks) {
93
92
  It looks like some of the broken links we found appear in many pages of your site.
94
93
  Maybe those broken links appear on all pages through your site layout?
95
94
  We recommend that you check your theme configuration for such links (particularly, theme navbar and footer).
96
- Frequent broken links are linking to:${frequentLinks}
97
- `;
95
+ Frequent broken links are linking to:${frequentLinks}`;
98
96
  }
99
97
  return `Docusaurus found broken links!
100
98
 
@@ -107,7 +105,6 @@ ${Object.entries(allBrokenLinks)
107
105
  .join('\n')}
108
106
  `;
109
107
  }
110
- exports.getBrokenLinksErrorMessage = getBrokenLinksErrorMessage;
111
108
  async function isExistingFile(filePath) {
112
109
  try {
113
110
  return (await fs_extra_1.default.stat(filePath)).isFile();
@@ -139,7 +136,6 @@ async function filterExistingFileLinks({ baseUrl, outDir, allCollectedLinks, })
139
136
  }
140
137
  return (0, combine_promises_1.default)(lodash_1.default.mapValues(allCollectedLinks, async (links) => (await Promise.all(links.map(async (link) => ((await linkFileExists(link)) ? '' : link)))).filter(Boolean)));
141
138
  }
142
- exports.filterExistingFileLinks = filterExistingFileLinks;
143
139
  async function handleBrokenLinks({ allCollectedLinks, onBrokenLinks, routes, baseUrl, outDir, }) {
144
140
  if (onBrokenLinks === 'ignore') {
145
141
  return;
@@ -7,6 +7,6 @@
7
7
  import type { DocusaurusConfig, I18nConfig } from '@docusaurus/types';
8
8
  import { Joi } from '@docusaurus/utils-validation';
9
9
  export declare const DEFAULT_I18N_CONFIG: I18nConfig;
10
- export declare const DEFAULT_CONFIG: Pick<DocusaurusConfig, 'i18n' | 'onBrokenLinks' | 'onBrokenMarkdownLinks' | 'onDuplicateRoutes' | 'plugins' | 'themes' | 'presets' | 'customFields' | 'themeConfig' | 'titleDelimiter' | 'noIndex' | 'tagline' | 'baseUrlIssueBanner' | 'staticDirectories'>;
10
+ export declare const DEFAULT_CONFIG: Pick<DocusaurusConfig, 'i18n' | 'onBrokenLinks' | 'onBrokenMarkdownLinks' | 'onDuplicateRoutes' | 'plugins' | 'themes' | 'presets' | 'stylesheets' | 'scripts' | 'clientModules' | 'customFields' | 'themeConfig' | 'titleDelimiter' | 'noIndex' | 'tagline' | 'baseUrlIssueBanner' | 'staticDirectories'>;
11
11
  export declare const ConfigSchema: Joi.ObjectSchema<any>;
12
12
  export declare function validateConfig(config: Partial<DocusaurusConfig>): DocusaurusConfig;
@@ -23,6 +23,9 @@ exports.DEFAULT_CONFIG = {
23
23
  plugins: [],
24
24
  themes: [],
25
25
  presets: [],
26
+ stylesheets: [],
27
+ scripts: [],
28
+ clientModules: [],
26
29
  customFields: {},
27
30
  themeConfig: {},
28
31
  titleDelimiter: '|',
@@ -131,19 +134,25 @@ exports.ConfigSchema = utils_validation_1.Joi.object({
131
134
  themes: utils_validation_1.Joi.array().items(ThemeSchema).default(exports.DEFAULT_CONFIG.themes),
132
135
  presets: utils_validation_1.Joi.array().items(PresetSchema).default(exports.DEFAULT_CONFIG.presets),
133
136
  themeConfig: utils_validation_1.Joi.object().unknown().default(exports.DEFAULT_CONFIG.themeConfig),
134
- scripts: utils_validation_1.Joi.array().items(utils_validation_1.Joi.string(), utils_validation_1.Joi.object({
137
+ scripts: utils_validation_1.Joi.array()
138
+ .items(utils_validation_1.Joi.string(), utils_validation_1.Joi.object({
135
139
  src: utils_validation_1.Joi.string().required(),
136
140
  async: utils_validation_1.Joi.bool(),
137
141
  defer: utils_validation_1.Joi.bool(),
138
142
  })
139
143
  // See https://github.com/facebook/docusaurus/issues/3378
140
- .unknown()),
144
+ .unknown())
145
+ .default(exports.DEFAULT_CONFIG.scripts),
141
146
  ssrTemplate: utils_validation_1.Joi.string(),
142
- stylesheets: utils_validation_1.Joi.array().items(utils_validation_1.Joi.string(), utils_validation_1.Joi.object({
147
+ stylesheets: utils_validation_1.Joi.array()
148
+ .items(utils_validation_1.Joi.string(), utils_validation_1.Joi.object({
143
149
  href: utils_validation_1.Joi.string().required(),
144
150
  type: utils_validation_1.Joi.string(),
145
- }).unknown()),
146
- clientModules: utils_validation_1.Joi.array().items(utils_validation_1.Joi.string()),
151
+ }).unknown())
152
+ .default(exports.DEFAULT_CONFIG.stylesheets),
153
+ clientModules: utils_validation_1.Joi.array()
154
+ .items(utils_validation_1.Joi.string())
155
+ .default(exports.DEFAULT_CONFIG.clientModules),
147
156
  tagline: utils_validation_1.Joi.string().allow('').default(exports.DEFAULT_CONFIG.tagline),
148
157
  titleDelimiter: utils_validation_1.Joi.string().default('|'),
149
158
  noIndex: utils_validation_1.Joi.bool().default(false),
@@ -5,6 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { ReportingSeverity, RouteConfig } from '@docusaurus/types';
8
- export declare function getAllDuplicateRoutes(pluginsRouteConfigs: RouteConfig[]): string[];
9
- export declare function getDuplicateRoutesMessage(allDuplicateRoutes: string[]): string;
10
8
  export declare function handleDuplicateRoutes(pluginsRouteConfigs: RouteConfig[], onDuplicateRoutes: ReportingSeverity): void;
@@ -6,28 +6,26 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.handleDuplicateRoutes = exports.getDuplicateRoutesMessage = exports.getAllDuplicateRoutes = void 0;
9
+ exports.handleDuplicateRoutes = void 0;
10
10
  const utils_1 = require("@docusaurus/utils");
11
11
  const utils_2 = require("./utils");
12
12
  function getAllDuplicateRoutes(pluginsRouteConfigs) {
13
13
  const allRoutes = (0, utils_2.getAllFinalRoutes)(pluginsRouteConfigs).map((routeConfig) => routeConfig.path);
14
- const seenRoutes = {};
14
+ const seenRoutes = new Set();
15
15
  return allRoutes.filter((route) => {
16
- if (Object.prototype.hasOwnProperty.call(seenRoutes, route)) {
16
+ if (seenRoutes.has(route)) {
17
17
  return true;
18
18
  }
19
- seenRoutes[route] = true;
19
+ seenRoutes.add(route);
20
20
  return false;
21
21
  });
22
22
  }
23
- exports.getAllDuplicateRoutes = getAllDuplicateRoutes;
24
23
  function getDuplicateRoutesMessage(allDuplicateRoutes) {
25
24
  const message = allDuplicateRoutes
26
- .map((duplicateRoute) => `Attempting to create page at ${duplicateRoute}, but a page already exists at this route`)
25
+ .map((duplicateRoute) => `- Attempting to create page at ${duplicateRoute}, but a page already exists at this route.`)
27
26
  .join('\n');
28
27
  return message;
29
28
  }
30
- exports.getDuplicateRoutesMessage = getDuplicateRoutesMessage;
31
29
  function handleDuplicateRoutes(pluginsRouteConfigs, onDuplicateRoutes) {
32
30
  if (onDuplicateRoutes === 'ignore') {
33
31
  return;
@@ -35,7 +33,9 @@ function handleDuplicateRoutes(pluginsRouteConfigs, onDuplicateRoutes) {
35
33
  const duplicatePaths = getAllDuplicateRoutes(pluginsRouteConfigs);
36
34
  const message = getDuplicateRoutesMessage(duplicatePaths);
37
35
  if (message) {
38
- const finalMessage = `Duplicate routes found!\n${message}\nThis could lead to non-deterministic routing behavior`;
36
+ const finalMessage = `Duplicate routes found!
37
+ ${message}
38
+ This could lead to non-deterministic routing behavior.`;
39
39
  (0, utils_1.reportMessage)(finalMessage, onDuplicateRoutes);
40
40
  }
41
41
  }
@@ -24,7 +24,7 @@ function htmlTagObjectToString(tagDefinition) {
24
24
  throw new Error(`Error loading ${JSON.stringify(tagDefinition)}, "${tagDefinition.tagName}" is not a valid HTML tags.`);
25
25
  }
26
26
  const isVoidTag = void_1.default.indexOf(tagDefinition.tagName) !== -1;
27
- const tagAttributes = tagDefinition.attributes || {};
27
+ const tagAttributes = tagDefinition.attributes ?? {};
28
28
  const attributes = Object.keys(tagAttributes)
29
29
  .filter((attributeName) => tagAttributes[attributeName] !== false)
30
30
  .map((attributeName) => {
@@ -4,6 +4,5 @@
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 { InjectedHtmlTags, HtmlTags, LoadedPlugin } from '@docusaurus/types';
8
- export declare function createHtmlTagsString(tags: HtmlTags): string;
7
+ import type { InjectedHtmlTags, LoadedPlugin } from '@docusaurus/types';
9
8
  export declare function loadHtmlTags(plugins: LoadedPlugin[]): InjectedHtmlTags;
@@ -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.loadHtmlTags = exports.createHtmlTagsString = void 0;
9
+ exports.loadHtmlTags = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const htmlTags_1 = tslib_1.__importDefault(require("./htmlTags"));
12
12
  function toString(val) {
@@ -15,13 +15,12 @@ function toString(val) {
15
15
  function createHtmlTagsString(tags) {
16
16
  return Array.isArray(tags) ? tags.map(toString).join('\n') : toString(tags);
17
17
  }
18
- exports.createHtmlTagsString = createHtmlTagsString;
19
18
  function loadHtmlTags(plugins) {
20
19
  const htmlTags = plugins.reduce((acc, plugin) => {
21
20
  if (!plugin.injectHtmlTags) {
22
21
  return acc;
23
22
  }
24
- const { headTags, preBodyTags, postBodyTags } = plugin.injectHtmlTags({ content: plugin.content }) || {};
23
+ const { headTags, preBodyTags, postBodyTags } = plugin.injectHtmlTags({ content: plugin.content }) ?? {};
25
24
  return {
26
25
  headTags: headTags
27
26
  ? `${acc.headTags}\n${createHtmlTagsString(headTags)}`
@@ -14,9 +14,6 @@ const rtl_detect_1 = require("rtl-detect");
14
14
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
15
15
  function getDefaultLocaleLabel(locale) {
16
16
  const languageName = new Intl.DisplayNames(locale, { type: 'language' }).of(locale);
17
- if (!languageName) {
18
- return locale;
19
- }
20
17
  return (languageName.charAt(0).toLocaleUpperCase(locale) + languageName.substring(1));
21
18
  }
22
19
  function getDefaultLocaleConfig(locale) {
@@ -100,8 +100,8 @@ async function loadPluginConfigs(context) {
100
100
  }
101
101
  presetPlugins = presetPlugins.map((plugin) => normalizeShorthand(plugin, 'plugin'));
102
102
  presetThemes = presetThemes.map((theme) => normalizeShorthand(theme, 'theme'));
103
- const standalonePlugins = (siteConfig.plugins || []).map((plugin) => normalizeShorthand(plugin, 'plugin'));
104
- const standaloneThemes = (siteConfig.themes || []).map((theme) => normalizeShorthand(theme, 'theme'));
103
+ const standalonePlugins = siteConfig.plugins.map((plugin) => normalizeShorthand(plugin, 'plugin'));
104
+ const standaloneThemes = siteConfig.themes.map((theme) => normalizeShorthand(theme, 'theme'));
105
105
  return [
106
106
  ...presetPlugins,
107
107
  ...presetThemes,
@@ -115,7 +115,7 @@ exports.loadPluginConfigs = loadPluginConfigs;
115
115
  // - Resolve aliased theme components
116
116
  // - Inject scripts/stylesheets
117
117
  function createBootstrapPlugin({ siteConfig, }) {
118
- const { stylesheets = [], scripts = [], clientModules: siteConfigClientModules = [], } = siteConfig;
118
+ const { stylesheets, scripts, clientModules: siteConfigClientModules, } = siteConfig;
119
119
  return {
120
120
  name: 'docusaurus-bootstrap-plugin',
121
121
  content: null,
@@ -208,6 +208,7 @@ async function load(siteDir, options = {}) {
208
208
  context.siteConfig.themeConfig = themeConfigTranslated;
209
209
  (0, duplicateRoutes_1.handleDuplicateRoutes)(pluginsRouteConfigs, siteConfig.onDuplicateRoutes);
210
210
  const genWarning = (0, utils_1.generate)(generatedFilesDir, 'DONT-EDIT-THIS-FOLDER', `This folder stores temp files that Docusaurus' client bundler accesses.
211
+
211
212
  DO NOT hand-modify files in this folder because they will be overwritten in the
212
213
  next build. You can clear all build artifacts (including this folder) with the
213
214
  \`docusaurus clear\` command.
@@ -215,20 +216,24 @@ next build. You can clear all build artifacts (including this folder) with the
215
216
  // Site config must be generated after plugins
216
217
  // We want the generated config to have been normalized by the plugins!
217
218
  const genSiteConfig = (0, utils_1.generate)(generatedFilesDir, utils_1.DEFAULT_CONFIG_FILE_NAME, `/*
218
- AUTOGENERATED - DON'T EDIT
219
- Your edits in this file will be overwritten in the next build!
220
- Modify the docusaurus.config.js file at your site's root instead.
221
- */
222
- export default ${JSON.stringify(siteConfig, null, 2)};`);
219
+ * AUTOGENERATED - DON'T EDIT
220
+ * Your edits in this file will be overwritten in the next build!
221
+ * Modify the docusaurus.config.js file at your site's root instead.
222
+ */
223
+ export default ${JSON.stringify(siteConfig, null, 2)};
224
+ `);
223
225
  plugins.push(createBootstrapPlugin({ siteConfig }));
224
226
  plugins.push(createMDXFallbackPlugin({ siteDir, siteConfig }));
225
227
  // Load client modules.
226
228
  const clientModules = (0, client_modules_1.default)(plugins);
227
- const genClientModules = (0, utils_1.generate)(generatedFilesDir, 'client-modules.js', `export default [\n${clientModules
229
+ const genClientModules = (0, utils_1.generate)(generatedFilesDir, 'client-modules.js', `export default [
230
+ ${clientModules
228
231
  // import() is async so we use require() because client modules can have
229
232
  // CSS and the order matters for loading CSS.
230
233
  .map((module) => ` require('${(0, utils_1.escapePath)(module)}'),`)
231
- .join('\n')}\n];\n`);
234
+ .join('\n')}
235
+ ];
236
+ `);
232
237
  // Load extra head & body html tags.
233
238
  const { headTags, preBodyTags, postBodyTags } = (0, html_tags_1.loadHtmlTags)(plugins);
234
239
  // Routing.
@@ -237,7 +242,8 @@ export default ${JSON.stringify(siteConfig, null, 2)};`);
237
242
  ${Object.entries(registry)
238
243
  .sort((a, b) => a[0].localeCompare(b[0]))
239
244
  .map(([key, chunk]) => ` '${key}': [${chunk.loader}, '${(0, utils_1.escapePath)(chunk.modulePath)}', require.resolveWeak('${(0, utils_1.escapePath)(chunk.modulePath)}')],`)
240
- .join('\n')}};\n`);
245
+ .join('\n')}};
246
+ `);
241
247
  const genRoutesChunkNames = (0, utils_1.generate)(generatedFilesDir, 'routesChunkNames.json', JSON.stringify(routesChunkNames, null, 2));
242
248
  const genRoutes = (0, utils_1.generate)(generatedFilesDir, 'routes.js', routesConfig);
243
249
  const genGlobalData = (0, utils_1.generate)(generatedFilesDir, 'globalData.json', JSON.stringify(globalData, null, 2));
@@ -14,9 +14,9 @@ async function loadPresets(context) {
14
14
  // We need to resolve presets from the perspective of the siteDir, since the
15
15
  // siteDir's package.json declares the dependency on these presets.
16
16
  const presetRequire = (0, module_1.createRequire)(context.siteConfigPath);
17
- const presets = context.siteConfig.presets || [];
18
- const unflatPlugins = [];
19
- const unflatThemes = [];
17
+ const { presets } = context.siteConfig;
18
+ const plugins = [];
19
+ const themes = [];
20
20
  presets.forEach((presetItem) => {
21
21
  let presetModuleImport;
22
22
  let presetOptions = {};
@@ -30,15 +30,12 @@ async function loadPresets(context) {
30
30
  const presetModule = (0, import_fresh_1.default)(presetRequire.resolve(presetName));
31
31
  const preset = (presetModule.default ?? presetModule)(context, presetOptions);
32
32
  if (preset.plugins) {
33
- unflatPlugins.push(preset.plugins);
33
+ plugins.push(...preset.plugins.filter(Boolean));
34
34
  }
35
35
  if (preset.themes) {
36
- unflatThemes.push(preset.themes);
36
+ themes.push(...preset.themes.filter(Boolean));
37
37
  }
38
38
  });
39
- return {
40
- plugins: unflatPlugins.flat().filter(Boolean),
41
- themes: unflatThemes.flat().filter(Boolean),
42
- };
39
+ return { plugins, themes };
43
40
  }
44
41
  exports.default = loadPresets;
@@ -86,7 +86,7 @@ class CleanWebpackPlugin {
86
86
  const statsAssets = stats.toJson({
87
87
  all: false,
88
88
  assets: true,
89
- }).assets || [];
89
+ }).assets ?? [];
90
90
  const assets = statsAssets.map((asset) => asset.name);
91
91
  /**
92
92
  * Get all files that were in the previous build but not the current
@@ -31,6 +31,12 @@ export declare const getCustomizableJSLoader: (jsLoader?: "babel" | ((isServer:
31
31
  */
32
32
  export declare function applyConfigureWebpack(configureWebpack: ConfigureWebpackFn, config: Configuration, isServer: boolean, jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined, content: unknown): Configuration;
33
33
  export declare function applyConfigurePostCss(configurePostCss: NonNullable<ConfigurePostCssFn>, config: Configuration): Configuration;
34
+ declare global {
35
+ interface Error {
36
+ /** @see https://webpack.js.org/api/node/#error-handling */
37
+ details: unknown;
38
+ }
39
+ }
34
40
  export declare function compile(config: Configuration[]): Promise<void>;
35
41
  export declare function getHttpsConfig(): Promise<boolean | {
36
42
  cert: Buffer;
@@ -171,9 +171,7 @@ function compile(config) {
171
171
  compiler.run((err, stats) => {
172
172
  if (err) {
173
173
  logger_1.default.error(err.stack || err);
174
- // @ts-expect-error: see https://webpack.js.org/api/node/#error-handling
175
174
  if (err.details) {
176
- // @ts-expect-error: see https://webpack.js.org/api/node/#error-handling
177
175
  logger_1.default.error(err.details);
178
176
  }
179
177
  reject(err);
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-4685",
4
+ "version": "0.0.0-4693",
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-4685",
45
- "@docusaurus/logger": "0.0.0-4685",
46
- "@docusaurus/mdx-loader": "0.0.0-4685",
44
+ "@docusaurus/cssnano-preset": "0.0.0-4693",
45
+ "@docusaurus/logger": "0.0.0-4693",
46
+ "@docusaurus/mdx-loader": "0.0.0-4693",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "0.0.0-4685",
49
- "@docusaurus/utils-common": "0.0.0-4685",
50
- "@docusaurus/utils-validation": "0.0.0-4685",
48
+ "@docusaurus/utils": "0.0.0-4693",
49
+ "@docusaurus/utils-common": "0.0.0-4693",
50
+ "@docusaurus/utils-validation": "0.0.0-4693",
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-4685",
110
- "@docusaurus/types": "0.0.0-4685",
109
+ "@docusaurus/module-type-aliases": "0.0.0-4693",
110
+ "@docusaurus/types": "0.0.0-4693",
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": "3a492428ff3bf2051bc6b660803a735d67c8ae66"
131
+ "gitHead": "f5ed3eaf62d30a211da3b0aaf76dfc6deafba859"
132
132
  }