Files
orca/mobile/patches/react-native-webview@13.16.2.patch
T
Jinwoo-H 41a79c5a78 fix(mobile): wire the Android WebView debugging patches so they apply
Under pnpm 12 the patch authority for the mobile workspace is
pnpm-workspace.yaml, not package.json, so the patchedDependencies block
added to mobile/package.json was inert: the three new patches never
applied and the lock carried no hash for them. The versions they named
were stale too, since pnpm resolves @expo/dom-webview to 55.0.6,
@expo/log-box to 55.0.13, and react-native-webview to 13.16.2.

Drop the dead pnpm block, declare the patches in pnpm-workspace.yaml
against the installed versions, and re-resolve each patch against the
real sources. The react-native-webview Android hunks fold into the
existing 13.16.2 patch, since pnpm allows one patch per package version.
Every hunk keeps its original intent: setWebContentsDebuggingEnabled is
gated on ApplicationInfo.FLAG_DEBUGGABLE.

The CDP session test read these patches by version-stamped filename,
which would break again on the next bump. Resolve them through
pnpm-workspace.yaml instead, so the test also fails when a patch is
declared nowhere.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
2026-09-01 16:38:21 -04:00

48 lines
2.4 KiB
Diff

diff --git a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt
index f83033b3597a425da159555233bacce250ccfce0..4dda472003fcc465b6146154c5fdb071fd5ac298 100644
--- a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt
+++ b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt
@@ -2,6 +2,7 @@ package com.reactnativecommunity.webview
import android.app.DownloadManager
import android.content.pm.ActivityInfo
+import android.content.pm.ApplicationInfo
import android.graphics.Bitmap
import android.graphics.Color
import android.net.Uri
@@ -88,7 +89,9 @@ class RNCWebViewManagerImpl(private val newArch: Boolean = false) {
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
- if (ReactBuildConfig.DEBUG) {
+ val isDebuggable =
+ webView.context.applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0
+ if (ReactBuildConfig.DEBUG && isDebuggable) {
WebView.setWebContentsDebuggingEnabled(true)
}
webView.setDownloadListener(DownloadListener { url, userAgent, contentDisposition, mimetype, contentLength ->
@@ -712,7 +715,9 @@ class RNCWebViewManagerImpl(private val newArch: Boolean = false) {
}
fun setWebviewDebuggingEnabled(viewWrapper: RNCWebViewWrapper, enabled: Boolean) {
- RNCWebView.setWebContentsDebuggingEnabled(enabled)
+ val isDebuggable =
+ viewWrapper.webView.context.applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0
+ RNCWebView.setWebContentsDebuggingEnabled(enabled && isDebuggable)
}
fun setPaymentRequestEnabled(viewWrapper: RNCWebViewWrapper, enabled: Boolean) {
diff --git a/index.d.ts b/index.d.ts
index 10b9c145b920a6a2ba1fb09bd72150328fafe211..626a67a3d6aca587ee9e74a52b799a2c50b4c52b 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -5,7 +5,7 @@ export { FileDownload, WebViewMessageEvent, WebViewNavigation } from './lib/WebV
export type WebViewProps = IOSWebViewProps & AndroidWebViewProps & WindowsWebViewProps;
-declare class WebView<P = undefined> extends Component<WebViewProps & P> {
+declare class WebView<P = {}> extends Component<WebViewProps & P> {
/**
* Go back one page in the webview's history.
*/