index.js
// Create Web Worker
const worker = new Worker('worker.js');
// Create proxy
const targetProxy = new TargetProxy(worker);
// Gave access to window object
targetProxy.register('window', window);
worker.js
// link proxy object
const window: any = WorkerProxyObject('window');
// eval native alert function in GUI thread from worker thread
window.alert('Hello From Worker');
// direct access to DOM from worker
window.document.body.innerText = 'Hello From Worker';
In two words Proxy & Promise. For more details, please see worker.ts file (less than 100 lines of code).