docusaurus-live-brython 3.0.0-beta.10 → 3.0.0-beta.4
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/README.md +0 -12
- package/lib/theme/CodeBlock/index.jsx +4 -2
- package/lib/theme/CodeEditor/Actions/DownloadCode.jsx +2 -2
- package/lib/theme/CodeEditor/Actions/Reset.jsx +2 -2
- package/lib/theme/CodeEditor/Actions/RunCode.jsx +2 -2
- package/lib/theme/CodeEditor/Actions/ShowRaw.jsx +2 -2
- package/lib/theme/CodeEditor/Actions/ShowSyncStatus.jsx +3 -3
- package/lib/theme/CodeEditor/BrythonCommunicator.jsx +2 -2
- package/lib/theme/CodeEditor/Button/index.d.ts +1 -1
- package/lib/theme/CodeEditor/Button/index.jsx +1 -1
- package/lib/theme/CodeEditor/CodeHistory/index.jsx +2 -2
- package/lib/theme/CodeEditor/Editor/EditorAce.jsx +2 -2
- package/lib/theme/CodeEditor/Editor/Header/index.jsx +6 -6
- package/lib/theme/CodeEditor/Editor/Result/Graphics/Canvas.d.ts +2 -2
- package/lib/theme/CodeEditor/Editor/Result/Graphics/Canvas.jsx +7 -7
- package/lib/theme/CodeEditor/Editor/Result/Graphics/Turtle.d.ts +2 -2
- package/lib/theme/CodeEditor/Editor/Result/Graphics/Turtle.jsx +8 -8
- package/lib/theme/CodeEditor/Editor/Result/Graphics/index.d.ts +2 -2
- package/lib/theme/CodeEditor/Editor/Result/Graphics/index.jsx +6 -6
- package/lib/theme/CodeEditor/Editor/Result/index.jsx +1 -1
- package/lib/theme/CodeEditor/Editor/index.jsx +11 -11
- package/lib/theme/CodeEditor/Editor/utils/saveSvg.js +1 -1
- package/lib/theme/CodeEditor/Icon/index.d.ts +1 -1
- package/lib/theme/CodeEditor/Icon/index.jsx +1 -1
- package/lib/theme/CodeEditor/WithScript/Storage.d.ts +1 -1
- package/lib/theme/CodeEditor/WithScript/Store.jsx +3 -3
- package/lib/theme/CodeEditor/index.jsx +4 -4
- package/package.json +6 -62
- package/src/theme/CodeBlock/index.tsx +8 -2
- package/src/theme/CodeEditor/Actions/DownloadCode.tsx +2 -2
- package/src/theme/CodeEditor/Actions/Reset.tsx +2 -2
- package/src/theme/CodeEditor/Actions/RunCode.tsx +2 -2
- package/src/theme/CodeEditor/Actions/ShowRaw.tsx +2 -2
- package/src/theme/CodeEditor/Actions/ShowSyncStatus.tsx +3 -3
- package/src/theme/CodeEditor/BrythonCommunicator.tsx +3 -3
- package/src/theme/CodeEditor/Button/index.tsx +2 -2
- package/src/theme/CodeEditor/CodeHistory/index.tsx +2 -2
- package/src/theme/CodeEditor/Editor/EditorAce.tsx +2 -2
- package/src/theme/CodeEditor/Editor/Header/index.tsx +6 -6
- package/src/theme/CodeEditor/Editor/Result/Graphics/Canvas.tsx +7 -7
- package/src/theme/CodeEditor/Editor/Result/Graphics/Turtle.tsx +8 -8
- package/src/theme/CodeEditor/Editor/Result/Graphics/index.tsx +6 -6
- package/src/theme/CodeEditor/Editor/Result/index.tsx +1 -1
- package/src/theme/CodeEditor/Editor/index.tsx +14 -12
- package/src/theme/CodeEditor/Editor/utils/saveSvg.ts +1 -1
- package/src/theme/CodeEditor/Editor/utils/svgWithoutAnimations.ts +1 -1
- package/src/theme/CodeEditor/Icon/index.tsx +1 -1
- package/src/theme/CodeEditor/WithScript/Storage.ts +1 -1
- package/src/theme/CodeEditor/WithScript/Store.tsx +3 -3
- package/src/theme/CodeEditor/index.tsx +5 -5
- package/.prettierrc +0 -9
package/README.md
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# Docusaurus Live Codeblock for Python
|
|
2
2
|
|
|
3
|
-

