|
|
|
@ -93,7 +93,7 @@ class Terminal { |
|
|
|
|
self.registerFilter('script', basicFilter) |
|
|
|
|
|
|
|
|
|
self._jsSandboxContext = {} |
|
|
|
|
self._jsSandbox = vm.createContext(self._jsSandboxContext) |
|
|
|
|
self._jsSandboxRegistered = {} |
|
|
|
|
if (opts.shell) self._shell = opts.shell |
|
|
|
|
register(self) |
|
|
|
|
} |
|
|
|
@ -381,6 +381,7 @@ class Terminal { |
|
|
|
|
</ul> |
|
|
|
|
</li> |
|
|
|
|
<li>Executing common command to interact with the Remix interface (see list of commands above). Note that these commands can also be included and run from a JavaScript script.</li> |
|
|
|
|
<li>Use exports/.register(key, obj)/.remove(key)/.clear() to register and reuse object across script executions.</li> |
|
|
|
|
</ul> |
|
|
|
|
</div>` |
|
|
|
|
|
|
|
|
@ -601,7 +602,7 @@ class Terminal { |
|
|
|
|
var self = this |
|
|
|
|
var context = domTerminalFeatures(self, scopedCommands) |
|
|
|
|
try { |
|
|
|
|
var cmds = vm.createContext(Object.assign(self._jsSandboxContext, context)) |
|
|
|
|
var cmds = vm.createContext(Object.assign(self._jsSandboxContext, context, self._jsSandboxRegistered)) |
|
|
|
|
var result = vm.runInContext(script, cmds) |
|
|
|
|
self._jsSandboxContext = Object.assign(cmds, context) |
|
|
|
|
done(null, result) |
|
|
|
@ -630,7 +631,12 @@ function domTerminalFeatures (self, scopedCommands) { |
|
|
|
|
return setInterval(() => { self._shell('(' + fn.toString() + ')()', scopedCommands, () => {}) }, time) |
|
|
|
|
}, |
|
|
|
|
clearTimeout: clearTimeout, |
|
|
|
|
clearInterval: clearInterval |
|
|
|
|
clearInterval: clearInterval, |
|
|
|
|
exports: { |
|
|
|
|
register: (key, obj) => { self._jsSandboxRegistered[key] = obj }, |
|
|
|
|
remove: (key) => { delete self._jsSandboxRegistered[key] }, |
|
|
|
|
clear: () => { self._jsSandboxRegistered = {} } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|