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.
Files changed (77) hide show
  1. package/README.md +0 -12
  2. package/lib/index.d.ts +7 -0
  3. package/lib/index.js +0 -15
  4. package/lib/theme/CodeBlock/index.jsx +4 -2
  5. package/lib/theme/CodeEditor/Actions/DownloadCode.jsx +2 -2
  6. package/lib/theme/CodeEditor/Actions/Reset.jsx +2 -2
  7. package/lib/theme/CodeEditor/Actions/RunCode.d.ts +1 -1
  8. package/lib/theme/CodeEditor/Actions/RunCode.jsx +2 -2
  9. package/lib/theme/CodeEditor/Actions/ShowRaw.jsx +2 -2
  10. package/lib/theme/CodeEditor/Actions/ShowSyncStatus.jsx +3 -3
  11. package/lib/theme/CodeEditor/BrythonCommunicator.jsx +2 -2
  12. package/lib/theme/CodeEditor/Button/index.d.ts +2 -2
  13. package/lib/theme/CodeEditor/Button/index.jsx +1 -1
  14. package/lib/theme/CodeEditor/CodeHistory/index.jsx +2 -2
  15. package/lib/theme/CodeEditor/Editor/EditorAce.jsx +2 -2
  16. package/lib/theme/CodeEditor/Editor/Header/index.d.ts +1 -1
  17. package/lib/theme/CodeEditor/Editor/Header/index.jsx +6 -6
  18. package/lib/theme/CodeEditor/Editor/Result/Graphics/Canvas.d.ts +2 -2
  19. package/lib/theme/CodeEditor/Editor/Result/Graphics/Canvas.jsx +7 -7
  20. package/lib/theme/CodeEditor/Editor/Result/Graphics/Turtle.d.ts +2 -2
  21. package/lib/theme/CodeEditor/Editor/Result/Graphics/Turtle.jsx +8 -8
  22. package/lib/theme/CodeEditor/Editor/Result/Graphics/index.d.ts +3 -3
  23. package/lib/theme/CodeEditor/Editor/Result/Graphics/index.jsx +6 -6
  24. package/lib/theme/CodeEditor/Editor/Result/index.d.ts +3 -1
  25. package/lib/theme/CodeEditor/Editor/Result/index.jsx +3 -2
  26. package/lib/theme/CodeEditor/Editor/index.d.ts +1 -1
  27. package/lib/theme/CodeEditor/Editor/index.jsx +11 -11
  28. package/lib/theme/CodeEditor/Editor/utils/saveSvg.js +1 -1
  29. package/lib/theme/CodeEditor/Icon/index.d.ts +2 -2
  30. package/lib/theme/CodeEditor/Icon/index.jsx +1 -1
  31. package/lib/theme/CodeEditor/WithScript/Storage.d.ts +1 -1
  32. package/lib/theme/CodeEditor/WithScript/Store.d.ts +7 -1
  33. package/lib/theme/CodeEditor/WithScript/Store.jsx +235 -2
  34. package/lib/theme/CodeEditor/WithScript/Types.d.ts +0 -1
  35. package/lib/theme/CodeEditor/index.d.ts +3 -3
  36. package/lib/theme/CodeEditor/index.jsx +6 -6
  37. package/lib/types.d.ts +28 -0
  38. package/lib/types.js +1 -0
  39. package/package.json +23 -79
  40. package/src/index.ts +0 -10
  41. package/src/theme/CodeBlock/index.tsx +9 -2
  42. package/src/theme/CodeEditor/Actions/DownloadCode.tsx +2 -2
  43. package/src/theme/CodeEditor/Actions/Reset.tsx +2 -2
  44. package/src/theme/CodeEditor/Actions/RunCode.tsx +3 -3
  45. package/src/theme/CodeEditor/Actions/ShowRaw.tsx +2 -2
  46. package/src/theme/CodeEditor/Actions/ShowSyncStatus.tsx +3 -3
  47. package/src/theme/CodeEditor/BrythonCommunicator.tsx +3 -3
  48. package/src/theme/CodeEditor/Button/index.tsx +3 -3
  49. package/src/theme/CodeEditor/CodeHistory/index.tsx +2 -2
  50. package/src/theme/CodeEditor/Editor/EditorAce.tsx +2 -2
  51. package/src/theme/CodeEditor/Editor/Header/index.tsx +7 -7
  52. package/src/theme/CodeEditor/Editor/Result/Graphics/Canvas.tsx +7 -7
  53. package/src/theme/CodeEditor/Editor/Result/Graphics/Turtle.tsx +8 -8
  54. package/src/theme/CodeEditor/Editor/Result/Graphics/index.tsx +7 -7
  55. package/src/theme/CodeEditor/Editor/Result/index.tsx +6 -2
  56. package/src/theme/CodeEditor/Editor/index.tsx +15 -13
  57. package/src/theme/CodeEditor/Editor/utils/saveSvg.ts +1 -1
  58. package/src/theme/CodeEditor/Editor/utils/svgWithoutAnimations.ts +1 -1
  59. package/src/theme/CodeEditor/Icon/index.tsx +2 -2
  60. package/src/theme/CodeEditor/WithScript/Storage.ts +1 -1
  61. package/src/theme/CodeEditor/WithScript/Store.tsx +269 -3
  62. package/src/theme/CodeEditor/WithScript/Types.ts +0 -1
  63. package/src/theme/CodeEditor/index.tsx +8 -8
  64. package/src/types.ts +29 -0
  65. package/.prettierrc +0 -9
  66. package/lib/theme/CodeEditor/WithScript/createStore.d.ts +0 -2
  67. package/lib/theme/CodeEditor/WithScript/createStore.js +0 -223
  68. package/lib/theme/CodeEditor/hooks/index.d.ts +0 -2
  69. package/lib/theme/CodeEditor/hooks/index.js +0 -2
  70. package/lib/theme/CodeEditor/hooks/useScript.d.ts +0 -4
  71. package/lib/theme/CodeEditor/hooks/useScript.js +0 -10
  72. package/lib/theme/CodeEditor/hooks/useStore.d.ts +0 -2
  73. package/lib/theme/CodeEditor/hooks/useStore.js +0 -4
  74. package/src/theme/CodeEditor/WithScript/createStore.ts +0 -247
  75. package/src/theme/CodeEditor/hooks/index.ts +0 -2
  76. package/src/theme/CodeEditor/hooks/useScript.ts +0 -15
  77. 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
