@capgo/capacitor-inappbrowser 8.10.3-beta.pr621.476.1 → 8.10.4

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.3"
202
+ private let pluginVersion: String = "8.10.4"
203
203
  public let identifier = "CapgoInAppBrowserPlugin"
204
204
  public let jsName = "CapgoInAppBrowser"
205
205
  public let pluginMethods: [CAPPluginMethod] = [
@@ -47,35 +47,6 @@ 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
-
79
50
  private struct BlobDownloadSession {
80
51
  let destinationURL: URL
81
52
  let sourceURL: String?
@@ -2037,7 +2008,16 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
2037
2008
  }
2038
2009
  let userContentController = webConfiguration.userContentController
2039
2010
  userContentController.removeAllUserScripts()
2040
- ScriptMessageHandlerSupport.removeAll(from: userContentController)
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")
2041
2021
 
2042
2022
  if proxyRequests || proxySchemeHandler != nil, let handler = proxySchemeHandler {
2043
2023
  WKWebView.enableCustomSchemeHandling(for: ["https", "http"])
@@ -2284,9 +2264,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
2284
2264
  self.enabledSafeTopMargin = parent.enabledSafeTopMargin
2285
2265
  self.blockedHosts = parent.blockedHosts
2286
2266
  self.authorizedAppLinks = parent.authorizedAppLinks
2287
- // createWebViewWith configs copy parent script handlers; start clean so
2288
- // initWebview can register blobDownload/etc without NSInvalidArgumentException.
2289
- configuration.userContentController = WKUserContentController()
2267
+ self.activeNativeNavigationForWebview = parent.activeNativeNavigationForWebview
2290
2268
  self.initialWebConfiguration = configuration
2291
2269
  self.persistWebViewData = parent.persistWebViewData
2292
2270
  self.disableOverscroll = parent.disableOverscroll
@@ -2570,7 +2548,20 @@ public extension WKWebViewController {
2570
2548
  webView.loadHTMLString("", baseURL: nil)
2571
2549
 
2572
2550
  webView.configuration.userContentController.removeAllUserScripts()
2573
- ScriptMessageHandlerSupport.removeAll(from: webView.configuration.userContentController)
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")
2574
2565
 
2575
2566
  webView.removeFromSuperview()
2576
2567
  // 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.3-beta.pr621.476.1",
3
+ "version": "8.10.4",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",