docusaurus-live-brython 3.0.0-beta.11 → 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/index.d.ts +7 -0
- package/lib/index.js +0 -15
- 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.d.ts +1 -1
- 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 +2 -2
- 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.d.ts +1 -1
- 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 +3 -3
- package/lib/theme/CodeEditor/Editor/Result/Graphics/index.jsx +6 -6
- package/lib/theme/CodeEditor/Editor/Result/index.d.ts +3 -1
- package/lib/theme/CodeEditor/Editor/Result/index.jsx +3 -2
- package/lib/theme/CodeEditor/Editor/index.d.ts +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 +2 -2
- 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.d.ts +7 -1
- package/lib/theme/CodeEditor/WithScript/Store.jsx +235 -2
- package/lib/theme/CodeEditor/WithScript/Types.d.ts +0 -1
- package/lib/theme/CodeEditor/index.d.ts +3 -3
- package/lib/theme/CodeEditor/index.jsx +6 -6
- package/lib/types.d.ts +28 -0
- package/lib/types.js +1 -0
- package/package.json +23 -79
- package/src/index.ts +0 -10
- package/src/theme/CodeBlock/index.tsx +9 -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 +3 -3
- 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 +3 -3
- 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 +7 -7
- 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 +7 -7
- package/src/theme/CodeEditor/Editor/Result/index.tsx +6 -2
- package/src/theme/CodeEditor/Editor/index.tsx +15 -13
- 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 +2 -2
- package/src/theme/CodeEditor/WithScript/Storage.ts +1 -1
- package/src/theme/CodeEditor/WithScript/Store.tsx +269 -3
- package/src/theme/CodeEditor/WithScript/Types.ts +0 -1
- package/src/theme/CodeEditor/index.tsx +8 -8
- package/src/types.ts +29 -0
- package/.prettierrc +0 -9
- package/lib/theme/CodeEditor/WithScript/createStore.d.ts +0 -2
- package/lib/theme/CodeEditor/WithScript/createStore.js +0 -223
- package/lib/theme/CodeEditor/hooks/index.d.ts +0 -2
- package/lib/theme/CodeEditor/hooks/index.js +0 -2
- package/lib/theme/CodeEditor/hooks/useScript.d.ts +0 -4
- package/lib/theme/CodeEditor/hooks/useScript.js +0 -10
- package/lib/theme/CodeEditor/hooks/useStore.d.ts +0 -2
- package/lib/theme/CodeEditor/hooks/useStore.js +0 -4
- package/src/theme/CodeEditor/WithScript/createStore.ts +0 -247
- package/src/theme/CodeEditor/hooks/index.ts +0 -2
- package/src/theme/CodeEditor/hooks/useScript.ts +0 -15
- package/src/theme/CodeEditor/hooks/useStore.ts +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
|
```
|
package/lib/index.d.ts
CHANGED
|
@@ -4,6 +4,13 @@
|
|
|
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
|
+
* Notes
|
|
9
|
+
* - how to add static files: https://github.com/facebook/docusaurus/discussions/6907
|
|
10
|
+
* ---> sitemap plugin: https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-plugin-sitemap/src/index.ts
|
|
11
|
+
* - call brython with arguments: https://github.com/brython-dev/brython/issues/2421
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
7
14
|
import type { HtmlTags, Plugin } from '@docusaurus/types';
|
|
8
15
|
import { type ThemeOptions, type Options } from './options';
|
|
9
16
|
export declare const NAME: "docusaurus-live-brython";
|
package/lib/index.js
CHANGED
|
@@ -4,14 +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
|
-
* Notes
|
|
9
|
-
* - how to add static files: https://github.com/facebook/docusaurus/discussions/6907
|
|
10
|
-
* ---> sitemap plugin: https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-plugin-sitemap/src/index.ts
|
|
11
|
-
* - call brython with arguments: https://github.com/brython-dev/brython/issues/2421
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
import { readDefaultCodeTranslationMessages } from '@docusaurus/theme-translations';
|
|
15
7
|
// eslint-disable-next-line import/no-extraneous-dependencies, import/order
|
|
16
8
|
import logger from '@docusaurus/logger';
|
|
17
9
|
import fs from 'fs-extra';
|
|
@@ -22,7 +14,6 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
22
14
|
export const NAME = 'docusaurus-live-brython';
|
|
23
15
|
export const DEFAULT_LIB_DIR = 'bry-libs';
|
|
24
16
|
const theme = (context, options) => {
|
|
25
|
-
const { i18n: { currentLocale }, } = context;
|
|
26
17
|
const libDir = options.libDir || DEFAULT_LIB_DIR;
|
|
27
18
|
return {
|
|
28
19
|
name: NAME,
|
|
@@ -42,12 +33,6 @@ const theme = (context, options) => {
|
|
|
42
33
|
}
|
|
43
34
|
}
|
|
44
35
|
},
|
|
45
|
-
getDefaultCodeTranslationMessages() {
|
|
46
|
-
return readDefaultCodeTranslationMessages({
|
|
47
|
-
locale: currentLocale,
|
|
48
|
-
name: NAME,
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
36
|
async contentLoaded({ content, actions }) {
|
|
52
37
|
const { setGlobalData } = actions;
|
|
53
38
|
const libDir = (options.libDir || DEFAULT_LIB_DIR).replace(/(\/|\\)/g, '');
|
|
@@ -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);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import * as Icons from '
|
|
2
|
+
import * as Icons from '../Icon/icons';
|
|
3
3
|
export declare enum Color {
|
|
4
4
|
Primary = "button--primary",
|
|
5
5
|
Secondary = "button--secondary",
|
|
@@ -13,7 +13,7 @@ export declare enum Size {
|
|
|
13
13
|
Small = "button--sm",
|
|
14
14
|
Large = "button--lg"
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
interface Props {
|
|
17
17
|
icon: keyof typeof Icons;
|
|
18
18
|
title?: string;
|
|
19
19
|
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
@@ -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,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
interface Props {
|
|
3
3
|
controls?: JSX.Element;
|
|
4
4
|
main?: JSX.Element;
|
|
5
5
|
}
|
|
6
|
-
declare const
|
|
7
|
-
export default
|
|
6
|
+
declare const GraphicsResult: (props: Props) => React.JSX.Element;
|
|
7
|
+
export default GraphicsResult;
|
|
@@ -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;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import styles from './styles.module.css';
|
|
3
|
+
// @ts-ignore
|
|
3
4
|
import CodeBlock from '@theme/CodeBlock';
|
|
4
|
-
import { useScript, useStore } from '
|
|
5
|
-
const Result = () => {
|
|
5
|
+
import { useScript, useStore } from '../../WithScript/Store';
|
|
6
|
+
const Result = (props) => {
|
|
6
7
|
const { store } = useScript();
|
|
7
8
|
const logs = useStore(store, (state) => state.logs);
|
|
8
9
|
if (logs.length === 0) {
|
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import * as Icons from '
|
|
2
|
+
import * as Icons from './icons';
|
|
3
3
|
export declare enum Color {
|
|
4
4
|
Primary = "var(--ifm-color-primary)",
|
|
5
5
|
Secondary = "var(--ifm-color-secondary)",
|
|
@@ -9,7 +9,7 @@ export declare enum Color {
|
|
|
9
9
|
Danger = "var(--ifm-color-danger)",
|
|
10
10
|
Link = "var(--ifm-color-link)"
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
interface Props {
|
|
13
13
|
icon: keyof typeof Icons;
|
|
14
14
|
size?: number | string;
|
|
15
15
|
spin?: boolean;
|
|
@@ -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,9 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { type InitState, type Store } from "
|
|
2
|
+
import { type InitState, type Store } from "./Types";
|
|
3
|
+
export declare const createStore: (props: InitState, libDir: string, syncMaxOnceEvery: number) => Store;
|
|
4
|
+
type Selector<T, R> = (state: T) => R;
|
|
5
|
+
export declare const useStore: <T, R>(store: Store<T>, selector: Selector<T, R>) => R;
|
|
3
6
|
export declare const Context: React.Context<{
|
|
4
7
|
store: Store;
|
|
5
8
|
}>;
|
|
6
9
|
declare const ScriptContext: (props: InitState & {
|
|
7
10
|
children: React.ReactNode;
|
|
8
11
|
}) => React.JSX.Element;
|
|
12
|
+
export declare function useScript(): {
|
|
13
|
+
store: Store;
|
|
14
|
+
};
|
|
9
15
|
export default ScriptContext;
|