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