@capgo/inappbrowser 1.3.1 → 1.3.15
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 +41 -21
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +29 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +22 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +15 -2
- package/dist/docs.json +40 -0
- package/dist/esm/definitions.d.ts +19 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +3 -0
- package/dist/esm/web.js +4 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +4 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +4 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/InAppBrowserPlugin.swift +16 -2
- package/ios/Plugin/WKWebViewController.swift +13 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -19,6 +19,8 @@ import { InAppBrowser } from '@capgo/inappbrowser'
|
|
|
19
19
|
InAppBrowser.open({ url: "YOUR_URL" });
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
Web platform is not supported. Use `window.open` instead.
|
|
23
|
+
|
|
22
24
|
### Camera usage
|
|
23
25
|
|
|
24
26
|
if you need the Camera to work in Android, you need to add the following to your `AndroidManifest.xml` file:
|
|
@@ -38,6 +40,7 @@ Then the permission will be asked when the camera is used.
|
|
|
38
40
|
* [`getCookies(...)`](#getcookies)
|
|
39
41
|
* [`close()`](#close)
|
|
40
42
|
* [`openWebView(...)`](#openwebview)
|
|
43
|
+
* [`executeScript(...)`](#executescript)
|
|
41
44
|
* [`setUrl(...)`](#seturl)
|
|
42
45
|
* [`addListener('urlChangeEvent', ...)`](#addlistenerurlchangeevent)
|
|
43
46
|
* [`addListener('closeEvent', ...)`](#addlistenercloseevent)
|
|
@@ -138,6 +141,21 @@ Open url in a new webview with toolbars
|
|
|
138
141
|
--------------------
|
|
139
142
|
|
|
140
143
|
|
|
144
|
+
### executeScript(...)
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
executeScript({ code }: { code: string; }) => Promise<void>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Injects JavaScript code into the InAppBrowser window.
|
|
151
|
+
|
|
152
|
+
| Param | Type |
|
|
153
|
+
| --------- | ------------------------------ |
|
|
154
|
+
| **`__0`** | <code>{ code: string; }</code> |
|
|
155
|
+
|
|
156
|
+
--------------------
|
|
157
|
+
|
|
158
|
+
|
|
141
159
|
### setUrl(...)
|
|
142
160
|
|
|
143
161
|
```typescript
|
|
@@ -284,27 +302,29 @@ Reload the current web page.
|
|
|
284
302
|
|
|
285
303
|
#### OpenWebViewOptions
|
|
286
304
|
|
|
287
|
-
| Prop
|
|
288
|
-
|
|
|
289
|
-
| **`url`**
|
|
290
|
-
| **`headers`**
|
|
291
|
-
| **`shareDisclaimer`**
|
|
292
|
-
| **`toolbarType`**
|
|
293
|
-
| **`shareSubject`**
|
|
294
|
-
| **`title`**
|
|
295
|
-
| **`backgroundColor`**
|
|
296
|
-
| **`
|
|
297
|
-
| **`
|
|
298
|
-
| **`
|
|
299
|
-
| **`
|
|
300
|
-
| **`
|
|
301
|
-
| **`
|
|
302
|
-
| **`
|
|
303
|
-
| **`
|
|
304
|
-
| **`
|
|
305
|
-
| **`
|
|
306
|
-
| **`
|
|
307
|
-
| **`
|
|
305
|
+
| Prop | Type | Description | Default | Since |
|
|
306
|
+
| -------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | ------ |
|
|
307
|
+
| **`url`** | <code>string</code> | Target URL to load. | | 0.1.0 |
|
|
308
|
+
| **`headers`** | <code><a href="#headers">Headers</a></code> | <a href="#headers">Headers</a> to send with the request. | | 0.1.0 |
|
|
309
|
+
| **`shareDisclaimer`** | <code><a href="#disclaimeroptions">DisclaimerOptions</a></code> | share options | | 0.1.0 |
|
|
310
|
+
| **`toolbarType`** | <code><a href="#toolbartype">ToolBarType</a></code> | Toolbar type | <code>ToolBarType.DEFAULT</code> | 0.1.0 |
|
|
311
|
+
| **`shareSubject`** | <code>string</code> | Share subject | | 0.1.0 |
|
|
312
|
+
| **`title`** | <code>string</code> | Title of the browser | <code>'New Window'</code> | 0.1.0 |
|
|
313
|
+
| **`backgroundColor`** | <code><a href="#backgroundcolor">BackgroundColor</a></code> | Background color of the browser, only on IOS | <code>BackgroundColor.BLACK</code> | 0.1.0 |
|
|
314
|
+
| **`activeNativeNavigationForWebview`** | <code>boolean</code> | If true, active the native navigation within the webview, Android only | <code>false</code> | |
|
|
315
|
+
| **`disableGoBackOnNativeApplication`** | <code>boolean</code> | Disable the possibility to go back on native application, usefull to force user to stay on the webview, Android only | <code>false</code> | |
|
|
316
|
+
| **`isPresentAfterPageLoad`** | <code>boolean</code> | Open url in a new window fullscreen isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately. | <code>false</code> | 0.1.0 |
|
|
317
|
+
| **`isInspectable`** | <code>boolean</code> | Whether the website in the webview is inspectable or not, ios only | <code>false</code> | |
|
|
318
|
+
| **`isAnimated`** | <code>boolean</code> | Whether the webview opening is animated or not, ios only | <code>true</code> | |
|
|
319
|
+
| **`showReloadButton`** | <code>boolean</code> | Shows a reload button that reloads the web page | <code>false</code> | 1.0.15 |
|
|
320
|
+
| **`closeModal`** | <code>boolean</code> | CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately. | <code>false</code> | 1.1.0 |
|
|
321
|
+
| **`closeModalTitle`** | <code>string</code> | CloseModalTitle: title of the confirm when user clicks on close button, only on IOS | <code>'Close'</code> | 1.1.0 |
|
|
322
|
+
| **`closeModalDescription`** | <code>string</code> | CloseModalDescription: description of the confirm when user clicks on close button, only on IOS | <code>'Are you sure you want to close this window?'</code> | 1.1.0 |
|
|
323
|
+
| **`closeModalOk`** | <code>string</code> | CloseModalOk: text of the confirm button when user clicks on close button, only on IOS | <code>'Close'</code> | 1.1.0 |
|
|
324
|
+
| **`closeModalCancel`** | <code>string</code> | CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS | <code>'Cancel'</code> | 1.1.0 |
|
|
325
|
+
| **`visibleTitle`** | <code>boolean</code> | visibleTitle: if true the website title would be shown else shown empty | <code>true</code> | 1.2.5 |
|
|
326
|
+
| **`toolbarColor`** | <code>string</code> | toolbarColor: color of the toolbar in hex format | <code>'#ffffff''</code> | 1.2.5 |
|
|
327
|
+
| **`showArrow`** | <code>boolean</code> | showArrow: if true an arrow would be shown instead of cross for closing the window | <code>false</code> | 1.2.5 |
|
|
308
328
|
|
|
309
329
|
|
|
310
330
|
#### DisclaimerOptions
|
|
@@ -256,6 +256,12 @@ public class InAppBrowserPlugin
|
|
|
256
256
|
options.setShareDisclaimer(call.getObject("shareDisclaimer", null));
|
|
257
257
|
options.setShareSubject(call.getString("shareSubject", null));
|
|
258
258
|
options.setToolbarType(call.getString("toolbarType", ""));
|
|
259
|
+
options.setActiveNativeNavigationForWebview(
|
|
260
|
+
call.getBoolean("activeNativeNavigationForWebview", false)
|
|
261
|
+
);
|
|
262
|
+
options.setDisableGoBackOnNativeApplication(
|
|
263
|
+
call.getBoolean("disableGoBackOnNativeApplication", false)
|
|
264
|
+
);
|
|
259
265
|
options.setPresentAfterPageLoad(
|
|
260
266
|
call.getBoolean("isPresentAfterPageLoad", false)
|
|
261
267
|
);
|
|
@@ -314,6 +320,28 @@ public class InAppBrowserPlugin
|
|
|
314
320
|
);
|
|
315
321
|
}
|
|
316
322
|
|
|
323
|
+
@PluginMethod
|
|
324
|
+
public void executeScript(PluginCall call) {
|
|
325
|
+
String script = call.getString("code");
|
|
326
|
+
if (script == null || TextUtils.isEmpty(script)) {
|
|
327
|
+
call.reject("No script to run");
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (webViewDialog != null) {
|
|
331
|
+
this.getActivity()
|
|
332
|
+
.runOnUiThread(
|
|
333
|
+
new Runnable() {
|
|
334
|
+
@Override
|
|
335
|
+
public void run() {
|
|
336
|
+
webViewDialog.executeScript(script);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
call.resolve();
|
|
343
|
+
}
|
|
344
|
+
|
|
317
345
|
@PluginMethod
|
|
318
346
|
public void reload(PluginCall call) {
|
|
319
347
|
if (webViewDialog != null) {
|
|
@@ -343,6 +371,7 @@ public class InAppBrowserPlugin
|
|
|
343
371
|
new JSObject().put("url", webViewDialog.getUrl())
|
|
344
372
|
);
|
|
345
373
|
webViewDialog.dismiss();
|
|
374
|
+
webViewDialog.destroy();
|
|
346
375
|
webViewDialog = null;
|
|
347
376
|
}
|
|
348
377
|
}
|
|
@@ -16,6 +16,8 @@ public class Options {
|
|
|
16
16
|
private String toolbarType;
|
|
17
17
|
private JSObject shareDisclaimer;
|
|
18
18
|
private String shareSubject;
|
|
19
|
+
private boolean disableGoBackOnNativeApplication;
|
|
20
|
+
private boolean activeNativeNavigationForWebview;
|
|
19
21
|
private boolean isPresentAfterPageLoad;
|
|
20
22
|
private WebViewCallbacks callbacks;
|
|
21
23
|
private PluginCall pluginCall;
|
|
@@ -129,6 +131,26 @@ public class Options {
|
|
|
129
131
|
this.shareSubject = shareSubject;
|
|
130
132
|
}
|
|
131
133
|
|
|
134
|
+
public boolean getActiveNativeNavigationForWebview() {
|
|
135
|
+
return activeNativeNavigationForWebview;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
public void setActiveNativeNavigationForWebview(
|
|
139
|
+
boolean activeNativeNavigationForWebview
|
|
140
|
+
) {
|
|
141
|
+
this.activeNativeNavigationForWebview = activeNativeNavigationForWebview;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public boolean getDisableGoBackOnNativeApplication() {
|
|
145
|
+
return disableGoBackOnNativeApplication;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
public void setDisableGoBackOnNativeApplication(
|
|
149
|
+
boolean disableGoBackOnNativeApplication
|
|
150
|
+
) {
|
|
151
|
+
this.disableGoBackOnNativeApplication = disableGoBackOnNativeApplication;
|
|
152
|
+
}
|
|
153
|
+
|
|
132
154
|
public boolean isPresentAfterPageLoad() {
|
|
133
155
|
return isPresentAfterPageLoad;
|
|
134
156
|
}
|
|
@@ -167,10 +167,18 @@ public class WebViewDialog extends Dialog {
|
|
|
167
167
|
_webView.reload();
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
public void destroy() {
|
|
171
|
+
_webView.destroy();
|
|
172
|
+
}
|
|
173
|
+
|
|
170
174
|
public String getUrl() {
|
|
171
175
|
return _webView.getUrl();
|
|
172
176
|
}
|
|
173
177
|
|
|
178
|
+
public void executeScript(String script) {
|
|
179
|
+
_webView.evaluateJavascript(script, null);
|
|
180
|
+
}
|
|
181
|
+
|
|
174
182
|
public void setUrl(String url) {
|
|
175
183
|
Map<String, String> requestHeaders = new HashMap<>();
|
|
176
184
|
if (_options.getHeaders() != null) {
|
|
@@ -264,6 +272,7 @@ public class WebViewDialog extends Dialog {
|
|
|
264
272
|
// Close button clicked, do something
|
|
265
273
|
dismiss();
|
|
266
274
|
_options.getCallbacks().closeEvent(_webView.getUrl());
|
|
275
|
+
_webView.destroy();
|
|
267
276
|
}
|
|
268
277
|
}
|
|
269
278
|
)
|
|
@@ -272,6 +281,7 @@ public class WebViewDialog extends Dialog {
|
|
|
272
281
|
} else {
|
|
273
282
|
dismiss();
|
|
274
283
|
_options.getCallbacks().closeEvent(_webView.getUrl());
|
|
284
|
+
_webView.destroy();
|
|
275
285
|
}
|
|
276
286
|
}
|
|
277
287
|
}
|
|
@@ -397,10 +407,13 @@ public class WebViewDialog extends Dialog {
|
|
|
397
407
|
public void onBackPressed() {
|
|
398
408
|
if (
|
|
399
409
|
_webView.canGoBack() &&
|
|
400
|
-
|
|
410
|
+
(
|
|
411
|
+
TextUtils.equals(_options.getToolbarType(), "navigation") ||
|
|
412
|
+
_options.getActiveNativeNavigationForWebview()
|
|
413
|
+
)
|
|
401
414
|
) {
|
|
402
415
|
_webView.goBack();
|
|
403
|
-
} else {
|
|
416
|
+
} else if (!_options.getDisableGoBackOnNativeApplication()) {
|
|
404
417
|
super.onBackPressed();
|
|
405
418
|
}
|
|
406
419
|
}
|
package/dist/docs.json
CHANGED
|
@@ -112,6 +112,22 @@
|
|
|
112
112
|
],
|
|
113
113
|
"slug": "openwebview"
|
|
114
114
|
},
|
|
115
|
+
{
|
|
116
|
+
"name": "executeScript",
|
|
117
|
+
"signature": "({ code }: { code: string; }) => Promise<void>",
|
|
118
|
+
"parameters": [
|
|
119
|
+
{
|
|
120
|
+
"name": "__0",
|
|
121
|
+
"docs": "",
|
|
122
|
+
"type": "{ code: string; }"
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"returns": "Promise<void>",
|
|
126
|
+
"tags": [],
|
|
127
|
+
"docs": "Injects JavaScript code into the InAppBrowser window.",
|
|
128
|
+
"complexTypes": [],
|
|
129
|
+
"slug": "executescript"
|
|
130
|
+
},
|
|
115
131
|
{
|
|
116
132
|
"name": "setUrl",
|
|
117
133
|
"signature": "(options: { url: string; }) => Promise<any>",
|
|
@@ -498,6 +514,30 @@
|
|
|
498
514
|
],
|
|
499
515
|
"type": "BackgroundColor"
|
|
500
516
|
},
|
|
517
|
+
{
|
|
518
|
+
"name": "activeNativeNavigationForWebview",
|
|
519
|
+
"tags": [
|
|
520
|
+
{
|
|
521
|
+
"text": "false",
|
|
522
|
+
"name": "default"
|
|
523
|
+
}
|
|
524
|
+
],
|
|
525
|
+
"docs": "If true, active the native navigation within the webview, Android only",
|
|
526
|
+
"complexTypes": [],
|
|
527
|
+
"type": "boolean | undefined"
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
"name": "disableGoBackOnNativeApplication",
|
|
531
|
+
"tags": [
|
|
532
|
+
{
|
|
533
|
+
"text": "false",
|
|
534
|
+
"name": "default"
|
|
535
|
+
}
|
|
536
|
+
],
|
|
537
|
+
"docs": "Disable the possibility to go back on native application,\nusefull to force user to stay on the webview, Android only",
|
|
538
|
+
"complexTypes": [],
|
|
539
|
+
"type": "boolean | undefined"
|
|
540
|
+
},
|
|
501
541
|
{
|
|
502
542
|
"name": "isPresentAfterPageLoad",
|
|
503
543
|
"tags": [
|
|
@@ -101,6 +101,19 @@ export interface OpenWebViewOptions {
|
|
|
101
101
|
* @default BackgroundColor.BLACK
|
|
102
102
|
*/
|
|
103
103
|
backgroundColor?: BackgroundColor;
|
|
104
|
+
/**
|
|
105
|
+
* If true, active the native navigation within the webview, Android only
|
|
106
|
+
*
|
|
107
|
+
* @default false
|
|
108
|
+
*/
|
|
109
|
+
activeNativeNavigationForWebview?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Disable the possibility to go back on native application,
|
|
112
|
+
* usefull to force user to stay on the webview, Android only
|
|
113
|
+
*
|
|
114
|
+
* @default false
|
|
115
|
+
*/
|
|
116
|
+
disableGoBackOnNativeApplication?: boolean;
|
|
104
117
|
/**
|
|
105
118
|
* Open url in a new window fullscreen
|
|
106
119
|
*
|
|
@@ -210,6 +223,12 @@ export interface InAppBrowserPlugin {
|
|
|
210
223
|
* @since 0.1.0
|
|
211
224
|
*/
|
|
212
225
|
openWebView(options: OpenWebViewOptions): Promise<any>;
|
|
226
|
+
/**
|
|
227
|
+
* Injects JavaScript code into the InAppBrowser window.
|
|
228
|
+
*/
|
|
229
|
+
executeScript({ code }: {
|
|
230
|
+
code: string;
|
|
231
|
+
}): Promise<void>;
|
|
213
232
|
setUrl(options: {
|
|
214
233
|
url: string;
|
|
215
234
|
}): Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,8BAAe,CAAA;IACf,2BAAY,CAAA;AACd,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB","sourcesContent":["import type { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface UrlEvent {\n /**\n * Emit when the url changes\n *\n * @since 0.0.1\n */\n url: string;\n}\nexport interface BtnEvent {\n /**\n * Emit when a button is clicked.\n *\n * @since 0.0.1\n */\n url: string;\n}\n\nexport type UrlChangeListener = (state: UrlEvent) => void;\nexport type ConfirmBtnListener = (state: BtnEvent) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n ACTIVITY = \"activity\",\n NAVIGATION = \"navigation\",\n BLANK = \"blank\",\n DEFAULT = \"\",\n}\n\nexport interface Headers {\n [key: string]: string;\n}\n\nexport interface GetCookieOptions {\n url: string;\n includeHttpOnly?: boolean;\n}\n\nexport interface ClearCookieOptions {\n url: string;\n cache?: boolean;\n}\n\nexport interface OpenOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n */\n isPresentAfterPageLoad?: boolean;\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n title: string;\n message: string;\n confirmBtn: string;\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * share options\n * @since 0.1.0\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n */\n toolbarType?: ToolBarType;\n /**\n * Share subject\n * @since 0.1.0\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default 'New Window'\n */\n title?: string;\n /**\n * Background color of the browser, only on IOS\n * @since 0.1.0\n * @default BackgroundColor.BLACK\n */\n backgroundColor?: BackgroundColor;\n /**\n * Open url in a new window fullscreen\n *\n * isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n * @default false\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * Whether the website in the webview is inspectable or not, ios only\n *\n * @default false\n */\n isInspectable?: boolean;\n /**\n * Whether the webview opening is animated or not, ios only\n *\n * @default true\n */\n isAnimated?: boolean;\n /**\n * Shows a reload button that reloads the web page\n * @since 1.0.15\n * @default false\n */\n showReloadButton?: boolean;\n /**\n * CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately.\n *\n * @since 1.1.0\n * @default false\n */\n closeModal?: boolean;\n /**\n * CloseModalTitle: title of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalTitle?: string;\n /**\n * CloseModalDescription: description of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Are you sure you want to close this window?'\n */\n closeModalDescription?: string;\n /**\n * CloseModalOk: text of the confirm button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalOk?: string;\n /**\n * CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Cancel'\n */\n closeModalCancel?: string;\n /**\n * visibleTitle: if true the website title would be shown else shown empty\n *\n * @since 1.2.5\n * @default true\n */\n visibleTitle?: boolean;\n /**\n * toolbarColor: color of the toolbar in hex format\n *\n * @since 1.2.5\n * @default '#ffffff''\n */\n toolbarColor?: string;\n /**\n * showArrow: if true an arrow would be shown instead of cross for closing the window\n *\n * @since 1.2.5\n * @default false\n */\n showArrow?: boolean;\n}\n\nexport interface InAppBrowserPlugin {\n /**\n * Open url in a new window fullscreen\n *\n * @since 0.1.0\n */\n open(options: OpenOptions): Promise<any>;\n\n /**\n * Clear cookies of url\n *\n * @since 0.5.0\n */\n clearCookies(options: ClearCookieOptions): Promise<any>;\n\n /**\n * Get cookies for a specific URL.\n * @param options The options, including the URL to get cookies for.\n * @returns A promise that resolves with the cookies.\n */\n getCookies(options: GetCookieOptions): Promise<Record<string, string>>;\n\n close(): Promise<any>;\n /**\n * Open url in a new webview with toolbars\n *\n * @since 0.1.0\n */\n openWebView(options: OpenWebViewOptions): Promise<any>;\n setUrl(options: { url: string }): Promise<any>;\n /**\n * Listen for url change, only for openWebView\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"urlChangeEvent\",\n listenerFunc: UrlChangeListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Listen for close click only for openWebView\n *\n * @since 0.4.0\n */\n addListener(\n eventName: \"closeEvent\",\n listenerFunc: UrlChangeListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n /**\n * Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"confirmBtnClicked\",\n listenerFunc: ConfirmBtnListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Reload the current web page.\n *\n * @since 1.0.0\n */\n reload(): Promise<any>; // Add this line\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,8BAAe,CAAA;IACf,2BAAY,CAAA;AACd,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB","sourcesContent":["import type { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface UrlEvent {\n /**\n * Emit when the url changes\n *\n * @since 0.0.1\n */\n url: string;\n}\nexport interface BtnEvent {\n /**\n * Emit when a button is clicked.\n *\n * @since 0.0.1\n */\n url: string;\n}\n\nexport type UrlChangeListener = (state: UrlEvent) => void;\nexport type ConfirmBtnListener = (state: BtnEvent) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n ACTIVITY = \"activity\",\n NAVIGATION = \"navigation\",\n BLANK = \"blank\",\n DEFAULT = \"\",\n}\n\nexport interface Headers {\n [key: string]: string;\n}\n\nexport interface GetCookieOptions {\n url: string;\n includeHttpOnly?: boolean;\n}\n\nexport interface ClearCookieOptions {\n url: string;\n cache?: boolean;\n}\n\nexport interface OpenOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n */\n isPresentAfterPageLoad?: boolean;\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n title: string;\n message: string;\n confirmBtn: string;\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * share options\n * @since 0.1.0\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n */\n toolbarType?: ToolBarType;\n /**\n * Share subject\n * @since 0.1.0\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default 'New Window'\n */\n title?: string;\n /**\n * Background color of the browser, only on IOS\n * @since 0.1.0\n * @default BackgroundColor.BLACK\n */\n backgroundColor?: BackgroundColor;\n /**\n * If true, active the native navigation within the webview, Android only\n *\n * @default false\n */\n activeNativeNavigationForWebview?: boolean;\n /**\n * Disable the possibility to go back on native application,\n * usefull to force user to stay on the webview, Android only\n *\n * @default false\n */\n disableGoBackOnNativeApplication?: boolean;\n /**\n * Open url in a new window fullscreen\n *\n * isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n * @default false\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * Whether the website in the webview is inspectable or not, ios only\n *\n * @default false\n */\n isInspectable?: boolean;\n /**\n * Whether the webview opening is animated or not, ios only\n *\n * @default true\n */\n isAnimated?: boolean;\n /**\n * Shows a reload button that reloads the web page\n * @since 1.0.15\n * @default false\n */\n showReloadButton?: boolean;\n /**\n * CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately.\n *\n * @since 1.1.0\n * @default false\n */\n closeModal?: boolean;\n /**\n * CloseModalTitle: title of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalTitle?: string;\n /**\n * CloseModalDescription: description of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Are you sure you want to close this window?'\n */\n closeModalDescription?: string;\n /**\n * CloseModalOk: text of the confirm button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalOk?: string;\n /**\n * CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Cancel'\n */\n closeModalCancel?: string;\n /**\n * visibleTitle: if true the website title would be shown else shown empty\n *\n * @since 1.2.5\n * @default true\n */\n visibleTitle?: boolean;\n /**\n * toolbarColor: color of the toolbar in hex format\n *\n * @since 1.2.5\n * @default '#ffffff''\n */\n toolbarColor?: string;\n /**\n * showArrow: if true an arrow would be shown instead of cross for closing the window\n *\n * @since 1.2.5\n * @default false\n */\n showArrow?: boolean;\n}\n\nexport interface InAppBrowserPlugin {\n /**\n * Open url in a new window fullscreen\n *\n * @since 0.1.0\n */\n open(options: OpenOptions): Promise<any>;\n\n /**\n * Clear cookies of url\n *\n * @since 0.5.0\n */\n clearCookies(options: ClearCookieOptions): Promise<any>;\n\n /**\n * Get cookies for a specific URL.\n * @param options The options, including the URL to get cookies for.\n * @returns A promise that resolves with the cookies.\n */\n getCookies(options: GetCookieOptions): Promise<Record<string, string>>;\n\n close(): Promise<any>;\n /**\n * Open url in a new webview with toolbars\n *\n * @since 0.1.0\n */\n openWebView(options: OpenWebViewOptions): Promise<any>;\n /**\n * Injects JavaScript code into the InAppBrowser window.\n */\n executeScript({ code }: { code: string }): Promise<void>;\n setUrl(options: { url: string }): Promise<any>;\n /**\n * Listen for url change, only for openWebView\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"urlChangeEvent\",\n listenerFunc: UrlChangeListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Listen for close click only for openWebView\n *\n * @since 0.4.0\n */\n addListener(\n eventName: \"closeEvent\",\n listenerFunc: UrlChangeListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n /**\n * Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"confirmBtnClicked\",\n listenerFunc: ConfirmBtnListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Reload the current web page.\n *\n * @since 1.0.0\n */\n reload(): Promise<any>; // Add this line\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ export declare class InAppBrowserWeb extends WebPlugin implements InAppBrowserPl
|
|
|
5
5
|
clearCookies(options: ClearCookieOptions): Promise<any>;
|
|
6
6
|
getCookies(options: GetCookieOptions): Promise<any>;
|
|
7
7
|
openWebView(options: OpenWebViewOptions): Promise<any>;
|
|
8
|
+
executeScript({ code }: {
|
|
9
|
+
code: string;
|
|
10
|
+
}): Promise<any>;
|
|
8
11
|
close(): Promise<any>;
|
|
9
12
|
setUrl(options: {
|
|
10
13
|
url: string;
|
package/dist/esm/web.js
CHANGED
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAU5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,OAA2B;QAC5C,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QACrC,OAAO;IACT,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAyB;QACxC,oCAAoC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAA2B;QAC3C,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAwB;QACnC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO;IACT,CAAC;IAED,KAAK,CAAC,MAAM;QACV,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACtB,OAAO;IACT,CAAC;CACF","sourcesContent":["import { WebPlugin } from \"@capacitor/core\";\n\nimport type {\n InAppBrowserPlugin,\n OpenWebViewOptions,\n OpenOptions,\n GetCookieOptions,\n ClearCookieOptions,\n} from \"./definitions\";\n\nexport class InAppBrowserWeb extends WebPlugin implements InAppBrowserPlugin {\n async open(options: OpenOptions): Promise<any> {\n console.log(\"open\", options);\n return options;\n }\n\n async clearCookies(options: ClearCookieOptions): Promise<any> {\n console.log(\"cleanCookies\", options);\n return;\n }\n\n async getCookies(options: GetCookieOptions): Promise<any> {\n // Web implementation to get cookies\n return options;\n }\n\n async openWebView(options: OpenWebViewOptions): Promise<any> {\n console.log(\"openWebView\", options);\n return options;\n }\n\n async close(): Promise<any> {\n console.log(\"close\");\n return;\n }\n\n async setUrl(options: { url: string }): Promise<any> {\n console.log(\"setUrl\", options.url);\n return;\n }\n\n async reload(): Promise<any> {\n console.log(\"reload\");\n return;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAU5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,OAA2B;QAC5C,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QACrC,OAAO;IACT,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAyB;QACxC,oCAAoC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAA2B;QAC3C,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAAE,IAAI,EAAoB;QAC5C,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAwB;QACnC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO;IACT,CAAC;IAED,KAAK,CAAC,MAAM;QACV,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACtB,OAAO;IACT,CAAC;CACF","sourcesContent":["import { WebPlugin } from \"@capacitor/core\";\n\nimport type {\n InAppBrowserPlugin,\n OpenWebViewOptions,\n OpenOptions,\n GetCookieOptions,\n ClearCookieOptions,\n} from \"./definitions\";\n\nexport class InAppBrowserWeb extends WebPlugin implements InAppBrowserPlugin {\n async open(options: OpenOptions): Promise<any> {\n console.log(\"open\", options);\n return options;\n }\n\n async clearCookies(options: ClearCookieOptions): Promise<any> {\n console.log(\"cleanCookies\", options);\n return;\n }\n\n async getCookies(options: GetCookieOptions): Promise<any> {\n // Web implementation to get cookies\n return options;\n }\n\n async openWebView(options: OpenWebViewOptions): Promise<any> {\n console.log(\"openWebView\", options);\n return options;\n }\n\n async executeScript({ code }: { code: string }): Promise<any> {\n console.log(\"code\", code);\n return code;\n }\n\n async close(): Promise<any> {\n console.log(\"close\");\n return;\n }\n\n async setUrl(options: { url: string }): Promise<any> {\n console.log(\"setUrl\", options.url);\n return;\n }\n\n async reload(): Promise<any> {\n console.log(\"reload\");\n return;\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BackgroundColor;\n(function (BackgroundColor) {\n BackgroundColor[\"WHITE\"] = \"white\";\n BackgroundColor[\"BLACK\"] = \"black\";\n})(BackgroundColor || (BackgroundColor = {}));\nexport var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from \"@capacitor/core\";\nconst InAppBrowser = registerPlugin(\"InAppBrowser\", {\n web: () => import(\"./web\").then((m) => new m.InAppBrowserWeb()),\n});\nexport * from \"./definitions\";\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log(\"open\", options);\n return options;\n }\n async clearCookies(options) {\n console.log(\"cleanCookies\", options);\n return;\n }\n async getCookies(options) {\n // Web implementation to get cookies\n return options;\n }\n async openWebView(options) {\n console.log(\"openWebView\", options);\n return options;\n }\n async close() {\n console.log(\"close\");\n return;\n }\n async setUrl(options) {\n console.log(\"setUrl\", options.url);\n return;\n }\n async reload() {\n console.log(\"reload\");\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BackgroundColor","ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;;AAAWA,iCAAgB;AAC3B,CAAC,UAAU,eAAe,EAAE;AAC5B,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACvC,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACvC,CAAC,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC,CAAC;AACnCC,6BAAY;AACvB,CAAC,UAAU,WAAW,EAAE;AACxB,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AACzC,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AAC7C,IAAI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AC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9B,QAAQ,OAAO;AACf,KAAK;AACL;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BackgroundColor;\n(function (BackgroundColor) {\n BackgroundColor[\"WHITE\"] = \"white\";\n BackgroundColor[\"BLACK\"] = \"black\";\n})(BackgroundColor || (BackgroundColor = {}));\nexport var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from \"@capacitor/core\";\nconst InAppBrowser = registerPlugin(\"InAppBrowser\", {\n web: () => import(\"./web\").then((m) => new m.InAppBrowserWeb()),\n});\nexport * from \"./definitions\";\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log(\"open\", options);\n return options;\n }\n async clearCookies(options) {\n console.log(\"cleanCookies\", options);\n return;\n }\n async getCookies(options) {\n // Web implementation to get cookies\n return options;\n }\n async openWebView(options) {\n console.log(\"openWebView\", options);\n return options;\n }\n async executeScript({ code }) {\n console.log(\"code\", code);\n return code;\n }\n async close() {\n console.log(\"close\");\n return;\n }\n async setUrl(options) {\n console.log(\"setUrl\", options.url);\n return;\n }\n async reload() {\n console.log(\"reload\");\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BackgroundColor","ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;;AAAWA,iCAAgB;AAC3B,CAAC,UAAU,eAAe,EAAE;AAC5B,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACvC,IAAI,eAAe,CAAC,OAAO,CAAC,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OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAClC,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;AAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;AAC3C,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9B,QAAQ,OAAO;AACf,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -35,6 +35,10 @@ var capacitorInAppBrowser = (function (exports, core) {
|
|
|
35
35
|
console.log("openWebView", options);
|
|
36
36
|
return options;
|
|
37
37
|
}
|
|
38
|
+
async executeScript({ code }) {
|
|
39
|
+
console.log("code", code);
|
|
40
|
+
return code;
|
|
41
|
+
}
|
|
38
42
|
async close() {
|
|
39
43
|
console.log("close");
|
|
40
44
|
return;
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BackgroundColor;\n(function (BackgroundColor) {\n BackgroundColor[\"WHITE\"] = \"white\";\n BackgroundColor[\"BLACK\"] = \"black\";\n})(BackgroundColor || (BackgroundColor = {}));\nexport var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from \"@capacitor/core\";\nconst InAppBrowser = registerPlugin(\"InAppBrowser\", {\n web: () => import(\"./web\").then((m) => new m.InAppBrowserWeb()),\n});\nexport * from \"./definitions\";\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log(\"open\", options);\n return options;\n }\n async clearCookies(options) {\n console.log(\"cleanCookies\", options);\n return;\n }\n async getCookies(options) {\n // Web implementation to get cookies\n return options;\n }\n async openWebView(options) {\n console.log(\"openWebView\", options);\n return options;\n }\n async close() {\n console.log(\"close\");\n return;\n }\n async setUrl(options) {\n console.log(\"setUrl\", options.url);\n return;\n }\n async reload() {\n console.log(\"reload\");\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BackgroundColor","ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;AAAWA,qCAAgB;IAC3B,CAAC,UAAU,eAAe,EAAE;IAC5B,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvC,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvC,CAAC,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC,CAAC;AACnCC,iCAAY;IACvB,CAAC,UAAU,WAAW,EAAE;IACxB,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;IACzC,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;IAC7C,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACnC,IAAI,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;IAChC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ACVhC,UAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACnE,CAAC;;ICFM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,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,YAAY,CAAC,OAAO,EAAE;IAChC,QAAQ,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC7C,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;IAC9B;IACA,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC5C,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,KAAK,GAAG;IAClB,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;IAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3C,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,MAAM,GAAG;IACnB,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,QAAQ,OAAO;IACf,KAAK;IACL;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BackgroundColor;\n(function (BackgroundColor) {\n BackgroundColor[\"WHITE\"] = \"white\";\n BackgroundColor[\"BLACK\"] = \"black\";\n})(BackgroundColor || (BackgroundColor = {}));\nexport var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from \"@capacitor/core\";\nconst InAppBrowser = registerPlugin(\"InAppBrowser\", {\n web: () => import(\"./web\").then((m) => new m.InAppBrowserWeb()),\n});\nexport * from \"./definitions\";\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log(\"open\", options);\n return options;\n }\n async clearCookies(options) {\n console.log(\"cleanCookies\", options);\n return;\n }\n async getCookies(options) {\n // Web implementation to get cookies\n return options;\n }\n async openWebView(options) {\n console.log(\"openWebView\", options);\n return options;\n }\n async executeScript({ code }) {\n console.log(\"code\", code);\n return code;\n }\n async close() {\n console.log(\"close\");\n return;\n }\n async setUrl(options) {\n console.log(\"setUrl\", options.url);\n return;\n }\n async reload() {\n console.log(\"reload\");\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BackgroundColor","ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;AAAWA,qCAAgB;IAC3B,CAAC,UAAU,eAAe,EAAE;IAC5B,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvC,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvC,CAAC,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC,CAAC;AACnCC,iCAAY;IACvB,CAAC,UAAU,WAAW,EAAE;IACxB,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;IACzC,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;IAC7C,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAA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AQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3C,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,MAAM,GAAG;IACnB,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,QAAQ,OAAO;IACf,KAAK;IACL;;;;;;;;;;;;;;;"}
|
|
@@ -198,14 +198,28 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
@objc func setUrl(_ call: CAPPluginCall) {
|
|
201
|
-
guard let
|
|
201
|
+
guard let urlString = call.getString("url") else {
|
|
202
202
|
call.reject("Cannot get new url to set")
|
|
203
203
|
return
|
|
204
204
|
}
|
|
205
|
-
|
|
205
|
+
|
|
206
|
+
guard let url = URL(string: urlString) else {
|
|
207
|
+
call.reject("Invalid URL")
|
|
208
|
+
return
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
self.webViewController?.load(remote: url)
|
|
206
212
|
call.resolve()
|
|
207
213
|
}
|
|
208
214
|
|
|
215
|
+
@objc func executeScript(_ call: CAPPluginCall) {
|
|
216
|
+
guard let script = call.getString("code") else {
|
|
217
|
+
call.reject("Cannot get script to execute")
|
|
218
|
+
return
|
|
219
|
+
}
|
|
220
|
+
self.webViewController?.executeScript(script: script)
|
|
221
|
+
}
|
|
222
|
+
|
|
209
223
|
func isHexColorCode(_ input: String) -> Bool {
|
|
210
224
|
let hexColorRegex = "^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$"
|
|
211
225
|
|
|
@@ -216,8 +216,9 @@ open class WKWebViewController: UIViewController {
|
|
|
216
216
|
let webConfiguration = WKWebViewConfiguration()
|
|
217
217
|
let webView = WKWebView(frame: .zero, configuration: webConfiguration)
|
|
218
218
|
|
|
219
|
-
if
|
|
220
|
-
|
|
219
|
+
if webView.responds(to: Selector(("setInspectable:"))) {
|
|
220
|
+
// Fix: https://stackoverflow.com/questions/76216183/how-to-debug-wkwebview-in-ios-16-4-1-using-xcode-14-2/76603043#76603043
|
|
221
|
+
webView.perform(Selector(("setInspectable:")), with: isInspectable)
|
|
221
222
|
}
|
|
222
223
|
|
|
223
224
|
webView.uiDelegate = self
|
|
@@ -245,8 +246,6 @@ open class WKWebViewController: UIViewController {
|
|
|
245
246
|
self.previousToolbarState = (navigation.toolbar.tintColor, navigation.toolbar.isHidden)
|
|
246
247
|
}
|
|
247
248
|
|
|
248
|
-
// self.restateViewHeight()
|
|
249
|
-
|
|
250
249
|
if let s = self.source {
|
|
251
250
|
self.load(source: s)
|
|
252
251
|
} else {
|
|
@@ -264,19 +263,19 @@ open class WKWebViewController: UIViewController {
|
|
|
264
263
|
var bottomPadding = CGFloat(0.0)
|
|
265
264
|
var topPadding = CGFloat(0.0)
|
|
266
265
|
if #available(iOS 11.0, *) {
|
|
267
|
-
let window = UIApplication.shared.
|
|
266
|
+
let window = UIApplication.shared.windows.first(where: { $0.isKeyWindow })
|
|
268
267
|
bottomPadding = window?.safeAreaInsets.bottom ?? 0.0
|
|
269
|
-
topPadding =
|
|
268
|
+
topPadding = window?.safeAreaInsets.top ?? 0.0
|
|
270
269
|
}
|
|
271
270
|
if UIDevice.current.orientation.isPortrait {
|
|
272
271
|
self.navigationController?.toolbar.isHidden = false
|
|
273
272
|
if self.viewHeightPortrait == nil {
|
|
274
273
|
self.viewHeightPortrait = self.view.safeAreaLayoutGuide.layoutFrame.size.height
|
|
275
274
|
if toolbarItemTypes.count == 0 {
|
|
276
|
-
self.viewHeightPortrait!
|
|
275
|
+
self.viewHeightPortrait! += bottomPadding
|
|
277
276
|
}
|
|
278
277
|
if self.navigationController?.navigationBar.isHidden == true {
|
|
279
|
-
self.viewHeightPortrait
|
|
278
|
+
self.viewHeightPortrait! += topPadding
|
|
280
279
|
}
|
|
281
280
|
}
|
|
282
281
|
self.currentViewHeight = self.viewHeightPortrait
|
|
@@ -285,10 +284,10 @@ open class WKWebViewController: UIViewController {
|
|
|
285
284
|
if self.viewHeightLandscape == nil {
|
|
286
285
|
self.viewHeightLandscape = self.view.safeAreaLayoutGuide.layoutFrame.size.height
|
|
287
286
|
if toolbarItemTypes.count == 0 {
|
|
288
|
-
self.viewHeightLandscape!
|
|
287
|
+
self.viewHeightLandscape! += bottomPadding
|
|
289
288
|
}
|
|
290
289
|
if self.navigationController?.navigationBar.isHidden == true {
|
|
291
|
-
self.viewHeightLandscape
|
|
290
|
+
self.viewHeightLandscape! += topPadding
|
|
292
291
|
}
|
|
293
292
|
}
|
|
294
293
|
self.currentViewHeight = self.viewHeightLandscape
|
|
@@ -380,6 +379,10 @@ public extension WKWebViewController {
|
|
|
380
379
|
func reload() {
|
|
381
380
|
webView?.reload()
|
|
382
381
|
}
|
|
382
|
+
|
|
383
|
+
func executeScript(script: String, completion: ((Any?, Error?) -> Void)? = nil) {
|
|
384
|
+
webView?.evaluateJavaScript(script, completionHandler: completion)
|
|
385
|
+
}
|
|
383
386
|
}
|
|
384
387
|
|
|
385
388
|
// MARK: - Fileprivate Methods
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/inappbrowser",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.15",
|
|
4
4
|
"description": "Capacitor plugin in app browser",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
],
|
|
31
31
|
"scripts": {
|
|
32
32
|
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
33
|
-
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin && cd ..",
|
|
33
|
+
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -sdk iphoneos -scheme Plugin && cd ..",
|
|
34
34
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
35
35
|
"verify:web": "npm run build",
|
|
36
36
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|