@aigens/aigens-sdk-core 0.0.10 → 0.0.11
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.
@@ -13,9 +13,9 @@ import Capacitor
|
|
13
13
|
|
14
14
|
// {themeColor: "#xxxxxx"}
|
15
15
|
public var options: Dictionary<String, Any>?
|
16
|
-
|
16
|
+
|
17
17
|
var externalProtocols: [String] = [
|
18
|
-
"octopus://", "alipay://", "alipays://", "alipayhk://", "https://itunes.apple.com", "tel:", "mailto:", "itms-apps://itunes.apple.com", "https://apps.apple.com", "payme://"
|
18
|
+
"octopus://", "alipay://", "alipays://", "alipayhk://", "https://itunes.apple.com", "tel:", "mailto:", "itms-apps://itunes.apple.com", "https://apps.apple.com", "payme://", "weixin://"
|
19
19
|
]
|
20
20
|
let containerView = WebContainer.webContainer()
|
21
21
|
var webContainerView: WebContainer {
|
@@ -28,22 +28,22 @@ import Capacitor
|
|
28
28
|
self.becomeFirstResponder()
|
29
29
|
loadWebViewCustom()
|
30
30
|
initView()
|
31
|
-
|
31
|
+
|
32
32
|
}
|
33
|
-
|
33
|
+
|
34
34
|
private func initView(){
|
35
|
-
|
35
|
+
|
36
36
|
print("VC initView")
|
37
|
-
|
37
|
+
|
38
38
|
//let bundle = Bundle(for: WebContainerViewController.self)
|
39
39
|
//let containerView = WebContainerView()
|
40
40
|
//let containerView = bundle.loadNibNamed("WebContainerView", owner: self, options: nil)?.first as! UIView
|
41
|
-
|
41
|
+
|
42
42
|
self.view.addSubview(webContainerView)
|
43
43
|
webContainerView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height)
|
44
44
|
setupOptions(webContainerView)
|
45
45
|
containerView.vc = self
|
46
|
-
|
46
|
+
|
47
47
|
//
|
48
48
|
//
|
49
49
|
|
@@ -61,14 +61,14 @@ import Capacitor
|
|
61
61
|
// containerView.webArea.addSubview(self.webView!)
|
62
62
|
//
|
63
63
|
|
64
|
-
|
64
|
+
|
65
65
|
}
|
66
|
-
|
66
|
+
|
67
67
|
open override func viewWillLayoutSubviews() {
|
68
68
|
super.viewWillLayoutSubviews()
|
69
69
|
webContainerView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height)
|
70
70
|
}
|
71
|
-
|
71
|
+
|
72
72
|
private func setupOptions(_ view: WebContainer) {
|
73
73
|
if let theme = self.options?["themeColor"] as? String, let color = UIColor.getHex(hex: theme) {
|
74
74
|
self.view.backgroundColor = color
|
@@ -79,9 +79,9 @@ import Capacitor
|
|
79
79
|
if let externalProtocols = options?["externalProtocols"] as? [String] {
|
80
80
|
self.externalProtocols.append(contentsOf: externalProtocols)
|
81
81
|
}
|
82
|
-
|
82
|
+
|
83
83
|
}
|
84
|
-
|
84
|
+
|
85
85
|
public final func loadWebViewCustom() {
|
86
86
|
|
87
87
|
//let bridge = self.bridge
|
@@ -95,13 +95,13 @@ import Capacitor
|
|
95
95
|
}
|
96
96
|
|
97
97
|
let url = URL(string: urlString!)
|
98
|
-
|
98
|
+
|
99
99
|
let member = self.options?["member"] as? Dictionary<String, Any>
|
100
|
-
|
100
|
+
|
101
101
|
CorePlugin.member = member
|
102
102
|
let deeplink = self.options?["deeplink"] as? Dictionary<String, Any>
|
103
103
|
CorePlugin.deeplink = deeplink
|
104
|
-
|
104
|
+
|
105
105
|
//bridge.webViewDelegationHandler.willLoadWebview(webView)
|
106
106
|
_ = webView?.load(URLRequest(url: url!))
|
107
107
|
webView?.navigationDelegate = self
|
@@ -134,12 +134,12 @@ import Capacitor
|
|
134
134
|
|
135
135
|
return descriptor
|
136
136
|
}
|
137
|
-
|
137
|
+
|
138
138
|
deinit {
|
139
139
|
print("WebContainerViewController deinit")
|
140
140
|
}
|
141
141
|
|
142
|
-
|
142
|
+
|
143
143
|
}
|
144
144
|
|
145
145
|
extension WebContainerViewController: WKNavigationDelegate {
|
@@ -149,12 +149,12 @@ extension WebContainerViewController: WKNavigationDelegate {
|
|
149
149
|
// Reset the bridge on each navigation
|
150
150
|
// self.bridge?.reset()
|
151
151
|
}
|
152
|
-
|
152
|
+
|
153
153
|
public func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
|
154
154
|
webContainerView.showError(false)
|
155
155
|
webContainerView.showLoading(true)
|
156
156
|
}
|
157
|
-
|
157
|
+
|
158
158
|
public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
159
159
|
// post a notification for any listeners
|
160
160
|
NotificationCenter.default.post(name: .capacitorDecidePolicyForNavigationAction, object: navigationAction)
|
@@ -164,7 +164,7 @@ extension WebContainerViewController: WKNavigationDelegate {
|
|
164
164
|
decisionHandler(.allow)
|
165
165
|
return
|
166
166
|
}
|
167
|
-
|
167
|
+
|
168
168
|
var isCanOpen = false
|
169
169
|
if externalProtocols.count > 0 {
|
170
170
|
externalProtocols.forEach { (url) in
|
@@ -174,7 +174,7 @@ extension WebContainerViewController: WKNavigationDelegate {
|
|
174
174
|
}
|
175
175
|
}
|
176
176
|
}
|
177
|
-
|
177
|
+
|
178
178
|
if isCanOpen {
|
179
179
|
if #available(iOS 10.0, *) {
|
180
180
|
UIApplication.shared.open(navURL, options: [:], completionHandler: nil);
|
@@ -184,7 +184,7 @@ extension WebContainerViewController: WKNavigationDelegate {
|
|
184
184
|
decisionHandler(.cancel)
|
185
185
|
return;
|
186
186
|
}
|
187
|
-
|
187
|
+
|
188
188
|
|
189
189
|
// first, give plugins the chance to handle the decision
|
190
190
|
// for pluginObject in bridge.plugins {
|
@@ -224,8 +224,8 @@ extension WebContainerViewController: WKNavigationDelegate {
|
|
224
224
|
// fallthrough to allowing it
|
225
225
|
decisionHandler(.allow)
|
226
226
|
}
|
227
|
-
|
228
|
-
|
227
|
+
|
228
|
+
|
229
229
|
// The force unwrap is part of the protocol declaration, so we should keep it.
|
230
230
|
// swiftlint:disable:next implicitly_unwrapped_optional
|
231
231
|
public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
@@ -237,7 +237,7 @@ extension WebContainerViewController: WKNavigationDelegate {
|
|
237
237
|
webContainerView.showError(false)
|
238
238
|
CAPLog.print("⚡️ WebView loaded")
|
239
239
|
}
|
240
|
-
|
240
|
+
|
241
241
|
// The force unwrap is part of the protocol declaration, so we should keep it.
|
242
242
|
// swiftlint:disable:next implicitly_unwrapped_optional
|
243
243
|
public func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
|
@@ -246,12 +246,12 @@ extension WebContainerViewController: WKNavigationDelegate {
|
|
246
246
|
// webViewLoadingState = .subsequentLoad
|
247
247
|
// }
|
248
248
|
webContainerView.showLoading(false)
|
249
|
-
|
249
|
+
|
250
250
|
webContainerView.showError(true, error.localizedDescription)
|
251
251
|
CAPLog.print("⚡️ WebView failed to load")
|
252
252
|
CAPLog.print("⚡️ Error: " + error.localizedDescription)
|
253
253
|
}
|
254
|
-
|
254
|
+
|
255
255
|
// The force unwrap is part of the protocol declaration, so we should keep it.
|
256
256
|
// swiftlint:disable:next implicitly_unwrapped_optional
|
257
257
|
public func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
|
@@ -265,7 +265,7 @@ extension WebContainerViewController: WKNavigationDelegate {
|
|
265
265
|
CAPLog.print("⚡️ Error: " + error.localizedDescription)
|
266
266
|
webContainerView.showError(true, error.localizedDescription)
|
267
267
|
}
|
268
|
-
|
268
|
+
|
269
269
|
public func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
|
270
270
|
webView.reload()
|
271
271
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@aigens/aigens-sdk-core",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.11",
|
4
4
|
"description": "Aigens Order.Place Core Plugin",
|
5
5
|
"main": "dist/plugin.cjs.js",
|
6
6
|
"module": "dist/esm/index.js",
|
@@ -74,8 +74,5 @@
|
|
74
74
|
"android": {
|
75
75
|
"src": "android"
|
76
76
|
}
|
77
|
-
},
|
78
|
-
"dependencies": {
|
79
|
-
"aigens-mono": "file:../.."
|
80
77
|
}
|
81
78
|
}
|