Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function server() {
window.require = require
// emit a `client` event on the window with the given packet object
function send(packet) {
var event = document.createEvent("CustomEvent")
event.initCustomEvent("client", false, true, packet)
console.log("client!", event.detail)
window.addEventListener("server", function(event) {
console.log("server?", event.detail)
var packet = event.detail
var result
try {
result = window.eval(packet.source)
catch (error) {
result = error
send({ from:, message: result })
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.