Skip to content

Commit

Permalink
Merge pull request #302 from JMarques1196/main
Browse files Browse the repository at this point in the history
Fix: Infinite Loop using Livecode
  • Loading branch information
maltejur authored Oct 25, 2024
2 parents 45353c8 + 11ea22a commit 88a153e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
9 changes: 2 additions & 7 deletions components/playgroundEditor/LiveCodes.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Dispatch, SetStateAction, useEffect, useState } from "react";
import { useEffect, useState } from "react";
import type { Config, Playground } from "livecodes";
import LiveCodesPlayground from "livecodes/react";
import { luaTestRunner, type Language } from "lib/playground/livecodes";
Expand All @@ -7,12 +7,10 @@ import { useDarkTheme } from "hooks/darkTheme";
export default function LiveCodes({
language,
code,
setCode,
tests,
}: {
language: Language;
code: string;
setCode: Dispatch<SetStateAction<string>>;
tests: string;
}) {
const [playground, setPlayground] = useState<Playground | undefined>();
Expand All @@ -26,17 +24,14 @@ export default function LiveCodes({
await sdk.runTests();
}
});
sdk.watch("code", (changed) => {
setCode(changed.code.script.content);
});
};

useEffect(() => {
playground?.setConfig({ theme: darkTheme ? "dark" : "light" });
}, [playground, darkTheme]);

const baseConfig: Partial<Config> = {
autoupdate: false,
autoupdate: true,
languages: [language === "jupyter" ? "python-wasm" : language],
script: {
language: language === "jupyter" ? "python-wasm" : language,
Expand Down
9 changes: 1 addition & 8 deletions components/playgroundEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@ export default function Editor({
tests: string;
}) {
if (isLiveCodesLanguage(language)) {
return (
<LiveCodes
language={language}
code={code}
setCode={setCode}
tests={tests}
/>
);
return <LiveCodes language={language} code={code} tests={tests} />;
}
return <PlaygroundEditor language={language} code={code} setCode={setCode} />;
}
2 changes: 1 addition & 1 deletion lib/wasm.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */
export default function checkWasm() {
export default function check() {
try {
if (
typeof WebAssembly === "object" &&
Expand Down
13 changes: 13 additions & 0 deletions public/locales/en/categories.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
"audio": "Audio",
"audiofilters": "Audio Filters",
"automaton": "Automaton",
"avltree": "AVL Tree",
"backtracking": "Backtracking",
"bags": "Bags",
"basic": "Basic",
"basicsoftensorflow": "Basics of Tensorflow",
"biginteger": "Big Integer",
"binary": "Binary",
"binaryheap": "Binary Heap",
"binarysearchtree": "Binary Search Tree",
"binarytree": "Binary Tree",
"bit": "Bit",
"bitmanipulation": "Bit Manipulation",
Expand All @@ -27,6 +29,7 @@
"cellularautomata": "Cellular Automata",
"checksum": "Checksum",
"ciphers": "Ciphers",
"circularqueue": "Circularqueue",
"classificationalgorithms": "Classification Algorithms",
"clientserver": "Client Server",
"cll": "CLL",
Expand Down Expand Up @@ -60,11 +63,13 @@
"discretemathematics": "Discrete Mathematics",
"disjointset": "Disjoint Set",
"disjointsetunion": "Disjointsetunion",
"diskscheduling": "Diskscheduling",
"distance": "Distance",
"distances": "Distances",
"dithering": "Dithering",
"divideandconquer": "Divide and Conquer",
"divisibilityofintegers": "Divisibility of Integers",
"docs": "Docs",
"dynamic": "Dynamic",
"dynamicarray": "Dynamic Array",
"dynamicprogramming": "Dynamic Programming",
Expand All @@ -73,6 +78,7 @@
"encoders": "Encoders",
"entities": "Entities",
"esolang": "Esolang",
"example": "Example",
"exercism": "Exercism",
"factorization": "Factorization",
"filetransfer": "File Transfer",
Expand All @@ -92,6 +98,7 @@
"graphics": "Graphics",
"graphs": "Graphs",
"greatestcommondivisor": "Greatest Common Divisor",
"greedy": "Greedy",
"greedyalgorithms": "Greedy Algorithms",
"greedyapproach": "Greedy Approach",
"greedymethods": "Greedy Methods",
Expand All @@ -105,11 +112,13 @@
"http": "Http",
"imageprocessing": "Image Processing",
"io": "Io",
"kdtree": "Kd Tree",
"knapsack": "Knapsack",
"levenshtein": "Levenshtein",
"linearalgebra": "Linear Algebra",
"linearprogramming": "Linear Programming",
"linearregression": "Linear Regression",
"lineclipping": "Lineclipping",
"linkedlist": "Linked List",
"list": "List",
"logisticregression": "Logistic-Regression",
Expand Down Expand Up @@ -180,10 +189,12 @@
"recursive": "Recursive",
"regressionalgorithms": "Regression Algorithms",
"robotics": "Robotics",
"rsa": "Rsa",
"scheduling": "Scheduling",
"scripts": "Scripts",
"sdbmhash": "Sdbm Hash",
"searches": "Searches",
"segmenttree": "Segment Tree",
"segmenttrees": "Segment Trees",
"sequences": "Sequences",
"series": "Series",
Expand All @@ -197,6 +208,7 @@
"spanningtree": "Spanning Tree",
"specializedstructure": "Specialized Structure",
"specialnumbers": "Special Numbers",
"splaytree": "Splay Tree",
"sqrt": "Sqrt",
"stablemarriage": "Stable Marriage",
"stacks": "Stacks",
Expand All @@ -205,6 +217,7 @@
"strings": "Strings",
"structure": "Structure",
"structures": "Structures",
"suffixtree": "Suffix Tree",
"sum": "Sum",
"textclassification": "Text Classification",
"threads": "Threads",
Expand Down

0 comments on commit 88a153e

Please sign in to comment.