Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Infinite Loop using Livecode #302

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading