@docusaurus/plugin-debug 2.0.0-beta.fbdeefcac → 2.0.0-rc.1

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.
Files changed (40) hide show
  1. package/lib/index.d.ts +2 -2
  2. package/lib/index.js +14 -11
  3. package/lib/theme/DebugConfig/index.d.ts +8 -0
  4. package/lib/theme/DebugConfig/index.js +19 -0
  5. package/lib/theme/DebugContent/index.d.ts +9 -0
  6. package/lib/theme/DebugContent/index.js +59 -0
  7. package/lib/theme/DebugGlobalData/index.d.ts +8 -0
  8. package/{src → lib}/theme/DebugGlobalData/index.js +4 -9
  9. package/lib/theme/DebugJsonView/index.d.ts +9 -0
  10. package/{src → lib}/theme/DebugJsonView/index.js +12 -18
  11. package/lib/theme/DebugLayout/index.d.ts +10 -0
  12. package/{src → lib}/theme/DebugLayout/index.js +16 -18
  13. package/lib/theme/DebugLayout/styles.module.css +75 -0
  14. package/lib/theme/DebugRegistry/index.d.ts +8 -0
  15. package/lib/theme/DebugRegistry/index.js +29 -0
  16. package/lib/theme/DebugRegistry/styles.module.css +13 -0
  17. package/lib/theme/DebugRoutes/index.d.ts +8 -0
  18. package/{src → lib}/theme/DebugRoutes/index.js +4 -9
  19. package/lib/theme/DebugRoutes/styles.module.css +21 -0
  20. package/lib/theme/DebugSiteMetadata/index.d.ts +8 -0
  21. package/{src → lib}/theme/DebugSiteMetadata/index.js +10 -14
  22. package/lib/theme/DebugSiteMetadata/styles.module.css +26 -0
  23. package/package.json +16 -9
  24. package/src/index.ts +7 -4
  25. package/src/plugin-debug.d.ts +59 -0
  26. package/src/theme/DebugConfig/{index.js → index.tsx} +4 -8
  27. package/src/theme/DebugContent/index.tsx +77 -0
  28. package/src/theme/DebugGlobalData/index.tsx +21 -0
  29. package/src/theme/DebugJsonView/index.tsx +58 -0
  30. package/src/theme/DebugLayout/index.tsx +60 -0
  31. package/src/theme/DebugLayout/styles.module.css +1 -1
  32. package/src/theme/DebugRegistry/{index.js → index.tsx} +3 -6
  33. package/src/theme/DebugRegistry/styles.module.css +0 -5
  34. package/src/theme/DebugRoutes/index.tsx +38 -0
  35. package/src/theme/DebugRoutes/styles.module.css +0 -5
  36. package/src/theme/DebugSiteMetadata/index.tsx +44 -0
  37. package/src/theme/DebugSiteMetadata/styles.module.css +0 -5
  38. package/lib/.tsbuildinfo +0 -1
  39. package/src/theme/DebugContent/index.js +0 -70
  40. package/tsconfig.json +0 -9
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-debug",
3
- "version": "2.0.0-beta.fbdeefcac",
3
+ "version": "2.0.0-rc.1",
4
4
  "description": "Debug plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
+ "types": "src/plugin-debug.d.ts",
6
7
  "scripts": {
7
- "build": "tsc",
8
- "watch": "tsc --watch"
8
+ "build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\"",
9
+ "watch": "run-p -c copy:watch build:watch",
10
+ "build:watch": "tsc --build --watch",
11
+ "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
9
12
  },
10
13
  "publishConfig": {
11
14
  "access": "public"
@@ -17,18 +20,22 @@
17
20
  },
18
21
  "license": "MIT",
19
22
  "dependencies": {
20
- "@docusaurus/core": "2.0.0-beta.fbdeefcac",
21
- "@docusaurus/types": "2.0.0-beta.fbdeefcac",
22
- "@docusaurus/utils": "2.0.0-beta.fbdeefcac",
23
+ "@docusaurus/core": "2.0.0-rc.1",
24
+ "@docusaurus/types": "2.0.0-rc.1",
25
+ "@docusaurus/utils": "2.0.0-rc.1",
26
+ "fs-extra": "^10.1.0",
23
27
  "react-json-view": "^1.21.3",
24
- "tslib": "^2.1.0"
28
+ "tslib": "^2.4.0"
29
+ },
30
+ "devDependencies": {
31
+ "@docusaurus/types": "2.0.0-beta.21"
25
32
  },
