initBackground(); globalThis['renderPage'] = function () { console.log('in main'); console.log('getting global emitter in main should fail', 'getJSModule' in lynx); const context = lynx.getJSContext(); console.log('js context', context); // dmj: this works context.addEventListener("message", (event) => { console.log('got event in js context', event); }); context.postMessage({ main : 'main' }); lynx.requestAnimationFrame(step); } function initBackground () { 'background only' console.log('in bg'); console.log('getting global emitter in bg should work', lynx.getJSModule('GlobalEventEmitter')); const coreContext = lynx.getCoreContext(); coreContext.addEventListener("message", (event) => { console.log('got event in core context, sending event back to main thread', event); coreContext.postMessage({ bg: 'bg' }); }); lynx.requestAnimationFrame(step); } // dmj: looping function step (frame) { lynx.requestAnimationFrame(step); } // dmj: need this globalThis['processData'] = function () { } // dmj: this might need to be configured differently globalThis['runWorklet'] = (worklet, params) => { return worklet(params); }