@capgo/inappbrowser 1.2.19 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,7 +34,8 @@ Then the permission will be asked when the camera is used.
34
34
  <docgen-index>
35
35
 
36
36
  * [`open(...)`](#open)
37
- * [`clearCookies()`](#clearcookies)
37
+ * [`clearCookies(...)`](#clearcookies)
38
+ * [`getCookies(...)`](#getcookies)
38
39
  * [`close()`](#close)
39
40
  * [`openWebView(...)`](#openwebview)
40
41
  * [`setUrl(...)`](#seturl)
@@ -71,13 +72,17 @@ Open url in a new window fullscreen
71
72
  --------------------
72
73
 
73
74
 
74
- ### clearCookies()
75
+ ### clearCookies(...)
75
76
 
76
77
  ```typescript
77
- clearCookies() => Promise<any>
78
+ clearCookies(options: ClearCookieOptions) => Promise<any>
78
79
  ```
79
80
 
80
- Clear all cookies
81
+ Clear cookies of url
82
+
83
+ | Param | Type |
84
+ | ------------- | ----------------------------------------------------------------- |
85
+ | **`options`** | <code><a href="#clearcookieoptions">ClearCookieOptions</a></code> |
81
86
 
82
87
  **Returns:** <code>Promise&lt;any&gt;</code>
83
88
 
@@ -86,6 +91,23 @@ Clear all cookies
86
91
  --------------------
87
92
 
88
93
 
94
+ ### getCookies(...)
95
+
96
+ ```typescript
97
+ getCookies(options: GetCookieOptions) => Promise<Record<string, string>>
98
+ ```
99
+
100
+ Get cookies for a specific URL.
101
+
102
+ | Param | Type | Description |
103
+ | ------------- | ------------------------------------------------------------- | -------------------------------------------------- |
104
+ | **`options`** | <code><a href="#getcookieoptions">GetCookieOptions</a></code> | The options, including the URL to get cookies for. |
105
+
106
+ **Returns:** <code>Promise&lt;<a href="#record">Record</a>&lt;string, string&gt;&gt;</code>
107
+
108
+ --------------------
109
+
110
+
89
111
  ### close()
90
112
 
91
113
  ```typescript
@@ -235,6 +257,31 @@ Reload the current web page.
235
257
  #### Headers
236
258
 
237
259
 
260
+ #### ClearCookieOptions
261
+
262
+ | Prop | Type |
263
+ | ----------- | -------------------- |
264
+ | **`url`** | <code>string</code> |
265
+ | **`cache`** | <code>boolean</code> |
266
+
267
+
268
+ #### HttpCookie
269
+
270
+ | Prop | Type |
271
+ | ----------- | ------------------- |
272
+ | **`url`** | <code>string</code> |
273
+ | **`key`** | <code>string</code> |
274
+ | **`value`** | <code>string</code> |
275
+
276
+
277
+ #### GetCookieOptions
278
+
279
+ | Prop | Type |
280
+ | --------------------- | -------------------- |
281
+ | **`url`** | <code>string</code> |
282
+ | **`includeHttpOnly`** | <code>boolean</code> |
283
+
284
+
238
285
  #### OpenWebViewOptions
239
286
 
240
287
  | Prop | Type | Description | Default | Since |
@@ -247,6 +294,8 @@ Reload the current web page.
247
294
  | **`title`** | <code>string</code> | Title of the browser | <code>'New Window'</code> | 0.1.0 |
248
295
  | **`backgroundColor`** | <code><a href="#backgroundcolor">BackgroundColor</a></code> | Background color of the browser, only on IOS | <code>BackgroundColor.BLACK</code> | 0.1.0 |
249
296
  | **`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 |
297
+ | **`isInspectable`** | <code>boolean</code> | Whether the website in the webview is inspectable or not, ios only | <code>false</code> | |
298
+ | **`isAnimated`** | <code>boolean</code> | Whether the webview opening is animated or not, ios only | <code>true</code> | |
250
299
  | **`showReloadButton`** | <code>boolean</code> | Shows a reload button that reloads the web page | <code>false</code> | 1.0.15 |
251
300
  | **`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 |
252
301
  | **`closeModalTitle`** | <code>string</code> | CloseModalTitle: title of the confirm when user clicks on close button, only on IOS | <code>'Close'</code> | 1.1.0 |
@@ -292,6 +341,44 @@ Reload the current web page.
292
341
  ### Type Aliases
293
342
 
294
343
 
344
+ #### ClearCookieOptions
345
+
346
+ <code><a href="#omit">Omit</a>&lt;<a href="#httpcookie">HttpCookie</a>, 'key' | 'value'&gt;</code>
347
+
348
+
349
+ #### Omit
350
+
351
+ Construct a type with the properties of T except for those in type K.
352
+
353
+ <code><a href="#pick">Pick</a>&lt;T, <a href="#exclude">Exclude</a>&lt;keyof T, K&gt;&gt;</code>
354
+
355
+
356
+ #### Pick
357
+
358
+ From T, pick a set of properties whose keys are in the union K
359
+
360
+ <code>{
295
361
  [P in K]: T[P];
296
362
  }</code>
363
+
364
+
365
+ #### Exclude
366
+
367
+ <a href="#exclude">Exclude</a> from T those types that are assignable to U
368
+
369
+ <code>T extends U ? never : T</code>
370
+
371
+
372
+ #### Record
373
+
374
+ Construct a type with a set of properties K of type T
375
+
376
+ <code>{
297
377
  [P in K]: T;
298
378
  }</code>
379
+
380
+
381
+ #### GetCookieOptions
382
+
383
+ <code><a href="#omit">Omit</a>&lt;<a href="#httpcookie">HttpCookie</a>, 'key' | 'value'&gt;</code>
384
+
385
+
299
386
  #### UrlChangeListener
300
387
 
301
388
  <code>(state: <a href="#urlevent">UrlEvent</a>): void</code>
@@ -187,27 +187,50 @@ public class InAppBrowserPlugin
187
187
 
188
188
  @PluginMethod
189
189
  public void clearCookies(PluginCall call) {
190
- if (webViewDialog == null) {
191
- call.reject("WebView is not open");
190
+ String url = call.getString("url");
191
+ Boolean clearCache = call.getBoolean("cache", false);
192
+ if (url == null || TextUtils.isEmpty(url)) {
193
+ call.reject("Invalid URL");
194
+ } else {
195
+ CookieManager cookieManager = CookieManager.getInstance();
196
+ String cookie = cookieManager.getCookie(url);
197
+ if (cookie != null) {
198
+ String[] cookies = cookie.split(";");
199
+ for (String c : cookies) {
200
+ String cookieName = c.substring(0, c.indexOf("="));
201
+ cookieManager.setCookie(
202
+ url,
203
+ cookieName + "=; Expires=Thu, 01 Jan 1970 00:00:01 GMT"
204
+ );
205
+ if (clearCache) {
206
+ cookieManager.removeSessionCookie();
207
+ }
208
+ }
209
+ }
210
+ call.resolve();
211
+ }
212
+ }
213
+
214
+ @PluginMethod
215
+ public void getCookies(PluginCall call) {
216
+ String url = call.getString("url");
217
+ if (url == null || TextUtils.isEmpty(url)) {
218
+ call.reject("Invalid URL");
192
219
  } else {
193
- String url = currentUrl;
194
- if (url == null || TextUtils.isEmpty(url)) {
195
- call.reject("Invalid URL");
196
- } else {
197
- CookieManager cookieManager = CookieManager.getInstance();
198
- String cookie = cookieManager.getCookie(url);
199
- if (cookie != null) {
200
- String[] cookies = cookie.split(";");
201
- for (String c : cookies) {
202
- String cookieName = c.substring(0, c.indexOf("="));
203
- cookieManager.setCookie(
204
- url,
205
- cookieName + "=; Expires=Thu, 01 Jan 1970 00:00:01 GMT"
206
- );
220
+ CookieManager cookieManager = CookieManager.getInstance();
221
+ String cookieString = cookieManager.getCookie(url);
222
+ if (cookieString != null) {
223
+ String[] cookiePairs = cookieString.split("; ");
224
+ JSObject result = new JSObject();
225
+ for (String cookie : cookiePairs) {
226
+ String[] parts = cookie.split("=", 2);
227
+ if (parts.length == 2) {
228
+ result.put(parts[0], parts[1]);
207
229
  }
208
230
  }
209
- call.resolve();
231
+ call.resolve(result);
210
232
  }
233
+ call.resolve(new JSObject());
211
234
  }
212
235
  }
213
236
 
package/dist/docs.json CHANGED
@@ -30,8 +30,14 @@
30
30
  },
31
31
  {
32
32
  "name": "clearCookies",
33
- "signature": "() => Promise<any>",
34
- "parameters": [],
33
+ "signature": "(options: ClearCookieOptions) => Promise<any>",
34
+ "parameters": [
35
+ {
36
+ "name": "options",
37
+ "docs": "",
38
+ "type": "ClearCookieOptions"
39
+ }
40
+ ],
35
41
  "returns": "Promise<any>",
36
42
  "tags": [
37
43
  {
@@ -39,10 +45,40 @@
39
45
  "text": "0.5.0"
40
46
  }
41
47
  ],
42
- "docs": "Clear all cookies",
43
- "complexTypes": [],
48
+ "docs": "Clear cookies of url",
49
+ "complexTypes": [
50
+ "ClearCookieOptions"
51
+ ],
44
52
  "slug": "clearcookies"
45
53
  },
54
+ {
55
+ "name": "getCookies",
56
+ "signature": "(options: GetCookieOptions) => Promise<Record<string, string>>",
57
+ "parameters": [
58
+ {
59
+ "name": "options",
60
+ "docs": "The options, including the URL to get cookies for.",
61
+ "type": "GetCookieOptions"
62
+ }
63
+ ],
64
+ "returns": "Promise<Record<string, string>>",
65
+ "tags": [
66
+ {
67
+ "name": "param",
68
+ "text": "options The options, including the URL to get cookies for."
69
+ },
70
+ {
71
+ "name": "returns",
72
+ "text": "A promise that resolves with the cookies."
73
+ }
74
+ ],
75
+ "docs": "Get cookies for a specific URL.",
76
+ "complexTypes": [
77
+ "Record",
78
+ "GetCookieOptions"
79
+ ],
80
+ "slug": "getcookies"
81
+ },
46
82
  {
47
83
  "name": "close",
48
84
  "signature": "() => Promise<any>",
@@ -275,6 +311,82 @@
275
311
  "methods": [],
276
312
  "properties": []
277
313
  },
314
+ {
315
+ "name": "ClearCookieOptions",
316
+ "slug": "clearcookieoptions",
317
+ "docs": "",
318
+ "tags": [],
319
+ "methods": [],
320
+ "properties": [
321
+ {
322
+ "name": "url",
323
+ "tags": [],
324
+ "docs": "",
325
+ "complexTypes": [],
326
+ "type": "string"
327
+ },
328
+ {
329
+ "name": "cache",
330
+ "tags": [],
331
+ "docs": "",
332
+ "complexTypes": [],
333
+ "type": "boolean | undefined"
334
+ }
335
+ ]
336
+ },
337
+ {
338
+ "name": "HttpCookie",
339
+ "slug": "httpcookie",
340
+ "docs": "",
341
+ "tags": [],
342
+ "methods": [],
343
+ "properties": [
344
+ {
345
+ "name": "url",
346
+ "tags": [],
347
+ "docs": "",
348
+ "complexTypes": [],
349
+ "type": "string | undefined"
350
+ },
351
+ {
352
+ "name": "key",
353
+ "tags": [],
354
+ "docs": "",
355
+ "complexTypes": [],
356
+ "type": "string"
357
+ },
358
+ {
359
+ "name": "value",
360
+ "tags": [],
361
+ "docs": "",
362
+ "complexTypes": [],
363
+ "type": "string"
364
+ }
365
+ ]
366
+ },
367
+ {
368
+ "name": "GetCookieOptions",
369
+ "slug": "getcookieoptions",
370
+ "docs": "",
371
+ "tags": [],
372
+ "methods": [],
373
+ "properties": [
374
+ {
375
+ "name": "url",
376
+ "tags": [],
377
+ "docs": "",
378
+ "complexTypes": [],
379
+ "type": "string"
380
+ },
381
+ {
382
+ "name": "includeHttpOnly",
383
+ "tags": [],
384
+ "docs": "",
385
+ "complexTypes": [],
386
+ "type": "boolean | undefined"
387
+ }
388
+ ]
389
+ },
278
390
  {
279
391
  "name": "OpenWebViewOptions",
280
392
  "slug": "openwebviewoptions",
@@ -366,7 +478,7 @@
366
478
  ],
367
479
  "docs": "Title of the browser",
368
480
  "complexTypes": [],
369
- "type": "string"
481
+ "type": "string | undefined"
370
482
  },
371
483
  {
372
484
  "name": "backgroundColor",
@@ -402,6 +514,30 @@
402
514
  "complexTypes": [],
403
515
  "type": "boolean | undefined"
404
516
  },
517
+ {
518
+ "name": "isInspectable",
519
+ "tags": [
520
+ {
521
+ "text": "false",
522
+ "name": "default"
523
+ }
524
+ ],
525
+ "docs": "Whether the website in the webview is inspectable or not, ios only",
526
+ "complexTypes": [],
527
+ "type": "boolean | undefined"
528
+ },
529
+ {
530
+ "name": "isAnimated",
531
+ "tags": [
532
+ {
533
+ "text": "true",
534
+ "name": "default"
535
+ }
536
+ ],
537
+ "docs": "Whether the webview opening is animated or not, ios only",
538
+ "complexTypes": [],
539
+ "type": "boolean | undefined"
540
+ },
405
541
  {
406
542
  "name": "showReloadButton",
407
543
  "tags": [
@@ -695,6 +831,93 @@
695
831
  }
696
832
  ],
697
833
  "typeAliases": [
834
+ {
835
+ "name": "ClearCookieOptions",
836
+ "slug": "clearcookieoptions",
837
+ "docs": "",
838
+ "types": [
839
+ {
840
+ "text": "Omit<HttpCookie, 'key' | 'value'>",
841
+ "complexTypes": [
842
+ "Omit",
843
+ "HttpCookie"
844
+ ]
845
+ }
846
+ ]
847
+ },
848
+ {
849
+ "name": "Omit",
850
+ "slug": "omit",
851
+ "docs": "Construct a type with the properties of T except for those in type K.",
852
+ "types": [
853
+ {
854
+ "text": "Pick<T, Exclude<keyof T, K>>",
855
+ "complexTypes": [
856
+ "Pick",
857
+ "T",
858
+ "Exclude",
859
+ "K"
860
+ ]
861
+ }
862
+ ]
863
+ },
864
+ {
865
+ "name": "Pick",
866
+ "slug": "pick",
867
+ "docs": "From T, pick a set of properties whose keys are in the union K",
868
+ "types": [
869
+ {
870
+ "text": "{\r\n [P in K]: T[P];\r\n}",
871
+ "complexTypes": [
872
+ "K",
873
+ "T",
874
+ "P"
875
+ ]
876
+ }
877
+ ]
878
+ },
879
+ {
880
+ "name": "Exclude",
881
+ "slug": "exclude",
882
+ "docs": "Exclude from T those types that are assignable to U",
883
+ "types": [
884
+ {
885
+ "text": "T extends U ? never : T",
886
+ "complexTypes": [
887
+ "T",
888
+ "U"
889
+ ]
890
+ }
891
+ ]
892
+ },
893
+ {
894
+ "name": "Record",
895
+ "slug": "record",
896
+ "docs": "Construct a type with a set of properties K of type T",
897
+ "types": [
898
+ {
899
+ "text": "{\r\n [P in K]: T;\r\n}",
900
+ "complexTypes": [
901
+ "K",
902
+ "T"
903
+ ]
904
+ }
905
+ ]
906
+ },
907
+ {
908
+ "name": "GetCookieOptions",
909
+ "slug": "getcookieoptions",
910
+ "docs": "",
911
+ "types": [
912
+ {
913
+ "text": "Omit<HttpCookie, 'key' | 'value'>",
914
+ "complexTypes": [
915
+ "Omit",
916
+ "HttpCookie"
917
+ ]
918
+ }
919
+ ]
920
+ },
698
921
  {
699
922
  "name": "UrlChangeListener",
700
923
  "slug": "urlchangelistener",
@@ -30,6 +30,14 @@ export declare enum ToolBarType {
30
30
  export interface Headers {
31
31
  [key: string]: string;
32
32
  }
33
+ export interface GetCookieOptions {
34
+ url: string;
35
+ includeHttpOnly?: boolean;
36
+ }
37
+ export interface ClearCookieOptions {
38
+ url: string;
39
+ cache?: boolean;
40
+ }
33
41
  export interface OpenOptions {
34
42
  /**
35
43
  * Target URL to load.
@@ -86,7 +94,7 @@ export interface OpenWebViewOptions {
86
94
  * @since 0.1.0
87
95
  * @default 'New Window'
88
96
  */
89
- title: string;
97
+ title?: string;
90
98
  /**
91
99
  * Background color of the browser, only on IOS
92
100
  * @since 0.1.0
@@ -101,6 +109,18 @@ export interface OpenWebViewOptions {
101
109
  * @default false
102
110
  */
103
111
  isPresentAfterPageLoad?: boolean;
112
+ /**
113
+ * Whether the website in the webview is inspectable or not, ios only
114
+ *
115
+ * @default false
116
+ */
117
+ isInspectable?: boolean;
118
+ /**
119
+ * Whether the webview opening is animated or not, ios only
120
+ *
121
+ * @default true
122
+ */
123
+ isAnimated?: boolean;
104
124
  /**
105
125
  * Shows a reload button that reloads the web page
106
126
  * @since 1.0.15
@@ -172,11 +192,17 @@ export interface InAppBrowserPlugin {
172
192
  */
173
193
  open(options: OpenOptions): Promise<any>;
174
194
  /**
175
- * Clear all cookies
195
+ * Clear cookies of url
176
196
  *
177
197
  * @since 0.5.0
178
198
  */
179
- clearCookies(): Promise<any>;
199
+ clearCookies(options: ClearCookieOptions): Promise<any>;
200
+ /**
201
+ * Get cookies for a specific URL.
202
+ * @param options The options, including the URL to get cookies for.
203
+ * @returns A promise that resolves with the cookies.
204
+ */
205
+ getCookies(options: GetCookieOptions): Promise<Record<string, string>>;
180
206
  close(): Promise<any>;
181
207
  /**
182
208
  * Open url in a new webview with toolbars
@@ -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 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 * 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 all cookies\n *\n * @since 0.5.0\n */\n clearCookies(): Promise<any>;\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 * 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"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { WebPlugin } from "@capacitor/core";
2
- import type { InAppBrowserPlugin, OpenWebViewOptions, OpenOptions } from "./definitions";
2
+ import type { InAppBrowserPlugin, OpenWebViewOptions, OpenOptions, GetCookieOptions, ClearCookieOptions } from "./definitions";
3
3
  export declare class InAppBrowserWeb extends WebPlugin implements InAppBrowserPlugin {
4
4
  open(options: OpenOptions): Promise<any>;
5
- clearCookies(): Promise<any>;
5
+ clearCookies(options: ClearCookieOptions): Promise<any>;
6
+ getCookies(options: GetCookieOptions): Promise<any>;
6
7
  openWebView(options: OpenWebViewOptions): Promise<any>;
7
8
  close(): Promise<any>;
8
9
  setUrl(options: {
package/dist/esm/web.js CHANGED
@@ -4,10 +4,14 @@ export class InAppBrowserWeb extends WebPlugin {
4
4
  console.log("open", options);
5
5
  return options;
6
6
  }
7
- async clearCookies() {
8
- console.log("cleanCookies");
7
+ async clearCookies(options) {
8
+ console.log("cleanCookies", options);
9
9
  return;
10
10
  }
11
+ async getCookies(options) {
12
+ // Web implementation to get cookies
13
+ return options;
14
+ }
11
15
  async openWebView(options) {
12
16
  console.log("openWebView", options);
13
17
  return options;
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQ5C,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;QAChB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC5B,OAAO;IACT,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} 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(): Promise<any> {\n console.log(\"cleanCookies\");\n return;\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,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"]}
@@ -24,10 +24,14 @@ class InAppBrowserWeb extends core.WebPlugin {
24
24
  console.log("open", options);
25
25
  return options;
26
26
  }
27
- async clearCookies() {
28
- console.log("cleanCookies");
27
+ async clearCookies(options) {
28
+ console.log("cleanCookies", options);
29
29
  return;
30
30
  }
31
+ async getCookies(options) {
32
+ // Web implementation to get cookies
33
+ return options;
34
+ }
31
35
  async openWebView(options) {
32
36
  console.log("openWebView", options);
33
37
  return options;
@@ -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() {\n console.log(\"cleanCookies\");\n return;\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,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;;ACVhC,MAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACnE,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,YAAY,GAAG;AACzB,QAAQ,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AACpC,QAAQ,OAAO;AACf,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,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,OAAO,CAAC,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 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,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;;ACVhC,MAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACnE,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,YAAY,CAAC,OAAO,EAAE;AAChC,QAAQ,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AAC7C,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;AAC9B;AACA,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,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9B,QAAQ,OAAO;AACf,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -23,10 +23,14 @@ var capacitorInAppBrowser = (function (exports, core) {
23
23
  console.log("open", options);
24
24
  return options;
25
25
  }
26
- async clearCookies() {
27
- console.log("cleanCookies");
26
+ async clearCookies(options) {
27
+ console.log("cleanCookies", options);
28
28
  return;
29
29
  }
30
+ async getCookies(options) {
31
+ // Web implementation to get cookies
32
+ return options;
33
+ }
30
34
  async openWebView(options) {
31
35
  console.log("openWebView", options);
32
36
  return options;
@@ -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() {\n console.log(\"cleanCookies\");\n return;\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,GAAG;IACzB,QAAQ,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACpC,QAAQ,OAAO;IACf,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 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;;;;;;;;;;;;;;;"}
@@ -6,6 +6,7 @@
6
6
  CAP_PLUGIN(InAppBrowserPlugin, "InAppBrowser",
7
7
  CAP_PLUGIN_METHOD(openWebView, CAPPluginReturnPromise);
8
8
  CAP_PLUGIN_METHOD(clearCookies, CAPPluginReturnPromise);
9
+ CAP_PLUGIN_METHOD(getCookies, CAPPluginReturnPromise);
9
10
  CAP_PLUGIN_METHOD(reload, CAPPluginReturnPromise);
10
11
  CAP_PLUGIN_METHOD(open, CAPPluginReturnPromise);
11
12
  CAP_PLUGIN_METHOD(setUrl, CAPPluginReturnPromise);
@@ -43,15 +43,57 @@ public class InAppBrowserPlugin: CAPPlugin {
43
43
  #endif
44
44
  }
45
45
 
46
- func presentView() {
47
- self.bridge?.viewController?.present(self.navigationWebViewController!, animated: true, completion: {
46
+ func presentView(isAnimated: Bool = true) {
47
+ self.bridge?.viewController?.present(self.navigationWebViewController!, animated: isAnimated, completion: {
48
48
  self.currentPluginCall?.resolve()
49
49
  })
50
50
  }
51
51
 
52
52
  @objc func clearCookies(_ call: CAPPluginCall) {
53
- HTTPCookieStorage.shared.cookies?.forEach(HTTPCookieStorage.shared.deleteCookie)
54
- call.resolve()
53
+ let dataStore = WKWebsiteDataStore.default()
54
+ let urlString = call.getString("url") ?? ""
55
+ let clearCache = call.getBool("cache") ?? false
56
+
57
+ if clearCache {
58
+ URLCache.shared.removeAllCachedResponses()
59
+ }
60
+
61
+ guard let url = URL(string: urlString), let hostName = url.host else {
62
+ call.reject("Invalid URL")
63
+ return
64
+ }
65
+ dataStore.httpCookieStore.getAllCookies { cookies in
66
+ let cookiesToDelete = cookies.filter { cookie in
67
+ cookie.domain == hostName || cookie.domain.hasSuffix(".\(hostName)") || hostName.hasSuffix(cookie.domain)
68
+ }
69
+
70
+ for cookie in cookiesToDelete {
71
+ dataStore.httpCookieStore.delete(cookie)
72
+ }
73
+
74
+ call.resolve()
75
+ }
76
+ }
77
+
78
+ @objc func getCookies(_ call: CAPPluginCall) {
79
+ let urlString = call.getString("url") ?? ""
80
+ let includeHttpOnly = call.getBool("includeHttpOnly") ?? true
81
+
82
+ guard let url = URL(string: urlString), let host = url.host else {
83
+ call.reject("Invalid URL")
84
+ return
85
+ }
86
+
87
+ WKWebsiteDataStore.default().httpCookieStore.getAllCookies { cookies in
88
+ var cookieDict = [String: String]()
89
+ for cookie in cookies {
90
+
91
+ if (includeHttpOnly || !cookie.isHTTPOnly) && (cookie.domain == host || cookie.domain.hasSuffix(".\(host)") || host.hasSuffix(cookie.domain)) {
92
+ cookieDict[cookie.name] = cookie.value
93
+ }
94
+ }
95
+ call.resolve(cookieDict)
96
+ }
55
97
  }
56
98
 
57
99
  @objc func openWebView(_ call: CAPPluginCall) {
@@ -76,6 +118,8 @@ public class InAppBrowserPlugin: CAPPlugin {
76
118
  let closeModalDescription = call.getString("closeModalDescription", "Are you sure you want to close this window?")
77
119
  let closeModalOk = call.getString("closeModalOk", "OK")
78
120
  let closeModalCancel = call.getString("closeModalCancel", "Cancel")
121
+ let isInspectable = call.getBool("isInspectable", false)
122
+ let isAnimated = call.getBool("isAnimated", true)
79
123
 
80
124
  var disclaimerContent = call.getObject("shareDisclaimer")
81
125
  let toolbarType = call.getString("toolbarType", "")
@@ -91,7 +135,7 @@ public class InAppBrowserPlugin: CAPPlugin {
91
135
  let url = URL(string: urlString)
92
136
 
93
137
  if self.isPresentAfterPageLoad {
94
- self.webViewController = WKWebViewController.init(url: url!, headers: headers)
138
+ self.webViewController = WKWebViewController.init(url: url!, headers: headers, isInspectable: isInspectable)
95
139
  } else {
96
140
  self.webViewController = WKWebViewController.init()
97
141
  self.webViewController?.setHeaders(headers: headers)
@@ -128,11 +172,11 @@ public class InAppBrowserPlugin: CAPPlugin {
128
172
  self.navigationWebViewController?.navigationBar.isHidden = true
129
173
  }
130
174
  if showReloadButton {
131
- var toolbarItems = self.getToolbarItems(toolbarType: toolbarType)
175
+ let toolbarItems = self.getToolbarItems(toolbarType: toolbarType)
132
176
  self.webViewController?.leftNavigaionBarItemTypes = toolbarItems + [.reload]
133
177
  }
134
178
  if !self.isPresentAfterPageLoad {
135
- self.presentView()
179
+ self.presentView(isAnimated: isAnimated)
136
180
  }
137
181
  }
138
182
  }
@@ -183,6 +227,8 @@ public class InAppBrowserPlugin: CAPPlugin {
183
227
  self.setup()
184
228
  }
185
229
 
230
+ let isInspectable = call.getBool("isInspectable", false)
231
+
186
232
  self.currentPluginCall = call
187
233
 
188
234
  guard let urlString = call.getString("url") else {
@@ -203,7 +249,7 @@ public class InAppBrowserPlugin: CAPPlugin {
203
249
  let url = URL(string: urlString)
204
250
 
205
251
  if self.isPresentAfterPageLoad {
206
- self.webViewController = WKWebViewController.init(url: url!, headers: headers)
252
+ self.webViewController = WKWebViewController.init(url: url!, headers: headers, isInspectable: isInspectable)
207
253
  } else {
208
254
  self.webViewController = WKWebViewController.init()
209
255
  self.webViewController?.setHeaders(headers: headers)
@@ -60,11 +60,11 @@ open class WKWebViewController: UIViewController {
60
60
  self.initWebview()
61
61
  }
62
62
 
63
- public init(url: URL, headers: [String: String]) {
63
+ public init(url: URL, headers: [String: String], isInspectable: Bool) {
64
64
  super.init(nibName: nil, bundle: nil)
65
65
  self.source = .remote(url)
66
66
  self.setHeaders(headers: headers)
67
- self.initWebview()
67
+ self.initWebview(isInspectable: isInspectable)
68
68
  }
69
69
 
70
70
  open var hasDynamicTitle = false
@@ -206,7 +206,7 @@ open class WKWebViewController: UIViewController {
206
206
  }
207
207
  }
208
208
 
209
- open func initWebview() {
209
+ open func initWebview(isInspectable: Bool = true) {
210
210
 
211
211
  self.view.backgroundColor = UIColor.white
212
212
 
@@ -216,6 +216,10 @@ open class WKWebViewController: UIViewController {
216
216
  let webConfiguration = WKWebViewConfiguration()
217
217
  let webView = WKWebView(frame: .zero, configuration: webConfiguration)
218
218
 
219
+ if #available(iOS 16.4, *) {
220
+ webView.isInspectable = isInspectable
221
+ }
222
+
219
223
  webView.uiDelegate = self
220
224
  webView.navigationDelegate = self
221
225
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "1.2.19",
3
+ "version": "1.3.1",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",