26
33
  "peerDependencies": {
27
34
  "react": "^16.8.4 || ^17.0.0",
28
35
  "react-dom": "^16.8.4 || ^17.0.0"
29
36
  },
30
37
  "engines": {
31
- "node": ">=12.13.0"
38
+ "node": ">=16.14"
32
39
  },
33
- "gitHead": "636c490f68d16a7452499ab722deb5ed51ef49fc"
40
+ "gitHead": "c8ddd02a8e68dfaf515c20465a049a83153bd205"
34
41
  }
package/src/index.ts CHANGED
@@ -5,14 +5,14 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import {LoadContext, Plugin} from '@docusaurus/types';
9
- import {docuHash, normalizeUrl, posixPath} from '@docusaurus/utils';
10
8
  import path from 'path';
9
+ import {docuHash, normalizeUrl, posixPath} from '@docusaurus/utils';
10
+ import type {LoadContext, Plugin} from '@docusaurus/types';
11
11
 
12
12
  export default function pluginDebug({
13
13
  siteConfig: {baseUrl},
14
14
  generatedFilesDir,
15
- }: LoadContext): Plugin<void> {
15
+ }: LoadContext): Plugin<undefined> {
16
16
  const pluginDataDirRoot = path.join(
17
17
  generatedFilesDir,
18
18
  'docusaurus-plugin-debug',
@@ -24,7 +24,10 @@ export default function pluginDebug({
24
24
  name: 'docusaurus-plugin-debug',
25
25
 
26
26
  getThemePath() {
27
- return path.resolve(__dirname, '../src/theme');
27
+ return '../lib/theme';
28
+ },
29
+ getTypeScriptThemePath() {
30
+ return '../src/theme';
28
31
  },
29
32
 
30
33
  async contentLoaded({actions: {createData, addRoute}, allContent}) {
@@ -0,0 +1,59 @@
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
+
8
+ /// <reference types="@docusaurus/module-type-aliases" />
9
+
10
+ declare module '@docusaurus/plugin-debug' {
11
+ import type {LoadContext, Plugin} from '@docusaurus/types';
12
+
13
+ export default function pluginDebug(context: LoadContext): Plugin<undefined>;
14
+ }
15
+
16
+ declare module '@theme/DebugConfig' {
17
+ export default function DebugMetadata(): JSX.Element;
18
+ }
19
+
20
+ declare module '@theme/DebugContent' {
21
+ import type {AllContent} from '@docusaurus/types';
22
+
23
+ export interface Props {
24
+ readonly allContent: AllContent;
25
+ }
26
+ export default function DebugContent(props: Props): JSX.Element;
27
+ }
28
+
29
+ declare module '@theme/DebugGlobalData' {
30
+ export default function DebugGlobalData(): JSX.Element;
31
+ }
32
+
33
+ declare module '@theme/DebugJsonView' {
34
+ export interface Props {
35
+ readonly src: unknown;
36
+ readonly collapseDepth?: number;
37
+ }
38
+ export default function DebugJsonView(props: Props): JSX.Element;
39
+ }
40
+
41
+ declare module '@theme/DebugLayout' {
42
+ import type {ReactNode} from 'react';
43
+
44
+ export default function DebugLayout(props: {
45
+ children: ReactNode;
46
+ }): JSX.Element;
47
+ }
48
+
49
+ declare module '@theme/DebugRegistry' {
50
+ export default function DebugRegistry(): JSX.Element;
51
+ }
52
+
53
+ declare module '@theme/DebugRoutes' {
54
+ export default function DebugRoutes(): JSX.Element;
55
+ }
56
+
57
+ declare module '@theme/DebugSiteMetadata' {
58
+ export default function DebugSiteMetadata(): JSX.Element;
59
+ }
@@ -6,20 +6,16 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
-
10
- import DebugLayout from '../DebugLayout';
11
- import DebugJsonView from '../DebugJsonView';
12
-
13
9
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
10
+ import DebugLayout from '@theme/DebugLayout';
11
+ import DebugJsonView from '@theme/DebugJsonView';
14
12
 
15
- function DebugMetadata() {
13
+ export default function DebugMetadata(): JSX.Element {
16
14
  const {siteConfig} = useDocusaurusContext();
17
15
  return (
18
16
  <DebugLayout>
19
17
  <h2>Site config</h2>
20
- <DebugJsonView src={siteConfig} collapseDepth="3" />
18
+ <DebugJsonView src={siteConfig} collapseDepth={3} />
21
19
  </DebugLayout>
22
20
  );
23
21
  }
24
-
25
- export default DebugMetadata;
@@ -0,0 +1,77 @@
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
+
8
+ import React from 'react';
9
+
10
+ import DebugLayout from '@theme/DebugLayout';
11
+ import DebugJsonView from '@theme/DebugJsonView';
12
+ import type {Props} from '@theme/DebugContent';
13
+
14
+ function PluginInstanceContent({
15
+ pluginId,
16
+ pluginInstanceContent,
17
+ }: {
18
+ pluginId: string;
19
+ pluginInstanceContent: unknown;
20
+ }) {
21
+ return (
22
+ <section style={{marginBottom: 30}}>
23
+ <code>{pluginId}</code>
24
+ <DebugJsonView src={pluginInstanceContent} collapseDepth={2} />
25
+ </section>
26
+ );
27
+ }
28
+
29
+ function PluginContent({
30
+ pluginName,
31
+ pluginContent,
32
+ }: {
33
+ pluginName: string;
34
+ pluginContent: {[pluginId: string]: unknown};
35
+ }) {
36
+ return (
37
+ <section style={{marginBottom: 60}}>
38
+ <h3>{pluginName}</h3>
39
+ <div>
40
+ {Object.entries(pluginContent)
41
+ // Filter plugin instances with no content
42
+ .filter(([, pluginInstanceContent]) => !!pluginInstanceContent)
43
+ .map(([pluginId, pluginInstanceContent]) => (
44
+ <PluginInstanceContent
45
+ key={pluginId}
46
+ pluginId={pluginId}
47
+ pluginInstanceContent={pluginInstanceContent}
48
+ />
49
+ ))}
50
+ </div>
51
+ </section>
52
+ );
53
+ }
54
+
55
+ export default function DebugContent({allContent}: Props): JSX.Element {
56
+ return (
57
+ <DebugLayout>
58
+ <h2>Plugin content</h2>
59
+ <div>
60
+ {Object.entries(allContent)
61
+ // Filter plugins with no content
62
+ .filter(([, pluginContent]) =>
63
+ Object.values(pluginContent).some(
64
+ (instanceContent) => !!instanceContent,
65
+ ),
66
+ )
67
+ .map(([pluginName, pluginContent]) => (
68
+ <PluginContent
69
+ key={pluginName}
70
+ pluginName={pluginName}
71
+ pluginContent={pluginContent}
72
+ />
73
+ ))}
74
+ </div>
75
+ </DebugLayout>
76
+ );
77
+ }
@@ -0,0 +1,21 @@
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
+
8
+ import React from 'react';
9
+ import useGlobalData from '@docusaurus/useGlobalData';
10
+ import DebugLayout from '@theme/DebugLayout';
11
+ import DebugJsonView from '@theme/DebugJsonView';
12
+
13
+ export default function DebugMetadata(): JSX.Element {
14
+ const globalData = useGlobalData();
15
+ return (
16
+ <DebugLayout>
17
+ <h2>Global data</h2>
18
+ <DebugJsonView src={globalData} collapseDepth={3} />
19
+ </DebugLayout>
20
+ );
21
+ }
@@ -0,0 +1,58 @@
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
+
8
+ import React from 'react';
9
+ import BrowserOnly from '@docusaurus/BrowserOnly';
10
+ import type {Props} from '@theme/DebugJsonView';
11
+ import type {ReactJsonViewProps} from 'react-json-view';
12
+
13
+ // Avoids "react-json-view" displaying "root"
14
+ const RootName = null;
15
+
16
+ // Seems ReactJson does not work with SSR
17
+ // https://github.com/mac-s-g/react-json-view/issues/121
18
+ function BrowserOnlyReactJson(props: ReactJsonViewProps) {
19
+ return (
20
+ <BrowserOnly>
21
+ {() => {
22
+ const {default: ReactJson} =
23
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
24
+ require('react-json-view') as typeof import('react-json-view');
25
+ return <ReactJson {...props} />;
26
+ }}
27
+ </BrowserOnly>
28
+ );
29
+ }
30
+
31
+ export default function DebugJsonView({
32
+ src,
33
+ collapseDepth,
34
+ }: Props): JSX.Element {
35
+ return (
36
+ <BrowserOnlyReactJson
37
+ src={src as object}
38
+ style={{
39
+ marginTop: '10px',
40
+ padding: '10px',
41
+ borderRadius: '4px',
42
+ backgroundColor: '#292a2b',
43
+ }}
44
+ name={RootName}
45
+ theme="paraiso"
46
+ shouldCollapse={(field) =>
47
+ // By default, we collapse the json for performance reasons
48
+ // See https://github.com/mac-s-g/react-json-view/issues/235
49
+ // Non-root elements that are larger than 50 fields are collapsed
50
+ field.name !== RootName && Object.keys(field.src).length > 50
51
+ }
52
+ collapsed={collapseDepth}
53
+ groupArraysAfterLength={5}
54
+ enableClipboard={false}
55
+ displayDataTypes={false}
56
+ />
57
+ );
58
+ }
@@ -0,0 +1,60 @@
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
+
8
+ import React, {type ReactNode} from 'react';
9
+ import Head from '@docusaurus/Head';
10
+ import Link from '@docusaurus/Link';
11
+ import styles from './styles.module.css';
12
+
13
+ function DebugNavLink({to, children}: {to: string; children: ReactNode}) {
14
+ return (
15
+ <Link
16
+ className={styles.navlink}
17
+ isNavLink
18
+ to={to}
19
+ exact
20
+ activeStyle={{
21
+ backgroundColor: '#363739',
22
+ }}>
23
+ {children}
24
+ </Link>
25
+ );
26
+ }
27
+
28
+ export default function DebugLayout({
29
+ children,
30
+ }: {
31
+ children: ReactNode;
32
+ }): JSX.Element {
33
+ return (
34
+ <>
35
+ <Head>
36
+ <html lang="en" />
37
+ <title>Docusaurus debug panel</title>
38
+ <meta name="robots" content="noindex" />
39
+ </Head>
40
+
41
+ <div>
42
+ <nav className={styles.nav}>
43
+ <DebugNavLink to="/__docusaurus/debug">Config</DebugNavLink>
44
+ <DebugNavLink to="/__docusaurus/debug/metadata">
45
+ Metadata
46
+ </DebugNavLink>
47
+ <DebugNavLink to="/__docusaurus/debug/registry">
48
+ Registry
49
+ </DebugNavLink>
50
+ <DebugNavLink to="/__docusaurus/debug/routes">Routes</DebugNavLink>
51
+ <DebugNavLink to="/__docusaurus/debug/content">Content</DebugNavLink>
52
+ <DebugNavLink to="/__docusaurus/debug/globalData">
53
+ Global data
54
+ </DebugNavLink>
55
+ </nav>
56
+ <main className={styles.container}>{children}</main>
57
+ </div>
58
+ </>
59
+ );
60
+ }
@@ -36,7 +36,7 @@
36
36
  font-size: clamp(12px, 4vw, 16px);
37
37
  text-align: center;
38
38
  border-radius: 4px;
39
- padding: 6px 6px;
39
+ padding: 6px;
40
40
  }
41
41
 
42
42
  .navlink:hover {
@@ -6,16 +6,15 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
-
10
- import DebugLayout from '../DebugLayout';
11
9
  import registry from '@generated/registry';
10
+ import DebugLayout from '@theme/DebugLayout';
12
11
  import styles from './styles.module.css';
13
12
 
14
- function DebugRegistry() {
13
+ export default function DebugRegistry(): JSX.Element {
15
14
  return (
16
15
  <DebugLayout>
17
16
  <h2>Registry</h2>
18
- <ul className={styles.list}>
17
+ <ul className="clean-list">
19
18
  {Object.values(registry).map(([, aliasedPath, resolved]) => (
20
19
  <li key={aliasedPath} className={styles.listItem}>
21
20
  <div style={{marginBottom: '10px'}}>
@@ -30,5 +29,3 @@ function DebugRegistry() {
30
29
  </DebugLayout>
31
30
  );
32
31
  }
33
-
34
- export default DebugRegistry;
@@ -5,12 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- .list {
9
- padding: 0;
10
- }
11
-
12
8
  .listItem {
13
- list-style: none;
14
9
  background-color: #242526;
15
10
  padding: 10px;
16
11
  border-radius: 4px;
@@ -0,0 +1,38 @@
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
+
8
+ import React from 'react';
9
+ import routes from '@generated/routes';
10
+ import DebugLayout from '@theme/DebugLayout';
11
+ import DebugJsonView from '@theme/DebugJsonView';
12
+ import styles from './styles.module.css';
13
+
14
+ export default function DebugRoutes(): JSX.Element {
15
+ return (
16
+ <DebugLayout>
17
+ <h2>Routes</h2>
18
+ <ul className="clean-list">
19
+ {routes.map(({path, exact, routes: childRoutes}) => (
20
+ <li key={path} className={styles.listItem}>
21
+ <div className={styles.route}>
22
+ <code className={styles.routeName}>{path}</code>
23
+ </div>
24
+ <div>
25
+ Is exact: <code>{String(Boolean(exact))}</code>
26
+ </div>
27
+ {childRoutes && (
28
+ <div>
29
+ Child Routes:
30
+ <DebugJsonView src={childRoutes} />
31
+ </div>
32
+ )}
33
+ </li>
34
+ ))}
35
+ </ul>
36
+ </DebugLayout>
37
+ );
38
+ }
@@ -5,12 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- .list {
9
- padding: 0;
10
- }
11
-
12
8
  .listItem {
13
- list-style: none;
14
9
  background-color: #242526;
15
10
  padding: 10px;
16
11
  border-radius: 4px;
@@ -0,0 +1,44 @@
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
+
8
+ import React from 'react';
9
+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
10
+ import DebugLayout from '@theme/DebugLayout';
11
+ import styles from './styles.module.css';
12
+
13
+ export default function DebugMetadata(): JSX.Element {
14
+ const {siteMetadata} = useDocusaurusContext();
15
+ return (
16
+ <DebugLayout>
17
+ <h2>Site Metadata</h2>
18
+ <div>
19
+ Docusaurus Version: <code>{siteMetadata.docusaurusVersion}</code>
20
+ </div>
21
+ <div>
22
+ Site Version:{' '}
23
+ <code>{siteMetadata.siteVersion ?? 'No version specified'}</code>
24
+ </div>
25
+ <h3 className={styles.sectionTitle}>Plugins and themes</h3>
26
+ <ul className="clean-list">
27
+ {Object.entries(siteMetadata.pluginVersions).map(
28
+ ([name, versionInformation]) => (
29
+ <li key={name} className={styles.listItem}>
30
+ {versionInformation.type === 'package' &&
31
+ versionInformation.version && (
32
+ <div className={styles.version}>
33
+ <code>{versionInformation.version}</code>
34
+ </div>
35
+ )}
36
+ <div className={styles.name}>{name}</div>
37
+ <div>Type: {versionInformation.type}</div>
38
+ </li>
39
+ ),
40
+ )}
41
+ </ul>
42
+ </DebugLayout>
43
+ );
44
+ }
@@ -9,12 +9,7 @@
9
9
  margin-top: 20px;
10
10
  }
11
11
 
12
- .list {
13
- padding: 0;
14
- }
15
-
16
12
  .listItem {
17
- list-style: none;
18
13
  background-color: #242526;
19
14
  padding: 10px;
20
15
  border-radius: 4px;