@capacitor/ios 8.3.7 → 8.3.8

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.
@@ -364,6 +364,10 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol {
364
364
  return
365
365
  }
366
366
 
367
+ guard !isDisabled(pluginInstance.jsName) else {
368
+ CAPLog.print("⚡️ Not registering disabled plugin \(pluginInstance.jsName)")
369
+ return
370
+ }
367
371
  if plugins[pluginInstance.jsName] != nil {
368
372
  CAPLog.print("⚡️ Overriding existing registered plugin \(pluginInstance.classForCoder)")
369
373
  }
@@ -382,11 +386,20 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol {
382
386
  }
383
387
  }
384
388
 
389
+ // Only built-in plugins with their own config section can be disabled; leave npm plugins out with includePlugins.
390
+ private func isDisabled(_ jsName: String) -> Bool {
391
+ ["CapacitorCookies", "CapacitorHttp", "SystemBars"].contains(jsName) && config.getPluginConfig(jsName).getBoolean("disabled", false)
392
+ }
393
+
385
394
  func loadPlugin(type: CAPPlugin.Type) -> CapacitorPlugin? {
386
395
  guard let plugin = type.init() as? CapacitorPlugin else {
387
396
  CAPLog.print("⚡️ Unable to load plugin \(type.classForCoder()). No such module found.")
388
397
  return nil
389
398
  }
399
+ guard !isDisabled(plugin.jsName) else {
400
+ CAPLog.print("⚡️ Not registering disabled plugin \(plugin.jsName)")
401
+ return nil
402
+ }
390
403
  plugin.load(on: self)
391
404
  plugins[plugin.jsName] = plugin
392
405
  return plugin
@@ -54,3 +54,10 @@ import Foundation
54
54
  return self.config
55
55
  }
56
56
  }
57
+
58
+ extension PluginConfig {
59
+ // `disabled` wins over `enabled`: a disabled plugin is not registered, so patching it in would leave calls hanging.
60
+ func isPatchEnabled() -> Bool {
61
+ getBoolean("enabled", false) && !getBoolean("disabled", false)
62
+ }
63
+ }
@@ -37,7 +37,7 @@ open class WebViewAssetHandler: NSObject, WKURLSchemeHandler {
37
37
  if url.path.starts(with: CapacitorBridge.httpInterceptorStartIdentifier) {
38
38
  // Only serve the proxy when CapacitorHttp is on. A scheme task can't tell a document from
39
39
  // a subresource, so keeping documents out relies on the check in decidePolicyFor.
40
- if configuration?.getPluginConfig("CapacitorHttp").getBoolean("enabled", false) == true {
40
+ if configuration?.getPluginConfig("CapacitorHttp").isPatchEnabled() == true {
41
41
  handleCapacitorHttpRequest(urlSchemeTask, localUrl, false)
42
42
  } else {
43
43
  urlSchemeTask.didFailWithError(URLError(.unsupportedURL))
@@ -290,13 +290,11 @@ open class WebViewDelegationHandler: NSObject, WKNavigationDelegate, WKUIDelegat
290
290
  // Don't present prompt
291
291
  return
292
292
  } else if type == "CapacitorCookies.isEnabled" {
293
- let pluginConfig = bridge!.config.getPluginConfig("CapacitorCookies")
294
- completionHandler(String(pluginConfig.getBoolean("enabled", false)))
293
+ completionHandler(String(bridge!.config.getPluginConfig("CapacitorCookies").isPatchEnabled()))
295
294
  // Don't present prompt
296
295
  return
297
296
  } else if type == "CapacitorHttp" {
298
- let pluginConfig = bridge!.config.getPluginConfig("CapacitorHttp")
299
- completionHandler(String(pluginConfig.getBoolean("enabled", false)))
297
+ completionHandler(String(bridge!.config.getPluginConfig("CapacitorHttp").isPatchEnabled()))
300
298
  // Don't present prompt
301
299
  return
302
300
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/ios",
3
- "version": "8.3.7",
3
+ "version": "8.3.8",
4
4
  "description": "Capacitor: Cross-platform apps with JavaScript and the web",
5
5
  "homepage": "https://capacitorjs.com",
6
6
  "author": "Ionic Team <hi@ionic.io> (https://ionic.io)",