Skip to content

Commit

Permalink
feat: fix python worker script
Browse files Browse the repository at this point in the history
  • Loading branch information
MR-Addict committed Oct 10, 2024
1 parent 3a30998 commit bbc7fee
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 49 deletions.
62 changes: 31 additions & 31 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"format": "prettier -c --write ."
},
"devDependencies": {
"@babel/standalone": "^7.25.6",
"@types/node": "^22.5.5",
"@types/react": "^18.3.8",
"@babel/standalone": "^7.25.8",
"@types/node": "^22.7.5",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
"@vitejs/plugin-react": "^4.3.2",
"ace-builds": "^1.36.2",
"autoprefixer": "^10.4.20",
"clsx": "^2.1.1",
Expand All @@ -26,9 +26,9 @@
"react-ace": "^12.0.0",
"react-dom": "^18.3.1",
"react-icons": "^5.3.0",
"tailwindcss": "^3.4.12",
"typescript": "^5.6.2",
"vite": "^5.4.7",
"tailwindcss": "^3.4.13",
"typescript": "^5.6.3",
"vite": "^5.4.8",
"zod": "^3.23.8"
},
"prettier": {
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/contexts/AppProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const defaultOutputs: OutputsType = {

const defaultEditorOptions: EditorType = {
theme: "light",
lang: "javascript",
code: defaultCodes.javascript,
defaultCode: defaultCodes.javascript,
lang: "python",
code: defaultCodes.python,
defaultCode: defaultCodes.python,
readonly: false
};

Expand Down
14 changes: 6 additions & 8 deletions frontend/src/workers/python-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ self.importScripts("https://cdn.jsdelivr.net/pyodide/v0.26.2/full/pyodide.js");

let pyodide = null;

const postmessage = (status, msg) => self.postMessage({ lang: "python", output: { status, data: [msg] } });
const stderr = (msg) => postmessage("running", [{ color: "red", msg }]);
const stdout = (msg) => {
// if the message is FLUSHHH, then ignore it
if (msg === "FLUSHHH") return;
const postmessage = (status, msg) => self.postMessage({ lang: "python", output: { status, data: msg } });

// remove the FLUSHHH from the message
if (msg.includes("FLUSHHH")) msg = msg.replace("FLUSHHH", "");
postmessage("running", [{ color: "normal", msg }]);
const stderr = (...msg) => postmessage("running", [{ color: "red", msg }]);
const stdout = (...msg) => {
// if the message is FLUSHHH, then ignore it
msg = msg.filter((m) => m !== "FLUSHHH");
if (msg.length) postmessage("running", [{ color: "normal", msg }]);
};

async function waitPyodideReady() {
Expand Down

0 comments on commit bbc7fee

Please sign in to comment.