@aigens/aigens-sdk-core 0.0.7 → 0.0.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.
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
10
10
  s.homepage = package['repository']['url']
11
11
  s.author = package['author']
12
12
  s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
- s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
13
+ s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp,xib}'
14
14
  s.ios.deployment_target = '12.0'
15
15
  s.dependency 'Capacitor'
16
16
  s.swift_version = '5.1'
package/README.md CHANGED
@@ -18,6 +18,8 @@ npx cap sync
18
18
  * [`finish(...)`](#finish)
19
19
  * [`getMember(...)`](#getmember)
20
20
  * [`openBrowser(...)`](#openbrowser)
21
+ * [`isInstalledApp(...)`](#isinstalledapp)
22
+ * [`openExternalUrl(...)`](#openexternalurl)
21
23
 
22
24
  </docgen-index>
23
25
 
@@ -98,4 +100,34 @@ openBrowser(options: any) => Promise<any>
98
100
 
99
101
  --------------------
100
102
 
103
+
104
+ ### isInstalledApp(...)
105
+
106
+ ```typescript
107
+ isInstalledApp(options: { key: string; }) => Promise<{ install: boolean; }>
108
+ ```
109
+
110
+ | Param | Type |
111
+ | ------------- | ----------------------------- |
112
+ | **`options`** | <code>{ key: string; }</code> |
113
+
114
+ **Returns:** <code>Promise&lt;{ install: boolean; }&gt;</code>
115
+
116
+ --------------------
117
+
118
+
119
+ ### openExternalUrl(...)
120
+
121
+ ```typescript
122
+ openExternalUrl(options: { url: string; }) => Promise<any>
123
+ ```
124
+
125
+ | Param | Type |
126
+ | ------------- | ----------------------------- |
127
+ | **`options`** | <code>{ url: string; }</code> |
128
+
129
+ **Returns:** <code>Promise&lt;any&gt;</code>
130
+
131
+ --------------------
132
+
101
133
  </docgen-api>
@@ -1,3 +1,12 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
1
2
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
3
  package="com.aigens.sdk">
4
+ <uses-permission android:name="android.permission.INTERNET" />
5
+ <application android:hardwareAccelerated="true">
6
+ <activity android:name=".WebContainerActivity"
7
+ android:screenOrientation="portrait"
8
+ >
9
+
10
+ </activity>
11
+ </application>
3
12
  </manifest>
@@ -1,11 +1,18 @@
1
1
  package com.aigens.sdk;
2
2
 
3
+ import android.app.Activity;
3
4
  import android.content.Intent;
4
5
  import android.content.res.AssetManager;
5
6
  import android.graphics.Bitmap;
7
+ import android.graphics.Color;
6
8
  import android.net.Uri;
9
+ import android.os.Build;
7
10
  import android.os.Bundle;
11
+ import android.text.TextUtils;
12
+ import android.util.Log;
8
13
  import android.view.View;
14
+ import android.webkit.ServiceWorkerClient;
15
+ import android.webkit.ServiceWorkerController;
9
16
  import android.webkit.WebResourceError;
10
17
  import android.webkit.WebResourceRequest;
11
18
  import android.webkit.WebResourceResponse;
@@ -21,7 +28,6 @@ import com.getcapacitor.CapConfig;
21
28
  import com.getcapacitor.Plugin;
22
29
  import com.getcapacitor.PluginLoadException;
23
30
  import com.getcapacitor.PluginManager;
24
- import com.aigens.sdk.R;
25
31
 
26
32
  import org.json.JSONException;
27
33
  import org.json.JSONObject;
@@ -40,6 +46,16 @@ public class WebContainerActivity extends BridgeActivity {
40
46
  private String url;
41
47
  private boolean navbar = false;
42
48
  private Map member;
49
+ private List<String> externalProtocols = new ArrayList<String>(){{
50
+ add("octopus://");
51
+ add("alipay://");
52
+ add("alipays://");
53
+ add("alipayhk://");
54
+ add("tel:");
55
+ add("mailto:");
56
+ add("payme://");
57
+ add("https://play.google.com");
58
+ }};
43
59
 
44
60
  private void debug(Object... msgs){
45
61
 
@@ -59,7 +75,9 @@ public class WebContainerActivity extends BridgeActivity {
59
75
 
60
76
  super.onCreate(savedInstanceState);
61
77
 
62
- setContentView(R.layout.sdk_layout_main);
78
+ setContentView(com.aigens.sdk.R.layout.sdk_layout_main);
79
+
80
+ disableServiceWorker();
63
81
 
64
82
  Intent intent = getIntent();
65
83
  this.url = intent.getStringExtra("url");
@@ -69,6 +87,13 @@ public class WebContainerActivity extends BridgeActivity {
69
87
 
70
88
  this.member = (Map) intent.getSerializableExtra("member");
71
89
 
90
+ List<String> externalProtocols_ = (List<String>) intent.getSerializableExtra("externalProtocols");
91
+ if (externalProtocols_ != null) {
92
+ for (String s : externalProtocols_) {
93
+ this.externalProtocols.add(s);
94
+ }
95
+ }
96
+
72
97
  if(this.member != null) {
73
98
  CorePlugin.setMember(this.member);
74
99
  }
@@ -119,6 +144,16 @@ public class WebContainerActivity extends BridgeActivity {
119
144
 
120
145
  }
121
146
 
147
+ addExtraPlugins(new String[] {
148
+ "com.aigens.googlepay.GooglePayPlugin",
149
+ "com.aigens.octopus.OctopusPlugin",
150
+ "com.aigens.wechatpay.WechatPayPlugin",
151
+ "com.aigens.alipay.AliPayPlugin",
152
+ "com.aigens.alipayhk.AliPayhkPlugin",
153
+ "com.aigens.payme.PaymePlugin",
154
+ }, plugins);
155
+ addExtraPlugins(intent.getStringArrayExtra("extraClasspaths"), plugins);
156
+
122
157
  debug("App plugins:" + plugins);
123
158
 
124
159
  super.init(savedInstanceState, plugins, cc);
@@ -126,12 +161,38 @@ public class WebContainerActivity extends BridgeActivity {
126
161
  //still have time to override webview client to avoid any intercept
127
162
 
128
163
  BypassWebViewClient wvc = new BypassWebViewClient(this.bridge);
164
+ wvc.activity = this;
165
+ wvc.externalProtocols = this.externalProtocols;
129
166
  this.bridge.getWebView().setWebViewClient(wvc);
130
167
 
131
168
  initView();
132
169
  initLayout(false, true, false);
133
170
  }
134
171
 
172
+ private void addExtraPlugins(String[] extraClasspaths, List<Class<? extends Plugin>> plugins) {
173
+ if (extraClasspaths == null) return;
174
+ for (int i = 0; i < extraClasspaths.length; i++) {
175
+ String classPath = extraClasspaths[i];
176
+ try {
177
+ Class<?> c = Class.forName(classPath);
178
+ Class<? extends Plugin> sub = c.asSubclass(Plugin.class);
179
+ String clsName = sub.getName();
180
+ Boolean add = false;
181
+ for (Class<? extends Plugin> plugin : plugins) {
182
+ if (plugin.getName() == clsName) {
183
+ add = true;
184
+ break;
185
+ }
186
+ }
187
+ if (!add) {
188
+ plugins.add(sub);
189
+ }
190
+ } catch (ClassNotFoundException e) {
191
+ e.printStackTrace();
192
+ }
193
+ }
194
+ }
195
+
135
196
  private void initView(){
136
197
 
137
198
  Button backButton = (Button) findViewById(R.id.back);
@@ -154,6 +215,8 @@ public class WebContainerActivity extends BridgeActivity {
154
215
  }
155
216
  });
156
217
 
218
+ setTheme();
219
+
157
220
  }
158
221
 
159
222
  private void reload(){
@@ -170,6 +233,18 @@ public class WebContainerActivity extends BridgeActivity {
170
233
 
171
234
  }
172
235
 
236
+ private void setTheme() {
237
+ Intent intent = getIntent();
238
+ String themeColor = intent.getStringExtra("themeColor");
239
+ if (!TextUtils.isEmpty(themeColor)) {
240
+ View info = findViewById(R.id.info);
241
+ View error = findViewById(R.id.error);
242
+ info.setBackgroundColor(Color.parseColor(themeColor));
243
+ error.setBackgroundColor(Color.parseColor(themeColor));
244
+ bridge.getWebView().setBackgroundColor(Color.parseColor(themeColor));
245
+ getWindow().setStatusBarColor(Color.parseColor(themeColor));//set statussbar color
246
+ }
247
+ }
173
248
  private void initLayout(boolean showWeb, boolean showInfo, boolean showError){
174
249
 
175
250
  if(showError){
@@ -203,6 +278,25 @@ public class WebContainerActivity extends BridgeActivity {
203
278
  return plugins;
204
279
  }
205
280
 
281
+ private static boolean SW_DISABLED = false;
282
+
283
+ private static void disableServiceWorker(){
284
+
285
+ if(SW_DISABLED) return;
286
+
287
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
288
+ ServiceWorkerController.getInstance().setServiceWorkerClient(new ServiceWorkerClient() {
289
+ @Override
290
+ public WebResourceResponse shouldInterceptRequest(WebResourceRequest request) {
291
+
292
+ return null;
293
+ }
294
+ });
295
+ }
296
+
297
+ SW_DISABLED = true;
298
+
299
+ }
206
300
 
207
301
 
208
302
  private static String readString(InputStream is) throws IOException {
@@ -254,10 +348,78 @@ public class WebContainerActivity extends BridgeActivity {
254
348
  //BridgeWebViewClient
255
349
  class BypassWebViewClient extends BridgeWebViewClient {
256
350
 
351
+ public Activity activity;
352
+ private String TAG = "BypassWebViewClient";
353
+ List<String> externalProtocols;
257
354
  public BypassWebViewClient(Bridge bridge) {
258
355
  super(bridge);
259
356
  }
260
357
 
358
+ public boolean loopExternalProtocols(String url) {
359
+ if (externalProtocols != null) {
360
+ for (String p : externalProtocols) {
361
+ if (url != null && url != "" && url.startsWith(p)) {
362
+ return true;
363
+ }
364
+ }
365
+ }
366
+ return false;
367
+ }
368
+ public boolean shouldOverrideUrl(WebView view, String url) {
369
+ if (url.startsWith(WebView.SCHEME_TEL)) {
370
+ try {
371
+ Intent intent = new Intent(Intent.ACTION_DIAL);
372
+ intent.setData(Uri.parse(url));
373
+ activity.startActivity(intent);
374
+ return true;
375
+ } catch (android.content.ActivityNotFoundException e) {
376
+ Log.e(TAG, "Error dialing " + url + ": " + e.toString());
377
+ }
378
+ } else if (url.startsWith("geo:") || url.startsWith(WebView.SCHEME_MAILTO) || url.startsWith("market:")
379
+ || loopExternalProtocols(url)) {
380
+ try {
381
+ Intent intent = new Intent(Intent.ACTION_VIEW);
382
+ intent.setData(Uri.parse(url));
383
+ activity.startActivity(intent);
384
+ return true;
385
+ } catch (android.content.ActivityNotFoundException e) {
386
+ Log.e(TAG, "Error with " + url + ": " + e.toString());
387
+ }
388
+ }
389
+ // If sms:5551212?body=This is the message
390
+ else if (url.startsWith("sms:")) {
391
+ try {
392
+ Intent intent = new Intent(Intent.ACTION_VIEW);
393
+
394
+ // Get address
395
+ String address = null;
396
+ int parmIndex = url.indexOf('?');
397
+ if (parmIndex == -1) {
398
+ address = url.substring(4);
399
+ } else {
400
+ address = url.substring(4, parmIndex);
401
+
402
+ // If body, then set sms body
403
+ Uri uri = Uri.parse(url);
404
+ String query = uri.getQuery();
405
+ if (query != null) {
406
+ if (query.startsWith("body=")) {
407
+ intent.putExtra("sms_body", query.substring(5));
408
+ }
409
+ }
410
+ }
411
+ intent.setData(Uri.parse("sms:" + address));
412
+ intent.putExtra("address", address);
413
+ intent.setType("vnd.android-dir/mms-sms");
414
+ activity.startActivity(intent);
415
+ return true;
416
+ } catch (android.content.ActivityNotFoundException e) {
417
+ Log.e(TAG, "Error sending sms " + url + ":" + e.toString());
418
+ }
419
+ }
420
+ return false;
421
+ }
422
+
261
423
  //somehow this must call parent, otherwise plugins won't work
262
424
  @Override
263
425
  public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
@@ -267,7 +429,9 @@ public class WebContainerActivity extends BridgeActivity {
267
429
  //debug("shouldInterceptRequest", url);
268
430
 
269
431
 
270
- if(url.indexOf("//scan") > 0){
432
+
433
+ //support redirect from /scan
434
+ if(url.indexOf("/scan?") > 0 || url.indexOf("/qr?") > 0 || url.indexOf("//scan") > 0){
271
435
  return null;
272
436
  }
273
437
 
@@ -281,11 +445,10 @@ public class WebContainerActivity extends BridgeActivity {
281
445
  @Override
282
446
  public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
283
447
  debug("shouldOverrideUrlLoading", request.getUrl());
284
- //Uri url = request.getUrl();
448
+ Uri url = request.getUrl();
285
449
 
286
450
  //return super.shouldOverrideUrlLoading(view, request);
287
-
288
- return false;
451
+ return shouldOverrideUrl(view, url.toString());
289
452
  }
290
453
 
291
454
  @Override
@@ -295,7 +458,7 @@ public class WebContainerActivity extends BridgeActivity {
295
458
 
296
459
  //return super.shouldOverrideUrlLoading(view, url);
297
460
 
298
- return false;
461
+ return shouldOverrideUrl(view, url);
299
462
  }
300
463
 
301
464
  @Override
@@ -2,11 +2,16 @@ package com.aigens.sdk.plugins;
2
2
 
3
3
  import android.app.Activity;
4
4
  import android.content.Intent;
5
+ import android.content.pm.PackageInfo;
6
+ import android.content.pm.PackageManager;
7
+ import android.net.Uri;
8
+ import android.os.Parcelable;
5
9
 
6
10
  import androidx.activity.result.ActivityResultLauncher;
7
11
  import androidx.appcompat.app.AppCompatActivity;
8
12
 
9
13
  import com.aigens.sdk.WebContainerActivity;
14
+ import com.getcapacitor.JSArray;
10
15
  import com.getcapacitor.JSObject;
11
16
  import com.getcapacitor.Plugin;
12
17
  import com.getcapacitor.PluginCall;
@@ -18,6 +23,8 @@ import org.json.JSONException;
18
23
  import java.io.Serializable;
19
24
  import java.util.HashMap;
20
25
  import java.util.Iterator;
26
+ import java.util.List;
27
+ import java.util.Locale;
21
28
  import java.util.Map;
22
29
 
23
30
  @CapacitorPlugin(name = "Core")
@@ -27,20 +34,20 @@ public class CorePlugin extends Plugin {
27
34
 
28
35
  private static Map member;
29
36
 
30
- private void debug(Object msg){
37
+ private void debug(Object msg) {
31
38
 
32
- if(DEBUG){
39
+ if (DEBUG) {
33
40
  System.out.println(msg);
34
41
  }
35
42
 
36
43
  }
37
44
 
38
- public static void setMember(Map member){
45
+ public static void setMember(Map member) {
39
46
  CorePlugin.member = member;
40
47
  }
41
48
 
42
49
  @Override
43
- protected void handleOnStart(){
50
+ protected void handleOnStart() {
44
51
 
45
52
  }
46
53
 
@@ -90,16 +97,16 @@ public class CorePlugin extends Plugin {
90
97
 
91
98
  String url = call.getString("url");
92
99
 
93
- if(url == null) return;
100
+ if (url == null) return;
94
101
 
95
102
  JSObject options = call.getObject("options", null);
96
103
  JSObject member = call.getObject("member", null);
97
104
 
98
105
  Map memMap = new HashMap();
99
106
 
100
- if(member != null){
107
+ if (member != null) {
101
108
  Iterator<String> iter = member.keys();
102
- while(iter.hasNext()){
109
+ while (iter.hasNext()) {
103
110
  String k = iter.next();
104
111
  try {
105
112
  Object v = member.get(k);
@@ -115,9 +122,20 @@ public class CorePlugin extends Plugin {
115
122
 
116
123
  Intent intent = new Intent(act, WebContainerActivity.class);
117
124
 
125
+ JSArray externalProtocols = call.getArray("externalProtocols");
126
+ try {
127
+ if (externalProtocols != null) {
128
+ List<String> es = externalProtocols.toList();
129
+ intent.putExtra("externalProtocols", (Serializable) es);
130
+ }
131
+ } catch (JSONException e) {
132
+ e.printStackTrace();
133
+ }
134
+
118
135
  intent.putExtra("url", url);
119
136
  intent.putExtra("member", (Serializable) memMap);
120
137
 
138
+
121
139
  act.startActivity(intent);
122
140
 
123
141
  JSObject ret = new JSObject();
@@ -125,4 +143,52 @@ public class CorePlugin extends Plugin {
125
143
  call.resolve(ret);
126
144
  }
127
145
 
146
+ @PluginMethod
147
+ public void openExternalUrl(PluginCall call) {
148
+ String url = call.getString("url");
149
+ if (url == null) {
150
+ call.reject("missing the url");
151
+ return;
152
+ }
153
+
154
+ final Intent intentExternal = new Intent();
155
+ intentExternal.setAction(Intent.ACTION_VIEW);
156
+ intentExternal.setData(Uri.parse(url));
157
+ Activity act = getActivity();
158
+ act.startActivity(intentExternal);
159
+ JSObject ret = new JSObject();
160
+ ret.put("open", true);
161
+ call.resolve(ret);
162
+ }
163
+
164
+ @PluginMethod
165
+ public void isInstalledApp(PluginCall call) {
166
+ String packname = call.getString("key");
167
+ Activity act = getActivity();
168
+ if (packname == null) {
169
+ call.reject("key is missing or is invaild key");
170
+ return;
171
+ }
172
+
173
+ try {
174
+ JSObject object = new JSObject();
175
+ final PackageManager packageManager = act.getPackageManager();// 获取packagemanager
176
+ List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);// 获取所有已安装程序的包信息
177
+ object.put("install", false);
178
+ if (pinfo != null && packname != null) {
179
+ packname = packname.toLowerCase(Locale.ENGLISH);
180
+ for (int i = 0; i < pinfo.size(); i++) {
181
+ String pn = pinfo.get(i).packageName.toLowerCase(Locale.ENGLISH);
182
+ if (pn.equals(packname)) {
183
+ object.put("install", true);
184
+ }
185
+ }
186
+ }
187
+ call.resolve(object);
188
+ } catch (Exception e) {
189
+ e.printStackTrace();
190
+ call.reject("key is missing or is invaild key");
191
+ }
192
+ }
193
+
128
194
  }
package/dist/docs.json CHANGED
@@ -84,6 +84,38 @@
84
84
  "docs": "",
85
85
  "complexTypes": [],
86
86
  "slug": "openbrowser"
87
+ },
88
+ {
89
+ "name": "isInstalledApp",
90
+ "signature": "(options: { key: string; }) => Promise<{ install: boolean; }>",
91
+ "parameters": [
92
+ {
93
+ "name": "options",
94
+ "docs": "",
95
+ "type": "{ key: string; }"
96
+ }
97
+ ],
98
+ "returns": "Promise<{ install: boolean; }>",
99
+ "tags": [],
100
+ "docs": "",
101
+ "complexTypes": [],
102
+ "slug": "isinstalledapp"
103
+ },
104
+ {
105
+ "name": "openExternalUrl",
106
+ "signature": "(options: { url: string; }) => Promise<any>",
107
+ "parameters": [
108
+ {
109
+ "name": "options",
110
+ "docs": "",
111
+ "type": "{ url: string; }"
112
+ }
113
+ ],
114
+ "returns": "Promise<any>",
115
+ "tags": [],
116
+ "docs": "",
117
+ "complexTypes": [],
118
+ "slug": "openexternalurl"
87
119
  }
88
120
  ],
89
121
  "properties": []
@@ -4,4 +4,12 @@ export interface CorePlugin {
4
4
  finish(options: any): Promise<any>;
5
5
  getMember(options: any): Promise<any>;
6
6
  openBrowser(options: any): Promise<any>;
7
+ isInstalledApp(options: {
8
+ key: string;
9
+ }): Promise<{
10
+ install: boolean;
11
+ }>;
12
+ openExternalUrl(options: {
13
+ url: string;
14
+ }): Promise<any>;
7
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface CorePlugin {\n echo(options: any): Promise<any>;\n dismiss(options: any): Promise<any>;\n finish(options: any): Promise<any>;\n getMember(options: any): Promise<any>;\n openBrowser(options: any): Promise<any>;\n\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface CorePlugin {\n echo(options: any): Promise<any>;\n dismiss(options: any): Promise<any>;\n finish(options: any): Promise<any>;\n getMember(options: any): Promise<any>;\n openBrowser(options: any): Promise<any>;\n isInstalledApp(options: { key: string }): Promise<{install: boolean}>;\n openExternalUrl(options: { url: string }): Promise<any>;\n\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -6,4 +6,12 @@ export declare class CoreWeb extends WebPlugin implements CorePlugin {
6
6
  dismiss(options: any): Promise<any>;
7
7
  finish(options: any): Promise<any>;
8
8
  openBrowser(options: any): Promise<any>;
9
+ isInstalledApp(options: {
10
+ key: string;
11
+ }): Promise<{
12
+ install: boolean;
13
+ }>;
14
+ openExternalUrl(options: {
15
+ url: string;
16
+ }): Promise<any>;
9
17
  }
package/dist/esm/web.js CHANGED
@@ -24,5 +24,15 @@ export class CoreWeb extends WebPlugin {
24
24
  console.log(options);
25
25
  throw new Error('Method not implemented.');
26
26
  }
27
+ async isInstalledApp(options) {
28
+ console.log(options);
29
+ throw new Error('Method not implemented.');
30
+ }
31
+ async openExternalUrl(options) {
32
+ window.open(options.url, "_blank");
33
+ return {
34
+ open: true
35
+ };
36
+ }
27
37
  }
28
38
  //# sourceMappingURL=web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,OAAQ,SAAQ,SAAS;IAClC,KAAK,CAAC,IAAI,CAAC,OAAY;QACnB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAY;;QACxB,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACnC,IAAI,MAAM,GAAG,EAAS,CAAC;QACvB,IAAI,CAAC,GAAG,MAAa,CAAC;QACtB,MAAM,CAAC,MAAM,eAAG,CAAC,CAAC,MAAM,0CAAE,OAAO,0CAAE,MAAM,CAAC;QAC1C,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAY;QACtB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAY;QACrB,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC/B,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAY;QAC1B,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;CAGJ","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport type { CorePlugin } from './definitions';\n\n\nexport class CoreWeb extends WebPlugin implements CorePlugin {\n async echo(options: any): Promise<any> {\n console.log('ECHO', options);\n return options;\n }\n\n async getMember(options: any): Promise<any> {\n console.log('GET MEMBER', options);\n var result = {} as any;\n var w = window as any;\n result.member = w.aigens?.context?.member;\n return result;\n }\n\n async dismiss(options: any): Promise<any> {\n console.log('DISMISS', options);\n return options;\n }\n\n async finish(options: any): Promise<any> {\n console.log('FINISH', options);\n return options;\n }\n\n async openBrowser(options: any): Promise<any> {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n\n\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,OAAQ,SAAQ,SAAS;IAClC,KAAK,CAAC,IAAI,CAAC,OAAY;QACnB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAY;;QACxB,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACnC,IAAI,MAAM,GAAG,EAAS,CAAC;QACvB,IAAI,CAAC,GAAG,MAAa,CAAC;QACtB,MAAM,CAAC,MAAM,eAAG,CAAC,CAAC,MAAM,0CAAE,OAAO,0CAAE,MAAM,CAAC;QAC1C,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAY;QACtB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAY;QACrB,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC/B,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAY;QAC1B,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAAwB;QACzC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAAwB;QAC1C,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACnC,OAAO;YACH,IAAI,EAAE,IAAI;SACb,CAAA;IACL,CAAC;CAGJ","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport type { CorePlugin } from './definitions';\n\n\nexport class CoreWeb extends WebPlugin implements CorePlugin {\n async echo(options: any): Promise<any> {\n console.log('ECHO', options);\n return options;\n }\n\n async getMember(options: any): Promise<any> {\n console.log('GET MEMBER', options);\n var result = {} as any;\n var w = window as any;\n result.member = w.aigens?.context?.member;\n return result;\n }\n\n async dismiss(options: any): Promise<any> {\n console.log('DISMISS', options);\n return options;\n }\n\n async finish(options: any): Promise<any> {\n console.log('FINISH', options);\n return options;\n }\n\n async openBrowser(options: any): Promise<any> {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n\n async isInstalledApp(options: { key: string }): Promise<{install: boolean}> {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n\n async openExternalUrl(options: { url: string }): Promise<any> {\n window.open(options.url, \"_blank\");\n return {\n open: true\n }\n }\n\n\n}\n"]}
@@ -33,6 +33,16 @@ class CoreWeb extends core.WebPlugin {
33
33
  console.log(options);
34
34
  throw new Error('Method not implemented.');
35
35
  }
36
+ async isInstalledApp(options) {
37
+ console.log(options);
38
+ throw new Error('Method not implemented.');
39
+ }
40
+ async openExternalUrl(options) {
41
+ window.open(options.url, "_blank");
42
+ return {
43
+ open: true
44
+ };
45
+ }
36
46
  }
37
47
 
38
48
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Core = registerPlugin('Core', {\n web: () => import('./web').then(m => new m.CoreWeb()),\n});\nexport * from './definitions';\nexport { Core };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CoreWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async getMember(options) {\n var _a, _b;\n console.log('GET MEMBER', options);\n var result = {};\n var w = window;\n result.member = (_b = (_a = w.aigens) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.member;\n return result;\n }\n async dismiss(options) {\n console.log('DISMISS', options);\n return options;\n }\n async finish(options) {\n console.log('FINISH', options);\n return options;\n }\n async openBrowser(options) {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,IAAI,GAAGA,mBAAc,CAAC,MAAM,EAAE;AACpC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AACzD,CAAC;;ACFM,MAAM,OAAO,SAASC,cAAS,CAAC;AACvC,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE;AAC7B,QAAQ,IAAI,EAAE,EAAE,EAAE,CAAC;AACnB,QAAQ,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AAC3C,QAAQ,IAAI,MAAM,GAAG,EAAE,CAAC;AACxB,QAAQ,IAAI,CAAC,GAAG,MAAM,CAAC;AACvB,QAAQ,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,MAAM,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;AAC9I,QAAQ,OAAO,MAAM,CAAC;AACtB,KAAK;AACL,IAAI,MAAM,OAAO,CAAC,OAAO,EAAE;AAC3B,QAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACxC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;AAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACvC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;AAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Core = registerPlugin('Core', {\n web: () => import('./web').then(m => new m.CoreWeb()),\n});\nexport * from './definitions';\nexport { Core };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CoreWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async getMember(options) {\n var _a, _b;\n console.log('GET MEMBER', options);\n var result = {};\n var w = window;\n result.member = (_b = (_a = w.aigens) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.member;\n return result;\n }\n async dismiss(options) {\n console.log('DISMISS', options);\n return options;\n }\n async finish(options) {\n console.log('FINISH', options);\n return options;\n }\n async openBrowser(options) {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n async isInstalledApp(options) {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n async openExternalUrl(options) {\n window.open(options.url, \"_blank\");\n return {\n open: true\n };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,IAAI,GAAGA,mBAAc,CAAC,MAAM,EAAE;AACpC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AACzD,CAAC;;ACFM,MAAM,OAAO,SAASC,cAAS,CAAC;AACvC,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE;AAC7B,QAAQ,IAAI,EAAE,EAAE,EAAE,CAAC;AACnB,QAAQ,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AAC3C,QAAQ,IAAI,MAAM,GAAG,EAAE,CAAC;AACxB,QAAQ,IAAI,CAAC,GAAG,MAAM,CAAC;AACvB,QAAQ,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,MAAM,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;AAC9I,QAAQ,OAAO,MAAM,CAAC;AACtB,KAAK;AACL,IAAI,MAAM,OAAO,CAAC,OAAO,EAAE;AAC3B,QAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACxC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;AAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACvC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;AAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,MAAM,cAAc,CAAC,OAAO,EAAE;AAClC,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,MAAM,eAAe,CAAC,OAAO,EAAE;AACnC,QAAQ,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC3C,QAAQ,OAAO;AACf,YAAY,IAAI,EAAE,IAAI;AACtB,SAAS,CAAC;AACV,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -30,6 +30,16 @@ var capacitorCore = (function (exports, core) {
30
30
  console.log(options);
31
31
  throw new Error('Method not implemented.');
32
32
  }
33
+ async isInstalledApp(options) {
34
+ console.log(options);
35
+ throw new Error('Method not implemented.');
36
+ }
37
+ async openExternalUrl(options) {
38
+ window.open(options.url, "_blank");
39
+ return {
40
+ open: true
41
+ };
42
+ }
33
43
  }
34
44
 
35
45
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Core = registerPlugin('Core', {\n web: () => import('./web').then(m => new m.CoreWeb()),\n});\nexport * from './definitions';\nexport { Core };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CoreWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async getMember(options) {\n var _a, _b;\n console.log('GET MEMBER', options);\n var result = {};\n var w = window;\n result.member = (_b = (_a = w.aigens) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.member;\n return result;\n }\n async dismiss(options) {\n console.log('DISMISS', options);\n return options;\n }\n async finish(options) {\n console.log('FINISH', options);\n return options;\n }\n async openBrowser(options) {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,IAAI,GAAGA,mBAAc,CAAC,MAAM,EAAE;IACpC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;IACzD,CAAC;;ICFM,MAAM,OAAO,SAASC,cAAS,CAAC;IACvC,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE;IAC7B,QAAQ,IAAI,EAAE,EAAE,EAAE,CAAC;IACnB,QAAQ,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC3C,QAAQ,IAAI,MAAM,GAAG,EAAE,CAAC;IACxB,QAAQ,IAAI,CAAC,GAAG,MAAM,CAAC;IACvB,QAAQ,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,MAAM,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAC9I,QAAQ,OAAO,MAAM,CAAC;IACtB,KAAK;IACL,IAAI,MAAM,OAAO,CAAC,OAAO,EAAE;IAC3B,QAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACxC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;IAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Core = registerPlugin('Core', {\n web: () => import('./web').then(m => new m.CoreWeb()),\n});\nexport * from './definitions';\nexport { Core };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CoreWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async getMember(options) {\n var _a, _b;\n console.log('GET MEMBER', options);\n var result = {};\n var w = window;\n result.member = (_b = (_a = w.aigens) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.member;\n return result;\n }\n async dismiss(options) {\n console.log('DISMISS', options);\n return options;\n }\n async finish(options) {\n console.log('FINISH', options);\n return options;\n }\n async openBrowser(options) {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n async isInstalledApp(options) {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n async openExternalUrl(options) {\n window.open(options.url, \"_blank\");\n return {\n open: true\n };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,IAAI,GAAGA,mBAAc,CAAC,MAAM,EAAE;IACpC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;IACzD,CAAC;;ICFM,MAAM,OAAO,SAASC,cAAS,CAAC;IACvC,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE;IAC7B,QAAQ,IAAI,EAAE,EAAE,EAAE,CAAC;IACnB,QAAQ,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC3C,QAAQ,IAAI,MAAM,GAAG,EAAE,CAAC;IACxB,QAAQ,IAAI,CAAC,GAAG,MAAM,CAAC;IACvB,QAAQ,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,MAAM,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAC9I,QAAQ,OAAO,MAAM,CAAC;IACtB,KAAK;IACL,IAAI,MAAM,OAAO,CAAC,OAAO,EAAE;IAC3B,QAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACxC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;IAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL,IAAI,MAAM,cAAc,CAAC,OAAO,EAAE;IAClC,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL,IAAI,MAAM,eAAe,CAAC,OAAO,EAAE;IACnC,QAAQ,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC3C,QAAQ,OAAO;IACf,YAAY,IAAI,EAAE,IAAI;IACtB,SAAS,CAAC;IACV,KAAK;IACL;;;;;;;;;;;;;;;;;"}
@@ -9,4 +9,6 @@ CAP_PLUGIN(CorePlugin, "Core",
9
9
  CAP_PLUGIN_METHOD(finish, CAPPluginReturnPromise);
10
10
  CAP_PLUGIN_METHOD(openBrowser, CAPPluginReturnPromise);
11
11
  CAP_PLUGIN_METHOD(getMember, CAPPluginReturnPromise);
12
+ CAP_PLUGIN_METHOD(isInstalledApp, CAPPluginReturnPromise);
13
+ CAP_PLUGIN_METHOD(openExternalUrl, CAPPluginReturnPromise);
12
14
  )
@@ -8,24 +8,24 @@ import UIKit
8
8
  */
9
9
  @objc(CorePlugin)
10
10
  public class CorePlugin: CAPPlugin {
11
-
11
+
12
12
  private let implementation = Core()
13
13
  public static var member: Dictionary<String, Any>?
14
-
14
+
15
15
  @objc func echo(_ call: CAPPluginCall) {
16
16
 
17
17
  print("CorePlugin echo")
18
-
18
+
19
19
  let value = call.getString("value") ?? ""
20
20
  call.resolve([
21
21
  "value": implementation.echo(value)
22
22
  ])
23
-
24
-
23
+
24
+
25
25
  }
26
-
26
+
27
27
  @objc func dismiss(_ call: CAPPluginCall) {
28
-
28
+
29
29
  print("CorePlugin dismiss")
30
30
 
31
31
  DispatchQueue.main.async {
@@ -38,8 +38,8 @@ public class CorePlugin: CAPPlugin {
38
38
  "success": true
39
39
  //"value": implementation.echo(value)
40
40
  ])
41
-
42
-
41
+
42
+
43
43
  }
44
44
 
45
45
  @objc func getMember(_ call: CAPPluginCall) {
@@ -52,7 +52,7 @@ public class CorePlugin: CAPPlugin {
52
52
  @objc func finish(_ call: CAPPluginCall) {
53
53
 
54
54
  print("CorePlugin finish")
55
-
55
+
56
56
  DispatchQueue.main.async {
57
57
  self.bridge?.viewController?.dismiss(animated: true);
58
58
  }
@@ -69,27 +69,31 @@ public class CorePlugin: CAPPlugin {
69
69
  @objc func openBrowser(_ call: CAPPluginCall) {
70
70
 
71
71
  print("CorePlugin openBrowser")
72
-
72
+
73
73
  let url = call.getString("url")
74
74
 
75
75
 
76
76
  if(url == nil){
77
77
  return
78
78
  }
79
-
79
+
80
80
  let member = call.getObject("member")
81
-
81
+ let externalProtocols = call.getArray("externalProtocols")
82
+
82
83
  DispatchQueue.main.async {
83
84
 
84
85
  let bridgeVC = WebContainerViewController()
85
86
 
86
87
  var options = [String: AnyObject]()
87
88
  options["url"] = url as AnyObject;
88
-
89
+
89
90
  if(member != nil){
90
91
  options["member"] = member as AnyObject;
91
92
  }
92
-
93
+ if (externalProtocols != nil) {
94
+ options["externalProtocols"] = externalProtocols as AnyObject
95
+ }
96
+
93
97
  bridgeVC.options = options;
94
98
 
95
99
  bridgeVC.modalPresentationStyle = .fullScreen
@@ -104,6 +108,39 @@ public class CorePlugin: CAPPlugin {
104
108
  ])
105
109
  }
106
110
 
111
+ @objc func isInstalledApp(_ call: CAPPluginCall) {
112
+ if let url = call.getString("key"), let URL_ = URL(string: url) {
113
+ let can = UIApplication.shared.canOpenURL(URL_)
114
+ call.resolve([
115
+ "install": can
116
+ ])
117
+ }else {
118
+ call.reject("key is missing or is invaild key")
119
+ return
120
+ }
121
+ }
122
+
123
+ @objc func openExternalUrl(_ call: CAPPluginCall) {
124
+ if let url = call.getString("url"), let URL_ = URL(string: url) {
125
+ let can = UIApplication.shared.canOpenURL(URL_)
126
+ if !can {
127
+ call.reject("cannot open the url:\(url)")
128
+ return;
129
+ }
130
+ if #available(iOS 10.0, *) {
131
+ UIApplication.shared.open(URL_, options: [:], completionHandler: nil)
132
+ } else {
133
+ UIApplication.shared.openURL(URL_)
134
+ }
135
+ call.resolve([
136
+ "open": true
137
+ ])
138
+
139
+ }else {
140
+ call.reject("url is missing or is invaild url")
141
+ return
142
+ }
143
+ }
107
144
 
108
145
 
109
146
 
@@ -0,0 +1,83 @@
1
+ //
2
+ // WebContainer.swift
3
+ // AigensSdkCore
4
+ //
5
+ // Created by 陈培爵 on 2022/6/7.
6
+ //
7
+
8
+ import UIKit
9
+
10
+ class WebContainer: UIView {
11
+ @IBOutlet weak var activity: UIActivityIndicatorView!
12
+
13
+ @IBOutlet weak var errorWrapper: UIView!
14
+
15
+ @IBOutlet weak var errorTextView: UITextView!
16
+
17
+ public weak var vc: WebContainerViewController?
18
+
19
+ public func setTheme(_ color: String) {
20
+ if let color = UIColor.getHex(hex: color) {
21
+ self.backgroundColor = color
22
+ }
23
+ }
24
+ override func awakeFromNib() {
25
+ super.awakeFromNib()
26
+ print("awakeFromNib")
27
+ }
28
+
29
+ private func hiddenSelf() {
30
+ self.alpha = 1.0
31
+ UIView.animate(withDuration: 0.5, animations: {
32
+ self.alpha = 0
33
+ })
34
+ }
35
+
36
+ public func showLoading(_ show: Bool) {
37
+ if show {
38
+ self.alpha = 1.0
39
+ activity.isHidden = false
40
+ activity.backgroundColor = .clear
41
+ activity.color = .darkGray
42
+ activity.alpha = 1.0
43
+ }else {
44
+ hiddenSelf()
45
+ activity?.isHidden = true
46
+ }
47
+ }
48
+ public func showError(_ show: Bool, _ error: String? = nil) {
49
+ if let e = error {
50
+ errorTextView?.text = e
51
+ }
52
+ if show {
53
+ errorWrapper?.isHidden = false
54
+ self.alpha = 1.0
55
+ }else {
56
+ errorWrapper?.isHidden = true
57
+ self.alpha = 0
58
+ }
59
+
60
+ }
61
+
62
+ /*
63
+ // Only override draw() if you perform custom drawing.
64
+ // An empty implementation adversely affects performance during animation.
65
+ override func draw(_ rect: CGRect) {
66
+ // Drawing code
67
+ }
68
+ */
69
+ @IBAction func dismiss(_ sender: UIButton) {
70
+ self.vc?.dismiss(animated: true);
71
+ }
72
+
73
+ @IBAction func reload(_ sender: UIButton) {
74
+ self.vc?.webView?.reload()
75
+ }
76
+ }
77
+
78
+ extension WebContainer {
79
+ class func webContainer() -> WebContainer {
80
+ let bundle = Bundle(for: WebContainer.self)
81
+ return bundle.loadNibNamed("WebContainer", owner: self, options: nil)?.first as! WebContainer
82
+ }
83
+ }
@@ -0,0 +1,113 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3
+ <device id="retina6_1" orientation="portrait" appearance="light"/>
4
+ <dependencies>
5
+ <deployment identifier="iOS"/>
6
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
7
+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
8
+ <capability name="System colors in document resources" minToolsVersion="11.0"/>
9
+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
10
+ </dependencies>
11
+ <objects>
12
+ <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
13
+ <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
14
+ <view contentMode="scaleToFill" id="iN0-l3-epB" customClass="WebContainer" customModule="Plugin" customModuleProvider="target">
15
+ <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
16
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
17
+ <subviews>
18
+ <activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" animating="YES" style="large" translatesAutoresizingMaskIntoConstraints="NO" id="QRW-cT-ZYH">
19
+ <rect key="frame" x="188.5" y="119" width="37" height="37"/>
20
+ <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
21
+ <color key="color" systemColor="secondaryLabelColor"/>
22
+ </activityIndicatorView>
23
+ <view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9XO-W2-mxO" userLabel="errorWrapper">
24
+ <rect key="frame" x="0.0" y="206" width="414" height="690"/>
25
+ <subviews>
26
+ <view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XSc-rN-cN8">
27
+ <rect key="frame" x="206.5" y="560" width="1" height="100"/>
28
+ <color key="backgroundColor" systemColor="systemBackgroundColor"/>
29
+ <constraints>
30
+ <constraint firstAttribute="width" constant="1" id="JtJ-kb-hPE"/>
31
+ <constraint firstAttribute="height" constant="100" id="SFb-3i-Gvl"/>
32
+ </constraints>
33
+ </view>
34
+ <button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Rie-2B-ejA" userLabel="reload">
35
+ <rect key="frame" x="237.5" y="579" width="70" height="31"/>
36
+ <color key="backgroundColor" systemColor="linkColor"/>
37
+ <state key="normal" title="Button"/>
38
+ <buttonConfiguration key="configuration" style="filled" title="Reload">
39
+ <color key="baseForegroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
40
+ </buttonConfiguration>
41
+ <connections>
42
+ <action selector="reload:" destination="iN0-l3-epB" eventType="touchUpInside" id="PwX-vF-t6u"/>
43
+ </connections>
44
+ </button>
45
+ <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" text="Got some errors, please try again later." textAlignment="center" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8vI-mF-YrJ">
46
+ <rect key="frame" x="30" y="30" width="354" height="519"/>
47
+ <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
48
+ <color key="textColor" systemColor="systemPinkColor"/>
49
+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
50
+ <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
51
+ </textView>
52
+ <button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3jG-Lv-8dD" userLabel="back">
53
+ <rect key="frame" x="120.5" y="579" width="70" height="31"/>
54
+ <color key="backgroundColor" systemColor="linkColor"/>
55
+ <state key="normal" title="Button"/>
56
+ <buttonConfiguration key="configuration" style="filled" title="Back">
57
+ <color key="baseForegroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
58
+ </buttonConfiguration>
59
+ <connections>
60
+ <action selector="dismiss:" destination="iN0-l3-epB" eventType="touchUpInside" id="uVj-47-Wse"/>
61
+ </connections>
62
+ </button>
63
+ </subviews>
64
+ <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
65
+ <constraints>
66
+ <constraint firstItem="8vI-mF-YrJ" firstAttribute="leading" secondItem="9XO-W2-mxO" secondAttribute="leading" constant="30" id="AS7-Ga-vyq"/>
67
+ <constraint firstItem="Rie-2B-ejA" firstAttribute="leading" secondItem="XSc-rN-cN8" secondAttribute="trailing" constant="30" id="CyI-hc-XkI"/>
68
+ <constraint firstItem="3jG-Lv-8dD" firstAttribute="bottom" secondItem="Rie-2B-ejA" secondAttribute="bottom" id="HAh-cE-mQ6"/>
69
+ <constraint firstItem="XSc-rN-cN8" firstAttribute="leading" secondItem="3jG-Lv-8dD" secondAttribute="trailing" constant="30" id="PAe-EE-twu"/>
70
+ <constraint firstAttribute="bottom" secondItem="XSc-rN-cN8" secondAttribute="bottom" constant="30" id="RPJ-VJ-HXw"/>
71
+ <constraint firstAttribute="bottom" secondItem="3jG-Lv-8dD" secondAttribute="bottom" constant="80" id="Upv-ms-zNA"/>
72
+ <constraint firstItem="8vI-mF-YrJ" firstAttribute="top" secondItem="9XO-W2-mxO" secondAttribute="top" constant="30" id="YIP-1g-G6E"/>
73
+ <constraint firstItem="3jG-Lv-8dD" firstAttribute="top" secondItem="8vI-mF-YrJ" secondAttribute="bottom" constant="30" id="aeR-w6-BjA"/>
74
+ <constraint firstItem="8vI-mF-YrJ" firstAttribute="centerX" secondItem="9XO-W2-mxO" secondAttribute="centerX" id="kmK-Va-dvk"/>
75
+ <constraint firstAttribute="trailing" secondItem="8vI-mF-YrJ" secondAttribute="trailing" constant="30" id="mUr-wg-3M2"/>
76
+ <constraint firstItem="XSc-rN-cN8" firstAttribute="centerX" secondItem="9XO-W2-mxO" secondAttribute="centerX" id="pNO-0x-6Wm"/>
77
+ </constraints>
78
+ </view>
79
+ </subviews>
80
+ <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
81
+ <color key="backgroundColor" systemColor="systemBackgroundColor"/>
82
+ <constraints>
83
+ <constraint firstItem="QRW-cT-ZYH" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="75" id="R5H-tF-5z7"/>
84
+ <constraint firstItem="9XO-W2-mxO" firstAttribute="top" secondItem="QRW-cT-ZYH" secondAttribute="bottom" constant="50" id="X4C-yj-HyP"/>
85
+ <constraint firstAttribute="bottom" secondItem="9XO-W2-mxO" secondAttribute="bottom" id="cOL-UR-HYb"/>
86
+ <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="9XO-W2-mxO" secondAttribute="trailing" id="fAe-qZ-xE4"/>
87
+ <constraint firstItem="9XO-W2-mxO" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="haw-0Q-SQQ"/>
88
+ <constraint firstItem="QRW-cT-ZYH" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="lwz-JW-uoD"/>
89
+ </constraints>
90
+ <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
91
+ <connections>
92
+ <outlet property="activity" destination="QRW-cT-ZYH" id="fKy-zs-iDE"/>
93
+ <outlet property="errorTextView" destination="8vI-mF-YrJ" id="4uw-Iq-Axh"/>
94
+ <outlet property="errorWrapper" destination="9XO-W2-mxO" id="ipj-rF-hT1"/>
95
+ </connections>
96
+ <point key="canvasLocation" x="137.68115942028987" y="102.45535714285714"/>
97
+ </view>
98
+ </objects>
99
+ <resources>
100
+ <systemColor name="linkColor">
101
+ <color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
102
+ </systemColor>
103
+ <systemColor name="secondaryLabelColor">
104
+ <color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
105
+ </systemColor>
106
+ <systemColor name="systemBackgroundColor">
107
+ <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
108
+ </systemColor>
109
+ <systemColor name="systemPinkColor">
110
+ <color red="1" green="0.17647058823529413" blue="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
111
+ </systemColor>
112
+ </resources>
113
+ </document>
@@ -11,15 +11,99 @@ import Capacitor
11
11
 
12
12
  @objc open class WebContainerViewController: CAPBridgeViewController {
13
13
 
14
+ // {themeColor: "#xxxxxx"}
14
15
  public var options: Dictionary<String, Any>?
15
-
16
+
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://"
19
+ ]
20
+ let containerView = WebContainer.webContainer()
21
+ var webContainerView: WebContainer {
22
+ return containerView
23
+ }
16
24
  override open func viewDidLoad() {
17
25
 
18
26
  print("WebContainerViewController viewDidLoad")
19
27
 
20
28
  self.becomeFirstResponder()
21
29
  loadWebViewCustom()
22
- //loadWebView()
30
+ initView()
31
+
32
+ }
33
+
34
+ private func initView(){
35
+
36
+ print("VC initView")
37
+
38
+ //let bundle = Bundle(for: WebContainerViewController.self)
39
+ //let containerView = WebContainerView()
40
+ //let containerView = bundle.loadNibNamed("WebContainerView", owner: self, options: nil)?.first as! UIView
41
+
42
+ self.view.addSubview(webContainerView)
43
+ webContainerView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height)
44
+ setupOptions(webContainerView)
45
+ containerView.vc = self
46
+
47
+ //
48
+ //
49
+
50
+
51
+ // let containerView = WebContainerView()
52
+ // self.view = containerView
53
+ //
54
+ // //containerView.frame = self.view!.bounds
55
+ // containerView.backgroundColor = UIColor.red
56
+ // containerView.translatesAutoresizingMaskIntoConstraints = false
57
+ //
58
+ // let webview = self.webView
59
+ // webview?.frame = containerView.webArea!.bounds
60
+ // webview?.frame.size = containerView.webArea.frame.size
61
+ // containerView.webArea.addSubview(self.webView!)
62
+ //
63
+
64
+
65
+ }
66
+
67
+ open override func viewWillLayoutSubviews() {
68
+ super.viewWillLayoutSubviews()
69
+ webContainerView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height)
70
+ }
71
+
72
+ private func setupOptions(_ view: WebContainer) {
73
+ if let theme = self.options?["themeColor"] as? String, let color = UIColor.getHex(hex: theme) {
74
+ self.view.backgroundColor = color
75
+ self.webView?.backgroundColor = color
76
+ self.webView?.scrollView.backgroundColor = color
77
+ view.setTheme(theme)
78
+ }
79
+ if let externalProtocols = options?["externalProtocols"] as? [String] {
80
+ self.externalProtocols.append(contentsOf: externalProtocols)
81
+ }
82
+
83
+ }
84
+
85
+ public final func loadWebViewCustom() {
86
+
87
+ //let bridge = self.bridge
88
+ //let plugins = self.bridge["plugins"]
89
+
90
+
91
+ let urlString = self.options?["url"] as? String;
92
+
93
+ if(urlString == nil){
94
+ return;
95
+ }
96
+
97
+ let url = URL(string: urlString!)
98
+
99
+ let member = self.options?["member"] as? Dictionary<String, Any>
100
+
101
+ CorePlugin.member = member
102
+
103
+ //bridge.webViewDelegationHandler.willLoadWebview(webView)
104
+ _ = webView?.load(URLRequest(url: url!))
105
+ webView?.navigationDelegate = self
106
+
23
107
  }
24
108
 
25
109
  //this method overwrite parent to return a desc with custom config.json
@@ -48,29 +132,153 @@ import Capacitor
48
132
 
49
133
  return descriptor
50
134
  }
135
+
136
+ deinit {
137
+ print("WebContainerViewController deinit")
138
+ }
51
139
 
52
- public final func loadWebViewCustom() {
53
-
54
- //let bridge = self.bridge
55
- //let plugins = self.bridge["plugins"]
56
-
140
+
141
+ }
57
142
 
58
- let urlString = self.options?["url"] as? String;
143
+ extension WebContainerViewController: WKNavigationDelegate {
144
+ // The force unwrap is part of the protocol declaration, so we should keep it.
145
+ // swiftlint:disable:next implicitly_unwrapped_optional
146
+ public func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
147
+ // Reset the bridge on each navigation
148
+ // self.bridge?.reset()
149
+ }
150
+
151
+ public func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
152
+ webContainerView.showError(false)
153
+ webContainerView.showLoading(true)
154
+ }
155
+
156
+ public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
157
+ // post a notification for any listeners
158
+ NotificationCenter.default.post(name: .capacitorDecidePolicyForNavigationAction, object: navigationAction)
59
159
 
60
- if(urlString == nil){
61
- return;
160
+ // sanity check, these shouldn't ever be nil in practice
161
+ guard let bridge = bridge, let navURL = navigationAction.request.url else {
162
+ decisionHandler(.allow)
163
+ return
62
164
  }
63
-
64
- let url = URL(string: urlString!)
65
-
66
- let member = self.options?["member"] as? Dictionary<String, Any>
67
165
 
68
- CorePlugin.member = member
166
+ var isCanOpen = false
167
+ if externalProtocols.count > 0 {
168
+ externalProtocols.forEach { (url) in
169
+ if (navURL.absoluteString.starts(with: url)) {
170
+ isCanOpen = UIApplication.shared.canOpenURL(navURL) ;
171
+ return;
172
+ }
173
+ }
174
+ }
69
175
 
176
+ if isCanOpen {
177
+ if #available(iOS 10.0, *) {
178
+ UIApplication.shared.open(navURL, options: [:], completionHandler: nil);
179
+ } else {
180
+ UIApplication.shared.openURL(navURL)
181
+ }
182
+ decisionHandler(.cancel)
183
+ return;
184
+ }
70
185
 
71
- //bridge.webViewDelegationHandler.willLoadWebview(webView)
72
- _ = webView?.load(URLRequest(url: url!))
73
186
 
187
+ // first, give plugins the chance to handle the decision
188
+ // for pluginObject in bridge.plugins {
189
+ // let plugin = pluginObject.value
190
+ // let selector = NSSelectorFromString("shouldOverrideLoad:")
191
+ // if plugin.responds(to: selector) {
192
+ // let shouldOverrideLoad = plugin.shouldOverrideLoad(navigationAction)
193
+ // if shouldOverrideLoad != nil {
194
+ // if shouldOverrideLoad == true {
195
+ // decisionHandler(.cancel)
196
+ // return
197
+ // } else if shouldOverrideLoad == false {
198
+ // decisionHandler(.allow)
199
+ // return
200
+ // }
201
+ // }
202
+ // }
203
+ // }
204
+
205
+ // next, check if this is covered by the allowedNavigation configuration
206
+ if let host = navURL.host, bridge.config.shouldAllowNavigation(to: host) {
207
+ decisionHandler(.allow)
208
+ return
209
+ }
210
+
211
+ // otherwise, is this a new window or a main frame navigation but to an outside source
212
+ let toplevelNavigation = (navigationAction.targetFrame == nil || navigationAction.targetFrame?.isMainFrame == true)
213
+ if navURL.absoluteString.contains(bridge.config.serverURL.absoluteString) == false, toplevelNavigation {
214
+ // disallow and let the system handle it
215
+ if UIApplication.shared.applicationState == .active {
216
+ UIApplication.shared.open(navURL, options: [:], completionHandler: nil)
217
+ }
218
+ decisionHandler(.cancel)
219
+ return
220
+ }
221
+
222
+ // fallthrough to allowing it
223
+ decisionHandler(.allow)
224
+ }
225
+
226
+
227
+ // The force unwrap is part of the protocol declaration, so we should keep it.
228
+ // swiftlint:disable:next implicitly_unwrapped_optional
229
+ public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
230
+ // if case .initialLoad(let isOpaque) = webViewLoadingState {
231
+ // webView.isOpaque = isOpaque
232
+ // webViewLoadingState = .subsequentLoad
233
+ // }
234
+ webContainerView.showLoading(false)
235
+ webContainerView.showError(false)
236
+ CAPLog.print("⚡️ WebView loaded")
237
+ }
238
+
239
+ // The force unwrap is part of the protocol declaration, so we should keep it.
240
+ // swiftlint:disable:next implicitly_unwrapped_optional
241
+ public func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
242
+ // if case .initialLoad(let isOpaque) = webViewLoadingState {
243
+ // webView.isOpaque = isOpaque
244
+ // webViewLoadingState = .subsequentLoad
245
+ // }
246
+ webContainerView.showLoading(false)
247
+
248
+ webContainerView.showError(true, error.localizedDescription)
249
+ CAPLog.print("⚡️ WebView failed to load")
250
+ CAPLog.print("⚡️ Error: " + error.localizedDescription)
251
+ }
252
+
253
+ // The force unwrap is part of the protocol declaration, so we should keep it.
254
+ // swiftlint:disable:next implicitly_unwrapped_optional
255
+ public func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
256
+ webContainerView.showLoading(false)
257
+ // cancel
258
+ let e = error as NSError
259
+ if (e.code == NSURLErrorCancelled || e.code == -999) {
260
+ webContainerView.showError(false)
261
+ }
262
+ CAPLog.print("⚡️ WebView failed provisional navigation")
263
+ CAPLog.print("⚡️ Error: " + error.localizedDescription)
264
+ webContainerView.showError(true, error.localizedDescription)
265
+ }
266
+
267
+ public func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
268
+ webView.reload()
269
+ }
270
+ }
74
271
 
272
+ extension UIColor {
273
+ static func getHex(hex: String, _ alpha: CGFloat = 1.0) -> UIColor? {
274
+ guard !hex.isEmpty && hex.hasPrefix("#") else { return nil }
275
+ var rgbValue: UInt32 = 0
276
+ let scanner = Scanner(string: hex)
277
+ scanner.scanLocation = 1
278
+ guard scanner.scanHexInt32(&rgbValue) else { return nil }
279
+ return UIColor(red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
280
+ green: CGFloat((rgbValue & 0xFF00) >> 8) / 255.0,
281
+ blue: CGFloat((rgbValue & 0xFF)) / 255.0,
282
+ alpha: alpha);
75
283
  }
76
284
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigens/aigens-sdk-core",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Aigens Order.Place Core Plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -74,5 +74,8 @@
74
74
  "android": {
75
75
  "src": "android"
76
76
  }
77
+ },
78
+ "dependencies": {
79
+ "aigens-mono": "file:../.."
77
80
  }
78
81
  }