@capgo/capacitor-inappbrowser 8.10.5 → 8.10.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -199,7 +199,7 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
199
199
  case aware = "AWARE"
200
200
  case fakeVisible = "FAKE_VISIBLE"
201
201
  }
202
- private let pluginVersion: String = "8.10.5"
202
+ private let pluginVersion: String = "8.10.6"
203
203
  public let identifier = "CapgoInAppBrowserPlugin"
204
204
  public let jsName = "CapgoInAppBrowser"
205
205
  public let pluginMethods: [CAPPluginMethod] = [
@@ -47,6 +47,35 @@ private enum BlobDownloadSupport {
47
47
  static let chunkBytes = 64 * 1024
48
48
  }
49
49
 
50
+ /// Script message handlers registered on every in-app browser WKWebView.
51
+ /// Popup configs from `createWebViewWith` copy parent handlers, so we must
52
+ /// remove these names before re-adding or WKWebView raises NSInvalidArgumentException.
53
+ enum ScriptMessageHandlerSupport {
54
+ static let allNames = [
55
+ "messageHandler",
56
+ "preShowScriptError",
57
+ "preShowScriptSuccess",
58
+ "close",
59
+ "hide",
60
+ "show",
61
+ "blobDownload",
62
+ "blobDownloadStart",
63
+ "blobDownloadChunk",
64
+ "blobDownloadFinish",
65
+ "blobDownloadAbort",
66
+ "takeScreenshot",
67
+ "consoleMessageHandler",
68
+ "magicPrint",
69
+ "capgoProxyBridge"
70
+ ]
71
+
72
+ static func removeAll(from userContentController: WKUserContentController) {
73
+ for name in allNames {
74
+ userContentController.removeScriptMessageHandler(forName: name)
75
+ }
76
+ }
77
+ }
78
+
50
79
  private struct BlobDownloadSession {
51
80
  let destinationURL: URL
52
81
  let sourceURL: String?
@@ -2008,16 +2037,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
2008
2037
  }
2009
2038
  let userContentController = webConfiguration.userContentController
2010
2039
  userContentController.removeAllUserScripts()
2011
- userContentController.removeScriptMessageHandler(forName: "messageHandler")
2012
- userContentController.removeScriptMessageHandler(forName: "preShowScriptError")
2013
- userContentController.removeScriptMessageHandler(forName: "preShowScriptSuccess")
2014
- userContentController.removeScriptMessageHandler(forName: "close")
2015
- userContentController.removeScriptMessageHandler(forName: "hide")
2016
- userContentController.removeScriptMessageHandler(forName: "show")
2017
- userContentController.removeScriptMessageHandler(forName: "takeScreenshot")
2018
- userContentController.removeScriptMessageHandler(forName: "consoleMessageHandler")
2019
- userContentController.removeScriptMessageHandler(forName: "magicPrint")
2020
- userContentController.removeScriptMessageHandler(forName: "capgoProxyBridge")
2040
+ ScriptMessageHandlerSupport.removeAll(from: userContentController)
2021
2041
 
2022
2042
  if proxyRequests || proxySchemeHandler != nil, let handler = proxySchemeHandler {
2023
2043
  WKWebView.enableCustomSchemeHandling(for: ["https", "http"])
@@ -2264,7 +2284,9 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
2264
2284
  self.enabledSafeTopMargin = parent.enabledSafeTopMargin
2265
2285
  self.blockedHosts = parent.blockedHosts
2266
2286
  self.authorizedAppLinks = parent.authorizedAppLinks
2267
- self.activeNativeNavigationForWebview = parent.activeNativeNavigationForWebview
2287
+ // createWebViewWith configs copy parent script handlers; start clean so
2288
+ // initWebview can register blobDownload/etc without NSInvalidArgumentException.
2289
+ configuration.userContentController = WKUserContentController()
2268
2290
  self.initialWebConfiguration = configuration
2269
2291
  self.persistWebViewData = parent.persistWebViewData
2270
2292
  self.disableOverscroll = parent.disableOverscroll
@@ -2548,20 +2570,7 @@ public extension WKWebViewController {
2548
2570
  webView.loadHTMLString("", baseURL: nil)
2549
2571
 
2550
2572
  webView.configuration.userContentController.removeAllUserScripts()
2551
- webView.configuration.userContentController.removeScriptMessageHandler(forName: "messageHandler")
2552
- webView.configuration.userContentController.removeScriptMessageHandler(forName: "close")
2553
- webView.configuration.userContentController.removeScriptMessageHandler(forName: "hide")
2554
- webView.configuration.userContentController.removeScriptMessageHandler(forName: "show")
2555
- if allowScreenshotsFromWebPage {
2556
- webView.configuration.userContentController.removeScriptMessageHandler(forName: "takeScreenshot")
2557
- }
2558
- if captureConsoleLogs {
2559
- webView.configuration.userContentController.removeScriptMessageHandler(forName: "consoleMessageHandler")
2560
- }
2561
- webView.configuration.userContentController.removeScriptMessageHandler(forName: "preShowScriptSuccess")
2562
- webView.configuration.userContentController.removeScriptMessageHandler(forName: "preShowScriptError")
2563
- webView.configuration.userContentController.removeScriptMessageHandler(forName: "magicPrint")
2564
- webView.configuration.userContentController.removeScriptMessageHandler(forName: "capgoProxyBridge")
2573
+ ScriptMessageHandlerSupport.removeAll(from: webView.configuration.userContentController)
2565
2574
 
2566
2575
  webView.removeFromSuperview()
2567
2576
  // Also clean progress bar view if present
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-inappbrowser",
3
- "version": "8.10.5",
3
+ "version": "8.10.6",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",