I wonder if the "break-out" frame should be generalized to just run any code that gets passed to it, so that it's not just limited to bluetooth handling.
Yeah I am not sure what the best abstraction is. Broadcast channel is not widely supported so I wonder if broadcast-channel polyfill would be better which is string only. Would work with your scheme.
I was thinking the right abstraction would be a "proxy" class rather than eval. But your suggestion reminds me of puppeteer [1] which is quite flexible and avoids the proxying sync methods impossibility.
1. https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pageevaluatepagefunction-args