@aigens/aigens-sdk-core 0.0.3 → 0.0.5

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.
package/README.md CHANGED
@@ -15,6 +15,7 @@ npx cap sync
15
15
 
16
16
  * [`echo(...)`](#echo)
17
17
  * [`finish(...)`](#finish)
18
+ * [`getMember(...)`](#getmember)
18
19
  * [`openBrowser(...)`](#openbrowser)
19
20
  * [`scan(...)`](#scan)
20
21
 
@@ -53,6 +54,21 @@ finish(options: any) => Promise<any>
53
54
  --------------------
54
55
 
55
56
 
57
+ ### getMember(...)
58
+
59
+ ```typescript
60
+ getMember(options: any) => Promise<any>
61
+ ```
62
+
63
+ | Param | Type |
64
+ | ------------- | ---------------- |
65
+ | **`options`** | <code>any</code> |
66
+
67
+ **Returns:** <code>Promise&lt;any&gt;</code>
68
+
69
+ --------------------
70
+
71
+
56
72
  ### openBrowser(...)
57
73
 
58
74
  ```typescript
@@ -1,3 +1,3 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="com.aigens.sdk.plugins">
2
+ package="com.aigens.sdk">
3
3
  </manifest>
@@ -5,16 +5,23 @@ import android.content.res.AssetManager;
5
5
  import android.graphics.Bitmap;
6
6
  import android.net.Uri;
7
7
  import android.os.Bundle;
8
+ import android.view.View;
9
+ import android.webkit.WebResourceError;
8
10
  import android.webkit.WebResourceRequest;
9
11
  import android.webkit.WebResourceResponse;
10
12
  import android.webkit.WebView;
11
13
  import android.webkit.WebViewClient;
14
+ import android.widget.Button;
12
15
 
16
+ import com.aigens.sdk.plugins.CorePlugin;
17
+ import com.getcapacitor.Bridge;
13
18
  import com.getcapacitor.BridgeActivity;
19
+ import com.getcapacitor.BridgeWebViewClient;
14
20
  import com.getcapacitor.CapConfig;
15
21
  import com.getcapacitor.Plugin;
16
22
  import com.getcapacitor.PluginLoadException;
17
23
  import com.getcapacitor.PluginManager;
24
+ import com.aigens.sdk.R;
18
25
 
19
26
  import org.json.JSONException;
20
27
  import org.json.JSONObject;
@@ -25,9 +32,26 @@ import java.io.InputStream;
25
32
  import java.io.InputStreamReader;
26
33
  import java.util.ArrayList;
27
34
  import java.util.List;
35
+ import java.util.Map;
28
36
 
29
37
  public class WebContainerActivity extends BridgeActivity {
30
38
 
39
+ private boolean DEBUG = CorePlugin.DEBUG;
40
+ private String url;
41
+ private boolean navbar = false;
42
+ private Map member;
43
+
44
+ private void debug(Object... msgs){
45
+
46
+
47
+ if(DEBUG){
48
+ for(Object m: msgs){
49
+ System.out.println(m);
50
+ }
51
+
52
+ }
53
+ }
54
+
31
55
 
32
56
 
33
57
  @Override
@@ -35,8 +59,19 @@ public class WebContainerActivity extends BridgeActivity {
35
59
 
36
60
  super.onCreate(savedInstanceState);
37
61
 
62
+ setContentView(R.layout.sdk_layout_main);
63
+
38
64
  Intent intent = getIntent();
39
- String url = intent.getStringExtra("URL");
65
+ this.url = intent.getStringExtra("url");
66
+
67
+ //if navbar = true, show nav bar with "Done" button
68
+ this.navbar = intent.getBooleanExtra("navbar", false);
69
+
70
+ this.member = (Map) intent.getSerializableExtra("member");
71
+
72
+ if(this.member != null) {
73
+ CorePlugin.setMember(this.member);
74
+ }
40
75
 
41
76
  System.out.println("OPEN URL:"+ url);
42
77
 
@@ -44,8 +79,14 @@ public class WebContainerActivity extends BridgeActivity {
44
79
  System.err.println("CONFIG ERROR MISSING NATIVE URL");
45
80
  }
46
81
 
82
+ if(member != null){
83
+ debug("member", member);
84
+ }
85
+
47
86
  JSONObject config = readConfig();
48
87
 
88
+ debug("config", config);
89
+
49
90
  JSONObject server = config.optJSONObject("server");
50
91
 
51
92
  try {
@@ -53,6 +94,9 @@ public class WebContainerActivity extends BridgeActivity {
53
94
  server.putOpt("url", url);
54
95
  }
55
96
 
97
+ //need to set this to avoid loading ServiceWorker
98
+ config.put("appendUserAgent", "AigensSDK");
99
+
56
100
  } catch (JSONException e) {
57
101
  e.printStackTrace();
58
102
  }
@@ -66,7 +110,6 @@ public class WebContainerActivity extends BridgeActivity {
66
110
  for(Class c: auto){
67
111
 
68
112
  String clsName = c.getName();
69
- //System.err.println("auto loaded plugins:" + clsName);
70
113
 
71
114
  if(clsName.endsWith("SplashScreenPlugin")){
72
115
  //don't add the splash screen plugin so it doesn't show the splash screen again
@@ -76,18 +119,73 @@ public class WebContainerActivity extends BridgeActivity {
76
119
 
77
120
  }
78
121
 
79
- //plugins.addAll(auto);
80
-
81
- //plugins.add(CorePlugin2.class);
82
- //plugins.add(AppPlugin.class);
83
- //plugins.add(GeolocationPlugin.class);
122
+ debug("App plugins:" + plugins);
84
123
 
85
124
  super.init(savedInstanceState, plugins, cc);
86
125
 
87
126
  //still have time to override webview client to avoid any intercept
88
- BypassWebViewClient wvc = new BypassWebViewClient();
127
+
128
+ BypassWebViewClient wvc = new BypassWebViewClient(this.bridge);
89
129
  this.bridge.getWebView().setWebViewClient(wvc);
90
130
 
131
+ initView();
132
+ initLayout(false, true, false);
133
+ }
134
+
135
+ private void initView(){
136
+
137
+ Button backButton = (Button) findViewById(R.id.back);
138
+ backButton.setOnClickListener(new View.OnClickListener() {
139
+ @Override
140
+ public void onClick(View arg0) {
141
+
142
+ debug("Back Clicked");
143
+ WebContainerActivity.this.finish();
144
+ }
145
+ });
146
+
147
+ Button reloadButton = (Button) findViewById(R.id.reload);
148
+ reloadButton.setOnClickListener(new View.OnClickListener() {
149
+ @Override
150
+ public void onClick(View arg0) {
151
+
152
+ debug("Reload Clicked");
153
+ reload();
154
+ }
155
+ });
156
+
157
+ }
158
+
159
+ private void reload(){
160
+
161
+ String url = this.url;
162
+
163
+ /*
164
+ if(DEBUG){
165
+ url = "https://test.order.place/test/app/store/500?nocache=true";
166
+ }*/
167
+
168
+ this.initLayout(false, true, false);
169
+ this.bridge.getWebView().reload();
170
+
171
+ }
172
+
173
+ private void initLayout(boolean showWeb, boolean showInfo, boolean showError){
174
+
175
+ if(showError){
176
+ showWeb = false;
177
+ showInfo = false;
178
+ }
179
+
180
+ View info = findViewById(R.id.info);
181
+ info.setVisibility(showInfo ? View.VISIBLE : View.INVISIBLE);
182
+
183
+ View error = findViewById(R.id.error);
184
+ error.setVisibility(showError ? View.VISIBLE : View.INVISIBLE);
185
+
186
+ bridge.getWebView().setVisibility(showWeb ? View.VISIBLE : View.INVISIBLE);
187
+
188
+
91
189
  }
92
190
 
93
191
  private List<Class<? extends Plugin>> loadPlugins(){
@@ -154,37 +252,87 @@ public class WebContainerActivity extends BridgeActivity {
154
252
  }
155
253
 
156
254
  //BridgeWebViewClient
157
- class BypassWebViewClient extends WebViewClient {
255
+ class BypassWebViewClient extends BridgeWebViewClient {
158
256
 
257
+ public BypassWebViewClient(Bridge bridge) {
258
+ super(bridge);
259
+ }
260
+
261
+ //somehow this must call parent, otherwise plugins won't work
159
262
  @Override
160
263
  public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
161
264
 
162
- return null;
265
+
266
+ String url = request.getUrl().toString();
267
+ //debug("shouldInterceptRequest", url);
268
+
269
+
270
+ if(url.indexOf("//scan") > 0){
271
+ return null;
272
+ }
273
+
274
+ return super.shouldInterceptRequest(view, request);
275
+
276
+ //super.shouldInterceptRequest(view, request);
277
+ //return null;
163
278
  }
164
279
 
165
280
 
166
281
  @Override
167
282
  public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
168
- //System.err.println("shouldOverrideUrlLoading:" + request.getUrl());
283
+ debug("shouldOverrideUrlLoading", request.getUrl());
169
284
  //Uri url = request.getUrl();
285
+
286
+ //return super.shouldOverrideUrlLoading(view, request);
287
+
170
288
  return false;
171
289
  }
172
290
 
173
291
  @Override
174
292
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
175
- //System.err.println("shouldOverrideUrlLoadingOld:" + url);
293
+ debug("shouldOverrideUrlLoading", url);
176
294
  //return bridge.launchIntent(Uri.parse(url));
295
+
296
+ //return super.shouldOverrideUrlLoading(view, url);
297
+
177
298
  return false;
178
299
  }
179
300
 
180
301
  @Override
181
302
  public void onPageStarted(WebView view, String url, Bitmap favicon) {
182
303
 
183
- //System.err.println("onPageStarted:" + url);
304
+ debug("onPageStarted", url);
184
305
 
185
- //super.onPageStarted(view, url, favicon);
306
+ super.onPageStarted(view, url, favicon);
186
307
 
308
+ //bridge.getWebView().setVisibility(View.VISIBLE);
309
+ initLayout(true, false, false);
187
310
  }
311
+
312
+ @Override
313
+ public void onPageFinished (WebView view, String url){
314
+
315
+ debug("onPageFinished", url);
316
+ //bridge.getWebView().setVisibility(View.VISIBLE);
317
+ }
318
+
319
+ @Override
320
+ public void onReceivedError (WebView view, int errorCode, String description, String failingUrl){
321
+ debug("onReceivedErrorOld", errorCode, description, failingUrl);
322
+
323
+ initLayout(false, true, true);
324
+ }
325
+
326
+ /*
327
+ @Override
328
+ public void onReceivedError (WebView view,
329
+ WebResourceRequest request,
330
+ WebResourceError error){
331
+
332
+ debug("onReceivedError2", request.getUrl());
333
+ }*/
188
334
  }
189
335
 
336
+
337
+
190
338
  }
@@ -15,31 +15,69 @@ import com.getcapacitor.annotation.CapacitorPlugin;
15
15
  import com.journeyapps.barcodescanner.ScanContract;
16
16
  import com.journeyapps.barcodescanner.ScanOptions;
17
17
 
18
+ import org.json.JSONException;
19
+
20
+ import java.io.Serializable;
21
+ import java.util.HashMap;
22
+ import java.util.Iterator;
23
+ import java.util.Map;
24
+
18
25
  @CapacitorPlugin(name = "Core")
19
26
  public class CorePlugin extends Plugin {
20
27
 
28
+ public static boolean DEBUG = false;
29
+
30
+ private static Map member;
31
+
32
+ private void debug(Object msg){
33
+
34
+ if(DEBUG){
35
+ System.out.println(msg);
36
+ }
37
+
38
+ }
39
+
40
+ public static void setMember(Map member){
41
+ CorePlugin.member = member;
42
+ }
21
43
 
22
44
  @Override
23
45
  protected void handleOnStart(){
24
46
 
47
+ debug("CorePlugin handleOnStart");
48
+
25
49
  prepareScan();
50
+
51
+ debug("CorePlugin handleOnStart END");
26
52
  }
27
53
 
28
54
  @PluginMethod()
29
55
  public void echo(PluginCall call) {
30
56
  String value = call.getString("value");
31
57
 
58
+ debug("CorePlugin echo:" + value);
59
+
32
60
  JSObject ret = new JSObject();
33
61
  ret.put("value", value);
34
62
  call.resolve(ret);
35
63
  }
36
64
 
65
+ @PluginMethod()
66
+ public void getMember(PluginCall call) {
67
+
68
+ debug("CorePlugin getMember:" + member);
69
+
70
+ JSObject ret = new JSObject();
71
+ ret.put("member", member);
72
+ call.resolve(ret);
73
+ }
74
+
37
75
  private PluginCall scanCall;
38
76
 
39
77
  @PluginMethod()
40
78
  public void scan(PluginCall call) {
41
79
 
42
- System.err.println("SCANNING!!");
80
+ debug("SCANNING!!");
43
81
 
44
82
  this.scanCall = call;
45
83
  scanRaw();
@@ -59,13 +97,13 @@ public class CorePlugin extends Plugin {
59
97
  result -> {
60
98
 
61
99
  if(scanCall == null){
62
- System.err.println("Missing scan callback");
100
+ debug("Missing scan callback");
63
101
  return;
64
102
  }
65
103
 
66
104
  if(result.getContents() == null) {
67
105
  //Toast.makeText(MyActivity.this, "Cancelled", Toast.LENGTH_LONG).show();
68
- System.err.println("scan cancelled");
106
+ debug("scan cancelled");
69
107
  JSObject ret = new JSObject();
70
108
  ret.put("hasContent", false);
71
109
  ret.put("success", false);
@@ -74,7 +112,7 @@ public class CorePlugin extends Plugin {
74
112
  //Toast.makeText(MyActivity.this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show();
75
113
  String val = result.getContents();
76
114
 
77
- System.err.println("scan result:" + val);
115
+ debug("scan result:" + val);
78
116
 
79
117
  if(val != null && val.length() > 0){
80
118
 
@@ -132,12 +170,31 @@ public class CorePlugin extends Plugin {
132
170
  if(url == null) return;
133
171
 
134
172
  JSObject options = call.getObject("options", null);
173
+ JSObject member = call.getObject("member", null);
174
+
175
+ Map memMap = new HashMap();
176
+
177
+ if(member != null){
178
+ Iterator<String> iter = member.keys();
179
+ while(iter.hasNext()){
180
+ String k = iter.next();
181
+ try {
182
+ Object v = member.get(k);
183
+ memMap.put(k, v);
184
+ } catch (JSONException e) {
185
+ e.printStackTrace();
186
+ }
187
+
188
+ }
189
+ }
135
190
 
136
191
  Activity act = getActivity();
137
192
 
138
193
  Intent intent = new Intent(act, WebContainerActivity.class);
139
194
 
140
- intent.putExtra("URL", url);
195
+ intent.putExtra("url", url);
196
+ intent.putExtra("member", (Serializable) memMap);
197
+
141
198
  act.startActivity(intent);
142
199
 
143
200
  JSObject ret = new JSObject();
@@ -0,0 +1,55 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:app="http://schemas.android.com/apk/res-auto"
4
+ xmlns:tools="http://schemas.android.com/tools"
5
+ android:layout_width="match_parent"
6
+ android:layout_height="match_parent"
7
+ tools:context="com.getcapacitor.BridgeActivity"
8
+ >
9
+
10
+ <com.getcapacitor.CapacitorWebView
11
+ android:id="@+id/webview"
12
+ android:layout_width="fill_parent"
13
+ android:layout_height="fill_parent">
14
+
15
+ </com.getcapacitor.CapacitorWebView>
16
+
17
+ <LinearLayout
18
+ android:id="@+id/info"
19
+ android:layout_width="match_parent"
20
+ android:layout_height="match_parent"
21
+ android:gravity="center"
22
+ android:orientation="vertical">
23
+
24
+ <ProgressBar
25
+ android:id="@+id/progress"
26
+ style="?android:attr/progressBarStyle"
27
+ android:layout_width="match_parent"
28
+ android:layout_height="wrap_content" />
29
+
30
+ </LinearLayout>
31
+
32
+ <LinearLayout
33
+ android:id="@+id/error"
34
+ android:layout_width="match_parent"
35
+ android:layout_height="match_parent"
36
+ android:gravity="center"
37
+ android:orientation="horizontal">
38
+
39
+ <Button
40
+ android:id="@+id/back"
41
+ android:layout_width="wrap_content"
42
+ android:layout_height="wrap_content"
43
+ android:layout_marginRight="8dp"
44
+ android:text="Exit" />
45
+
46
+ <Button
47
+ android:id="@+id/reload"
48
+ android:layout_width="wrap_content"
49
+ android:layout_height="wrap_content"
50
+ android:text="Reload" />
51
+
52
+ </LinearLayout>
53
+
54
+
55
+ </FrameLayout>
package/dist/docs.json CHANGED
@@ -37,6 +37,22 @@
37
37
  "complexTypes": [],
38
38
  "slug": "finish"
39
39
  },
40
+ {
41
+ "name": "getMember",
42
+ "signature": "(options: any) => Promise<any>",
43
+ "parameters": [
44
+ {
45
+ "name": "options",
46
+ "docs": "",
47
+ "type": "any"
48
+ }
49
+ ],
50
+ "returns": "Promise<any>",
51
+ "tags": [],
52
+ "docs": "",
53
+ "complexTypes": [],
54
+ "slug": "getmember"
55
+ },
40
56
  {
41
57
  "name": "openBrowser",
42
58
  "signature": "(options: any) => Promise<any>",
@@ -1,6 +1,7 @@
1
1
  export interface CorePlugin {
2
2
  echo(options: any): Promise<any>;
3
3
  finish(options: any): Promise<any>;
4
+ getMember(options: any): Promise<any>;
4
5
  openBrowser(options: any): Promise<any>;
5
6
  scan(options: any): Promise<any>;
6
7
  }
@@ -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 finish(options: any): Promise<any>;\n openBrowser(options: any): Promise<any>;\n scan(options: any): Promise<any>;\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 finish(options: any): Promise<any>;\n getMember(options: any): Promise<any>;\n openBrowser(options: any): Promise<any>;\n scan(options: any): Promise<any>;\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -2,6 +2,7 @@ import { WebPlugin } from '@capacitor/core';
2
2
  import type { CorePlugin } from './definitions';
3
3
  export declare class CoreWeb extends WebPlugin implements CorePlugin {
4
4
  echo(options: any): Promise<any>;
5
+ getMember(options: any): Promise<any>;
5
6
  finish(options: any): Promise<any>;
6
7
  openBrowser(options: any): Promise<any>;
7
8
  scan(options: any): Promise<any>;
package/dist/esm/web.js CHANGED
@@ -4,6 +4,14 @@ export class CoreWeb extends WebPlugin {
4
4
  console.log('ECHO', options);
5
5
  return options;
6
6
  }
7
+ async getMember(options) {
8
+ var _a, _b;
9
+ console.log('GET MEMBER', options);
10
+ var result = {};
11
+ var w = window;
12
+ result.member = (_b = (_a = w.aigens) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.member;
13
+ return result;
14
+ }
7
15
  async finish(options) {
8
16
  console.log('FINISH', options);
9
17
  return options;
@@ -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,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,IAAI,CAAC,OAAY;QACnB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;CACJ","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CorePlugin } from './definitions';\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 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 scan(options: any): Promise<any> {\n console.log(options);\n throw new Error('Method not implemented.');\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,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,IAAI,CAAC,OAAY;QACnB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;CACJ","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 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 scan(options: any): Promise<any> {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n}\n"]}
@@ -13,6 +13,14 @@ class CoreWeb extends core.WebPlugin {
13
13
  console.log('ECHO', options);
14
14
  return options;
15
15
  }
16
+ async getMember(options) {
17
+ var _a, _b;
18
+ console.log('GET MEMBER', options);
19
+ var result = {};
20
+ var w = window;
21
+ result.member = (_b = (_a = w.aigens) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.member;
22
+ return result;
23
+ }
16
24
  async finish(options) {
17
25
  console.log('FINISH', options);
18
26
  return options;
@@ -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 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 scan(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,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,IAAI,CAAC,OAAO,EAAE;AACxB,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 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 scan(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,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,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -10,6 +10,14 @@ var capacitorCore = (function (exports, core) {
10
10
  console.log('ECHO', options);
11
11
  return options;
12
12
  }
13
+ async getMember(options) {
14
+ var _a, _b;
15
+ console.log('GET MEMBER', options);
16
+ var result = {};
17
+ var w = window;
18
+ result.member = (_b = (_a = w.aigens) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.member;
19
+ return result;
20
+ }
13
21
  async finish(options) {
14
22
  console.log('FINISH', options);
15
23
  return options;
@@ -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 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 scan(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,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,IAAI,CAAC,OAAO,EAAE;IACxB,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 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 scan(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,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,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL;;;;;;;;;;;;;;;;;"}
@@ -8,4 +8,5 @@ CAP_PLUGIN(CorePlugin, "Core",
8
8
  CAP_PLUGIN_METHOD(finish, CAPPluginReturnPromise);
9
9
  CAP_PLUGIN_METHOD(openBrowser, CAPPluginReturnPromise);
10
10
  CAP_PLUGIN_METHOD(scan, CAPPluginReturnPromise);
11
+ CAP_PLUGIN_METHOD(getMember, CAPPluginReturnPromise);
11
12
  )
@@ -9,79 +9,95 @@ import UIKit
9
9
  */
10
10
  @objc(CorePlugin)
11
11
  public class CorePlugin: CAPPlugin, AVCaptureMetadataOutputObjectsDelegate {
12
+
12
13
  private let implementation = Core()
13
-
14
+ public static var member: Dictionary<String, Any>?
15
+
14
16
  @objc func echo(_ call: CAPPluginCall) {
15
-
17
+
16
18
  let value = call.getString("value") ?? ""
17
19
  call.resolve([
18
20
  "value": implementation.echo(value)
19
21
  ])
22
+
23
+
20
24
  }
21
-
22
-
25
+
26
+ @objc func getMember(_ call: CAPPluginCall) {
27
+
28
+ call.resolve([
29
+ "member": CorePlugin.member!
30
+ ])
31
+ }
32
+
23
33
  @objc func finish(_ call: CAPPluginCall) {
24
-
34
+
25
35
  DispatchQueue.main.async {
26
36
  self.bridge?.viewController?.dismiss(animated: true);
27
37
  }
28
-
29
-
38
+
39
+
30
40
  //let value = call.getString("value") ?? ""
31
41
  call.resolve([
32
42
  "success": true
33
43
  //"value": implementation.echo(value)
34
44
  ])
35
45
  }
36
-
46
+
37
47
  @objc func scan(_ call: CAPPluginCall) {
38
-
48
+
39
49
  let cancelButton = call.getString("cancelButton")
40
50
  if(cancelButton != nil){
41
51
  self.cancelText = cancelButton!
42
52
  }else{
43
53
  self.cancelText = "Cancel"
44
54
  }
45
-
55
+
46
56
  DispatchQueue.main.async {
47
57
  self.loadScan()
48
58
  self.startScan(call)
49
59
  }
50
60
  }
51
-
52
-
61
+
62
+
53
63
  @objc func openBrowser(_ call: CAPPluginCall) {
54
-
64
+
55
65
  let url = call.getString("url")
56
-
57
-
66
+
67
+
58
68
  if(url == nil){
59
69
  return
60
70
  }
61
71
 
72
+ let member = call.getObject("member")
73
+
62
74
  DispatchQueue.main.async {
63
-
75
+
64
76
  let bridgeVC = WebContainerViewController()
65
-
77
+
66
78
  var options = [String: AnyObject]()
67
79
  options["url"] = url as AnyObject;
68
-
69
- bridgeVC.options = options;
70
80
 
81
+ if(member != nil){
82
+ options["member"] = member as AnyObject;
83
+ }
84
+
85
+ bridgeVC.options = options;
86
+
71
87
  bridgeVC.modalPresentationStyle = .fullScreen
72
88
  let currentVC = self.bridge?.viewController;
73
89
  currentVC?.present(bridgeVC, animated: true);
74
90
  }
75
-
76
-
91
+
92
+
77
93
  call.resolve([
78
94
  "success": true
79
95
  //"value": implementation.echo(value)
80
96
  ])
81
97
  }
82
-
98
+
83
99
  //SCAN PLAUGIN HERE
84
-
100
+
85
101
  class CameraView: UIView {
86
102
  var videoPreviewLayer:AVCaptureVideoPreviewLayer?
87
103
 
@@ -201,41 +217,41 @@ public class CorePlugin: CAPPlugin, AVCaptureMetadataOutputObjectsDelegate {
201
217
  case frontCameraUnavailable
202
218
  case couldNotCaptureInput(error: NSError)
203
219
  }
204
-
220
+
205
221
  @objc func buttonTapped( _ button : UIButton)
206
222
  {
207
-
223
+
208
224
  self.destroy()
209
225
  }
210
-
211
-
226
+
227
+
212
228
 
213
229
  private func loadScan() {
214
-
230
+
215
231
  if(self.cameraView != nil){
216
232
  return
217
233
  }
218
-
219
-
234
+
235
+
220
236
  self.cameraView = CameraView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height))
221
237
  self.cameraView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
222
-
238
+
223
239
  let button = UIButton()
224
240
  //button.backgroundColor = UIColor.orange
225
-
241
+
226
242
  //let iconImage = UIImage(named: "search")
227
243
  //button.setImage(iconImage, for: .normal)
228
-
244
+
229
245
  button.setTitle("< " + self.cancelText, for: .normal)
230
246
  button.contentMode = UIView.ContentMode.scaleToFill
231
247
  button.frame = CGRect(x: 20, y: 10, width:200 , height:100)
232
248
  button.titleLabel?.textColor = UIColor.white
233
249
  button.contentHorizontalAlignment = .left
234
-
250
+
235
251
  button.addTarget(self, action: #selector(self.buttonTapped(_:)), for: UIControl.Event.touchUpInside)
236
-
252
+
237
253
  self.cancelButton = button
238
-
254
+
239
255
  }
240
256
 
241
257
  private func hasCameraPermission() -> Bool {
@@ -245,14 +261,14 @@ public class CorePlugin: CAPPlugin, AVCaptureMetadataOutputObjectsDelegate {
245
261
  }
246
262
  return false
247
263
  }
248
-
264
+
249
265
  private func addViews(){
250
266
  self.webView!.superview!.insertSubview(cameraView, aboveSubview: self.webView!)
251
267
  self.webView!.superview!.insertSubview(cancelButton, aboveSubview: cameraView)
252
268
  }
253
-
269
+
254
270
  private func removeViews(){
255
-
271
+
256
272
  DispatchQueue.main.async {
257
273
  self.cancelButton.removeFromSuperview()
258
274
  self.cameraView.removeFromSuperview()
@@ -265,11 +281,11 @@ public class CorePlugin: CAPPlugin, AVCaptureMetadataOutputObjectsDelegate {
265
281
  var cameraDir = cameraDirection
266
282
  cameraView.backgroundColor = UIColor.clear
267
283
  //self.webView!.superview!.insertSubview(cameraView, belowSubview: self.webView!)
268
-
284
+
269
285
  //self.webView!.superview!.insertSubview(cameraView, aboveSubview: self.webView!)
270
286
  //self.webView!.superview!.insertSubview(cancelButton, aboveSubview: cameraView)
271
287
  addViews()
272
-
288
+
273
289
  let availableVideoDevices = discoverCaptureDevices()
274
290
  for device in availableVideoDevices {
275
291
  if device.position == AVCaptureDevice.Position.back {
@@ -391,9 +407,9 @@ public class CorePlugin: CAPPlugin, AVCaptureMetadataOutputObjectsDelegate {
391
407
  }
392
408
 
393
409
  private func destroy() {
394
-
410
+
395
411
  self.removeViews()
396
-
412
+
397
413
  self.showBackground()
398
414
 
399
415
  self.dismantleCamera()
@@ -466,7 +482,7 @@ public class CorePlugin: CAPPlugin, AVCaptureMetadataOutputObjectsDelegate {
466
482
  }
467
483
 
468
484
  private func showBackground() {
469
-
485
+
470
486
  /*
471
487
  DispatchQueue.main.async {
472
488
  let javascript = "document.documentElement.style.backgroundColor = ''"
@@ -636,6 +652,7 @@ public class CorePlugin: CAPPlugin, AVCaptureMetadataOutputObjectsDelegate {
636
652
  }
637
653
  }
638
654
 
655
+ /*
639
656
  @objc func openAppSettings(_ call: CAPPluginCall) {
640
657
  guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
641
658
  return
@@ -649,8 +666,9 @@ public class CorePlugin: CAPPlugin, AVCaptureMetadataOutputObjectsDelegate {
649
666
  }
650
667
  }
651
668
  }
669
+ */
652
670
 
653
- @objc func enableTorch(_ call: CAPPluginCall) {
671
+ @objc func enableTorch(_ call: CAPPluginCall) {
654
672
  guard let device = AVCaptureDevice.default(for: AVMediaType.video) else { return }
655
673
  guard device.hasTorch else { return }
656
674
  guard device.isTorchAvailable else { return }
@@ -10,36 +10,67 @@ import Capacitor
10
10
 
11
11
 
12
12
  @objc open class WebContainerViewController: CAPBridgeViewController {
13
-
14
- public var options: Dictionary<String, AnyObject>?
15
-
13
+
14
+ public var options: Dictionary<String, Any>?
15
+
16
16
  override open func viewDidLoad() {
17
-
17
+
18
18
  print("WebContainerViewController viewDidLoad")
19
-
19
+
20
20
  self.becomeFirstResponder()
21
21
  loadWebViewCustom()
22
22
  //loadWebView()
23
23
  }
24
-
25
-
24
+
25
+ //this method overwrite parent to return a desc with custom config.json
26
+ override open func instanceDescriptor() -> InstanceDescriptor {
27
+
28
+ //print("WebContainerViewController custom instanceDescriptor")
29
+
30
+ //let configLoc = Bundle.main.url(forResource: "capacitor.config", withExtension: "json")
31
+
32
+ //default config paths
33
+ var wwwLoc = Bundle.main.url(forResource: "public", withExtension: nil)
34
+ var configLoc = Bundle.main.url(forResource: "capacitor.config", withExtension: "json")
35
+
36
+ //if config is missing, it's a dynamic page, load config from sdk core
37
+ if(configLoc == nil){
38
+ configLoc = Bundle(for: WebContainerViewController.self).url(forResource: "capacitor.config", withExtension: "json")
39
+
40
+ //www folder will be dynamic, set to anything is ok
41
+ //wwwLoc = configLoc
42
+ wwwLoc = FileManager.default.temporaryDirectory
43
+ }
44
+
45
+
46
+ let descriptor = InstanceDescriptor.init(at: wwwLoc!, configuration: configLoc, cordovaConfiguration: nil)
47
+
48
+
49
+ return descriptor
50
+ }
51
+
26
52
  public final func loadWebViewCustom() {
27
-
53
+
28
54
  //let bridge = self.bridge
29
55
  //let plugins = self.bridge["plugins"]
30
-
31
-
56
+
57
+
32
58
  let urlString = self.options?["url"] as? String;
33
59
 
34
60
  if(urlString == nil){
35
61
  return;
36
62
  }
37
-
63
+
38
64
  let url = URL(string: urlString!)
39
-
65
+
66
+ let member = self.options?["member"] as? Dictionary<String, Any>
67
+
68
+ CorePlugin.member = member
69
+
70
+
40
71
  //bridge.webViewDelegationHandler.willLoadWebview(webView)
41
72
  _ = webView?.load(URLRequest(url: url!))
42
-
43
-
73
+
74
+
44
75
  }
45
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigens/aigens-sdk-core",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Aigens Order.Place Core Plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",