@docusaurus/theme-live-codeblock 3.0.0-alpha.0 → 3.0.0-rc.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/lib/theme/CodeBlock/index.d.ts +2 -2
- package/lib/theme/CodeBlock/index.js +0 -1
- package/lib/theme/Playground/index.js +5 -11
- package/lib/theme/Playground/styles.module.css +0 -4
- package/lib/theme/ReactLiveScope/index.d.ts +1 -1
- package/package.json +11 -11
- package/src/deps.d.ts +2 -1
- package/src/theme/CodeBlock/index.tsx +0 -1
- package/src/theme/Playground/index.tsx +5 -13
- package/src/theme/Playground/styles.module.css +0 -4
- package/src/theme-live-codeblock.d.ts +2 -1
|
@@ -4,7 +4,7 @@
|
|
|
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
|
-
|
|
7
|
+
import React from 'react';
|
|
8
8
|
import { type Props } from '@theme-init/CodeBlock';
|
|
9
|
-
declare const _default: (props: Props) => JSX.Element;
|
|
9
|
+
declare const _default: (props: Props) => React.JSX.Element;
|
|
10
10
|
export default _default;
|
|
@@ -11,7 +11,6 @@ import CodeBlock from '@theme-init/CodeBlock';
|
|
|
11
11
|
const withLiveEditor = (Component) => {
|
|
12
12
|
function WrappedComponent(props) {
|
|
13
13
|
if (props.live) {
|
|
14
|
-
// @ts-expect-error: we have deliberately widened the type of language prop
|
|
15
14
|
return <Playground scope={ReactLiveScope} {...props} />;
|
|
16
15
|
}
|
|
17
16
|
return <Component {...props} />;
|
|
@@ -12,7 +12,7 @@ import Translate from '@docusaurus/Translate';
|
|
|
12
12
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
13
13
|
import BrowserOnly from '@docusaurus/BrowserOnly';
|
|
14
14
|
import {
|
|
15
|
-
|
|
15
|
+
ErrorBoundaryErrorMessageFallback,
|
|
16
16
|
usePrismTheme,
|
|
17
17
|
} from '@docusaurus/theme-common';
|
|
18
18
|
import ErrorBoundary from '@docusaurus/ErrorBoundary';
|
|
@@ -25,14 +25,6 @@ function LivePreviewLoader() {
|
|
|
25
25
|
// eslint-disable-next-line @docusaurus/no-untranslated-text
|
|
26
26
|
return <div>Loading...</div>;
|
|
27
27
|
}
|
|
28
|
-
function ErrorFallback({error, tryAgain}) {
|
|
29
|
-
return (
|
|
30
|
-
<div className={styles.errorFallback}>
|
|
31
|
-
<p>{error.message}</p>
|
|
32
|
-
<ErrorBoundaryTryAgainButton onClick={tryAgain} />
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
28
|
function Preview() {
|
|
37
29
|
// No SSR for the live preview
|
|
38
30
|
// See https://github.com/facebook/docusaurus/issues/5747
|
|
@@ -40,7 +32,10 @@ function Preview() {
|
|
|
40
32
|
<BrowserOnly fallback={<LivePreviewLoader />}>
|
|
41
33
|
{() => (
|
|
42
34
|
<>
|
|
43
|
-
<ErrorBoundary
|
|
35
|
+
<ErrorBoundary
|
|
36
|
+
fallback={(params) => (
|
|
37
|
+
<ErrorBoundaryErrorMessageFallback {...params} />
|
|
38
|
+
)}>
|
|
44
39
|
<LivePreview />
|
|
45
40
|
</ErrorBoundary>
|
|
46
41
|
<LiveError />
|
|
@@ -102,7 +97,6 @@ export default function Playground({children, transformCode, ...props}) {
|
|
|
102
97
|
const noInline = props.metastring?.includes('noInline') ?? false;
|
|
103
98
|
return (
|
|
104
99
|
<div className={styles.playgroundContainer}>
|
|
105
|
-
{/* @ts-expect-error: type incompatibility with refs */}
|
|
106
100
|
<LiveProvider
|
|
107
101
|
code={children.replace(/\n$/, '')}
|
|
108
102
|
noInline={noInline}
|
|
@@ -65,7 +65,7 @@ declare const ReactLiveScope: {
|
|
|
65
65
|
forEach<C_3>(children: C_3 | readonly C_3[], fn: (child: C_3, index: number) => void): void;
|
|
66
66
|
count(children: any): number;
|
|
67
67
|
only<C_4>(children: C_4): C_4 extends any[] ? never : C_4;
|
|
68
|
-
toArray(children: React.ReactNode | React.ReactNode[]): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.
|
|
68
|
+
toArray(children: React.ReactNode | React.ReactNode[]): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal)[];
|
|
69
69
|
};
|
|
70
70
|
Fragment: React.ExoticComponent<{
|
|
71
71
|
children?: React.ReactNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-live-codeblock",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-rc.0",
|
|
4
4
|
"description": "Docusaurus live code block component.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-live-codeblock.d.ts",
|
|
@@ -23,18 +23,18 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@docusaurus/core": "3.0.0-
|
|
27
|
-
"@docusaurus/theme-common": "3.0.0-
|
|
28
|
-
"@docusaurus/theme-translations": "3.0.0-
|
|
29
|
-
"@docusaurus/utils-validation": "3.0.0-
|
|
26
|
+
"@docusaurus/core": "3.0.0-rc.0",
|
|
27
|
+
"@docusaurus/theme-common": "3.0.0-rc.0",
|
|
28
|
+
"@docusaurus/theme-translations": "3.0.0-rc.0",
|
|
29
|
+
"@docusaurus/utils-validation": "3.0.0-rc.0",
|
|
30
30
|
"@philpl/buble": "^0.19.7",
|
|
31
31
|
"clsx": "^1.2.1",
|
|
32
|
-
"fs-extra": "^11.1.
|
|
33
|
-
"react-live": "
|
|
34
|
-
"tslib": "^2.
|
|
32
|
+
"fs-extra": "^11.1.1",
|
|
33
|
+
"react-live": "^4.1.5",
|
|
34
|
+
"tslib": "^2.6.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@docusaurus/types": "3.0.0-
|
|
37
|
+
"@docusaurus/types": "3.0.0-rc.0",
|
|
38
38
|
"@types/buble": "^0.20.1"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"react-dom": "^18.0.0"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
|
-
"node": ">=
|
|
45
|
+
"node": ">=18.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "e66dfe04d2972edce66f431908470c61340f8ffc"
|
|
48
48
|
}
|
package/src/deps.d.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
declare module '@philpl/buble' {
|
|
9
9
|
import type {TransformOptions as OriginalTransformOptions} from 'buble';
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
11
12
|
export * from 'buble';
|
|
12
13
|
export const features: string[];
|
|
13
14
|
export type TransformOptions = OriginalTransformOptions & {
|
|
@@ -13,7 +13,6 @@ import CodeBlock, {type Props} from '@theme-init/CodeBlock';
|
|
|
13
13
|
const withLiveEditor = (Component: typeof CodeBlock) => {
|
|
14
14
|
function WrappedComponent(props: Props) {
|
|
15
15
|
if (props.live) {
|
|
16
|
-
// @ts-expect-error: we have deliberately widened the type of language prop
|
|
17
16
|
return <Playground scope={ReactLiveScope} {...props} />;
|
|
18
17
|
}
|
|
19
18
|
|
|
@@ -13,13 +13,12 @@ import Translate from '@docusaurus/Translate';
|
|
|
13
13
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
14
14
|
import BrowserOnly from '@docusaurus/BrowserOnly';
|
|
15
15
|
import {
|
|
16
|
-
|
|
16
|
+
ErrorBoundaryErrorMessageFallback,
|
|
17
17
|
usePrismTheme,
|
|
18
18
|
} from '@docusaurus/theme-common';
|
|
19
19
|
import ErrorBoundary from '@docusaurus/ErrorBoundary';
|
|
20
20
|
|
|
21
21
|
import type {Props} from '@theme/Playground';
|
|
22
|
-
import type {Props as ErrorProps} from '@theme/Error';
|
|
23
22
|
import type {ThemeConfig} from '@docusaurus/theme-live-codeblock';
|
|
24
23
|
|
|
25
24
|
import styles from './styles.module.css';
|
|
@@ -34,15 +33,6 @@ function LivePreviewLoader() {
|
|
|
34
33
|
return <div>Loading...</div>;
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
function ErrorFallback({error, tryAgain}: ErrorProps): JSX.Element {
|
|
38
|
-
return (
|
|
39
|
-
<div className={styles.errorFallback}>
|
|
40
|
-
<p>{error.message}</p>
|
|
41
|
-
<ErrorBoundaryTryAgainButton onClick={tryAgain} />
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
36
|
function Preview() {
|
|
47
37
|
// No SSR for the live preview
|
|
48
38
|
// See https://github.com/facebook/docusaurus/issues/5747
|
|
@@ -50,7 +40,10 @@ function Preview() {
|
|
|
50
40
|
<BrowserOnly fallback={<LivePreviewLoader />}>
|
|
51
41
|
{() => (
|
|
52
42
|
<>
|
|
53
|
-
<ErrorBoundary
|
|
43
|
+
<ErrorBoundary
|
|
44
|
+
fallback={(params) => (
|
|
45
|
+
<ErrorBoundaryErrorMessageFallback {...params} />
|
|
46
|
+
)}>
|
|
54
47
|
<LivePreview />
|
|
55
48
|
</ErrorBoundary>
|
|
56
49
|
<LiveError />
|
|
@@ -122,7 +115,6 @@ export default function Playground({
|
|
|
122
115
|
|
|
123
116
|
return (
|
|
124
117
|
<div className={styles.playgroundContainer}>
|
|
125
|
-
{/* @ts-expect-error: type incompatibility with refs */}
|
|
126
118
|
<LiveProvider
|
|
127
119
|
code={children.replace(/\n$/, '')}
|
|
128
120
|
noInline={noInline}
|
|
@@ -18,9 +18,10 @@ declare module '@docusaurus/theme-live-codeblock' {
|
|
|
18
18
|
|
|
19
19
|
declare module '@theme/Playground' {
|
|
20
20
|
import type {Props as BaseProps} from '@theme/CodeBlock';
|
|
21
|
-
import type {
|
|
21
|
+
import type {LiveProvider} from 'react-live';
|
|
22
22
|
|
|
23
23
|
type CodeBlockProps = Omit<BaseProps, 'className' | 'language' | 'title'>;
|
|
24
|
+
type LiveProviderProps = React.ComponentProps<typeof LiveProvider>;
|
|
24
25
|
|
|
25
26
|
export interface Props extends CodeBlockProps, LiveProviderProps {
|
|
26
27
|
children: string;
|