@capgo/inappbrowser 0.0.1 → 0.0.4
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 +93 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +5 -0
- package/dist/docs.json +160 -1
- package/dist/esm/definitions.d.ts +34 -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.m +1 -0
- package/ios/Plugin/InAppBrowserPlugin.swift +20 -16
- package/ios/Plugin/WKWebViewController.swift +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,11 @@ npx cap sync
|
|
|
16
16
|
* [`open(...)`](#open)
|
|
17
17
|
* [`close()`](#close)
|
|
18
18
|
* [`openWebView(...)`](#openwebview)
|
|
19
|
+
* [`setUrl(...)`](#seturl)
|
|
20
|
+
* [`addListener('urlChangeEvent', ...)`](#addlistenerurlchangeevent)
|
|
21
|
+
* [`addListener('confirmBtnClicked', ...)`](#addlistenerconfirmbtnclicked)
|
|
19
22
|
* [Interfaces](#interfaces)
|
|
23
|
+
* [Type Aliases](#type-aliases)
|
|
20
24
|
* [Enums](#enums)
|
|
21
25
|
|
|
22
26
|
</docgen-index>
|
|
@@ -65,6 +69,61 @@ openWebView(options: OpenWebViewOptions) => Promise<any>
|
|
|
65
69
|
--------------------
|
|
66
70
|
|
|
67
71
|
|
|
72
|
+
### setUrl(...)
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
setUrl(options: { url: string; }) => Promise<any>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
| Param | Type |
|
|
79
|
+
| ------------- | ----------------------------- |
|
|
80
|
+
| **`options`** | <code>{ url: string; }</code> |
|
|
81
|
+
|
|
82
|
+
**Returns:** <code>Promise<any></code>
|
|
83
|
+
|
|
84
|
+
--------------------
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
### addListener('urlChangeEvent', ...)
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
addListener(eventName: 'urlChangeEvent', listenerFunc: UrlChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Listen for url change
|
|
94
|
+
|
|
95
|
+
| Param | Type |
|
|
96
|
+
| ------------------ | --------------------------------------------------------------- |
|
|
97
|
+
| **`eventName`** | <code>'urlChangeEvent'</code> |
|
|
98
|
+
| **`listenerFunc`** | <code><a href="#urlchangelistener">UrlChangeListener</a></code> |
|
|
99
|
+
|
|
100
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>> & <a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
|
|
101
|
+
|
|
102
|
+
**Since:** 0.0.1
|
|
103
|
+
|
|
104
|
+
--------------------
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
### addListener('confirmBtnClicked', ...)
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
addListener(eventName: 'confirmBtnClicked', listenerFunc: ConfirmBtnListener) => Promise<PluginListenerHandle> & PluginListenerHandle
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS
|
|
114
|
+
|
|
115
|
+
| Param | Type |
|
|
116
|
+
| ------------------ | ----------------------------------------------------------------- |
|
|
117
|
+
| **`eventName`** | <code>'confirmBtnClicked'</code> |
|
|
118
|
+
| **`listenerFunc`** | <code><a href="#confirmbtnlistener">ConfirmBtnListener</a></code> |
|
|
119
|
+
|
|
120
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>> & <a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
|
|
121
|
+
|
|
122
|
+
**Since:** 0.0.1
|
|
123
|
+
|
|
124
|
+
--------------------
|
|
125
|
+
|
|
126
|
+
|
|
68
127
|
### Interfaces
|
|
69
128
|
|
|
70
129
|
|
|
@@ -103,6 +162,40 @@ openWebView(options: OpenWebViewOptions) => Promise<any>
|
|
|
103
162
|
| **`cancelBtn`** | <code>string</code> |
|
|
104
163
|
|
|
105
164
|
|
|
165
|
+
#### PluginListenerHandle
|
|
166
|
+
|
|
167
|
+
| Prop | Type |
|
|
168
|
+
| ------------ | ----------------------------------------- |
|
|
169
|
+
| **`remove`** | <code>() => Promise<void></code> |
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
#### UrlEvent
|
|
173
|
+
|
|
174
|
+
| Prop | Type | Description | Since |
|
|
175
|
+
| --------- | ------------------- | ------------------------- | ----- |
|
|
176
|
+
| **`url`** | <code>string</code> | Emit when the url changes | 0.0.1 |
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
#### BtnEvent
|
|
180
|
+
|
|
181
|
+
| Prop | Type | Description | Since |
|
|
182
|
+
| --------- | ------------------- | ------------------------------ | ----- |
|
|
183
|
+
| **`url`** | <code>string</code> | Emit when a button is clicked. | 0.0.1 |
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
### Type Aliases
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
#### UrlChangeListener
|
|
190
|
+
|
|
191
|
+
<code>(state: <a href="#urlevent">UrlEvent</a>): void</code>
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
#### ConfirmBtnListener
|
|
195
|
+
|
|
196
|
+
<code>(state: <a href="#btnevent">BtnEvent</a>): void</code>
|
|
197
|
+
|
|
198
|
+
|
|
106
199
|
### Enums
|
|
107
200
|
|
|
108
201
|
|
package/dist/docs.json
CHANGED
|
@@ -50,6 +50,80 @@
|
|
|
50
50
|
"OpenWebViewOptions"
|
|
51
51
|
],
|
|
52
52
|
"slug": "openwebview"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "setUrl",
|
|
56
|
+
"signature": "(options: { url: string; }) => Promise<any>",
|
|
57
|
+
"parameters": [
|
|
58
|
+
{
|
|
59
|
+
"name": "options",
|
|
60
|
+
"docs": "",
|
|
61
|
+
"type": "{ url: string; }"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"returns": "Promise<any>",
|
|
65
|
+
"tags": [],
|
|
66
|
+
"docs": "",
|
|
67
|
+
"complexTypes": [],
|
|
68
|
+
"slug": "seturl"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "addListener",
|
|
72
|
+
"signature": "(eventName: 'urlChangeEvent', listenerFunc: UrlChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle",
|
|
73
|
+
"parameters": [
|
|
74
|
+
{
|
|
75
|
+
"name": "eventName",
|
|
76
|
+
"docs": "",
|
|
77
|
+
"type": "'urlChangeEvent'"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "listenerFunc",
|
|
81
|
+
"docs": "",
|
|
82
|
+
"type": "UrlChangeListener"
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"returns": "Promise<PluginListenerHandle> & PluginListenerHandle",
|
|
86
|
+
"tags": [
|
|
87
|
+
{
|
|
88
|
+
"name": "since",
|
|
89
|
+
"text": "0.0.1"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"docs": "Listen for url change",
|
|
93
|
+
"complexTypes": [
|
|
94
|
+
"PluginListenerHandle",
|
|
95
|
+
"UrlChangeListener"
|
|
96
|
+
],
|
|
97
|
+
"slug": "addlistenerurlchangeevent"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"name": "addListener",
|
|
101
|
+
"signature": "(eventName: 'confirmBtnClicked', listenerFunc: ConfirmBtnListener) => Promise<PluginListenerHandle> & PluginListenerHandle",
|
|
102
|
+
"parameters": [
|
|
103
|
+
{
|
|
104
|
+
"name": "eventName",
|
|
105
|
+
"docs": "",
|
|
106
|
+
"type": "'confirmBtnClicked'"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"name": "listenerFunc",
|
|
110
|
+
"docs": "",
|
|
111
|
+
"type": "ConfirmBtnListener"
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"returns": "Promise<PluginListenerHandle> & PluginListenerHandle",
|
|
115
|
+
"tags": [
|
|
116
|
+
{
|
|
117
|
+
"name": "since",
|
|
118
|
+
"text": "0.0.1"
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"docs": "Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS",
|
|
122
|
+
"complexTypes": [
|
|
123
|
+
"PluginListenerHandle",
|
|
124
|
+
"ConfirmBtnListener"
|
|
125
|
+
],
|
|
126
|
+
"slug": "addlistenerconfirmbtnclicked"
|
|
53
127
|
}
|
|
54
128
|
],
|
|
55
129
|
"properties": []
|
|
@@ -195,6 +269,64 @@
|
|
|
195
269
|
"type": "string"
|
|
196
270
|
}
|
|
197
271
|
]
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"name": "PluginListenerHandle",
|
|
275
|
+
"slug": "pluginlistenerhandle",
|
|
276
|
+
"docs": "",
|
|
277
|
+
"tags": [],
|
|
278
|
+
"methods": [],
|
|
279
|
+
"properties": [
|
|
280
|
+
{
|
|
281
|
+
"name": "remove",
|
|
282
|
+
"tags": [],
|
|
283
|
+
"docs": "",
|
|
284
|
+
"complexTypes": [],
|
|
285
|
+
"type": "() => Promise<void>"
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"name": "UrlEvent",
|
|
291
|
+
"slug": "urlevent",
|
|
292
|
+
"docs": "",
|
|
293
|
+
"tags": [],
|
|
294
|
+
"methods": [],
|
|
295
|
+
"properties": [
|
|
296
|
+
{
|
|
297
|
+
"name": "url",
|
|
298
|
+
"tags": [
|
|
299
|
+
{
|
|
300
|
+
"text": "0.0.1",
|
|
301
|
+
"name": "since"
|
|
302
|
+
}
|
|
303
|
+
],
|
|
304
|
+
"docs": "Emit when the url changes",
|
|
305
|
+
"complexTypes": [],
|
|
306
|
+
"type": "string"
|
|
307
|
+
}
|
|
308
|
+
]
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"name": "BtnEvent",
|
|
312
|
+
"slug": "btnevent",
|
|
313
|
+
"docs": "",
|
|
314
|
+
"tags": [],
|
|
315
|
+
"methods": [],
|
|
316
|
+
"properties": [
|
|
317
|
+
{
|
|
318
|
+
"name": "url",
|
|
319
|
+
"tags": [
|
|
320
|
+
{
|
|
321
|
+
"text": "0.0.1",
|
|
322
|
+
"name": "since"
|
|
323
|
+
}
|
|
324
|
+
],
|
|
325
|
+
"docs": "Emit when a button is clicked.",
|
|
326
|
+
"complexTypes": [],
|
|
327
|
+
"type": "string"
|
|
328
|
+
}
|
|
329
|
+
]
|
|
198
330
|
}
|
|
199
331
|
],
|
|
200
332
|
"enums": [
|
|
@@ -229,6 +361,33 @@
|
|
|
229
361
|
]
|
|
230
362
|
}
|
|
231
363
|
],
|
|
232
|
-
"typeAliases": [
|
|
364
|
+
"typeAliases": [
|
|
365
|
+
{
|
|
366
|
+
"name": "UrlChangeListener",
|
|
367
|
+
"slug": "urlchangelistener",
|
|
368
|
+
"docs": "",
|
|
369
|
+
"types": [
|
|
370
|
+
{
|
|
371
|
+
"text": "(state: UrlEvent): void",
|
|
372
|
+
"complexTypes": [
|
|
373
|
+
"UrlEvent"
|
|
374
|
+
]
|
|
375
|
+
}
|
|
376
|
+
]
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
"name": "ConfirmBtnListener",
|
|
380
|
+
"slug": "confirmbtnlistener",
|
|
381
|
+
"docs": "",
|
|
382
|
+
"types": [
|
|
383
|
+
{
|
|
384
|
+
"text": "(state: BtnEvent): void",
|
|
385
|
+
"complexTypes": [
|
|
386
|
+
"BtnEvent"
|
|
387
|
+
]
|
|
388
|
+
}
|
|
389
|
+
]
|
|
390
|
+
}
|
|
391
|
+
],
|
|
233
392
|
"pluginConfigs": []
|
|
234
393
|
}
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import type { PluginListenerHandle } from '@capacitor/core';
|
|
2
|
+
export interface UrlEvent {
|
|
3
|
+
/**
|
|
4
|
+
* Emit when the url changes
|
|
5
|
+
*
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
*/
|
|
8
|
+
url: string;
|
|
9
|
+
}
|
|
10
|
+
export interface BtnEvent {
|
|
11
|
+
/**
|
|
12
|
+
* Emit when a button is clicked.
|
|
13
|
+
*
|
|
14
|
+
* @since 0.0.1
|
|
15
|
+
*/
|
|
16
|
+
url: string;
|
|
17
|
+
}
|
|
18
|
+
export declare type UrlChangeListener = (state: UrlEvent) => void;
|
|
19
|
+
export declare type ConfirmBtnListener = (state: BtnEvent) => void;
|
|
1
20
|
export declare enum ToolBarType {
|
|
2
21
|
ACTIVITY = "activity",
|
|
3
22
|
NAVIGATION = "navigation",
|
|
@@ -31,4 +50,19 @@ export interface InAppBrowserPlugin {
|
|
|
31
50
|
open(options: OpenOptions): Promise<any>;
|
|
32
51
|
close(): Promise<any>;
|
|
33
52
|
openWebView(options: OpenWebViewOptions): Promise<any>;
|
|
53
|
+
setUrl(options: {
|
|
54
|
+
url: string;
|
|
55
|
+
}): Promise<any>;
|
|
56
|
+
/**
|
|
57
|
+
* Listen for url change
|
|
58
|
+
*
|
|
59
|
+
* @since 0.0.1
|
|
60
|
+
*/
|
|
61
|
+
addListener(eventName: 'urlChangeEvent', listenerFunc: UrlChangeListener): Promise<PluginListenerHandle> & PluginListenerHandle;
|
|
62
|
+
/**
|
|
63
|
+
* Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS
|
|
64
|
+
*
|
|
65
|
+
* @since 0.0.1
|
|
66
|
+
*/
|
|
67
|
+
addListener(eventName: 'confirmBtnClicked', listenerFunc: ConfirmBtnListener): Promise<PluginListenerHandle> & PluginListenerHandle;
|
|
34
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAsBA,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 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 OpenOptions {\n url: string;\n headers?: Headers;\n isPresentAfterPageLoad?: boolean;\n}\n\nexport interface DisclaimerOptions {\n title: string;\n message: string;\n confirmBtn: string;\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n url: string;\n headers?: Headers;\n shareDisclaimer?: DisclaimerOptions;\n toolbarType?: ToolBarType;\n shareSubject?: string;\n title: string;\n isPresentAfterPageLoad?: boolean;\n}\n\n// CapBrowser.addListener(\"urlChangeEvent\", (info: any) => {\n// console.log(info.url)\n// })\n\n// CapBrowser.addListener(\"confirmBtnClicked\", (info: any) => {\n// // will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n// console.log(info.url)\n// })\nexport interface InAppBrowserPlugin {\n open(options: OpenOptions): Promise<any>;\n close(): Promise<any>;\n openWebView(options: OpenWebViewOptions): Promise<any>;\n setUrl(options: {url: string}): Promise<any>;\n /**\n * Listen for url change \n *\n * @since 0.0.1\n */\n addListener(\n eventName: 'urlChangeEvent',\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"]}
|
package/dist/esm/web.d.ts
CHANGED
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;AAI5C,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;IACD,KAAK,CAAC,WAAW,CAAC,OAA2B;QAC3C,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { InAppBrowserPlugin, OpenWebViewOptions, OpenOptions } 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 async openWebView(options: OpenWebViewOptions): Promise<any> {\n console.log('openWebView', options);\n return options;\n }\n async close(): Promise<any> {\n console.log('close');\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;AAI5C,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;IACD,KAAK,CAAC,WAAW,CAAC,OAA2B;QAC3C,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAuB;QAClC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO;IACT,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { InAppBrowserPlugin, OpenWebViewOptions, OpenOptions } 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 async openWebView(options: OpenWebViewOptions): Promise<any> {\n console.log('openWebView', options);\n return options;\n }\n async close(): Promise<any> {\n console.log('close');\n return;\n }\n async setUrl(options: { url: string}): Promise<any> {\n console.log('setUrl', options.url);\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 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 openWebView(options) {\n console.log('openWebView', options);\n return options;\n }\n async close() {\n console.log('close');\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;;;;AAAWA,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,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACnC,IAAI,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;AAChC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ACLhC,MAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACjE,CAAC;;ACFM,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,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,WAAW,CAAC,OAAO,EAAE;AAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC5C,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,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 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 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}\n//# sourceMappingURL=web.js.map"],"names":["ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;;;;AAAWA,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,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACnC,IAAI,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;AAChC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ACLhC,MAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACjE,CAAC;;ACFM,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,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,WAAW,CAAC,OAAO,EAAE;AAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC5C,QAAQ,OAAO,OAAO,CAAC;AACvB,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;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
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 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 openWebView(options) {\n console.log('openWebView', options);\n return options;\n }\n async close() {\n console.log('close');\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;AAAWA,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;;ACLhC,UAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjE,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,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;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export 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 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}\n//# sourceMappingURL=web.js.map"],"names":["ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;AAAWA,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;;ACLhC,UAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjE,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,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;;;;;;;;;;;;;;;;;"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
CAP_PLUGIN(InAppBrowserPlugin, "InAppBrowser",
|
|
7
7
|
CAP_PLUGIN_METHOD(openWebView, CAPPluginReturnPromise);
|
|
8
8
|
CAP_PLUGIN_METHOD(open, CAPPluginReturnPromise);
|
|
9
|
+
CAP_PLUGIN_METHOD(setUrl, CAPPluginReturnPromise);
|
|
9
10
|
CAP_PLUGIN_METHOD(show, CAPPluginReturnPromise);
|
|
10
11
|
CAP_PLUGIN_METHOD(close, CAPPluginReturnPromise);
|
|
11
12
|
CAP_PLUGIN_METHOD(hide, CAPPluginReturnPromise);
|
|
@@ -26,8 +26,8 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
func presentView() {
|
|
29
|
-
self.bridge
|
|
30
|
-
self.currentPluginCall?.
|
|
29
|
+
self.bridge?.viewController?.present(self.navigationWebViewController!, animated: true, completion: {
|
|
30
|
+
self.currentPluginCall?.resolve()
|
|
31
31
|
})
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -38,34 +38,34 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
38
38
|
self.currentPluginCall = call
|
|
39
39
|
|
|
40
40
|
guard let urlString = call.getString("url") else {
|
|
41
|
-
call.
|
|
41
|
+
call.reject("Must provide a URL to open")
|
|
42
42
|
return
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
if urlString.isEmpty {
|
|
46
|
-
call.
|
|
46
|
+
call.reject("URL must not be empty")
|
|
47
47
|
return
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
let headers = call.
|
|
50
|
+
let headers = call.getObject("headers", [:]).mapValues { String(describing: $0 as Any) }
|
|
51
51
|
|
|
52
|
-
var disclaimerContent = call.getObject("shareDisclaimer"
|
|
52
|
+
var disclaimerContent = call.getObject("shareDisclaimer")
|
|
53
53
|
let toolbarType = call.getString("toolbarType")
|
|
54
54
|
if toolbarType != "activity" {
|
|
55
55
|
disclaimerContent = nil
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
|
|
58
|
+
self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
|
|
59
59
|
|
|
60
60
|
DispatchQueue.main.async {
|
|
61
61
|
let url = URL(string: urlString)
|
|
62
62
|
let webViewController: WKWebViewController?
|
|
63
63
|
|
|
64
64
|
if self.isPresentAfterPageLoad {
|
|
65
|
-
webViewController = WKWebViewController.init(url: url!, headers: headers
|
|
65
|
+
webViewController = WKWebViewController.init(url: url!, headers: headers)
|
|
66
66
|
} else {
|
|
67
67
|
webViewController = WKWebViewController.init()
|
|
68
|
-
webViewController?.setHeaders(headers: headers
|
|
68
|
+
webViewController?.setHeaders(headers: headers)
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
webViewController?.source = .remote(url!)
|
|
@@ -103,6 +103,10 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
103
103
|
return result
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
@objc func setUrl(_ call: CAPPluginCall) {
|
|
107
|
+
call.resolve()
|
|
108
|
+
}
|
|
109
|
+
|
|
106
110
|
@objc func open(_ call: CAPPluginCall) {
|
|
107
111
|
if !self.isSetupDone {
|
|
108
112
|
self.setup()
|
|
@@ -111,28 +115,28 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
111
115
|
self.currentPluginCall = call
|
|
112
116
|
|
|
113
117
|
guard let urlString = call.getString("url") else {
|
|
114
|
-
call.
|
|
118
|
+
call.reject("Must provide a URL to open")
|
|
115
119
|
return
|
|
116
120
|
}
|
|
117
121
|
|
|
118
122
|
if urlString.isEmpty {
|
|
119
|
-
call.
|
|
123
|
+
call.reject("URL must not be empty")
|
|
120
124
|
return
|
|
121
125
|
}
|
|
122
126
|
|
|
123
|
-
let headers = call.
|
|
127
|
+
let headers = call.getObject("headers", [:]).mapValues { String(describing: $0 as Any) }
|
|
124
128
|
|
|
125
|
-
self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
|
|
129
|
+
self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
|
|
126
130
|
|
|
127
131
|
DispatchQueue.main.async {
|
|
128
132
|
let url = URL(string: urlString)
|
|
129
133
|
let webViewController: WKWebViewController?
|
|
130
134
|
|
|
131
135
|
if self.isPresentAfterPageLoad {
|
|
132
|
-
webViewController = WKWebViewController.init(url: url!, headers: headers
|
|
136
|
+
webViewController = WKWebViewController.init(url: url!, headers: headers)
|
|
133
137
|
} else {
|
|
134
138
|
webViewController = WKWebViewController.init()
|
|
135
|
-
webViewController?.setHeaders(headers: headers
|
|
139
|
+
webViewController?.setHeaders(headers: headers)
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
webViewController?.source = .remote(url!)
|
|
@@ -155,7 +159,7 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
155
159
|
@objc func close(_ call: CAPPluginCall) {
|
|
156
160
|
DispatchQueue.main.async {
|
|
157
161
|
self.navigationWebViewController?.dismiss(animated: true, completion: nil)
|
|
158
|
-
call.
|
|
162
|
+
call.resolve()
|
|
159
163
|
}
|
|
160
164
|
}
|
|
161
165
|
|
|
@@ -67,7 +67,7 @@ open class WKWebViewController: UIViewController {
|
|
|
67
67
|
open var bypassedSSLHosts: [String]?
|
|
68
68
|
open var cookies: [HTTPCookie]?
|
|
69
69
|
open var headers: [String: String]?
|
|
70
|
-
open var capBrowserPlugin:
|
|
70
|
+
open var capBrowserPlugin: InAppBrowserPlugin?
|
|
71
71
|
var shareDisclaimer: [String: Any]?
|
|
72
72
|
var shareSubject: String?
|
|
73
73
|
var didpageInit = false
|
|
@@ -322,7 +322,7 @@ open class WKWebViewController: UIViewController {
|
|
|
322
322
|
self.navigationItem.title = webView?.url?.host
|
|
323
323
|
}
|
|
324
324
|
case "URL":
|
|
325
|
-
self.capBrowserPlugin?.notifyListeners("urlChangeEvent", data: ["url" : webView?.url?.absoluteString])
|
|
325
|
+
self.capBrowserPlugin?.notifyListeners("urlChangeEvent", data: ["url" : webView?.url?.absoluteString ?? ""])
|
|
326
326
|
default:
|
|
327
327
|
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
|
|
328
328
|
}
|
|
@@ -583,7 +583,8 @@ fileprivate extension WKWebViewController {
|
|
|
583
583
|
func openURLWithApp(_ url: URL) -> Bool {
|
|
584
584
|
let application = UIApplication.shared
|
|
585
585
|
if application.canOpenURL(url) {
|
|
586
|
-
|
|
586
|
+
application.open(url, options: [:], completionHandler: nil)
|
|
587
|
+
return true
|
|
587
588
|
}
|
|
588
589
|
|
|
589
590
|
return false
|