diff --git a/examples/server/public/index.html.gz b/examples/server/public/index.html.gz index 73f2707b8..a640b7333 100644 Binary files a/examples/server/public/index.html.gz and b/examples/server/public/index.html.gz differ diff --git a/examples/server/webui/src/components/CanvasPyInterpreter.tsx b/examples/server/webui/src/components/CanvasPyInterpreter.tsx index b53474984..c2707fe20 100644 --- a/examples/server/webui/src/components/CanvasPyInterpreter.tsx +++ b/examples/server/webui/src/components/CanvasPyInterpreter.tsx @@ -3,6 +3,7 @@ import { useAppContext } from '../utils/app.context'; import { OpenInNewTab, XCloseButton } from '../utils/common'; import { CanvasType } from '../utils/types'; import { PlayIcon, StopIcon } from '@heroicons/react/24/outline'; +import StorageUtils from '../utils/storage'; const canInterrupt = typeof SharedArrayBuffer === 'function'; @@ -54,6 +55,18 @@ const interruptBuffer = canInterrupt ? new Uint8Array(new SharedArrayBuffer(1)) : null; +const startWorker = () => { + if (!worker) { + worker = new Worker( + URL.createObjectURL(new Blob([WORKER_CODE], { type: 'text/javascript' })) + ); + } +}; + +if (StorageUtils.getConfig().pyIntepreterEnabled) { + startWorker(); +} + const runCodeInWorker = ( pyCode: string, callbackRunning: () => void @@ -61,11 +74,7 @@ const runCodeInWorker = ( donePromise: Promise; interrupt: () => void; } => { - if (!worker) { - worker = new Worker( - URL.createObjectURL(new Blob([WORKER_CODE], { type: 'text/javascript' })) - ); - } + startWorker(); const id = Math.random() * 1e8; const context = {}; if (interruptBuffer) { diff --git a/examples/server/webui/src/components/ChatScreen.tsx b/examples/server/webui/src/components/ChatScreen.tsx index f8a09d272..b5053d565 100644 --- a/examples/server/webui/src/components/ChatScreen.tsx +++ b/examples/server/webui/src/components/ChatScreen.tsx @@ -137,7 +137,7 @@ export default function ChatScreen() { {canvasData && ( -
+
)}