@capgo/inappbrowser 0.0.2 → 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 +81 -4
- package/dist/docs.json +147 -4
- package/dist/esm/definitions.d.ts +34 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +3 -1
- package/dist/esm/web.js +2 -2
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +2 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +2 -2
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/InAppBrowserPlugin.swift +40 -36
- package/ios/Plugin/WKWebViewController.swift +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,10 @@ npx cap sync
|
|
|
17
17
|
* [`close()`](#close)
|
|
18
18
|
* [`openWebView(...)`](#openwebview)
|
|
19
19
|
* [`setUrl(...)`](#seturl)
|
|
20
|
+
* [`addListener('urlChangeEvent', ...)`](#addlistenerurlchangeevent)
|
|
21
|
+
* [`addListener('confirmBtnClicked', ...)`](#addlistenerconfirmbtnclicked)
|
|
20
22
|
* [Interfaces](#interfaces)
|
|
23
|
+
* [Type Aliases](#type-aliases)
|
|
21
24
|
* [Enums](#enums)
|
|
22
25
|
|
|
23
26
|
</docgen-index>
|
|
@@ -69,18 +72,58 @@ openWebView(options: OpenWebViewOptions) => Promise<any>
|
|
|
69
72
|
### setUrl(...)
|
|
70
73
|
|
|
71
74
|
```typescript
|
|
72
|
-
setUrl(url: string) => Promise<any>
|
|
75
|
+
setUrl(options: { url: string; }) => Promise<any>
|
|
73
76
|
```
|
|
74
77
|
|
|
75
|
-
| Param
|
|
76
|
-
|
|
|
77
|
-
| **`
|
|
78
|
+
| Param | Type |
|
|
79
|
+
| ------------- | ----------------------------- |
|
|
80
|
+
| **`options`** | <code>{ url: string; }</code> |
|
|
78
81
|
|
|
79
82
|
**Returns:** <code>Promise<any></code>
|
|
80
83
|
|
|
81
84
|
--------------------
|
|
82
85
|
|
|
83
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
|
+
|
|
84
127
|
### Interfaces
|
|
85
128
|
|
|
86
129
|
|
|
@@ -119,6 +162,40 @@ setUrl(url: string) => Promise<any>
|
|
|
119
162
|
| **`cancelBtn`** | <code>string</code> |
|
|
120
163
|
|
|
121
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
|
+
|
|
122
199
|
### Enums
|
|
123
200
|
|
|
124
201
|
|
package/dist/docs.json
CHANGED
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
"name": "setUrl",
|
|
56
|
-
"signature": "(url: string) => Promise<any>",
|
|
56
|
+
"signature": "(options: { url: string; }) => Promise<any>",
|
|
57
57
|
"parameters": [
|
|
58
58
|
{
|
|
59
|
-
"name": "
|
|
59
|
+
"name": "options",
|
|
60
60
|
"docs": "",
|
|
61
|
-
"type": "string"
|
|
61
|
+
"type": "{ url: string; }"
|
|
62
62
|
}
|
|
63
63
|
],
|
|
64
64
|
"returns": "Promise<any>",
|
|
@@ -66,6 +66,64 @@
|
|
|
66
66
|
"docs": "",
|
|
67
67
|
"complexTypes": [],
|
|
68
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"
|
|
69
127
|
}
|
|
70
128
|
],
|
|
71
129
|
"properties": []
|
|
@@ -211,6 +269,64 @@
|
|
|
211
269
|
"type": "string"
|
|
212
270
|
}
|
|
213
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
|
+
]
|
|
214
330
|
}
|
|
215
331
|
],
|
|
216
332
|
"enums": [
|
|
@@ -245,6 +361,33 @@
|
|
|
245
361
|
]
|
|
246
362
|
}
|
|
247
363
|
],
|
|
248
|
-
"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
|
+
],
|
|
249
392
|
"pluginConfigs": []
|
|
250
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,5 +50,19 @@ export interface InAppBrowserPlugin {
|
|
|
31
50
|
open(options: OpenOptions): Promise<any>;
|
|
32
51
|
close(): Promise<any>;
|
|
33
52
|
openWebView(options: OpenWebViewOptions): Promise<any>;
|
|
34
|
-
setUrl(
|
|
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;
|
|
35
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
|
@@ -4,5 +4,7 @@ export declare class InAppBrowserWeb extends WebPlugin implements InAppBrowserPl
|
|
|
4
4
|
open(options: OpenOptions): Promise<any>;
|
|
5
5
|
openWebView(options: OpenWebViewOptions): Promise<any>;
|
|
6
6
|
close(): Promise<any>;
|
|
7
|
-
setUrl(
|
|
7
|
+
setUrl(options: {
|
|
8
|
+
url: string;
|
|
9
|
+
}): Promise<any>;
|
|
8
10
|
}
|
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;IACD,KAAK,CAAC,MAAM,CAAC,
|
|
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 async setUrl(
|
|
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 async setUrl(
|
|
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;;;;;;;;;;;;;;;;;"}
|
|
@@ -12,6 +12,7 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
12
12
|
private var isSetupDone = false
|
|
13
13
|
var currentPluginCall: CAPPluginCall?
|
|
14
14
|
var isPresentAfterPageLoad = false
|
|
15
|
+
var webViewController: WKWebViewController?
|
|
15
16
|
|
|
16
17
|
private func setup(){
|
|
17
18
|
self.isSetupDone = true
|
|
@@ -26,8 +27,8 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
func presentView() {
|
|
29
|
-
self.bridge
|
|
30
|
-
self.currentPluginCall?.
|
|
30
|
+
self.bridge?.viewController?.present(self.navigationWebViewController!, animated: true, completion: {
|
|
31
|
+
self.currentPluginCall?.resolve()
|
|
31
32
|
})
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -38,46 +39,45 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
38
39
|
self.currentPluginCall = call
|
|
39
40
|
|
|
40
41
|
guard let urlString = call.getString("url") else {
|
|
41
|
-
call.
|
|
42
|
+
call.reject("Must provide a URL to open")
|
|
42
43
|
return
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
if urlString.isEmpty {
|
|
46
|
-
call.
|
|
47
|
+
call.reject("URL must not be empty")
|
|
47
48
|
return
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
let headers = call.
|
|
51
|
+
let headers = call.getObject("headers", [:]).mapValues { String(describing: $0 as Any) }
|
|
51
52
|
|
|
52
|
-
var disclaimerContent = call.getObject("shareDisclaimer"
|
|
53
|
+
var disclaimerContent = call.getObject("shareDisclaimer")
|
|
53
54
|
let toolbarType = call.getString("toolbarType")
|
|
54
55
|
if toolbarType != "activity" {
|
|
55
56
|
disclaimerContent = nil
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
|
|
59
|
+
self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
|
|
59
60
|
|
|
60
61
|
DispatchQueue.main.async {
|
|
61
62
|
let url = URL(string: urlString)
|
|
62
|
-
let webViewController: WKWebViewController?
|
|
63
63
|
|
|
64
64
|
if self.isPresentAfterPageLoad {
|
|
65
|
-
webViewController = WKWebViewController.init(url: url!, headers: headers
|
|
65
|
+
self.webViewController = WKWebViewController.init(url: url!, headers: headers)
|
|
66
66
|
} else {
|
|
67
|
-
webViewController = WKWebViewController.init()
|
|
68
|
-
webViewController?.setHeaders(headers: headers
|
|
67
|
+
self.webViewController = WKWebViewController.init()
|
|
68
|
+
self.webViewController?.setHeaders(headers: headers)
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
webViewController?.source = .remote(url!)
|
|
72
|
-
webViewController?.leftNavigaionBarItemTypes = self.getToolbarItems(toolbarType: toolbarType ?? "")
|
|
71
|
+
self.webViewController?.source = .remote(url!)
|
|
72
|
+
self.webViewController?.leftNavigaionBarItemTypes = self.getToolbarItems(toolbarType: toolbarType ?? "")
|
|
73
73
|
|
|
74
|
-
webViewController?.toolbarItemTypes = []
|
|
75
|
-
webViewController?.doneBarButtonItemPosition = .right
|
|
76
|
-
webViewController?.capBrowserPlugin = self
|
|
77
|
-
webViewController?.title = call.getString("title") ?? ""
|
|
78
|
-
webViewController?.shareSubject = call.getString("shareSubject")
|
|
79
|
-
webViewController?.shareDisclaimer = disclaimerContent
|
|
80
|
-
self.navigationWebViewController = UINavigationController.init(rootViewController: webViewController!)
|
|
74
|
+
self.webViewController?.toolbarItemTypes = []
|
|
75
|
+
self.webViewController?.doneBarButtonItemPosition = .right
|
|
76
|
+
self.webViewController?.capBrowserPlugin = self
|
|
77
|
+
self.webViewController?.title = call.getString("title") ?? ""
|
|
78
|
+
self.webViewController?.shareSubject = call.getString("shareSubject")
|
|
79
|
+
self.webViewController?.shareDisclaimer = disclaimerContent
|
|
80
|
+
self.navigationWebViewController = UINavigationController.init(rootViewController: self.webViewController!)
|
|
81
81
|
self.navigationWebViewController?.navigationBar.isTranslucent = false
|
|
82
82
|
self.navigationWebViewController?.toolbar.isTranslucent = false
|
|
83
83
|
self.navigationWebViewController?.navigationBar.backgroundColor = .white
|
|
@@ -104,7 +104,12 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
@objc func setUrl(_ call: CAPPluginCall) {
|
|
107
|
-
call.
|
|
107
|
+
guard let url = call.getString("url") else {
|
|
108
|
+
call.reject("Cannot get new url to set")
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
self.webViewController?.load(remote: URL(string: url)!)
|
|
112
|
+
call.resolve()
|
|
108
113
|
}
|
|
109
114
|
|
|
110
115
|
@objc func open(_ call: CAPPluginCall) {
|
|
@@ -115,36 +120,35 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
115
120
|
self.currentPluginCall = call
|
|
116
121
|
|
|
117
122
|
guard let urlString = call.getString("url") else {
|
|
118
|
-
call.
|
|
123
|
+
call.reject("Must provide a URL to open")
|
|
119
124
|
return
|
|
120
125
|
}
|
|
121
126
|
|
|
122
127
|
if urlString.isEmpty {
|
|
123
|
-
call.
|
|
128
|
+
call.reject("URL must not be empty")
|
|
124
129
|
return
|
|
125
130
|
}
|
|
126
131
|
|
|
127
|
-
let headers = call.
|
|
132
|
+
let headers = call.getObject("headers", [:]).mapValues { String(describing: $0 as Any) }
|
|
128
133
|
|
|
129
|
-
self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
|
|
134
|
+
self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
|
|
130
135
|
|
|
131
136
|
DispatchQueue.main.async {
|
|
132
137
|
let url = URL(string: urlString)
|
|
133
|
-
let webViewController: WKWebViewController?
|
|
134
138
|
|
|
135
139
|
if self.isPresentAfterPageLoad {
|
|
136
|
-
webViewController = WKWebViewController.init(url: url!, headers: headers
|
|
140
|
+
self.webViewController = WKWebViewController.init(url: url!, headers: headers)
|
|
137
141
|
} else {
|
|
138
|
-
webViewController = WKWebViewController.init()
|
|
139
|
-
webViewController?.setHeaders(headers: headers
|
|
142
|
+
self.webViewController = WKWebViewController.init()
|
|
143
|
+
self.webViewController?.setHeaders(headers: headers)
|
|
140
144
|
}
|
|
141
145
|
|
|
142
|
-
webViewController?.source = .remote(url!)
|
|
143
|
-
webViewController?.leftNavigaionBarItemTypes = [.reload]
|
|
144
|
-
webViewController?.toolbarItemTypes = [.back, .forward, .activity]
|
|
145
|
-
webViewController?.capBrowserPlugin = self
|
|
146
|
-
webViewController?.hasDynamicTitle = true
|
|
147
|
-
self.navigationWebViewController = UINavigationController.init(rootViewController: webViewController!)
|
|
146
|
+
self.webViewController?.source = .remote(url!)
|
|
147
|
+
self.webViewController?.leftNavigaionBarItemTypes = [.reload]
|
|
148
|
+
self.webViewController?.toolbarItemTypes = [.back, .forward, .activity]
|
|
149
|
+
self.webViewController?.capBrowserPlugin = self
|
|
150
|
+
self.webViewController?.hasDynamicTitle = true
|
|
151
|
+
self.navigationWebViewController = UINavigationController.init(rootViewController: self.webViewController!)
|
|
148
152
|
self.navigationWebViewController?.navigationBar.isTranslucent = false
|
|
149
153
|
self.navigationWebViewController?.toolbar.isTranslucent = false
|
|
150
154
|
self.navigationWebViewController?.navigationBar.backgroundColor = .white
|
|
@@ -159,7 +163,7 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
159
163
|
@objc func close(_ call: CAPPluginCall) {
|
|
160
164
|
DispatchQueue.main.async {
|
|
161
165
|
self.navigationWebViewController?.dismiss(animated: true, completion: nil)
|
|
162
|
-
call.
|
|
166
|
+
call.resolve()
|
|
163
167
|
}
|
|
164
168
|
}
|
|
165
169
|
|
|
@@ -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
|