- ![NPM Version](https://img.shields.io/npm/v/docusaurus-live-brython)
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 '@theme/CodeEditor';
5
- import ScriptContext from '@theme/CodeEditor/WithScript/Store';
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 '@theme/CodeEditor/hooks';
3
- import Button from '@theme/CodeEditor/Button';
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 '@theme/CodeEditor/hooks';
3
- import Button from '@theme/CodeEditor/Button';
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,5 +1,5 @@
1
1
  import * as React from 'react';
2
- export interface Props {
2
+ interface Props {
3
3
  title: string;
4
4
  slim: boolean;
5
5
  }
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { useScript, useStore } from '@theme/CodeEditor/hooks';
3
- import Button, { Color } from '@theme/CodeEditor/Button';
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 '@theme/CodeEditor/hooks';
3
- import Button, { Color } from '@theme/CodeEditor/Button';
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 '@theme/CodeEditor/hooks';
3
- import Icon, { Color } from '@theme/CodeEditor/Icon';
4
- import { Status } from '@theme/CodeEditor/WithScript/Types';
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 "@theme/CodeEditor/constants";
3
- import { useScript, useStore } from '@theme/CodeEditor/hooks';
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 '@theme/CodeEditor/Icon/icons';
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
- export interface Props {
16
+ interface Props {
17
17
  icon: keyof typeof Icons;
18
18
  title?: string;
19
19
  onClick?: React.MouseEventHandler<HTMLButtonElement>;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import styles from './styles.module.css';
3
3
  import clsx from 'clsx';
4
- import Icon from '@theme/CodeEditor/Icon';
4
+ import Icon from '../Icon';
5
5
  export var Color;
6
6
  (function (Color) {
7
7
  Color["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 '@theme/CodeEditor/hooks';
7
+ import { useScript, useStore } from '../WithScript/Store';
8
8
  import Translate, { translate } from '@docusaurus/Translate';
9
- import Button from '@theme/CodeEditor/Button';
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 '@theme/CodeEditor/constants';
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 '@theme/CodeEditor/hooks';
13
+ import { useScript, useStore } from '../WithScript/Store';
14
14
  const ALIAS_LANG_MAP_ACE = {
15
15
  mpy: 'python',
16
16
  };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- export interface Props {
2
+ interface Props {
3
3
  slim: boolean;
4
4
  title: string;
5
5
  resettable: boolean;
@@ -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 '@theme/CodeEditor/hooks';
5
- import ShowSyncStatus from '@theme/CodeEditor/Actions/ShowSyncStatus';
6
- import Reset from '@theme/CodeEditor/Actions/Reset';
7
- import DownloadCode from '@theme/CodeEditor/Actions/DownloadCode';
8
- import ShowRaw from '@theme/CodeEditor/Actions/ShowRaw';
9
- import RunCode from '@theme/CodeEditor/Actions/RunCode';
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 Canvas: () => React.JSX.Element;
3
- export default Canvas;
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 '@theme/CodeEditor/constants';
3
- import Graphics from '@theme/CodeEditor/Editor/Result/Graphics';
2
+ import { DOM_ELEMENT_IDS } from '../../../constants';
3
+ import GraphicsResult from '.';
4
4
  import styles from './styles.module.css';
5
- import { useScript, useStore } from '@theme/CodeEditor/hooks';
6
- import Button from '@theme/CodeEditor/Button';
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 Canvas = () => {
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 (<Graphics controls={<Button icon='Download' iconSize='12px' onClick={() => {
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 Canvas;
36
+ export default CanvasResult;
@@ -1,3 +1,3 @@
1
1
  import * as React from 'react';
2
- declare const Turtle: () => React.JSX.Element;
3
- export default Turtle;
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 '@theme/CodeEditor/constants';
4
- import Graphics from '@theme/CodeEditor/Editor/Result/Graphics';
5
- import { saveSvg } from '@theme/CodeEditor/Editor/utils/saveSvg';
6
- import { useScript, useStore } from '@theme/CodeEditor/hooks';
7
- import Button from '@theme/CodeEditor/Button';
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 Turtle = () => {
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 (<Graphics controls={<React.Fragment>
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 Turtle;
28
+ export default TurtleResult;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
- export interface Props {
2
+ interface Props {
3
3
  controls?: JSX.Element;
4
4
  main?: JSX.Element;
5
5
  }
6
- declare const Graphics: (props: Props) => React.JSX.Element;
7
- export default Graphics;
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 '@theme/CodeEditor/constants';
3
+ import { DOM_ELEMENT_IDS } from '../../../constants';
4
4
  import Draggable from 'react-draggable';
5
- import { checkForButtonClick } from '@theme/CodeEditor/Editor/utils/checkForButtonClick';
6
- import { useScript, useStore } from '@theme/CodeEditor/hooks';
7
- import Button from '@theme/CodeEditor/Button';
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 Graphics = (props) => {
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 Graphics;
29
+ export default GraphicsResult;
@@ -1,3 +1,5 @@
1
1
  import * as React from 'react';
2
- declare const Result: () => React.JSX.Element;
2
+ interface Props {
3
+ }
4
+ declare const Result: (props: Props) => React.JSX.Element;
3
5
  export default Result;
@@ -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 '@theme/CodeEditor/hooks';
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,5 +1,5 @@
1
1
  import * as React from "react";
2
- export interface Props {
2
+ interface Props {
3
3
  slim: boolean;
4
4
  title: string;
5
5
  resettable: boolean;
@@ -1,12 +1,12 @@
1
1
  import * as React from "react";
2
- import { DOM_ELEMENT_IDS, } from "@theme/CodeEditor/constants";
3
- import { useScript, useStore } from '@theme/CodeEditor/hooks';
4
- import Result from "@theme/CodeEditor/Editor/Result";
5
- import Turtle from "@theme/CodeEditor/Editor/Result/Graphics/Turtle";
6
- import Canvas from "@theme/CodeEditor/Editor/Result/Graphics/Canvas";
7
- import Graphics from "@theme/CodeEditor/Editor/Result/Graphics";
8
- import Header from "@theme/CodeEditor/Editor/Header";
9
- import EditorAce from "@theme/CodeEditor/Editor/EditorAce";
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 && (<Turtle />)}
26
- {hasCanvasOutput && (<Canvas />)}
27
- {!hasCanvasOutput && !hasTurtleOutput && (<Graphics />)}
25
+ {hasTurtleOutput && (<TurtleResult />)}
26
+ {hasCanvasOutput && (<CanvasResult />)}
27
+ {!hasCanvasOutput && !hasTurtleOutput && (<GraphicsResult />)}
28
28
  </>)}
29
29
  </>}
30
30
  </React.Fragment>);
@@ -1,4 +1,4 @@
1
- import { removeAnimations } from "@theme/CodeEditor/Editor/utils/svgWithoutAnimations";
1
+ import { removeAnimations } from "./svgWithoutAnimations";
2
2
  const duration = (anim) => {
3
3
  const dur = anim.getAttribute('dur') || '';
4
4
  if (/ms$/.test(dur)) {
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import * as Icons from '@theme/CodeEditor/Icon/icons';
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
- export interface Props {
12
+ interface Props {
13
13
  icon: keyof typeof Icons;
14
14
  size?: number | string;
15
15
  spin?: boolean;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import * as Icons from '@theme/CodeEditor/Icon/icons';
2
+ import * as Icons from './icons';
3
3
  import styles from './styles.module.css';
4
4
  import clsx from 'clsx';
5
5
  export var Color;
@@ -1,3 +1,3 @@
1
- import type { StorageSlot, StoredScript } from "@theme/CodeEditor/WithScript/Types";
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 "@theme/CodeEditor/WithScript/Types";
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;