UNPKG

rkeys

Version:

A platform for creating tablet/HTML5 virtual-keyboard apps to send keystrokes to remote X11

39 lines (38 loc) 890 B
// Generated by LiveScript 1.3.0 (function(){ var _, Vm, DIRECTIVE, SANDBOX; _ = require('lodash'); Vm = require('vm'); DIRECTIVE = 'javascript'; SANDBOX = { log: console.log, require: require, _: _ }; module.exports = function(it){ var cmd, code, e; if ((cmd = it.command) == null) { return false; } if (_.isArray(cmd)) { return false; } if (!_.startsWith(cmd, DIRECTIVE)) { return false; } code = _.trim(cmd.substring(DIRECTIVE.length)); try { log2(cmd = Vm.runInNewContext(code, (SANDBOX.params = it.params, SANDBOX))); if (!_.isString(cmd)) { log("must evaluate to a string command, not " + cmd + "\n" + code); return true; } } catch (e$) { e = e$; log(e + "\n" + code); return true; } it.command = cmd; return false; }; }).call(this);