@docusaurus/core 3.4.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/docusaurus.mjs +13 -12
- package/lib/babel/preset.js +1 -1
- package/lib/client/App.d.ts +0 -2
- package/lib/client/BaseUrlIssueBanner/index.d.ts +0 -1
- package/lib/client/BrokenLinksContext.d.ts +0 -1
- package/lib/client/SiteMetadataDefaults.d.ts +0 -1
- package/lib/client/exports/BrowserOnly.d.ts +0 -2
- package/lib/client/exports/ErrorBoundary.d.ts +0 -1
- package/lib/client/exports/Head.d.ts +0 -2
- package/lib/client/exports/Interpolate.d.ts +0 -1
- package/lib/client/exports/Link.d.ts +0 -1
- package/lib/client/exports/Link.js +15 -4
- package/lib/client/exports/Translate.d.ts +0 -2
- package/lib/client/exports/useBaseUrl.d.ts +0 -1
- package/lib/client/exports/useBrokenLinks.d.ts +0 -1
- package/lib/client/hasHydratedDataAttribute.d.ts +0 -1
- package/lib/client/theme-fallback/Error/index.d.ts +0 -2
- package/lib/client/theme-fallback/Layout/index.d.ts +0 -2
- package/lib/client/theme-fallback/Loading/index.d.ts +0 -1
- package/lib/client/theme-fallback/NotFound/index.d.ts +0 -1
- package/lib/client/theme-fallback/Root/index.d.ts +0 -2
- package/lib/client/theme-fallback/SiteMetadata/index.d.ts +0 -1
- package/lib/commands/build.js +1 -2
- package/lib/commands/clear.js +1 -2
- package/lib/commands/deploy.js +1 -2
- package/lib/commands/external.js +1 -2
- package/lib/commands/serve.js +2 -3
- package/lib/commands/start/start.js +1 -2
- package/lib/commands/start/utils.js +2 -3
- package/lib/commands/start/watcher.js +5 -6
- package/lib/commands/start/webpack.js +1 -2
- package/lib/commands/swizzle/actions.js +4 -4
- package/lib/commands/swizzle/common.js +7 -7
- package/lib/commands/swizzle/components.js +5 -6
- package/lib/commands/swizzle/config.js +2 -3
- package/lib/commands/swizzle/context.js +19 -8
- package/lib/commands/swizzle/index.js +1 -2
- package/lib/commands/swizzle/prompts.js +4 -5
- package/lib/commands/swizzle/tables.js +2 -3
- package/lib/commands/swizzle/themes.js +5 -6
- package/lib/commands/writeHeadingIds.js +1 -2
- package/lib/commands/writeTranslations.js +1 -2
- package/lib/server/brokenLinks.js +1 -2
- package/lib/server/clientModules.js +1 -2
- package/lib/server/codegen/codegen.js +1 -2
- package/lib/server/codegen/codegenRoutes.js +4 -5
- package/lib/server/config.js +1 -2
- package/lib/server/configValidation.js +2 -2
- package/lib/server/getHostPort.js +1 -2
- package/lib/server/htmlTags.js +1 -2
- package/lib/server/i18n.js +2 -3
- package/lib/server/plugins/actions.js +1 -2
- package/lib/server/plugins/configs.js +1 -2
- package/lib/server/plugins/init.d.ts +11 -0
- package/lib/server/plugins/init.js +42 -7
- package/lib/server/plugins/moduleShorthand.d.ts +0 -1
- package/lib/server/plugins/moduleShorthand.js +2 -3
- package/lib/server/plugins/pluginIds.js +1 -2
- package/lib/server/plugins/plugins.js +2 -3
- package/lib/server/plugins/pluginsUtils.js +7 -8
- package/lib/server/plugins/presets.js +1 -2
- package/lib/server/plugins/routeConfig.js +2 -3
- package/lib/server/plugins/synthetic.js +2 -3
- package/lib/server/routes.js +2 -3
- package/lib/server/site.js +4 -5
- package/lib/server/siteMetadata.js +3 -4
- package/lib/server/storage.js +1 -2
- package/lib/server/translations/translations.js +9 -10
- package/lib/server/translations/translationsExtractor.js +4 -5
- package/lib/server/utils.js +1 -2
- package/lib/ssg.d.ts +0 -1
- package/lib/ssg.js +3 -4
- package/lib/templates/templates.js +3 -4
- package/lib/webpack/aliases/index.js +4 -5
- package/lib/webpack/base.js +3 -3
- package/lib/webpack/client.js +3 -4
- package/lib/webpack/configure.js +3 -4
- package/lib/webpack/minification.js +1 -2
- package/lib/webpack/plugins/StaticDirectoriesCopyPlugin.js +1 -2
- package/lib/webpack/server.js +1 -1
- package/lib/webpack/utils.d.ts +1 -2
- package/lib/webpack/utils.js +8 -8
- package/package.json +10 -10
package/bin/docusaurus.mjs
CHANGED
|
@@ -222,7 +222,8 @@ cli
|
|
|
222
222
|
|
|
223
223
|
cli.arguments('<command>').action((cmd) => {
|
|
224
224
|
cli.outputHelp();
|
|
225
|
-
logger.error`
|
|
225
|
+
logger.error`Unknown Docusaurus CLI command name=${cmd}.`;
|
|
226
|
+
process.exit(1);
|
|
226
227
|
});
|
|
227
228
|
|
|
228
229
|
// === The above is the commander configuration ===
|
|
@@ -247,24 +248,24 @@ function isInternalCommand(command) {
|
|
|
247
248
|
);
|
|
248
249
|
}
|
|
249
250
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
// ]
|
|
251
|
+
/**
|
|
252
|
+
* @param {string | undefined} command
|
|
253
|
+
*/
|
|
254
|
+
function isExternalCommand(command) {
|
|
255
|
+
return !!(command && !isInternalCommand(command) && !command.startsWith('-'));
|
|
256
|
+
}
|
|
257
257
|
|
|
258
|
-
//
|
|
259
|
-
//
|
|
260
|
-
if (process.argv.length < 3
|
|
258
|
+
// No command? We print the help message because Commander doesn't
|
|
259
|
+
// Note argv looks like this: ['../node','../docusaurus.mjs','<command>',...rest]
|
|
260
|
+
if (process.argv.length < 3) {
|
|
261
261
|
cli.outputHelp();
|
|
262
|
+
logger.error`Please provide a Docusaurus CLI command.`;
|
|
262
263
|
process.exit(1);
|
|
263
264
|
}
|
|
264
265
|
|
|
265
266
|
// There is an unrecognized subcommand
|
|
266
267
|
// Let plugins extend the CLI before parsing
|
|
267
|
-
if (
|
|
268
|
+
if (isExternalCommand(process.argv[2])) {
|
|
268
269
|
// TODO: in this step, we must assume default site structure because there's
|
|
269
270
|
// no way to know the siteDir/config yet. Maybe the root cli should be
|
|
270
271
|
// responsible for parsing these arguments?
|
package/lib/babel/preset.js
CHANGED
|
@@ -6,6 +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.default = babelPresets;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
12
|
function getTransformOptions(isServer) {
|
|
@@ -77,4 +78,3 @@ function babelPresets(api) {
|
|
|
77
78
|
const callerName = api.caller((caller) => caller?.name);
|
|
78
79
|
return getTransformOptions(callerName === 'server');
|
|
79
80
|
}
|
|
80
|
-
exports.default = babelPresets;
|
package/lib/client/App.d.ts
CHANGED
|
@@ -4,7 +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
|
-
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
|
-
/// <reference types="react" />
|
|
9
7
|
import '@generated/client-modules';
|
|
10
8
|
export default function App(): JSX.Element;
|
|
@@ -4,7 +4,6 @@
|
|
|
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
|
-
/// <reference types="react" />
|
|
8
7
|
import './styles.module.css';
|
|
9
8
|
/**
|
|
10
9
|
* We want to help the users with a bad baseUrl configuration (very common
|
|
@@ -4,7 +4,6 @@
|
|
|
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
|
-
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
7
|
import { type ReactNode } from 'react';
|
|
9
8
|
import type { BrokenLinks } from '@docusaurus/useBrokenLinks';
|
|
10
9
|
export type StatefulBrokenLinks = BrokenLinks & {
|
|
@@ -4,7 +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
|
-
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
|
-
/// <reference types="react" />
|
|
9
7
|
import type { Props } from '@docusaurus/BrowserOnly';
|
|
10
8
|
export default function BrowserOnly({ children, fallback, }: Props): JSX.Element | null;
|
|
@@ -4,7 +4,6 @@
|
|
|
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
|
-
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
7
|
import React, { type ReactNode } from 'react';
|
|
9
8
|
import type { Props } from '@docusaurus/ErrorBoundary';
|
|
10
9
|
type State = {
|
|
@@ -4,7 +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
|
-
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
|
-
/// <reference types="react" />
|
|
9
7
|
import type { Props } from '@docusaurus/Head';
|
|
10
8
|
export default function Head(props: Props): JSX.Element;
|
|
@@ -4,7 +4,6 @@
|
|
|
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
|
-
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
7
|
import { type ReactNode } from 'react';
|
|
9
8
|
import type { InterpolateProps, InterpolateValues } from '@docusaurus/Interpolate';
|
|
10
9
|
export declare function interpolate<Str extends string>(text: Str, values?: InterpolateValues<Str, string | number>): string;
|
|
@@ -4,7 +4,6 @@
|
|
|
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
|
-
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
7
|
import React from 'react';
|
|
9
8
|
import type { Props } from '@docusaurus/Link';
|
|
10
9
|
declare const _default: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
@@ -95,7 +95,7 @@ function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLi
|
|
|
95
95
|
};
|
|
96
96
|
useEffect(() => {
|
|
97
97
|
// If IO is not supported. We prefetch by default (only once).
|
|
98
|
-
if (!IOSupported && isInternal) {
|
|
98
|
+
if (!IOSupported && isInternal && ExecutionEnvironment.canUseDOM) {
|
|
99
99
|
if (targetLink != null) {
|
|
100
100
|
window.docusaurus.prefetch(targetLink);
|
|
101
101
|
}
|
|
@@ -113,19 +113,30 @@ function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLi
|
|
|
113
113
|
// https://github.com/remix-run/react-router/blob/v5/packages/react-router-dom/modules/Link.js#L47
|
|
114
114
|
const hasInternalTarget = !props.target || props.target === '_self';
|
|
115
115
|
// Should we use a regular <a> tag instead of React-Router Link component?
|
|
116
|
-
const isRegularHtmlLink = !targetLink ||
|
|
116
|
+
const isRegularHtmlLink = !targetLink ||
|
|
117
|
+
!isInternal ||
|
|
118
|
+
!hasInternalTarget ||
|
|
119
|
+
// When using the hash router, we can't use the regular <a> link for anchors
|
|
120
|
+
// We need to use React Router to navigate to /#/pathname/#anchor
|
|
121
|
+
// And not /#anchor
|
|
122
|
+
// See also https://github.com/facebook/docusaurus/pull/10311
|
|
123
|
+
(isAnchorLink && router !== 'hash');
|
|
117
124
|
if (!noBrokenLinkCheck && (isAnchorLink || !isRegularHtmlLink)) {
|
|
118
125
|
brokenLinks.collectLink(targetLink);
|
|
119
126
|
}
|
|
120
127
|
if (props.id) {
|
|
121
128
|
brokenLinks.collectAnchor(props.id);
|
|
122
129
|
}
|
|
130
|
+
// These props are only added in unit tests to assert/capture the type of link
|
|
131
|
+
const testOnlyProps = process.env.NODE_ENV === 'test'
|
|
132
|
+
? { 'data-test-link-type': isRegularHtmlLink ? 'regular' : 'react-router' }
|
|
133
|
+
: {};
|
|
123
134
|
return isRegularHtmlLink ? (
|
|
124
135
|
// eslint-disable-next-line jsx-a11y/anchor-has-content, @docusaurus/no-html-links
|
|
125
136
|
<a ref={innerRef} href={targetLink} {...(targetLinkUnprefixed &&
|
|
126
|
-
!isInternal && { target: '_blank', rel: 'noopener noreferrer' })} {...props}/>) : (<LinkComponent {...props} onMouseEnter={onInteractionEnter} onTouchStart={onInteractionEnter} innerRef={handleRef} to={targetLink}
|
|
137
|
+
!isInternal && { target: '_blank', rel: 'noopener noreferrer' })} {...props} {...testOnlyProps}/>) : (<LinkComponent {...props} onMouseEnter={onInteractionEnter} onTouchStart={onInteractionEnter} innerRef={handleRef} to={targetLink}
|
|
127
138
|
// Avoid "React does not recognize the `activeClassName` prop on a DOM
|
|
128
139
|
// element"
|
|
129
|
-
{...(isNavLink && { isActive, activeClassName })}/>);
|
|
140
|
+
{...(isNavLink && { isActive, activeClassName })} {...testOnlyProps}/>);
|
|
130
141
|
}
|
|
131
142
|
export default React.forwardRef(Link);
|
|
@@ -4,8 +4,6 @@
|
|
|
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
|
-
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
|
-
/// <reference types="react" />
|
|
9
7
|
import { type InterpolateValues } from '@docusaurus/Interpolate';
|
|
10
8
|
import type { TranslateParam, TranslateProps } from '@docusaurus/Translate';
|
|
11
9
|
export declare function translate<Str extends string>({ message, id }: TranslateParam<Str>, values?: InterpolateValues<Str, string | number>): string;
|
|
@@ -4,7 +4,6 @@
|
|
|
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
|
-
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
7
|
import type { BaseUrlOptions, BaseUrlUtils } from '@docusaurus/useBaseUrl';
|
|
9
8
|
import type { RouterType } from '@docusaurus/types';
|
|
10
9
|
export declare function addBaseUrl({ siteUrl, baseUrl, url, options: { forcePrependBaseUrl, absolute }, router, }: {
|
|
@@ -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
|
-
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
7
|
import type { BrokenLinks } from '@docusaurus/useBrokenLinks';
|
|
9
8
|
export default function useBrokenLinks(): BrokenLinks;
|
|
@@ -4,7 +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
|
-
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
|
-
/// <reference types="react" />
|
|
9
7
|
import type { Props } from '@theme/Error';
|
|
10
8
|
export default function Error({ error, tryAgain }: Props): JSX.Element;
|
|
@@ -4,7 +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
|
-
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
|
-
/// <reference types="react" />
|
|
9
7
|
import type { Props } from '@theme/Layout';
|
|
10
8
|
export default function Layout({ children }: Props): JSX.Element;
|
|
@@ -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
|
-
/// <reference types="react" />
|
|
8
7
|
import type { LoadingComponentProps } from 'react-loadable';
|
|
9
8
|
export default function Loading({ error, retry, pastDelay, }: LoadingComponentProps): JSX.Element | null;
|
|
@@ -4,7 +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
|
-
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
|
-
/// <reference types="react" />
|
|
9
7
|
import type { Props } from '@theme/Root';
|
|
10
8
|
export default function Root({ children }: Props): JSX.Element;
|
package/lib/commands/build.js
CHANGED
|
@@ -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.build =
|
|
9
|
+
exports.build = build;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -72,7 +72,6 @@ forceTerminate = true) {
|
|
|
72
72
|
}
|
|
73
73
|
}));
|
|
74
74
|
}
|
|
75
|
-
exports.build = build;
|
|
76
75
|
async function getLocalesToBuild({ siteDir, cliOptions, }) {
|
|
77
76
|
if (cliOptions.locale) {
|
|
78
77
|
return [cliOptions.locale];
|
package/lib/commands/clear.js
CHANGED
|
@@ -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.clear =
|
|
9
|
+
exports.clear = clear;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -42,4 +42,3 @@ async function clear(siteDirParam = '.') {
|
|
|
42
42
|
}));
|
|
43
43
|
await Promise.all([generatedFolder, buildFolder, ...cacheFolders].map(removePath));
|
|
44
44
|
}
|
|
45
|
-
exports.clear = clear;
|
package/lib/commands/deploy.js
CHANGED
|
@@ -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.deploy =
|
|
9
|
+
exports.deploy = deploy;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -196,4 +196,3 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
|
|
|
196
196
|
await runDeploy(outDir);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
exports.deploy = deploy;
|
package/lib/commands/external.js
CHANGED
|
@@ -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.externalCommand =
|
|
9
|
+
exports.externalCommand = externalCommand;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
12
|
const site_1 = require("../server/site");
|
|
@@ -20,4 +20,3 @@ async function externalCommand(cli) {
|
|
|
20
20
|
plugin.extendCli?.(cli);
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
exports.externalCommand = externalCommand;
|
package/lib/commands/serve.js
CHANGED
|
@@ -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.serve =
|
|
9
|
+
exports.serve = serve;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
12
|
const http_1 = tslib_1.__importDefault(require("http"));
|
|
@@ -56,7 +56,7 @@ async function serve(siteDirParam = '.', cliOptions = {}) {
|
|
|
56
56
|
if (baseUrl !== '/') {
|
|
57
57
|
// Not super robust, but should be good enough for our use case
|
|
58
58
|
// See https://github.com/facebook/docusaurus/pull/10090
|
|
59
|
-
const looksLikeAsset = !!req.url.match(
|
|
59
|
+
const looksLikeAsset = !!req.url.match(/\.[a-zA-Z\d]{1,4}$/);
|
|
60
60
|
if (!looksLikeAsset) {
|
|
61
61
|
const normalizedUrl = (0, utils_common_1.applyTrailingSlash)(req.url, {
|
|
62
62
|
trailingSlash,
|
|
@@ -89,4 +89,3 @@ async function serve(siteDirParam = '.', cliOptions = {}) {
|
|
|
89
89
|
(0, openBrowser_1.default)(url);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
exports.serve = serve;
|
|
@@ -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.start =
|
|
9
|
+
exports.start = start;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
12
12
|
const openBrowser_1 = tslib_1.__importDefault(require("react-dev-utils/openBrowser"));
|
|
@@ -44,4 +44,3 @@ async function start(siteDirParam = '.', cliOptions = {}) {
|
|
|
44
44
|
(0, openBrowser_1.default)(reloadableSite.getOpenUrl());
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
exports.start = start;
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.createOpenUrlContext = createOpenUrlContext;
|
|
10
|
+
exports.createReloadableSite = createReloadableSite;
|
|
10
11
|
const tslib_1 = require("tslib");
|
|
11
12
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
13
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
@@ -33,7 +34,6 @@ async function createOpenUrlContext({ cliOptions, }) {
|
|
|
33
34
|
};
|
|
34
35
|
return { host, port, getOpenUrl };
|
|
35
36
|
}
|
|
36
|
-
exports.createOpenUrlContext = createOpenUrlContext;
|
|
37
37
|
async function createLoadSiteParams({ siteDirParam, cliOptions, }) {
|
|
38
38
|
const siteDir = await fs_extra_1.default.realpath(siteDirParam);
|
|
39
39
|
return {
|
|
@@ -89,4 +89,3 @@ async function createReloadableSite(startParams) {
|
|
|
89
89
|
};
|
|
90
90
|
return { get, getOpenUrl, reload, reloadPlugin, openUrlContext };
|
|
91
91
|
}
|
|
92
|
-
exports.createReloadableSite = createReloadableSite;
|
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.createPollingOptions = createPollingOptions;
|
|
10
|
+
exports.watch = watch;
|
|
11
|
+
exports.getSitePathsToWatch = getSitePathsToWatch;
|
|
12
|
+
exports.getPluginPathsToWatch = getPluginPathsToWatch;
|
|
13
|
+
exports.setupSiteFileWatchers = setupSiteFileWatchers;
|
|
10
14
|
const tslib_1 = require("tslib");
|
|
11
15
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
16
|
const chokidar_1 = tslib_1.__importDefault(require("chokidar"));
|
|
@@ -19,7 +23,6 @@ function createPollingOptions(cliOptions) {
|
|
|
19
23
|
: undefined,
|
|
20
24
|
};
|
|
21
25
|
}
|
|
22
|
-
exports.createPollingOptions = createPollingOptions;
|
|
23
26
|
/**
|
|
24
27
|
* Watch file system paths for changes and emit events
|
|
25
28
|
* Returns an async handle to stop watching
|
|
@@ -34,7 +37,6 @@ function watch(params, callback) {
|
|
|
34
37
|
fsWatcher.on('all', (name, eventPath) => callback({ name, path: eventPath }));
|
|
35
38
|
return () => fsWatcher.close();
|
|
36
39
|
}
|
|
37
|
-
exports.watch = watch;
|
|
38
40
|
function getSitePathsToWatch({ props }) {
|
|
39
41
|
return [
|
|
40
42
|
// TODO we should also watch all imported modules!
|
|
@@ -43,7 +45,6 @@ function getSitePathsToWatch({ props }) {
|
|
|
43
45
|
props.localizationDir,
|
|
44
46
|
];
|
|
45
47
|
}
|
|
46
|
-
exports.getSitePathsToWatch = getSitePathsToWatch;
|
|
47
48
|
function getPluginPathsToWatch({ siteDir, plugin, }) {
|
|
48
49
|
const normalizeToSiteDir = (filepath) => {
|
|
49
50
|
if (filepath && path_1.default.isAbsolute(filepath)) {
|
|
@@ -55,7 +56,6 @@ function getPluginPathsToWatch({ siteDir, plugin, }) {
|
|
|
55
56
|
.filter(Boolean)
|
|
56
57
|
.map(normalizeToSiteDir);
|
|
57
58
|
}
|
|
58
|
-
exports.getPluginPathsToWatch = getPluginPathsToWatch;
|
|
59
59
|
function setupSiteFileWatchers({ props, cliOptions, }, callback) {
|
|
60
60
|
const { siteDir } = props;
|
|
61
61
|
const pollingOptions = createPollingOptions(cliOptions);
|
|
@@ -75,4 +75,3 @@ function setupSiteFileWatchers({ props, cliOptions, }, callback) {
|
|
|
75
75
|
}, (event) => callback({ plugin, event }));
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
exports.setupSiteFileWatchers = setupSiteFileWatchers;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.createWebpackDevServer =
|
|
9
|
+
exports.createWebpackDevServer = createWebpackDevServer;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
12
|
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
@@ -130,4 +130,3 @@ async function createWebpackDevServer({ props, cliOptions, openUrlContext, }) {
|
|
|
130
130
|
const devServerConfig = (0, webpack_merge_1.default)([defaultDevServerConfig, config.devServer].filter(Boolean));
|
|
131
131
|
return new webpack_dev_server_1.default(devServerConfig, compiler);
|
|
132
132
|
}
|
|
133
|
-
exports.createWebpackDevServer = createWebpackDevServer;
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.SwizzleActions = void 0;
|
|
10
|
+
exports.getAction = getAction;
|
|
11
|
+
exports.eject = eject;
|
|
12
|
+
exports.wrap = wrap;
|
|
10
13
|
const tslib_1 = require("tslib");
|
|
11
14
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
15
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -24,7 +27,6 @@ async function getAction(componentConfig, options) {
|
|
|
24
27
|
}
|
|
25
28
|
return (0, prompts_1.askSwizzleAction)(componentConfig);
|
|
26
29
|
}
|
|
27
|
-
exports.getAction = getAction;
|
|
28
30
|
async function isDir(dirPath) {
|
|
29
31
|
return ((await fs_extra_1.default.pathExists(dirPath)) && (await fs_extra_1.default.stat(dirPath)).isDirectory());
|
|
30
32
|
}
|
|
@@ -65,7 +67,6 @@ async function eject({ siteDir, themePath, componentName, typescript, }) {
|
|
|
65
67
|
}));
|
|
66
68
|
return { createdFiles };
|
|
67
69
|
}
|
|
68
|
-
exports.eject = eject;
|
|
69
70
|
async function wrap({ siteDir, themePath, componentName: themeComponentName, typescript, importType = 'original', }) {
|
|
70
71
|
const isDirectory = await isDir(path_1.default.join(themePath, themeComponentName));
|
|
71
72
|
// Top/Parent/ComponentName => ComponentName
|
|
@@ -104,4 +105,3 @@ export default function ${wrapperComponentName}(props) {
|
|
|
104
105
|
await fs_extra_1.default.outputFile(toPath, content);
|
|
105
106
|
return { createdFiles: [toPath] };
|
|
106
107
|
}
|
|
107
|
-
exports.wrap = wrap;
|
|
@@ -6,7 +6,13 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.PartiallySafeHint = exports.SwizzleActionsStatuses = exports.SwizzleActions = void 0;
|
|
10
|
+
exports.actionStatusLabel = actionStatusLabel;
|
|
11
|
+
exports.actionStatusColor = actionStatusColor;
|
|
12
|
+
exports.actionStatusSuffix = actionStatusSuffix;
|
|
13
|
+
exports.normalizeOptions = normalizeOptions;
|
|
14
|
+
exports.findStringIgnoringCase = findStringIgnoringCase;
|
|
15
|
+
exports.findClosestValue = findClosestValue;
|
|
10
16
|
const tslib_1 = require("tslib");
|
|
11
17
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
18
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
@@ -21,7 +27,6 @@ exports.PartiallySafeHint = logger_1.default.red('*');
|
|
|
21
27
|
function actionStatusLabel(status) {
|
|
22
28
|
return lodash_1.default.capitalize(status);
|
|
23
29
|
}
|
|
24
|
-
exports.actionStatusLabel = actionStatusLabel;
|
|
25
30
|
const SwizzleActionStatusColors = {
|
|
26
31
|
safe: logger_1.default.green,
|
|
27
32
|
unsafe: logger_1.default.yellow,
|
|
@@ -31,11 +36,9 @@ function actionStatusColor(status, str) {
|
|
|
31
36
|
const colorFn = SwizzleActionStatusColors[status];
|
|
32
37
|
return colorFn(str);
|
|
33
38
|
}
|
|
34
|
-
exports.actionStatusColor = actionStatusColor;
|
|
35
39
|
function actionStatusSuffix(status, options = {}) {
|
|
36
40
|
return ` (${actionStatusColor(status, actionStatusLabel(status))}${options.partiallySafe ? exports.PartiallySafeHint : ''})`;
|
|
37
41
|
}
|
|
38
|
-
exports.actionStatusSuffix = actionStatusSuffix;
|
|
39
42
|
function normalizeOptions(options) {
|
|
40
43
|
return {
|
|
41
44
|
typescript: options.typescript ?? false,
|
|
@@ -47,12 +50,9 @@ function normalizeOptions(options) {
|
|
|
47
50
|
config: options.config ?? undefined,
|
|
48
51
|
};
|
|
49
52
|
}
|
|
50
|
-
exports.normalizeOptions = normalizeOptions;
|
|
51
53
|
function findStringIgnoringCase(str, values) {
|
|
52
54
|
return values.find((v) => v.toLowerCase() === str.toLowerCase());
|
|
53
55
|
}
|
|
54
|
-
exports.findStringIgnoringCase = findStringIgnoringCase;
|
|
55
56
|
function findClosestValue(str, values, maxLevenshtein = 3) {
|
|
56
57
|
return values.find((v) => (0, leven_1.default)(v, str) <= maxLevenshtein);
|
|
57
58
|
}
|
|
58
|
-
exports.findClosestValue = findClosestValue;
|
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.getMissingIntermediateComponentFolderNames = getMissingIntermediateComponentFolderNames;
|
|
10
|
+
exports.readComponentNames = readComponentNames;
|
|
11
|
+
exports.listComponentNames = listComponentNames;
|
|
12
|
+
exports.getThemeComponents = getThemeComponents;
|
|
13
|
+
exports.getComponentName = getComponentName;
|
|
10
14
|
const tslib_1 = require("tslib");
|
|
11
15
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
16
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -37,7 +41,6 @@ function getMissingIntermediateComponentFolderNames(componentNames) {
|
|
|
37
41
|
const expandedComponentNames = lodash_1.default.uniq(componentNames.flatMap((componentName) => getAllIntermediatePaths(componentName)));
|
|
38
42
|
return lodash_1.default.difference(expandedComponentNames, componentNames);
|
|
39
43
|
}
|
|
40
|
-
exports.getMissingIntermediateComponentFolderNames = getMissingIntermediateComponentFolderNames;
|
|
41
44
|
const skipReadDirNames = ['__test__', '__tests__', '__mocks__', '__fixtures__'];
|
|
42
45
|
async function readComponentNames(themePath) {
|
|
43
46
|
if (!(await fs_extra_1.default.pathExists(themePath))) {
|
|
@@ -71,7 +74,6 @@ async function readComponentNames(themePath) {
|
|
|
71
74
|
const componentNames = componentFiles.map((f) => f.componentName);
|
|
72
75
|
return sortComponentNames(componentNames);
|
|
73
76
|
}
|
|
74
|
-
exports.readComponentNames = readComponentNames;
|
|
75
77
|
function listComponentNames(themeComponents) {
|
|
76
78
|
if (themeComponents.all.length === 0) {
|
|
77
79
|
return 'No component to swizzle.';
|
|
@@ -81,7 +83,6 @@ function listComponentNames(themeComponents) {
|
|
|
81
83
|
${(0, tables_1.helpTables)()}
|
|
82
84
|
`;
|
|
83
85
|
}
|
|
84
|
-
exports.listComponentNames = listComponentNames;
|
|
85
86
|
async function getThemeComponents({ themeName, themePath, swizzleConfig, }) {
|
|
86
87
|
const FallbackSwizzleActionStatus = 'unsafe';
|
|
87
88
|
const FallbackSwizzleComponentDescription = 'N/A';
|
|
@@ -151,7 +152,6 @@ async function getThemeComponents({ themeName, themePath, swizzleConfig, }) {
|
|
|
151
152
|
hasAllSafeAction,
|
|
152
153
|
};
|
|
153
154
|
}
|
|
154
|
-
exports.getThemeComponents = getThemeComponents;
|
|
155
155
|
// Returns a valid value if recovering is possible
|
|
156
156
|
function handleInvalidComponentNameParam({ componentNameParam, themeComponents, }) {
|
|
157
157
|
// Trying to recover invalid value
|
|
@@ -198,4 +198,3 @@ async function getComponentName({ componentNameParam, themeComponents, list, })
|
|
|
198
198
|
: await (0, prompts_1.askComponentName)(themeComponents);
|
|
199
199
|
return componentName;
|
|
200
200
|
}
|
|
201
|
-
exports.getComponentName = getComponentName;
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.normalizeSwizzleConfig = normalizeSwizzleConfig;
|
|
10
|
+
exports.getThemeSwizzleConfig = getThemeSwizzleConfig;
|
|
10
11
|
const tslib_1 = require("tslib");
|
|
11
12
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
12
13
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
@@ -63,7 +64,6 @@ function normalizeSwizzleConfig(unsafeSwizzleConfig) {
|
|
|
63
64
|
});
|
|
64
65
|
return swizzleConfig;
|
|
65
66
|
}
|
|
66
|
-
exports.normalizeSwizzleConfig = normalizeSwizzleConfig;
|
|
67
67
|
const FallbackSwizzleConfig = {
|
|
68
68
|
components: {},
|
|
69
69
|
};
|
|
@@ -81,4 +81,3 @@ function getThemeSwizzleConfig(themeName, plugins) {
|
|
|
81
81
|
}
|
|
82
82
|
return FallbackSwizzleConfig;
|
|
83
83
|
}
|
|
84
|
-
exports.getThemeSwizzleConfig = getThemeSwizzleConfig;
|