Skip to content

Commit

Permalink
Removed commented out stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
markemer committed Dec 16, 2024
1 parent c231c96 commit fcd1bc3
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 86 deletions.
1 change: 0 additions & 1 deletion ios/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class ApplicationDelegateProxy: NSObject, UIApplicationDelegate {
"url": url,
"options": options
])
//NotificationCenter.default.post(name: NSNotification.Name.CDVPluginHandleOpenURL, object: url)
lastURL = url
return true
}
Expand Down
1 change: 0 additions & 1 deletion ios/Capacitor/Capacitor/CAPInstanceDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ internal extension InstanceDescriptor {
extension InstanceDescriptor {
@objc public var cordovaDeployDisabled: Bool {
return false
//return (cordovaConfiguration.settings?["DisableDeploy".lowercased()] as? NSString)?.boolValue ?? false
}

@objc public func normalize() {
Expand Down
51 changes: 23 additions & 28 deletions ios/Capacitor/Capacitor/CapacitorBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,10 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol {
@objc public var config: InstanceConfiguration
// Map of all loaded and instantiated plugins by pluginId -> instance
var plugins = [String: CapacitorPlugin]()
// Manager for getting Cordova plugins
//var cordovaPluginManager: CDVPluginManager?
// Calls we are storing to resolve later
var storedCalls = ConcurrentDictionary<CAPPluginCall>()
// Whether to inject the Cordova files
private var cordovaIsPresent = false
//private var cordovaParser: CDVConfigParser?

// Background dispatch queue for plugin calls
open private(set) var dispatchQueue = DispatchQueue(label: "bridge")
Expand Down Expand Up @@ -198,8 +195,6 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol {

// MARK: - Initialization



@available(*, deprecated, renamed: "init", message: "Use different init")
public convenience init(with configuration: InstanceConfiguration, delegate bridgeDelegate: CAPBridgeDelegate, cordovaConfiguration: Any, assetHandler: WebViewAssetHandler, delegationHandler: WebViewDelegationHandler, autoRegisterPlugins: Bool = true) {
self.init(with: configuration, delegate: bridgeDelegate, assetHandler: assetHandler, delegationHandler: delegationHandler, autoRegisterPlugins: autoRegisterPlugins)
Expand Down Expand Up @@ -519,29 +514,29 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol {
Handle a Cordova call from JavaScript. First, find the corresponding plugin,
construct a selector, and perform that selector on the plugin instance.
*/
// func handleCordovaJSCall(call: JSCall) {
// // Create a selector to send to the plugin
//
// if let plugin = self.cordovaPluginManager?.getCommandInstance(call.pluginId.lowercased()) {
// let selector = NSSelectorFromString("\(call.method):")
// if !plugin.responds(to: selector) {
// CAPLog.print("Error: Plugin \(plugin.className ?? "") does not respond to method call \(selector).")
// CAPLog.print("Ensure plugin method exists and uses @objc in its declaration")
// return
// }
//
// let arguments: [Any] = call.options["options"] as? [Any] ?? []
// let pluginCall = CDVInvokedUrlCommand(arguments: arguments,
// callbackId: call.callbackId,
// className: plugin.className,
// methodName: call.method)
// plugin.perform(selector, with: pluginCall)
//
// } else {
// CAPLog.print("Error: Cordova Plugin mapping not found")
// return
// }
// }
// func handleCordovaJSCall(call: JSCall) {
// // Create a selector to send to the plugin
//
// if let plugin = self.cordovaPluginManager?.getCommandInstance(call.pluginId.lowercased()) {
// let selector = NSSelectorFromString("\(call.method):")
// if !plugin.responds(to: selector) {
// CAPLog.print("Error: Plugin \(plugin.className ?? "") does not respond to method call \(selector).")
// CAPLog.print("Ensure plugin method exists and uses @objc in its declaration")
// return
// }
//
// let arguments: [Any] = call.options["options"] as? [Any] ?? []
// let pluginCall = CDVInvokedUrlCommand(arguments: arguments,
// callbackId: call.callbackId,
// className: plugin.className,
// methodName: call.method)
// plugin.perform(selector, with: pluginCall)
//
// } else {
// CAPLog.print("Error: Cordova Plugin mapping not found")
// return
// }
// }

/**
Send a successful result to the JavaScript layer.
Expand Down
60 changes: 21 additions & 39 deletions ios/Capacitor/Capacitor/JSExport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,6 @@ internal class JSExport {
}
}

// static func exportCordovaJS(userContentController: WKUserContentController) throws {
// guard let cordovaUrl = Bundle.main.url(forResource: "public/cordova", withExtension: "js") else {
// CAPLog.print("ERROR: Required cordova.js file not found. Cordova plugins will not function!")
// throw CapacitorBridgeError.errorExportingCoreJS
// }
// guard let cordovaPluginsUrl = Bundle.main.url(forResource: "public/cordova_plugins", withExtension: "js") else {
// CAPLog.print("ERROR: Required cordova_plugins.js file not found. Cordova plugins will not function!")
// throw CapacitorBridgeError.errorExportingCoreJS
// }
// do {
// try self.injectFile(fileURL: cordovaUrl, userContentController: userContentController)
// try self.injectFile(fileURL: cordovaPluginsUrl, userContentController: userContentController)
// } catch {
// CAPLog.print("ERROR: Unable to read required cordova files. Cordova plugins will not function!")
// throw CapacitorBridgeError.errorExportingCoreJS
// }
// }

/**
Export the JS required to implement the given plugin.
*/
Expand Down Expand Up @@ -170,27 +152,27 @@ internal class JSExport {
return lines.joined(separator: "\n")
}

// static func exportCordovaPluginsJS(userContentController: WKUserContentController) throws {
// if let pluginsJSFolder = Bundle.main.url(forResource: "public/plugins", withExtension: nil) {
// self.injectFilesForFolder(folder: pluginsJSFolder, userContentController: userContentController)
// }
// }

// static func injectFilesForFolder(folder: URL, userContentController: WKUserContentController) {
// let fileManager = FileManager.default
// do {
// let fileURLs = try fileManager.contentsOfDirectory(at: folder, includingPropertiesForKeys: nil, options: [])
// for fileURL in fileURLs {
// if fileURL.hasDirectoryPath {
// injectFilesForFolder(folder: fileURL, userContentController: userContentController)
// } else {
// try self.injectFile(fileURL: fileURL, userContentController: userContentController)
// }
// }
// } catch {
// CAPLog.print("Error while enumerating files")
// }
// }
// static func exportCordovaPluginsJS(userContentController: WKUserContentController) throws {
// if let pluginsJSFolder = Bundle.main.url(forResource: "public/plugins", withExtension: nil) {
// self.injectFilesForFolder(folder: pluginsJSFolder, userContentController: userContentController)
// }
// }

// static func injectFilesForFolder(folder: URL, userContentController: WKUserContentController) {
// let fileManager = FileManager.default
// do {
// let fileURLs = try fileManager.contentsOfDirectory(at: folder, includingPropertiesForKeys: nil, options: [])
// for fileURL in fileURLs {
// if fileURL.hasDirectoryPath {
// injectFilesForFolder(folder: fileURL, userContentController: userContentController)
// } else {
// try self.injectFile(fileURL: fileURL, userContentController: userContentController)
// }
// }
// } catch {
// CAPLog.print("Error while enumerating files")
// }
// }

static func injectFile(fileURL: URL, userContentController: WKUserContentController) throws {
do {
Expand Down
18 changes: 3 additions & 15 deletions ios/Capacitor/Capacitor/WebViewDelegationHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,29 +180,17 @@ open class WebViewDelegationHandler: NSObject, WKNavigationDelegate, WKUIDelegat
let pluginId = dict["pluginId"] as? String ?? ""
let method = dict["methodName"] as? String ?? ""
let callbackId = dict["callbackId"] as? String ?? ""

let options = dict["options"] as? [String: Any] ?? [:]

if pluginId != "Console" {
CAPLog.print("⚡️ To Native -> ", pluginId, method, callbackId)
}

bridge.handleJSCall(call: JSCall(options: options, pluginId: pluginId, method: method, callbackId: callbackId))
} else if let handler = bridge.callInterceptors[type] {
handler(dict)
}
// } else if type == "cordova" {
// let pluginId = dict["service"] as? String ?? ""
// let method = dict["action"] as? String ?? ""
// let callbackId = dict["callbackId"] as? String ?? ""
//
// let args = dict["actionArgs"] as? Array ?? []
// let options = ["options": args]
//
// CAPLog.print("To Native Cordova -> ", pluginId, method, callbackId, options)
//
// //bridge.handleCordovaJSCall(call: JSCall(options: options, pluginId: pluginId, method: method, callbackId: callbackId))
// }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class CordovaPlugin: CAPPlugin, CAPBridgedPlugin {

private var _cordovaDeployDisabled = false

public override func load() {
override public func load() {
injectJavascript()
configureRuntime()
}
Expand Down Expand Up @@ -68,7 +68,7 @@ public class CordovaPlugin: CAPPlugin, CAPBridgedPlugin {
return
}
}

_cordovaDeployDisabled = (cordovaConfigParser.settings?["DisableDeploy".lowercased()] as? NSString)?.boolValue ?? false
}

Expand Down

0 comments on commit fcd1bc3

Please sign in to comment.