|
|
4
|
-
|
|
5
|
-
|
|
6
3
|
> [!NOTE]\
|
|
7
4
|
> This theme works with Docusaurus v3+.
|
|
8
5
|
|
|
@@ -118,13 +115,4 @@ yarn link docusaurus-live-brython
|
|
|
118
115
|
Then start the website
|
|
119
116
|
```sh
|
|
120
117
|
yarn run start
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### Publish
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
yarn run build
|
|
127
|
-
# when running inside wsl, use --auth=legacy
|
|
128
|
-
npm login --auth=legacy
|
|
129
|
-
npm publish --auth=legacy
|
|
130
118
|
```
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import CodeBlock from '@theme-init/CodeBlock';
|
|
3
3
|
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
4
|
-
import CodeEditor from '
|
|
5
|
-
import
|
|
4
|
+
import CodeEditor from '../CodeEditor';
|
|
5
|
+
// import Playground from '@theme-original/Playground';
|
|
6
|
+
// import ReactLiveScope from '@theme-original/ReactLiveScope';
|
|
7
|
+
import ScriptContext from '../CodeEditor/WithScript/Store';
|
|
6
8
|
const sanitizedTitle = (id) => {
|
|
7
9
|
if (!id) {
|
|
8
10
|
return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useScript, useStore } from '
|
|
3
|
-
import Button from '
|
|
2
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
3
|
+
import Button from '../Button';
|
|
4
4
|
import { translate } from '@docusaurus/Translate';
|
|
5
5
|
const DownloadCode = (props) => {
|
|
6
6
|
const { store } = useScript();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useScript, useStore } from '
|
|
3
|
-
import Button from '
|
|
2
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
3
|
+
import Button from '../Button';
|
|
4
4
|
import { translate } from '@docusaurus/Translate';
|
|
5
5
|
const Reset = () => {
|
|
6
6
|
const { store } = useScript();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useScript, useStore } from '
|
|
3
|
-
import Button, { Color } from '
|
|
2
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
3
|
+
import Button, { Color } from '../Button';
|
|
4
4
|
import { translate } from '@docusaurus/Translate';
|
|
5
5
|
import styles from './styles.module.css';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useScript, useStore } from '
|
|
3
|
-
import Button, { Color } from '
|
|
2
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
3
|
+
import Button, { Color } from '../Button';
|
|
4
4
|
import { translate } from '@docusaurus/Translate';
|
|
5
5
|
const ShowRaw = () => {
|
|
6
6
|
const { store } = useScript();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useScript, useStore } from '
|
|
3
|
-
import Icon, { Color } from '
|
|
4
|
-
import { Status } from '
|
|
2
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
3
|
+
import Icon, { Color } from '../Icon';
|
|
4
|
+
import { Status } from '../WithScript/Types';
|
|
5
5
|
const ShowSyncStatus = () => {
|
|
6
6
|
const { store } = useScript();
|
|
7
7
|
const isLoaded = useStore(store, (state) => state.isLoaded);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { BRYTHON_NOTIFICATION_EVENT, DOM_ELEMENT_IDS } from "
|
|
3
|
-
import { useScript, useStore } from '
|
|
2
|
+
import { BRYTHON_NOTIFICATION_EVENT, DOM_ELEMENT_IDS } from "./constants";
|
|
3
|
+
import { useScript, useStore } from './WithScript/Store';
|
|
4
4
|
const BrythonCommunicator = () => {
|
|
5
5
|
const { store } = useScript();
|
|
6
6
|
const codeId = useStore(store, (state) => state.codeId);
|
|
@@ -4,9 +4,9 @@ import styles from './styles.module.css';
|
|
|
4
4
|
import { Prism } from 'prism-react-renderer';
|
|
5
5
|
import Slider from 'rc-slider';
|
|
6
6
|
import 'rc-slider/assets/index.css';
|
|
7
|
-
import { useScript, useStore } from '
|
|
7
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
8
8
|
import Translate, { translate } from '@docusaurus/Translate';
|
|
9
|
-
import Button from '
|
|
9
|
+
import Button from '../Button';
|
|
10
10
|
import DiffViewer from 'react-diff-viewer';
|
|
11
11
|
import Details from '@theme/Details';
|
|
12
12
|
const highlightSyntax = (str) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import styles from './styles.module.css';
|
|
4
|
-
import { DOM_ELEMENT_IDS } from '
|
|
4
|
+
import { DOM_ELEMENT_IDS } from '../constants';
|
|
5
5
|
import AceEditor from 'react-ace';
|
|
6
6
|
import 'ace-builds/src-noconflict/ext-searchbox';
|
|
7
7
|
import 'ace-builds/src-noconflict/mode-python';
|
|
@@ -10,7 +10,7 @@ import 'ace-builds/src-noconflict/mode-svg';
|
|
|
10
10
|
import 'ace-builds/src-noconflict/theme-dracula';
|
|
11
11
|
import 'ace-builds/src-noconflict/ext-language_tools';
|
|
12
12
|
import 'ace-builds/webpack-resolver';
|
|
13
|
-
import { useScript, useStore } from '
|
|
13
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
14
14
|
const ALIAS_LANG_MAP_ACE = {
|
|
15
15
|
mpy: 'python',
|
|
16
16
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import styles from './styles.module.css';
|
|
4
|
-
import { useScript, useStore } from '
|
|
5
|
-
import ShowSyncStatus from '
|
|
6
|
-
import Reset from '
|
|
7
|
-
import DownloadCode from '
|
|
8
|
-
import ShowRaw from '
|
|
9
|
-
import RunCode from '
|
|
4
|
+
import { useScript, useStore } from '../../WithScript/Store';
|
|
5
|
+
import ShowSyncStatus from '../../Actions/ShowSyncStatus';
|
|
6
|
+
import Reset from '../../Actions/Reset';
|
|
7
|
+
import DownloadCode from '../../Actions/DownloadCode';
|
|
8
|
+
import ShowRaw from '../../Actions/ShowRaw';
|
|
9
|
+
import RunCode from '../../Actions/RunCode';
|
|
10
10
|
const Header = (props) => {
|
|
11
11
|
const { store } = useScript();
|
|
12
12
|
const hasEdits = useStore(store, (state) => state.hasEdits);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const CanvasResult: () => React.JSX.Element;
|
|
3
|
+
export default CanvasResult;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { DOM_ELEMENT_IDS } from '
|
|
3
|
-
import
|
|
2
|
+
import { DOM_ELEMENT_IDS } from '../../../constants';
|
|
3
|
+
import GraphicsResult from '.';
|
|
4
4
|
import styles from './styles.module.css';
|
|
5
|
-
import { useScript, useStore } from '
|
|
6
|
-
import Button from '
|
|
5
|
+
import { useScript, useStore } from '../../../WithScript/Store';
|
|
6
|
+
import Button from '../../../Button';
|
|
7
7
|
const downloadCanvas = (canvasId) => {
|
|
8
8
|
const canvas = document.getElementById(canvasId);
|
|
9
9
|
if (!canvas) {
|
|
@@ -21,11 +21,11 @@ const downloadCanvas = (canvasId) => {
|
|
|
21
21
|
downloadLink.click();
|
|
22
22
|
document.body.removeChild(downloadLink);
|
|
23
23
|
};
|
|
24
|
-
const
|
|
24
|
+
const CanvasResult = () => {
|
|
25
25
|
const { store } = useScript();
|
|
26
26
|
// const { codeId } = useStore(store, (state) => ({codeId: state.codeId}));
|
|
27
27
|
const codeId = useStore(store, (state) => state.codeId);
|
|
28
|
-
return (<
|
|
28
|
+
return (<GraphicsResult controls={<Button icon='Download' iconSize='12px' onClick={() => {
|
|
29
29
|
downloadCanvas(DOM_ELEMENT_IDS.canvasContainer(codeId));
|
|
30
30
|
}} title="Download SVG" className={styles.slimStrippedButton}/>} main={<canvas id={DOM_ELEMENT_IDS.canvasContainer(codeId)} width="500" height="500" style={{
|
|
31
31
|
display: 'block',
|
|
@@ -33,4 +33,4 @@ const Canvas = () => {
|
|
|
33
33
|
height: '500px'
|
|
34
34
|
}}></canvas>}/>);
|
|
35
35
|
};
|
|
36
|
-
export default
|
|
36
|
+
export default CanvasResult;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const TurtleResult: () => React.JSX.Element;
|
|
3
|
+
export default TurtleResult;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import styles from './styles.module.css';
|
|
3
|
-
import { DOM_ELEMENT_IDS } from '
|
|
4
|
-
import
|
|
5
|
-
import { saveSvg } from '
|
|
6
|
-
import { useScript, useStore } from '
|
|
7
|
-
import Button from '
|
|
3
|
+
import { DOM_ELEMENT_IDS } from '../../../constants';
|
|
4
|
+
import GraphicsResult from '.';
|
|
5
|
+
import { saveSvg } from '../../utils/saveSvg';
|
|
6
|
+
import { useScript, useStore } from '../../../WithScript/Store';
|
|
7
|
+
import Button from '../../../Button';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
|
-
const
|
|
9
|
+
const TurtleResult = () => {
|
|
10
10
|
const { store } = useScript();
|
|
11
11
|
const codeId = useStore(store, (state) => state.codeId);
|
|
12
12
|
const code = useStore(store, (state) => state.code);
|
|
13
|
-
return (<
|
|
13
|
+
return (<GraphicsResult controls={<React.Fragment>
|
|
14
14
|
<Button icon='AnimationPlay' onClick={() => {
|
|
15
15
|
const turtleResult = document.getElementById(DOM_ELEMENT_IDS.turtleSvgContainer(codeId));
|
|
16
16
|
if (turtleResult) {
|
|
@@ -25,4 +25,4 @@ const Turtle = () => {
|
|
|
25
25
|
}} title="Download SVG" className={styles.slimStrippedButton}/>
|
|
26
26
|
</React.Fragment>}/>);
|
|
27
27
|
};
|
|
28
|
-
export default
|
|
28
|
+
export default TurtleResult;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import styles from './styles.module.css';
|
|
3
|
-
import { DOM_ELEMENT_IDS } from '
|
|
3
|
+
import { DOM_ELEMENT_IDS } from '../../../constants';
|
|
4
4
|
import Draggable from 'react-draggable';
|
|
5
|
-
import { checkForButtonClick } from '
|
|
6
|
-
import { useScript, useStore } from '
|
|
7
|
-
import Button from '
|
|
5
|
+
import { checkForButtonClick } from '../../utils/checkForButtonClick';
|
|
6
|
+
import { useScript, useStore } from '../../../WithScript/Store';
|
|
7
|
+
import Button from '../../../Button';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
|
-
const
|
|
9
|
+
const GraphicsResult = (props) => {
|
|
10
10
|
const { store } = useScript();
|
|
11
11
|
const codeId = useStore(store, (state) => state.codeId);
|
|
12
12
|
return (<Draggable onStop={checkForButtonClick} positionOffset={{ x: 0, y: '-50%' }}>
|
|
@@ -26,4 +26,4 @@ const Graphics = (props) => {
|
|
|
26
26
|
</div>
|
|
27
27
|
</Draggable>);
|
|
28
28
|
};
|
|
29
|
-
export default
|
|
29
|
+
export default GraphicsResult;
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from './styles.module.css';
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import CodeBlock from '@theme/CodeBlock';
|
|
5
|
-
import { useScript, useStore } from '
|
|
5
|
+
import { useScript, useStore } from '../../WithScript/Store';
|
|
6
6
|
const Result = (props) => {
|
|
7
7
|
const { store } = useScript();
|
|
8
8
|
const logs = useStore(store, (state) => state.logs);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { DOM_ELEMENT_IDS, } from "
|
|
3
|
-
import { useScript, useStore } from '
|
|
4
|
-
import Result from "
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import Header from "
|
|
9
|
-
import EditorAce from "
|
|
2
|
+
import { DOM_ELEMENT_IDS, } from "../constants";
|
|
3
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
4
|
+
import Result from "./Result";
|
|
5
|
+
import TurtleResult from "./Result/Graphics/Turtle";
|
|
6
|
+
import CanvasResult from "./Result/Graphics/Canvas";
|
|
7
|
+
import GraphicsResult from "./Result/Graphics";
|
|
8
|
+
import Header from "./Header";
|
|
9
|
+
import EditorAce from "./EditorAce";
|
|
10
10
|
const Editor = (props) => {
|
|
11
11
|
const { store } = useScript();
|
|
12
12
|
const lang = useStore(store, (state) => state.lang);
|
|
@@ -22,9 +22,9 @@ const Editor = (props) => {
|
|
|
22
22
|
<Result />
|
|
23
23
|
<div id={DOM_ELEMENT_IDS.outputDiv(codeId)}></div>
|
|
24
24
|
{isGraphicsmodalOpen && (<>
|
|
25
|
-
{hasTurtleOutput && (<
|
|
26
|
-
{hasCanvasOutput && (<
|
|
27
|
-
{!hasCanvasOutput && !hasTurtleOutput && (<
|
|
25
|
+
{hasTurtleOutput && (<TurtleResult />)}
|
|
26
|
+
{hasCanvasOutput && (<CanvasResult />)}
|
|
27
|
+
{!hasCanvasOutput && !hasTurtleOutput && (<GraphicsResult />)}
|
|
28
28
|
</>)}
|
|
29
29
|
</>}
|
|
30
30
|
</React.Fragment>);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { StorageSlot, StoredScript } from "
|
|
1
|
+
import type { StorageSlot, StoredScript } from "./Types";
|
|
2
2
|
export declare const getStorageScript: (storage: StorageSlot) => StoredScript | undefined;
|
|
3
3
|
export declare const syncStorageScript: (script: StoredScript, storage: StorageSlot) => boolean;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
import { useSyncExternalStore } from "react";
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
-
import { checkCanvasOutput, checkGraphicsOutput, checkTurtleOutput, getPreCode, sanitizePyScript } from "
|
|
4
|
+
import { checkCanvasOutput, checkGraphicsOutput, checkTurtleOutput, getPreCode, sanitizePyScript } from "./helpers";
|
|
5
5
|
import { ReactContextError, createStorageSlot } from "@docusaurus/theme-common";
|
|
6
6
|
import { usePluginData } from "@docusaurus/useGlobalData";
|
|
7
|
-
import { DOM_ELEMENT_IDS } from "
|
|
7
|
+
import { DOM_ELEMENT_IDS } from "../constants";
|
|
8
8
|
import throttle from 'lodash/throttle';
|
|
9
|
-
import { getStorageScript, syncStorageScript } from "
|
|
9
|
+
import { getStorageScript, syncStorageScript } from "./Storage";
|
|
10
10
|
import { Status } from "./Types";
|
|
11
11
|
export const createStore = (props, libDir, syncMaxOnceEvery) => {
|
|
12
12
|
const canSave = !!props.id;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import styles from './styles.module.css';
|
|
3
|
-
import Editor from '
|
|
4
|
-
import BrythonCommunicator from '
|
|
3
|
+
import Editor from './Editor';
|
|
4
|
+
import BrythonCommunicator from './BrythonCommunicator';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import { useScript, useStore } from '
|
|
6
|
+
import { useScript, useStore } from './WithScript/Store';
|
|
7
7
|
import BrowserOnly from '@docusaurus/BrowserOnly';
|
|
8
|
-
import CodeHistory from '
|
|
8
|
+
import CodeHistory from './CodeHistory';
|
|
9
9
|
const PyAceEditor = (props) => {
|
|
10
10
|
const { store } = useScript();
|
|
11
11
|
const lang = useStore(store, (state) => state.lang);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-live-brython",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"description": "Docusaurus live code block component for python.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,65 +13,11 @@
|
|
|
13
13
|
"types": "./lib/index.d.ts",
|
|
14
14
|
"default": "./lib/index.js"
|
|
15
15
|
},
|
|
16
|
-
"./
|
|
17
|
-
|
|
18
|
-
"default": "./lib/theme/CodeEditor/Editor/index.jsx"
|
|
19
|
-
},
|
|
20
|
-
"./theme/CodeEditor/Editor/Result": {
|
|
21
|
-
"types": "./lib/theme/CodeEditor/Editor/Result/index.d.ts",
|
|
22
|
-
"default": "./lib/theme/CodeEditor/Editor/Result/index.jsx"
|
|
23
|
-
},
|
|
24
|
-
"./theme/CodeEditor/Editor/Header": {
|
|
25
|
-
"types": "./lib/theme/CodeEditor/Editor/Header/index.d.ts",
|
|
26
|
-
"default": "./lib/theme/CodeEditor/Editor/Header/index.jsx"
|
|
27
|
-
},
|
|
28
|
-
"./theme/CodeEditor/Editor/Result/Graphics": {
|
|
29
|
-
"types": "./lib/theme/CodeEditor/Editor/Result/Graphics/index.d.ts",
|
|
30
|
-
"default": "./lib/theme/CodeEditor/Editor/Result/Graphics/index.jsx"
|
|
31
|
-
},
|
|
32
|
-
"./theme/CodeEditor/CodeHistory": {
|
|
33
|
-
"types": "./lib/theme/CodeEditor/CodeHistory/index.d.ts",
|
|
34
|
-
"default": "./lib/theme/CodeEditor/CodeHistory/index.jsx"
|
|
35
|
-
},
|
|
36
|
-
"./theme/CodeEditor/Icon": {
|
|
37
|
-
"types": "./lib/theme/CodeEditor/Icon/index.d.ts",
|
|
38
|
-
"default": "./lib/theme/CodeEditor/Icon/index.jsx"
|
|
39
|
-
},
|
|
40
|
-
"./theme/CodeEditor/Button": {
|
|
41
|
-
"types": "./lib/theme/CodeEditor/Button/index.d.ts",
|
|
42
|
-
"default": "./lib/theme/CodeEditor/Button/index.jsx"
|
|
43
|
-
},
|
|
44
|
-
"./theme/CodeEditor/constants": {
|
|
45
|
-
"types": "./lib/theme/CodeEditor/constants.d.ts",
|
|
46
|
-
"default": "./lib/theme/CodeEditor/constants.js"
|
|
47
|
-
},
|
|
48
|
-
"./theme/CodeEditor/Icon/icons": {
|
|
49
|
-
"types": "./lib/theme/CodeEditor/Icon/icons.d.ts",
|
|
50
|
-
"default": "./lib/theme/CodeEditor/Icon/icons.js"
|
|
51
|
-
},
|
|
52
|
-
"./theme/CodeEditor": {
|
|
53
|
-
"types": "./lib/theme/CodeEditor/index.d.ts",
|
|
54
|
-
"default": "./lib/theme/CodeEditor/index.jsx"
|
|
55
|
-
},
|
|
56
|
-
"./theme/CodeEditor/Editor/utils/*": {
|
|
57
|
-
"types": "./lib/theme/CodeEditor/Editor/utils/*.d.ts",
|
|
58
|
-
"default": "./lib/theme/CodeEditor/Editor/utils/*.js"
|
|
59
|
-
},
|
|
60
|
-
"./theme/CodeEditor/WithScript/Store": {
|
|
61
|
-
"types": "./lib/theme/CodeEditor/WithScript/Store.d.ts",
|
|
62
|
-
"default": "./lib/theme/CodeEditor/WithScript/Store.jsx"
|
|
63
|
-
},
|
|
64
|
-
"./theme/CodeEditor/WithScript/*": {
|
|
65
|
-
"types": "./lib/theme/CodeEditor/WithScript/*.d.ts",
|
|
66
|
-
"default": "./lib/theme/CodeEditor/WithScript/*.js"
|
|
67
|
-
},
|
|
68
|
-
"./theme/CodeEditor/*": {
|
|
69
|
-
"types": "./lib/theme/CodeEditor/*.d.ts",
|
|
70
|
-
"default": "./lib/theme/CodeEditor/*.jsx"
|
|
71
|
-
}
|
|
16
|
+
"./lib/*": "./lib/*",
|
|
17
|
+
"./src/*": "./src/*"
|
|
72
18
|
},
|
|
73
19
|
"scripts": {
|
|
74
|
-
"build": "tsc --build && node ./bin/copyUntypedFiles.js
|
|
20
|
+
"build": "tsc --build && node ./bin/copyUntypedFiles.js",
|
|
75
21
|
"watch": "run-p -c copy:watch build:watch",
|
|
76
22
|
"build:watch": "tsc --build --watch",
|
|
77
23
|
"copy:watch": "node ./bin/copyUntypedFiles.js --watch"
|
|
@@ -79,11 +25,10 @@
|
|
|
79
25
|
"license": "MIT",
|
|
80
26
|
"repository": {
|
|
81
27
|
"type": "git",
|
|
82
|
-
"url": "git://github.com/lebalz/
|
|
28
|
+
"url": "git://github.com/lebalz/dokusaurus-live-brython.git"
|
|
83
29
|
},
|
|
84
30
|
"author": "Balthasar Hofer <lebalz@outlook.com>",
|
|
85
|
-
"bugs": "https://github.com/lebalz/
|
|
86
|
-
"homepage": "https://lebalz.github.io/docusaurus-live-brython/",
|
|
31
|
+
"bugs": "https://github.com/lebalz/dokusaurus-live-brython/issues",
|
|
87
32
|
"dependencies": {
|
|
88
33
|
"ace-builds": "^1.4.12",
|
|
89
34
|
"clsx": "^2.1.1",
|
|
@@ -110,7 +55,6 @@
|
|
|
110
55
|
"concurrently": "^8.2.2",
|
|
111
56
|
"fs-extra": "^11.2.0",
|
|
112
57
|
"npm-run-all": "^4.1.5",
|
|
113
|
-
"prettier": "^3.2.5",
|
|
114
58
|
"prism-react-renderer": "^2.3.1",
|
|
115
59
|
"typescript": "^5.4.2"
|
|
116
60
|
},
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import CodeBlock, {type Props as CodeBlockType} from '@theme-init/CodeBlock';
|
|
3
|
+
import { default as ThemeCodeBlock } from '@theme-original/CodeBlock';
|
|
4
|
+
// import CodeBlock from '@theme-original/CodeBlock';
|
|
5
|
+
// import CodeBlockType from '@theme/CodeBlock';
|
|
3
6
|
// @ts-ignore
|
|
4
7
|
import type { WrapperProps } from '@docusaurus/types';
|
|
5
8
|
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
6
|
-
import CodeEditor from '
|
|
9
|
+
import CodeEditor from '../CodeEditor';
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
|
|
12
|
+
// import Playground from '@theme-original/Playground';
|
|
13
|
+
// import ReactLiveScope from '@theme-original/ReactLiveScope';
|
|
14
|
+
import ScriptContext from '../CodeEditor/WithScript/Store';
|
|
9
15
|
|
|
10
16
|
|
|
11
17
|
type Props = WrapperProps<typeof CodeBlockType>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useScript, useStore } from '
|
|
3
|
-
import Button, { Color } from '
|
|
2
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
3
|
+
import Button, { Color } from '../Button';
|
|
4
4
|
import { translate } from '@docusaurus/Translate';
|
|
5
5
|
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useScript, useStore } from '
|
|
3
|
-
import Button, { Color } from '
|
|
2
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
3
|
+
import Button, { Color } from '../Button';
|
|
4
4
|
import { translate } from '@docusaurus/Translate';
|
|
5
5
|
|
|
6
6
|
const Reset = () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useScript, useStore } from '
|
|
3
|
-
import Button, { Color } from '
|
|
2
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
3
|
+
import Button, { Color } from '../Button';
|
|
4
4
|
import { translate } from '@docusaurus/Translate';
|
|
5
5
|
import styles from './styles.module.css';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useScript, useStore } from '
|
|
3
|
-
import Button, { Color } from '
|
|
2
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
3
|
+
import Button, { Color } from '../Button';
|
|
4
4
|
import { translate } from '@docusaurus/Translate';
|
|
5
5
|
|
|
6
6
|
const ShowRaw = () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useScript, useStore } from '
|
|
3
|
-
import Icon, { Color } from '
|
|
4
|
-
import { Status } from '
|
|
2
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
3
|
+
import Icon, { Color } from '../Icon';
|
|
4
|
+
import { Status } from '../WithScript/Types';
|
|
5
5
|
|
|
6
6
|
const ShowSyncStatus = () => {
|
|
7
7
|
const { store } = useScript();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { BRYTHON_NOTIFICATION_EVENT, DOM_ELEMENT_IDS } from "
|
|
3
|
-
import { useScript, useStore } from '
|
|
4
|
-
import { type LogMessage } from '
|
|
2
|
+
import { BRYTHON_NOTIFICATION_EVENT, DOM_ELEMENT_IDS } from "./constants";
|
|
3
|
+
import { useScript, useStore } from './WithScript/Store';
|
|
4
|
+
import { type LogMessage } from './WithScript/Types';
|
|
5
5
|
|
|
6
6
|
const BrythonCommunicator = () => {
|
|
7
7
|
const { store } = useScript();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import * as Icons from '
|
|
2
|
+
import * as Icons from '../Icon/icons';
|
|
3
3
|
import styles from './styles.module.css';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
-
import Icon from '
|
|
5
|
+
import Icon from '../Icon';
|
|
6
6
|
|
|
7
7
|
export enum Color {
|
|
8
8
|
Primary = 'button--primary',
|
|
@@ -4,9 +4,9 @@ import styles from './styles.module.css';
|
|
|
4
4
|
import { Prism } from 'prism-react-renderer';
|
|
5
5
|
import Slider from 'rc-slider';
|
|
6
6
|
import 'rc-slider/assets/index.css';
|
|
7
|
-
import { useScript, useStore } from '
|
|
7
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
8
8
|
import Translate, { translate } from '@docusaurus/Translate';
|
|
9
|
-
import Button from '
|
|
9
|
+
import Button from '../Button';
|
|
10
10
|
import DiffViewer from 'react-diff-viewer';
|
|
11
11
|
import Details from '@theme/Details';
|
|
12
12
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import styles from './styles.module.css';
|
|
4
|
-
import { DOM_ELEMENT_IDS } from '
|
|
4
|
+
import { DOM_ELEMENT_IDS } from '../constants';
|
|
5
5
|
import AceEditor from 'react-ace';
|
|
6
6
|
import 'ace-builds/src-noconflict/ext-searchbox';
|
|
7
7
|
import 'ace-builds/src-noconflict/mode-python';
|
|
@@ -10,7 +10,7 @@ import 'ace-builds/src-noconflict/mode-svg';
|
|
|
10
10
|
import 'ace-builds/src-noconflict/theme-dracula';
|
|
11
11
|
import 'ace-builds/src-noconflict/ext-language_tools';
|
|
12
12
|
import 'ace-builds/webpack-resolver';
|
|
13
|
-
import { useScript, useStore } from '
|
|
13
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
14
14
|
// import 'ace-builds/src-noconflict/theme-textmate';
|
|
15
15
|
// import('ace-builds/src-noconflict/snippets/python'),
|
|
16
16
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import styles from './styles.module.css';
|
|
4
|
-
import { useScript, useStore } from '
|
|
5
|
-
import ShowSyncStatus from '
|
|
6
|
-
import Reset from '
|
|
7
|
-
import DownloadCode from '
|
|
8
|
-
import ShowRaw from '
|
|
9
|
-
import RunCode from '
|
|
4
|
+
import { useScript, useStore } from '../../WithScript/Store';
|
|
5
|
+
import ShowSyncStatus from '../../Actions/ShowSyncStatus';
|
|
6
|
+
import Reset from '../../Actions/Reset';
|
|
7
|
+
import DownloadCode from '../../Actions/DownloadCode';
|
|
8
|
+
import ShowRaw from '../../Actions/ShowRaw';
|
|
9
|
+
import RunCode from '../../Actions/RunCode';
|
|
10
10
|
|
|
11
11
|
interface Props {
|
|
12
12
|
slim: boolean;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { DOM_ELEMENT_IDS } from '
|
|
3
|
-
import
|
|
2
|
+
import { DOM_ELEMENT_IDS } from '../../../constants';
|
|
3
|
+
import GraphicsResult from '.';
|
|
4
4
|
import styles from './styles.module.css';
|
|
5
|
-
import { useScript, useStore } from '
|
|
6
|
-
import Button from '
|
|
5
|
+
import { useScript, useStore } from '../../../WithScript/Store';
|
|
6
|
+
import Button from '../../../Button';
|
|
7
7
|
|
|
8
8
|
const downloadCanvas = (canvasId: string) => {
|
|
9
9
|
const canvas = document.getElementById(canvasId) as HTMLCanvasElement;
|
|
@@ -25,13 +25,13 @@ const downloadCanvas = (canvasId: string) => {
|
|
|
25
25
|
document.body.removeChild(downloadLink);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const CanvasResult = () => {
|
|
29
29
|
const { store } = useScript();
|
|
30
30
|
// const { codeId } = useStore(store, (state) => ({codeId: state.codeId}));
|
|
31
31
|
const codeId = useStore(store, (state) => state.codeId);
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
|
-
<
|
|
34
|
+
<GraphicsResult
|
|
35
35
|
controls={
|
|
36
36
|
<Button
|
|
37
37
|
icon='Download'
|
|
@@ -58,4 +58,4 @@ const Canvas = () => {
|
|
|
58
58
|
)
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
export default
|
|
61
|
+
export default CanvasResult;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import styles from './styles.module.css';
|
|
3
|
-
import { DOM_ELEMENT_IDS } from '
|
|
4
|
-
import
|
|
5
|
-
import { saveSvg } from '
|
|
6
|
-
import { useScript, useStore } from '
|
|
7
|
-
import Button from '
|
|
3
|
+
import { DOM_ELEMENT_IDS } from '../../../constants';
|
|
4
|
+
import GraphicsResult from '.';
|
|
5
|
+
import { saveSvg } from '../../utils/saveSvg';
|
|
6
|
+
import { useScript, useStore } from '../../../WithScript/Store';
|
|
7
|
+
import Button, { Color } from '../../../Button';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const TurtleResult = () => {
|
|
11
11
|
const { store } = useScript();
|
|
12
12
|
const codeId = useStore(store, (state) => state.codeId);
|
|
13
13
|
const code = useStore(store, (state) => state.code);
|
|
14
14
|
return (
|
|
15
|
-
<
|
|
15
|
+
<GraphicsResult
|
|
16
16
|
controls={
|
|
17
17
|
<React.Fragment>
|
|
18
18
|
<Button
|
|
@@ -45,4 +45,4 @@ const Turtle = () => {
|
|
|
45
45
|
)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export default
|
|
48
|
+
export default TurtleResult;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import styles from './styles.module.css';
|
|
3
|
-
import { DOM_ELEMENT_IDS } from '
|
|
3
|
+
import { DOM_ELEMENT_IDS } from '../../../constants';
|
|
4
4
|
import Draggable from 'react-draggable';
|
|
5
|
-
import { checkForButtonClick } from '
|
|
6
|
-
import { useScript, useStore } from '
|
|
7
|
-
import Button from '
|
|
5
|
+
import { checkForButtonClick } from '../../utils/checkForButtonClick';
|
|
6
|
+
import { useScript, useStore } from '../../../WithScript/Store';
|
|
7
|
+
import Button from '../../../Button';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
interface Props {
|
|
10
10
|
controls?: JSX.Element;
|
|
11
11
|
main?: JSX.Element;
|
|
12
12
|
}
|
|
13
|
-
const
|
|
13
|
+
const GraphicsResult = (props: Props) => {
|
|
14
14
|
const { store } = useScript();
|
|
15
15
|
const codeId = useStore(store, (state) => state.codeId);
|
|
16
16
|
return (
|
|
@@ -44,4 +44,4 @@ const Graphics = (props: Props) => {
|
|
|
44
44
|
);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
export default
|
|
47
|
+
export default GraphicsResult;
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from './styles.module.css';
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import CodeBlock from '@theme/CodeBlock';
|
|
5
|
-
import { useScript, useStore } from '
|
|
5
|
+
import { useScript, useStore } from '../../WithScript/Store';
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
8
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import styles from "./styles.module.css";
|
|
2
4
|
import {
|
|
3
5
|
DOM_ELEMENT_IDS,
|
|
4
|
-
} from "
|
|
5
|
-
import { useScript, useStore } from '
|
|
6
|
-
import Result from "
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import Header from "
|
|
11
|
-
import EditorAce from "
|
|
6
|
+
} from "../constants";
|
|
7
|
+
import { useScript, useStore } from '../WithScript/Store';
|
|
8
|
+
import Result from "./Result";
|
|
9
|
+
import TurtleResult from "./Result/Graphics/Turtle";
|
|
10
|
+
import CanvasResult from "./Result/Graphics/Canvas";
|
|
11
|
+
import GraphicsResult from "./Result/Graphics";
|
|
12
|
+
import Header from "./Header";
|
|
13
|
+
import EditorAce from "./EditorAce";
|
|
12
14
|
|
|
13
15
|
interface Props {
|
|
14
16
|
slim: boolean;
|
|
@@ -52,13 +54,13 @@ const Editor = (props: Props) => {
|
|
|
52
54
|
{isGraphicsmodalOpen && (
|
|
53
55
|
<>
|
|
54
56
|
{hasTurtleOutput && (
|
|
55
|
-
<
|
|
57
|
+
<TurtleResult />
|
|
56
58
|
)}
|
|
57
59
|
{hasCanvasOutput && (
|
|
58
|
-
<
|
|
60
|
+
<CanvasResult />
|
|
59
61
|
)}
|
|
60
62
|
{!hasCanvasOutput && !hasTurtleOutput && (
|
|
61
|
-
<
|
|
63
|
+
<GraphicsResult />
|
|
62
64
|
)}
|
|
63
65
|
</>
|
|
64
66
|
)}
|
|
@@ -68,4 +70,4 @@ const Editor = (props: Props) => {
|
|
|
68
70
|
);
|
|
69
71
|
};
|
|
70
72
|
|
|
71
|
-
export default Editor;
|
|
73
|
+
export default Editor;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
import { useSyncExternalStore } from "react";
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
-
import { checkCanvasOutput, checkGraphicsOutput, checkTurtleOutput, getPreCode, sanitizePyScript } from "
|
|
4
|
+
import { checkCanvasOutput, checkGraphicsOutput, checkTurtleOutput, getPreCode, sanitizePyScript } from "./helpers";
|
|
5
5
|
import { ReactContextError, createStorageSlot } from "@docusaurus/theme-common";
|
|
6
6
|
import { usePluginData } from "@docusaurus/useGlobalData";
|
|
7
|
-
import { DOM_ELEMENT_IDS } from "
|
|
7
|
+
import { DOM_ELEMENT_IDS } from "../constants";
|
|
8
8
|
import throttle from 'lodash/throttle';
|
|
9
|
-
import { getStorageScript, syncStorageScript } from "
|
|
9
|
+
import { getStorageScript, syncStorageScript } from "./Storage";
|
|
10
10
|
import { type InitState, type LogMessage, type Script, Status, type Store, type StoredScript, type Version } from "./Types";
|
|
11
11
|
export const createStore = (props: InitState, libDir: string, syncMaxOnceEvery: number): Store => {
|
|
12
12
|
const canSave = !!props.id;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import styles from './styles.module.css';
|
|
3
|
-
import Editor from '
|
|
4
|
-
import BrythonCommunicator from '
|
|
3
|
+
import Editor from './Editor';
|
|
4
|
+
import BrythonCommunicator from './BrythonCommunicator';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import
|
|
6
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
7
|
+
import { useScript, useStore } from './WithScript/Store';
|
|
7
8
|
import BrowserOnly from '@docusaurus/BrowserOnly';
|
|
8
|
-
import CodeHistory from '
|
|
9
|
+
import CodeHistory from './CodeHistory';
|
|
9
10
|
|
|
10
11
|
interface Props {
|
|
11
12
|
slim: boolean;
|
|
@@ -54,4 +55,3 @@ const PyAceEditor = (props: Props) => {
|
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
export default PyAceEditor;
|
|
57
|
-
|