Skip to content
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
14 changes: 1 addition & 13 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@
"@xterm/addon-web-links": "^0.11.0",
"@xterm/addon-webgl": "^0.18.0",
"@xterm/xterm": "^5.5.0",
"acorn": "^8.15.0",
"autosize": "^6.0.1",
"cordova": "13.0.0",
"core-js": "^3.45.0",
"crypto-js": "^4.2.0",
"dompurify": "^3.2.6",
"escape-string-regexp": "^5.0.0",
"esprima": "^4.0.1",
"filesize": "^11.0.2",
"html-tag-js": "^2.4.15",
"js-base64": "^3.7.7",
Expand Down
18 changes: 10 additions & 8 deletions src/lib/console.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "core-js/stable";
import "html-tag-js/dist/polyfill";
import * as esprima from "esprima";
import { parse } from "acorn";
import css from "styles/console.m.scss";
import loadPolyFill from "utils/polyfill";

Expand Down Expand Up @@ -374,16 +374,21 @@ import loadPolyFill from "utils/polyfill";
});
}

/** @type {import("acorn").Options} */
const acornOptions = {
ecmaVersion: "latest",
};

function parseFunction(data) {
let parsed;
let str;

try {
parsed = esprima.parse(data.toString()).body[0];
parsed = parse(data.toString(), acornOptions).body[0];
} catch (error) {
try {
const fun = ("(" + data.toString() + ")").replace(/\{.*\}/, "{}");
parsed = esprima.parse(fun).body[0];
parsed = parse(fun, acornOptions).body[0];
} catch (error) {
return data
.toString()
Expand Down Expand Up @@ -632,9 +637,7 @@ import loadPolyFill from "utils/polyfill";
function execute(code) {
let res = null;
try {
const parsed = esprima.parse(code, {
range: true,
}).body;
const parsed = parse(code, acornOptions).body;
res = execParsedCode(parsed);
} catch (e) {
res = execParsedCode([]);
Expand All @@ -648,8 +651,7 @@ import loadPolyFill from "utils/polyfill";
if (st.type === "VariableDeclaration") {
if (["const", "let"].indexOf(st.kind) < 0) return;

const range = st.range;
const exCode = code.substring(range[0], range[1]) + ";";
const exCode = code.substring(st.start, st.end) + ";";
extra += exCode;
}
});
Expand Down