blob: c1919d0b9a7b1c1ef991cfd6018a8268e271eb1a [file] [log] [blame]
let channel;
let port;
onmessage = (e) => {
if (e.data.port) {
port = e.data.port;
port.onmessage = (event) => channel.send(event.data.message);
}
if (e.data.channel) {
channel = e.data.channel;
channel.onopen = () => port.postMessage("opened");
channel.onerror = () => port.postMessage("errored");
channel.onclose = () => port.postMessage("closed");
channel.onmessage = (event) => port.postMessage(event.data);
}
};