JetBrains: Create Java→JS bridge
Created by: vdavid
Closes #34797 (closed) Closes https://github.com/sourcegraph/sourcegraph/issues/34812
Creates a way to call JS from the Java side.
This is not trivial because the JBCefJSQuery
object that runs the executeJavaScript()
calls on the Java side has to be create before the browser gets created.
17 sec Loom where I enthusiastically demo the theme change
Caveats:
- The
JavaToJSBridge
is not shared as a service. I was lucky with the theme change event, because that actually travels through the IDE's event bus and I could set up an event listener inSourcegraphJBCefBrowser
for it. But for our plugin setting change and other events, we'll either use the event bus, or share the bridge as a service so that it's accessible at arbitrary places. - I had to export a few things from the main
index.ts
file. This is not a nice direction of dependencies and will result in unwanted interdependencies if it's left this way. I think it's fine for now, as it's easy to refactor later.
Test plan
- Watch the Loom
- Check the code
- The standalone version is not affected as it's not getting any calls from the (nonexistent) Java side.
App preview:
Check out the client app preview documentation to learn more.