Add native invoke bridge and slim down install()

Merged
SE
4mo ago
+615-314

Summary

  • Native invoke bridge โ€” adds window.wvbAndroid so web invoke(name, params) calls reach native handlers, with built-in source/remote/updater commands (Bridge, BridgeCodec, BridgeError, WebViewBundleBridge, Log).
  • install() only adds bundle behavior โ€” InstallOptions no longer mutates the host's WebView settings; the host owns them. WebViewSetup.kt folded into WebViewBundle.kt.
  • R8 safety โ€” ships consumer-rules.pro so @JavascriptInterface bridge 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.wvbAndroid bridge for invoke() with JSON encode/decode, background handlers, and main-thread replies; attaches via WebMessageListener when supported (logs and skips if not).
    • Built-in commands expose source, remote, and updater via WebViewBundleBridge.
    • install() now only sets the client and optional bridge; returns a closeable handle. New InstallOptions: delegate, disableBridge, and bridge { ... }.
    • Added R8 consumer rules to keep @JavascriptInterface methods. WebViewBundle.getInstance(...) (and wvb(...)/webViewBundle(...)) provides a process-wide singleton.
  • Migration

    • Configure your own WebView settings and debugging (removed: applyRecommendedSettings, webContentsDebuggingEnabled, installServiceWorker, and configureWebView). If you need Service Worker interception, set it up with ServiceWorkerControllerCompat.
    • Update calls to install(webView) { delegate = ...; bridge { /* handlers */ } } or set disableBridge = true if not using the native bridge.
    • Use WebViewBundle.getInstance(context, config) to reuse the shared instance; call close() only when you need to drop it.