ProtonDesigner / roadmap

This is where progress on Proton features are tracked.
0 stars 0 forks source link

Code engine (Context) #4

Open TechStudent10 opened 1 year ago

TechStudent10 commented 1 year ago

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

The app also needs a Context class that will help the user

TechStudent10 commented 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.
TechStudent10 commented 1 year ago

Or better yet, using Lua: https://npmjs.com/package/wasmoon