@docusaurus/core 0.0.0-4517 → 0.0.0-4523
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/beforeCli.js +101 -92
- package/bin/docusaurus.js +3 -2
- package/lib/client/App.js +12 -6
- package/lib/client/LinksCollector.js +1 -1
- package/lib/client/PendingNavigation.js +1 -1
- package/lib/client/baseUrlIssueBanner/BaseUrlIssueBanner.js +7 -5
- package/lib/client/clientEntry.js +3 -2
- package/lib/client/exports/BrowserOnly.js +1 -1
- package/lib/client/exports/ComponentCreator.js +2 -3
- package/lib/client/exports/Head.js +1 -1
- package/lib/client/exports/Interpolate.js +4 -3
- package/lib/client/exports/Link.js +4 -2
- package/lib/client/exports/browserContext.js +1 -1
- package/lib/client/exports/docusaurusContext.js +1 -1
- package/lib/client/serverEntry.js +7 -4
- package/lib/client/theme-fallback/Error/index.d.ts +11 -0
- package/lib/client/theme-fallback/Error/index.js +19 -28
- package/lib/client/theme-fallback/Layout/index.d.ts +11 -0
- package/lib/client/theme-fallback/Layout/index.js +10 -18
- package/lib/client/theme-fallback/Loading/index.d.ts +9 -0
- package/lib/client/theme-fallback/Loading/index.js +46 -114
- package/lib/client/theme-fallback/NotFound/index.d.ts +9 -0
- package/lib/client/theme-fallback/NotFound/index.js +8 -14
- package/lib/client/theme-fallback/Root/index.d.ts +11 -0
- package/lib/client/theme-fallback/Root/index.js +2 -4
- package/lib/commands/external.d.ts +2 -2
- package/lib/server/configValidation.d.ts +1 -1
- package/lib/server/configValidation.js +2 -1
- package/package.json +11 -10
package/bin/beforeCli.js
CHANGED
|
@@ -20,105 +20,114 @@ const {
|
|
|
20
20
|
engines: {node: requiredVersion},
|
|
21
21
|
} = require('../package.json');
|
|
22
22
|
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
23
|
+
// eslint-disable-next-line import/no-dynamic-require
|
|
24
|
+
const sitePkg = require(path.resolve(process.cwd(), 'package.json'));
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Notify user if `@docusaurus` packages are outdated
|
|
28
|
+
*
|
|
29
|
+
* Note: this is a 2-step process to avoid delaying cli usage by awaiting a
|
|
30
|
+
* response:
|
|
31
|
+
* - 1st run: trigger background job to check releases + store result
|
|
32
|
+
* - 2nd run: display potential update to users
|
|
33
|
+
*
|
|
34
|
+
* cache data is stored in `~/.config/configstore/update-notifier-@docusaurus`
|
|
35
|
+
*/
|
|
36
|
+
function beforeCli() {
|
|
37
|
+
const notifier = updateNotifier({
|
|
38
|
+
pkg: {
|
|
39
|
+
name,
|
|
40
|
+
version,
|
|
41
|
+
},
|
|
42
|
+
// Check is in background so it's fine to use a small value like 1h
|
|
43
|
+
// Use 0 for debugging
|
|
44
|
+
updateCheckInterval: 1000 * 60 * 60,
|
|
45
|
+
// updateCheckInterval: 0
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Hacky way to ensure we check for updates on first run
|
|
49
|
+
// Note: the notification will only happen in the 2nd run
|
|
50
|
+
// See https://github.com/yeoman/update-notifier/issues/209
|
|
51
|
+
try {
|
|
52
|
+
if (
|
|
53
|
+
notifier.config &&
|
|
54
|
+
// @ts-expect-error: this is an internal API
|
|
55
|
+
!notifier.disabled &&
|
|
56
|
+
Date.now() - notifier.config.get('lastUpdateCheck') < 50
|
|
57
|
+
) {
|
|
58
|
+
notifier.config.set('lastUpdateCheck', 0);
|
|
59
|
+
notifier.check();
|
|
60
|
+
}
|
|
61
|
+
} catch (e) {
|
|
62
|
+
// Do not stop cli if this fails, see https://github.com/facebook/docusaurus/issues/5400
|
|
63
|
+
logger.error(e);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* We don't want to display update message for canary releases.
|
|
68
|
+
* See https://github.com/facebook/docusaurus/issues/5378
|
|
69
|
+
* @param {import('update-notifier').UpdateInfo} update
|
|
70
|
+
*/
|
|
71
|
+
function ignoreUpdate(update) {
|
|
72
|
+
const isCanaryRelease =
|
|
73
|
+
update && update.current && update.current.startsWith('0.0.0');
|
|
74
|
+
return isCanaryRelease;
|
|
75
|
+
}
|
|
76
|
+
|
|
48
77
|
if (
|
|
49
78
|
notifier.config &&
|
|
50
|
-
|
|
51
|
-
|
|
79
|
+
notifier.update &&
|
|
80
|
+
semver.lt(notifier.update.current, notifier.update.latest)
|
|
52
81
|
) {
|
|
53
|
-
notifier
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// Do not stop cli if this fails, see https://github.com/facebook/docusaurus/issues/5400
|
|
58
|
-
logger.error(e);
|
|
59
|
-
}
|
|
82
|
+
// Because notifier clears cached data after reading it, leading to notifier
|
|
83
|
+
// not consistently displaying the update.
|
|
84
|
+
// See https://github.com/yeoman/update-notifier/issues/209
|
|
85
|
+
notifier.config.set('update', notifier.update);
|
|
60
86
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const isCanaryRelease =
|
|
65
|
-
update && update.current && update.current.startsWith('0.0.0');
|
|
66
|
-
return isCanaryRelease;
|
|
67
|
-
}
|
|
87
|
+
if (ignoreUpdate(notifier.update)) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
68
90
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
91
|
+
const siteDocusaurusPackagesForUpdate = Object.keys({
|
|
92
|
+
...sitePkg.dependencies,
|
|
93
|
+
...sitePkg.devDependencies,
|
|
94
|
+
})
|
|
95
|
+
.filter((p) => p.startsWith('@docusaurus'))
|
|
96
|
+
.map((p) => p.concat('@latest'))
|
|
97
|
+
.join(' ');
|
|
98
|
+
const isYarnUsed = fs.existsSync(path.resolve(process.cwd(), 'yarn.lock'));
|
|
99
|
+
const upgradeCommand = isYarnUsed
|
|
100
|
+
? `yarn upgrade ${siteDocusaurusPackagesForUpdate}`
|
|
101
|
+
: `npm i ${siteDocusaurusPackagesForUpdate}`;
|
|
77
102
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
103
|
+
/** @type {import('boxen').Options} */
|
|
104
|
+
const boxenOptions = {
|
|
105
|
+
padding: 1,
|
|
106
|
+
margin: 1,
|
|
107
|
+
align: 'center',
|
|
108
|
+
borderColor: 'yellow',
|
|
109
|
+
borderStyle: 'round',
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const docusaurusUpdateMessage = boxen(
|
|
113
|
+
`Update available ${logger.dim(
|
|
114
|
+
`${notifier.update.current}`,
|
|
115
|
+
)} → ${logger.green(`${notifier.update.latest}`)}
|
|
116
|
+
|
|
117
|
+
To upgrade Docusaurus packages with the latest version, run the following command:
|
|
118
|
+
${logger.code(upgradeCommand)}`,
|
|
119
|
+
boxenOptions,
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
console.log(docusaurusUpdateMessage);
|
|
81
123
|
}
|
|
82
124
|
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
.filter((p) => p.startsWith('@docusaurus'))
|
|
90
|
-
.map((p) => p.concat('@latest'))
|
|
91
|
-
.join(' ');
|
|
92
|
-
const isYarnUsed = fs.existsSync(path.resolve(process.cwd(), 'yarn.lock'));
|
|
93
|
-
const upgradeCommand = isYarnUsed
|
|
94
|
-
? `yarn upgrade ${siteDocusaurusPackagesForUpdate}`
|
|
95
|
-
: `npm i ${siteDocusaurusPackagesForUpdate}`;
|
|
96
|
-
|
|
97
|
-
/** @type {import('boxen').Options} */
|
|
98
|
-
const boxenOptions = {
|
|
99
|
-
padding: 1,
|
|
100
|
-
margin: 1,
|
|
101
|
-
align: 'center',
|
|
102
|
-
borderColor: 'yellow',
|
|
103
|
-
borderStyle: 'round',
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const docusaurusUpdateMessage = boxen(
|
|
107
|
-
`Update available ${logger.dim(
|
|
108
|
-
`${notifier.update.current}`,
|
|
109
|
-
)} → ${logger.green(`${notifier.update.latest}`)}
|
|
110
|
-
|
|
111
|
-
To upgrade Docusaurus packages with the latest version, run the following command:
|
|
112
|
-
${logger.code(upgradeCommand)}`,
|
|
113
|
-
boxenOptions,
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
console.log(docusaurusUpdateMessage);
|
|
125
|
+
// notify user if node version needs to be updated
|
|
126
|
+
if (!semver.satisfies(process.version, requiredVersion)) {
|
|
127
|
+
logger.error('Minimum Node.js version not met :(');
|
|
128
|
+
logger.info`You are using Node.js number=${process.version}, Requirement: Node.js number=${requiredVersion}.`;
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
117
131
|
}
|
|
118
132
|
|
|
119
|
-
|
|
120
|
-
if (!semver.satisfies(process.version, requiredVersion)) {
|
|
121
|
-
logger.error('Minimum Node.js version not met :(');
|
|
122
|
-
logger.info`You are using Node.js number=${process.version}, Requirement: Node.js number=${requiredVersion}.`;
|
|
123
|
-
process.exit(1);
|
|
124
|
-
}
|
|
133
|
+
module.exports = beforeCli;
|
package/bin/docusaurus.js
CHANGED
|
@@ -23,7 +23,9 @@ const {
|
|
|
23
23
|
writeHeadingIds,
|
|
24
24
|
} = require('../lib');
|
|
25
25
|
|
|
26
|
-
require('./beforeCli');
|
|
26
|
+
const beforeCli = require('./beforeCli');
|
|
27
|
+
|
|
28
|
+
beforeCli();
|
|
27
29
|
|
|
28
30
|
const resolveDir = (dir = '.') => fs.realpathSync(dir);
|
|
29
31
|
|
|
@@ -239,7 +241,6 @@ function isInternalCommand(command) {
|
|
|
239
241
|
|
|
240
242
|
async function run() {
|
|
241
243
|
if (!isInternalCommand(process.argv.slice(2)[0])) {
|
|
242
|
-
// @ts-expect-error: Hmmm
|
|
243
244
|
await externalCommand(cli, resolveDir('.'));
|
|
244
245
|
}
|
|
245
246
|
|
package/lib/client/App.js
CHANGED
|
@@ -17,11 +17,17 @@ import './client-lifecycles-dispatcher';
|
|
|
17
17
|
import ErrorBoundary from '@docusaurus/ErrorBoundary';
|
|
18
18
|
import Error from '@theme/Error';
|
|
19
19
|
function App() {
|
|
20
|
-
return (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
return (<ErrorBoundary fallback={Error}>
|
|
21
|
+
<DocusaurusContextProvider>
|
|
22
|
+
<BrowserContextProvider>
|
|
23
|
+
<Root>
|
|
24
|
+
<BaseUrlIssueBanner />
|
|
25
|
+
<PendingNavigation routes={routes} delay={1000}>
|
|
26
|
+
{renderRoutes(routes)}
|
|
27
|
+
</PendingNavigation>
|
|
28
|
+
</Root>
|
|
29
|
+
</BrowserContextProvider>
|
|
30
|
+
</DocusaurusContextProvider>
|
|
31
|
+
</ErrorBoundary>);
|
|
26
32
|
}
|
|
27
33
|
export default App;
|
|
@@ -23,5 +23,5 @@ const Context = createContext({
|
|
|
23
23
|
});
|
|
24
24
|
export const useLinksCollector = () => useContext(Context);
|
|
25
25
|
export function ProvideLinksCollector({ children, linksCollector, }) {
|
|
26
|
-
return
|
|
26
|
+
return <Context.Provider value={linksCollector}>{children}</Context.Provider>;
|
|
27
27
|
}
|
|
@@ -92,7 +92,7 @@ class PendingNavigation extends React.Component {
|
|
|
92
92
|
}
|
|
93
93
|
render() {
|
|
94
94
|
const { children, location } = this.props;
|
|
95
|
-
return (
|
|
95
|
+
return (<Route location={normalizeLocation(location)} render={() => children}/>);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
export default withRouter(PendingNavigation);
|
|
@@ -67,10 +67,12 @@ function BaseUrlIssueBannerEnabled() {
|
|
|
67
67
|
useLayoutEffect(() => {
|
|
68
68
|
window[InsertBannerWindowAttribute] = false;
|
|
69
69
|
}, []);
|
|
70
|
-
return (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
return (<>
|
|
71
|
+
{!ExecutionEnvironment.canUseDOM && (<Head>
|
|
72
|
+
<script>{createInlineScript(baseUrl)}</script>
|
|
73
|
+
</Head>)}
|
|
74
|
+
<div id={BannerContainerId}/>
|
|
75
|
+
</>);
|
|
74
76
|
}
|
|
75
77
|
// We want to help the users with a bad baseUrl configuration (very common error)
|
|
76
78
|
// Help message is inlined, and hidden if JS or CSS is able to load
|
|
@@ -83,5 +85,5 @@ export default function BaseUrlIssueBanner() {
|
|
|
83
85
|
// returns true for the homepage during SRR
|
|
84
86
|
const isHomePage = pathname === baseUrl;
|
|
85
87
|
const enabled = baseUrlIssueBanner && isHomePage;
|
|
86
|
-
return enabled ?
|
|
88
|
+
return enabled ? <BaseUrlIssueBannerEnabled /> : null;
|
|
87
89
|
}
|
|
@@ -20,8 +20,9 @@ if (ExecutionEnvironment.canUseDOM) {
|
|
|
20
20
|
// Note that we also preload async component to avoid first-load loading screen.
|
|
21
21
|
const renderMethod = process.env.NODE_ENV === 'production' ? hydrate : render;
|
|
22
22
|
preload(routes, window.location.pathname).then(() => {
|
|
23
|
-
renderMethod(
|
|
24
|
-
|
|
23
|
+
renderMethod(<BrowserRouter>
|
|
24
|
+
<App />
|
|
25
|
+
</BrowserRouter>, document.getElementById('__docusaurus'));
|
|
25
26
|
});
|
|
26
27
|
// Webpack Hot Module Replacement API
|
|
27
28
|
if (module.hot) {
|
|
@@ -16,7 +16,7 @@ function BrowserOnly({ children, fallback, }) {
|
|
|
16
16
|
throw new Error(`Docusaurus error: The children of <BrowserOnly> must be a "render function", e.g. <BrowserOnly>{() => <span>{window.location.href}</span>}</BrowserOnly>.
|
|
17
17
|
Current type: ${isValidElement(children) ? 'React element' : typeof children}`);
|
|
18
18
|
}
|
|
19
|
-
return
|
|
19
|
+
return <>{children()}</>;
|
|
20
20
|
}
|
|
21
21
|
return fallback || null;
|
|
22
22
|
}
|
|
@@ -38,11 +38,10 @@ function ComponentCreator(path, hash) {
|
|
|
38
38
|
Object.keys(flatChunkNames).forEach((key) => {
|
|
39
39
|
const chunkRegistry = registry[flatChunkNames[key]];
|
|
40
40
|
if (chunkRegistry) {
|
|
41
|
-
|
|
41
|
+
// eslint-disable-next-line prefer-destructuring
|
|
42
42
|
optsLoader[key] = chunkRegistry[0];
|
|
43
43
|
optsModules.push(chunkRegistry[1]);
|
|
44
44
|
optsWebpack.push(chunkRegistry[2]);
|
|
45
|
-
/* eslint-enable prefer-destructuring */
|
|
46
45
|
}
|
|
47
46
|
});
|
|
48
47
|
return Loadable.Map({
|
|
@@ -70,7 +69,7 @@ function ComponentCreator(path, hash) {
|
|
|
70
69
|
});
|
|
71
70
|
const Component = loadedModules.component;
|
|
72
71
|
delete loadedModules.component;
|
|
73
|
-
return
|
|
72
|
+
return <Component {...loadedModules} {...props}/>;
|
|
74
73
|
},
|
|
75
74
|
});
|
|
76
75
|
}
|
|
@@ -44,9 +44,10 @@ export function interpolate(text, values) {
|
|
|
44
44
|
else {
|
|
45
45
|
return processedText.split(ValueFoundMarker).reduce((array, value, index) => [
|
|
46
46
|
...array,
|
|
47
|
-
React.
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
<React.Fragment key={index}>
|
|
48
|
+
{value}
|
|
49
|
+
{elements[index]}
|
|
50
|
+
</React.Fragment>,
|
|
50
51
|
], []);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
@@ -107,7 +107,9 @@ function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLi
|
|
|
107
107
|
}
|
|
108
108
|
return isRegularHtmlLink ? (
|
|
109
109
|
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
<a href={targetLink} {...(targetLinkUnprefixed &&
|
|
111
|
+
!isInternal && { target: '_blank', rel: 'noopener noreferrer' })} {...props}/>) : (<LinkComponent {...props} onMouseEnter={onMouseEnter} innerRef={handleRef} to={targetLink || ''}
|
|
112
|
+
// avoid "React does not recognize the `activeClassName` prop on a DOM element"
|
|
113
|
+
{...(isNavLink && { isActive, activeClassName })}/>);
|
|
112
114
|
}
|
|
113
115
|
export default Link;
|
|
@@ -17,5 +17,5 @@ export function BrowserContextProvider({ children, }) {
|
|
|
17
17
|
useEffect(() => {
|
|
18
18
|
setIsBrowser(true);
|
|
19
19
|
}, []);
|
|
20
|
-
return
|
|
20
|
+
return <Context.Provider value={isBrowser}>{children}</Context.Provider>;
|
|
21
21
|
}
|
|
@@ -21,5 +21,5 @@ const contextValue = {
|
|
|
21
21
|
};
|
|
22
22
|
export const Context = React.createContext(contextValue);
|
|
23
23
|
export function DocusaurusContextProvider({ children, }) {
|
|
24
|
-
return
|
|
24
|
+
return <Context.Provider value={contextValue}>{children}</Context.Provider>;
|
|
25
25
|
}
|
|
@@ -54,10 +54,13 @@ async function doRender(locals) {
|
|
|
54
54
|
const modules = new Set();
|
|
55
55
|
const context = {};
|
|
56
56
|
const linksCollector = createStatefulLinksCollector();
|
|
57
|
-
const appHtml = ReactDOMServer.renderToString(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
const appHtml = ReactDOMServer.renderToString(<Loadable.Capture report={(moduleName) => modules.add(moduleName)}>
|
|
58
|
+
<StaticRouter location={location} context={context}>
|
|
59
|
+
<ProvideLinksCollector linksCollector={linksCollector}>
|
|
60
|
+
<App />
|
|
61
|
+
</ProvideLinksCollector>
|
|
62
|
+
</StaticRouter>
|
|
63
|
+
</Loadable.Capture>);
|
|
61
64
|
onLinksCollected(location, linksCollector.getCollectedLinks());
|
|
62
65
|
const helmet = Helmet.renderStatic();
|
|
63
66
|
const htmlAttributes = helmet.htmlAttributes.toString();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
|
+
/// <reference types="react" />
|
|
9
|
+
import type { Props } from '@theme/Error';
|
|
10
|
+
declare function Error({ error, tryAgain }: Props): JSX.Element;
|
|
11
|
+
export default Error;
|
|
@@ -4,44 +4,35 @@
|
|
|
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
|
-
|
|
8
7
|
import React from 'react';
|
|
9
8
|
import Layout from '@theme/Layout';
|
|
10
9
|
import ErrorBoundary from '@docusaurus/ErrorBoundary';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
width: '100%',
|
|
22
|
-
fontSize: '20px',
|
|
23
|
-
}}>
|
|
10
|
+
function ErrorDisplay({ error, tryAgain }) {
|
|
11
|
+
return (<div style={{
|
|
12
|
+
display: 'flex',
|
|
13
|
+
flexDirection: 'column',
|
|
14
|
+
justifyContent: 'center',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
height: '50vh',
|
|
17
|
+
width: '100%',
|
|
18
|
+
fontSize: '20px',
|
|
19
|
+
}}>
|
|
24
20
|
<h1>This page crashed.</h1>
|
|
25
21
|
<p>{error.message}</p>
|
|
26
22
|
<button type="button" onClick={tryAgain}>
|
|
27
23
|
Try again
|
|
28
24
|
</button>
|
|
29
|
-
</div>
|
|
30
|
-
);
|
|
25
|
+
</div>);
|
|
31
26
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<
|
|
38
|
-
// Note: we display the original error here, not the error that we captured in this extra error boundary
|
|
39
|
-
fallback={() => <ErrorDisplay error={error} tryAgain={tryAgain} />}>
|
|
27
|
+
function Error({ error, tryAgain }) {
|
|
28
|
+
// We wrap the error in its own error boundary because the layout can actually throw too...
|
|
29
|
+
// Only the ErrorDisplay component is simple enough to be considered safe to never throw
|
|
30
|
+
return (<ErrorBoundary
|
|
31
|
+
// Note: we display the original error here, not the error that we captured in this extra error boundary
|
|
32
|
+
fallback={() => <ErrorDisplay error={error} tryAgain={tryAgain}/>}>
|
|
40
33
|
<Layout title="Page Error">
|
|
41
|
-
<ErrorDisplay error={error} tryAgain={tryAgain}
|
|
34
|
+
<ErrorDisplay error={error} tryAgain={tryAgain}/>
|
|
42
35
|
</Layout>
|
|
43
|
-
</ErrorBoundary>
|
|
44
|
-
);
|
|
36
|
+
</ErrorBoundary>);
|
|
45
37
|
}
|
|
46
|
-
|
|
47
38
|
export default Error;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
|
+
/// <reference types="react" />
|
|
9
|
+
import type { Props } from '@theme/Layout';
|
|
10
|
+
declare function Layout({ children, title, description }: Props): JSX.Element;
|
|
11
|
+
export default Layout;
|
|
@@ -4,31 +4,23 @@
|
|
|
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
|
-
|
|
8
7
|
import React from 'react';
|
|
9
8
|
import Head from '@docusaurus/Head';
|
|
10
9
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
11
10
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const faviconUrl = useBaseUrl(favicon);
|
|
19
|
-
return (
|
|
20
|
-
<>
|
|
11
|
+
function Layout({ children, title, description }) {
|
|
12
|
+
const context = useDocusaurusContext();
|
|
13
|
+
const { siteConfig } = context;
|
|
14
|
+
const { favicon, tagline, title: defaultTitle } = siteConfig;
|
|
15
|
+
const faviconUrl = useBaseUrl(favicon);
|
|
16
|
+
return (<>
|
|
21
17
|
<Head defaultTitle={`${defaultTitle}${tagline ? ` · ${tagline}` : ''}`}>
|
|
22
18
|
{title && <title>{`${title} · ${tagline}`}</title>}
|
|
23
|
-
{favicon && <link rel="icon" href={faviconUrl}
|
|
24
|
-
{description && <meta name="description" content={description}
|
|
25
|
-
{description && (
|
|
26
|
-
<meta property="og:description" content={description} />
|
|
27
|
-
)}
|
|
19
|
+
{favicon && <link rel="icon" href={faviconUrl}/>}
|
|
20
|
+
{description && <meta name="description" content={description}/>}
|
|
21
|
+
{description && (<meta property="og:description" content={description}/>)}
|
|
28
22
|
</Head>
|
|
29
23
|
{children}
|
|
30
|
-
</>
|
|
31
|
-
);
|
|
24
|
+
</>);
|
|
32
25
|
}
|
|
33
|
-
|
|
34
26
|
export default Layout;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="react" />
|
|
8
|
+
import type { LoadingComponentProps } from 'react-loadable';
|
|
9
|
+
export default function Loading({ error, retry, pastDelay, }: LoadingComponentProps): JSX.Element | null;
|
|
@@ -4,133 +4,65 @@
|
|
|
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
|
-
|
|
8
7
|
import React from 'react';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
maxWidth: '50%',
|
|
30
|
-
width: '100%',
|
|
31
|
-
}}>
|
|
8
|
+
export default function Loading({ error, retry, pastDelay, }) {
|
|
9
|
+
if (error) {
|
|
10
|
+
return (<div style={{
|
|
11
|
+
textAlign: 'center',
|
|
12
|
+
color: '#fff',
|
|
13
|
+
backgroundColor: '#fa383e',
|
|
14
|
+
borderColor: '#fa383e',
|
|
15
|
+
borderStyle: 'solid',
|
|
16
|
+
borderRadius: '0.25rem',
|
|
17
|
+
borderWidth: '1px',
|
|
18
|
+
boxSizing: 'border-box',
|
|
19
|
+
display: 'block',
|
|
20
|
+
padding: '1rem',
|
|
21
|
+
flex: '0 0 50%',
|
|
22
|
+
marginLeft: '25%',
|
|
23
|
+
marginRight: '25%',
|
|
24
|
+
marginTop: '5rem',
|
|
25
|
+
maxWidth: '50%',
|
|
26
|
+
width: '100%',
|
|
27
|
+
}}>
|
|
32
28
|
<p>{error.message}</p>
|
|
33
29
|
<div>
|
|
34
30
|
<button type="button" onClick={retry}>
|
|
35
31
|
Retry
|
|
36
32
|
</button>
|
|
37
33
|
</div>
|
|
38
|
-
</div>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
width: 128,
|
|
55
|
-
height: 110,
|
|
56
|
-
position: 'absolute',
|
|
57
|
-
top: 'calc(100vh - 64%)',
|
|
58
|
-
}}
|
|
59
|
-
viewBox="0 0 45 45"
|
|
60
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
61
|
-
stroke="#61dafb">
|
|
62
|
-
<g
|
|
63
|
-
fill="none"
|
|
64
|
-
fillRule="evenodd"
|
|
65
|
-
transform="translate(1 1)"
|
|
66
|
-
strokeWidth="2">
|
|
34
|
+
</div>);
|
|
35
|
+
}
|
|
36
|
+
if (pastDelay) {
|
|
37
|
+
return (<div style={{
|
|
38
|
+
display: 'flex',
|
|
39
|
+
justifyContent: 'center',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
height: '100vh',
|
|
42
|
+
}}>
|
|
43
|
+
<svg id="loader" style={{
|
|
44
|
+
width: 128,
|
|
45
|
+
height: 110,
|
|
46
|
+
position: 'absolute',
|
|
47
|
+
top: 'calc(100vh - 64%)',
|
|
48
|
+
}} viewBox="0 0 45 45" xmlns="http://www.w3.org/2000/svg" stroke="#61dafb">
|
|
49
|
+
<g fill="none" fillRule="evenodd" transform="translate(1 1)" strokeWidth="2">
|
|
67
50
|
<circle cx="22" cy="22" r="6" strokeOpacity="0">
|
|
68
|
-
<animate
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
dur="3s"
|
|
72
|
-
values="6;22"
|
|
73
|
-
calcMode="linear"
|
|
74
|
-
repeatCount="indefinite"
|
|
75
|
-
/>
|
|
76
|
-
<animate
|
|
77
|
-
attributeName="stroke-opacity"
|
|
78
|
-
begin="1.5s"
|
|
79
|
-
dur="3s"
|
|
80
|
-
values="1;0"
|
|
81
|
-
calcMode="linear"
|
|
82
|
-
repeatCount="indefinite"
|
|
83
|
-
/>
|
|
84
|
-
<animate
|
|
85
|
-
attributeName="stroke-width"
|
|
86
|
-
begin="1.5s"
|
|
87
|
-
dur="3s"
|
|
88
|
-
values="2;0"
|
|
89
|
-
calcMode="linear"
|
|
90
|
-
repeatCount="indefinite"
|
|
91
|
-
/>
|
|
51
|
+
<animate attributeName="r" begin="1.5s" dur="3s" values="6;22" calcMode="linear" repeatCount="indefinite"/>
|
|
52
|
+
<animate attributeName="stroke-opacity" begin="1.5s" dur="3s" values="1;0" calcMode="linear" repeatCount="indefinite"/>
|
|
53
|
+
<animate attributeName="stroke-width" begin="1.5s" dur="3s" values="2;0" calcMode="linear" repeatCount="indefinite"/>
|
|
92
54
|
</circle>
|
|
93
55
|
<circle cx="22" cy="22" r="6" strokeOpacity="0">
|
|
94
|
-
<animate
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
dur="3s"
|
|
98
|
-
values="6;22"
|
|
99
|
-
calcMode="linear"
|
|
100
|
-
repeatCount="indefinite"
|
|
101
|
-
/>
|
|
102
|
-
<animate
|
|
103
|
-
attributeName="stroke-opacity"
|
|
104
|
-
begin="3s"
|
|
105
|
-
dur="3s"
|
|
106
|
-
values="1;0"
|
|
107
|
-
calcMode="linear"
|
|
108
|
-
repeatCount="indefinite"
|
|
109
|
-
/>
|
|
110
|
-
<animate
|
|
111
|
-
attributeName="stroke-width"
|
|
112
|
-
begin="3s"
|
|
113
|
-
dur="3s"
|
|
114
|
-
values="2;0"
|
|
115
|
-
calcMode="linear"
|
|
116
|
-
repeatCount="indefinite"
|
|
117
|
-
/>
|
|
56
|
+
<animate attributeName="r" begin="3s" dur="3s" values="6;22" calcMode="linear" repeatCount="indefinite"/>
|
|
57
|
+
<animate attributeName="stroke-opacity" begin="3s" dur="3s" values="1;0" calcMode="linear" repeatCount="indefinite"/>
|
|
58
|
+
<animate attributeName="stroke-width" begin="3s" dur="3s" values="2;0" calcMode="linear" repeatCount="indefinite"/>
|
|
118
59
|
</circle>
|
|
119
60
|
<circle cx="22" cy="22" r="8">
|
|
120
|
-
<animate
|
|
121
|
-
attributeName="r"
|
|
122
|
-
begin="0s"
|
|
123
|
-
dur="1.5s"
|
|
124
|
-
values="6;1;2;3;4;5;6"
|
|
125
|
-
calcMode="linear"
|
|
126
|
-
repeatCount="indefinite"
|
|
127
|
-
/>
|
|
61
|
+
<animate attributeName="r" begin="0s" dur="1.5s" values="6;1;2;3;4;5;6" calcMode="linear" repeatCount="indefinite"/>
|
|
128
62
|
</circle>
|
|
129
63
|
</g>
|
|
130
64
|
</svg>
|
|
131
|
-
</div>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return null;
|
|
65
|
+
</div>);
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
136
68
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="react" />
|
|
8
|
+
declare function NotFound(): JSX.Element;
|
|
9
|
+
export default NotFound;
|
|
@@ -4,25 +4,19 @@
|
|
|
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
|
-
|
|
8
7
|
import React from 'react';
|
|
9
8
|
import Layout from '@theme/Layout';
|
|
10
|
-
|
|
11
9
|
function NotFound() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
height: '50vh',
|
|
20
|
-
fontSize: '20px',
|
|
10
|
+
return (<Layout title="Page Not Found">
|
|
11
|
+
<div style={{
|
|
12
|
+
display: 'flex',
|
|
13
|
+
justifyContent: 'center',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
height: '50vh',
|
|
16
|
+
fontSize: '20px',
|
|
21
17
|
}}>
|
|
22
18
|
<h1>Oops, page not found </h1>
|
|
23
19
|
</div>
|
|
24
|
-
</Layout>
|
|
25
|
-
);
|
|
20
|
+
</Layout>);
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
export default NotFound;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type { ReactNode } from 'react';
|
|
8
|
+
declare function Root({ children }: {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}): ReactNode;
|
|
11
|
+
export default Root;
|
|
@@ -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
|
-
|
|
8
7
|
// Wrapper at the very top of the app, that is applied constantly
|
|
9
8
|
// and does not depend on current route (unlike the layout)
|
|
10
9
|
//
|
|
@@ -12,8 +11,7 @@
|
|
|
12
11
|
// and these providers won't reset state when we navigate
|
|
13
12
|
//
|
|
14
13
|
// See https://github.com/facebook/docusaurus/issues/3919
|
|
15
|
-
function Root({children}) {
|
|
16
|
-
|
|
14
|
+
function Root({ children }) {
|
|
15
|
+
return children;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
export default Root;
|
|
@@ -4,5 +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 {
|
|
8
|
-
export default function externalCommand(cli:
|
|
7
|
+
import type { CommanderStatic } from 'commander';
|
|
8
|
+
export default function externalCommand(cli: CommanderStatic, siteDir: string): Promise<void>;
|
|
@@ -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' | 'baseUrlIssueBanner' | 'staticDirectories'>;
|
|
10
|
+
export declare const DEFAULT_CONFIG: Pick<DocusaurusConfig, 'i18n' | 'onBrokenLinks' | 'onBrokenMarkdownLinks' | 'onDuplicateRoutes' | 'plugins' | 'themes' | 'presets' | '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;
|
|
@@ -29,6 +29,7 @@ exports.DEFAULT_CONFIG = {
|
|
|
29
29
|
themeConfig: {},
|
|
30
30
|
titleDelimiter: '|',
|
|
31
31
|
noIndex: false,
|
|
32
|
+
tagline: '',
|
|
32
33
|
baseUrlIssueBanner: true,
|
|
33
34
|
staticDirectories: [utils_1.STATIC_DIR_NAME],
|
|
34
35
|
};
|
|
@@ -143,7 +144,7 @@ exports.ConfigSchema = utils_validation_1.Joi.object({
|
|
|
143
144
|
type: utils_validation_1.Joi.string(),
|
|
144
145
|
}).unknown()),
|
|
145
146
|
clientModules: utils_validation_1.Joi.array().items(utils_validation_1.Joi.string()),
|
|
146
|
-
tagline: utils_validation_1.Joi.string().allow(''),
|
|
147
|
+
tagline: utils_validation_1.Joi.string().allow('').default(exports.DEFAULT_CONFIG.tagline),
|
|
147
148
|
titleDelimiter: utils_validation_1.Joi.string().default('|'),
|
|
148
149
|
noIndex: utils_validation_1.Joi.bool().default(false),
|
|
149
150
|
webpack: utils_validation_1.Joi.object({
|
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-
|
|
4
|
+
"version": "0.0.0-4523",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"@babel/runtime": "^7.16.3",
|
|
42
42
|
"@babel/runtime-corejs3": "^7.16.3",
|
|
43
43
|
"@babel/traverse": "^7.16.3",
|
|
44
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
45
|
-
"@docusaurus/logger": "0.0.0-
|
|
46
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
44
|
+
"@docusaurus/cssnano-preset": "0.0.0-4523",
|
|
45
|
+
"@docusaurus/logger": "0.0.0-4523",
|
|
46
|
+
"@docusaurus/mdx-loader": "0.0.0-4523",
|
|
47
47
|
"@docusaurus/react-loadable": "5.5.2",
|
|
48
|
-
"@docusaurus/utils": "0.0.0-
|
|
49
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
50
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
48
|
+
"@docusaurus/utils": "0.0.0-4523",
|
|
49
|
+
"@docusaurus/utils-common": "0.0.0-4523",
|
|
50
|
+
"@docusaurus/utils-validation": "0.0.0-4523",
|
|
51
51
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.0",
|
|
52
52
|
"@svgr/webpack": "^6.0.0",
|
|
53
53
|
"autoprefixer": "^10.3.5",
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"webpackbar": "^5.0.2"
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
109
|
-
"@docusaurus/types": "0.0.0-
|
|
108
|
+
"@docusaurus/module-type-aliases": "0.0.0-4523",
|
|
109
|
+
"@docusaurus/types": "0.0.0-4523",
|
|
110
110
|
"@types/copy-webpack-plugin": "^8.0.1",
|
|
111
111
|
"@types/detect-port": "^1.3.0",
|
|
112
112
|
"@types/mini-css-extract-plugin": "^1.4.3",
|
|
@@ -116,6 +116,7 @@
|
|
|
116
116
|
"@types/react-router-config": "^5.0.1",
|
|
117
117
|
"@types/rtl-detect": "^1.0.0",
|
|
118
118
|
"@types/serve-handler": "^6.1.1",
|
|
119
|
+
"@types/update-notifier": "^5.1.0",
|
|
119
120
|
"@types/wait-on": "^5.2.0",
|
|
120
121
|
"@types/webpack-bundle-analyzer": "^4.4.1",
|
|
121
122
|
"react-test-renderer": "^17.0.2",
|
|
@@ -128,5 +129,5 @@
|
|
|
128
129
|
"engines": {
|
|
129
130
|
"node": ">=14"
|
|
130
131
|
},
|
|
131
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "e78e68d4bc6a23f7e616eb7b59da9c79d9fb7452"
|
|
132
133
|
}
|