Add native invoke bridge and slim down install()
Merged
SE
4mo ago+615+615+012345678901234567890123456789-314-314-012345678901234567890123456789
Summary
- Native invoke bridge โ adds
window.wvbAndroidso webinvoke(name, params)calls reach native handlers, with built-in source/remote/updater commands (Bridge,BridgeCodec,BridgeError,WebViewBundleBridge,Log). install()only adds bundle behavior โInstallOptionsno longer mutates the host's WebView settings; the host owns them.WebViewSetup.ktfolded intoWebViewBundle.kt.- R8 safety โ ships
consumer-rules.proso@JavascriptInterfacebridge methods aren't stripped/renamed in minified consumer apps. - testapp / assets โ host applies its own WebView settings, back-key, and debugging; e2e modules and builtin bundles refreshed.
๐ค Generated with Claude Code
Summary by cubic
Adds a native web-to-Android invoke bridge and makes install() only wire bundle behavior. Web apps can call invoke(name, params) via window.wvbAndroid, and hosts now own all WebView settings.
-
New Features
- Native
window.wvbAndroidbridge forinvoke()with JSON encode/decode, background handlers, and main-thread replies; attaches viaWebMessageListenerwhen supported (logs and skips if not). - Built-in commands expose
source,remote, andupdaterviaWebViewBundleBridge. install()now only sets the client and optional bridge; returns a closeable handle. NewInstallOptions:delegate,disableBridge, andbridge { ... }.- Added R8 consumer rules to keep
@JavascriptInterfacemethods.WebViewBundle.getInstance(...)(andwvb(...)/webViewBundle(...)) provides a process-wide singleton.
- Native
-
Migration
- Configure your own
WebViewsettings and debugging (removed:applyRecommendedSettings,webContentsDebuggingEnabled,installServiceWorker, andconfigureWebView). If you need Service Worker interception, set it up withServiceWorkerControllerCompat. - Update calls to
install(webView) { delegate = ...; bridge { /* handlers */ } }or setdisableBridge = trueif not using the native bridge. - Use
WebViewBundle.getInstance(context, config)to reuse the shared instance; callclose()only when you need to drop it.
- Configure your own