Open TechStudent10 opened 1 year ago
For future reference:
Node.JS has a built-in vm
module that allows you execute JavaScript in a sandboxed or contextified environment: https://nodejs.org/api/vm.html#vm-executing-javascript
Example (from the Node.JS docs):
const vm = require('node:vm');
const x = 1;
const context = { x: 2 };
vm.createContext(context); // Contextify the object.
const code = 'x += 40; var y = 17;';
// `x` and `y` are global variables in the context.
// Initially, x has the value 2 because that is the value of context.x.
vm.runInContext(code, context);
console.log(context.x); // 42
console.log(context.y); // 17
console.log(x); // 1; y is not defined.
Or better yet, using Lua: https://npmjs.com/package/wasmoon
The Context Engine must be completed in order for scripting to work.
The way the Context Engine is supposed to work is that it will
main.js
scriptThe app also needs a
Context
class that will help the user