@capgo/inappbrowser 1.2.19 → 1.2.20

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,30 @@ 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
+
266
+
267
+ #### HttpCookie
268
+
269
+ | Prop | Type |
270
+ | ----------- | ------------------- |
271
+ | **`url`** | <code>string</code> |
272
+ | **`key`** | <code>string</code> |
273
+ | **`value`** | <code>string</code> |
274
+
275
+
276
+ #### GetCookieOptions
277
+
278
+ | Prop | Type |
279
+ | --------------------- | -------------------- |
280
+ | **`url`** | <code>string</code> |
281
+ | **`includeHttpOnly`** | <code>boolean</code> |
282
+
283
+
238
284
  #### OpenWebViewOptions
239
285
 
240
286
  | Prop | Type | Description | Default | Since |
@@ -292,6 +338,44 @@ Reload the current web page.
292
338
  ### Type Aliases
293
339
 
294
340
 
341
+ #### ClearCookieOptions
342
+
343
+ <code><a href="#omit">Omit</a>&lt;<a href="#httpcookie">HttpCookie</a>, 'key' | 'value'&gt;</code>
344
+
345
+
346
+ #### Omit
347
+
348
+ Construct a type with the properties of T except for those in type K.
349
+
350
+ <code><a href="#pick">Pick</a>&lt;T, <a href="#exclude">Exclude</a>&lt;keyof T, K&gt;&gt;</code>
351
+
352
+
353
+ #### Pick
354
+
355
+ From T, pick a set of properties whose keys are in the union K
356
+
357
+ <code>{
295
358
  [P in K]: T[P];
296
359
  }</code>
360
+
361
+
362
+ #### Exclude
363
+
364
+ <a href="#exclude">Exclude</a> from T those types that are assignable to U
365
+
366
+ <code>T extends U ? never : T</code>
367
+
368
+
369
+ #### Record
370
+
371
+ Construct a type with a set of properties K of type T
372
+
373
+ <code>{
297
374
  [P in K]: T;
298
375
  }</code>
376
+
377
+
378
+ #### GetCookieOptions
379
+
380
+ <code><a href="#omit">Omit</a>&lt;<a href="#httpcookie">HttpCookie</a>, 'key' | 'value'&gt;</code>
381
+
382
+
299
383
  #### UrlChangeListener
300
384
 
301
385
  <code>(state: <a href="#urlevent">UrlEvent</a>): void</code>
@@ -187,27 +187,46 @@ 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
+ if (url == null || TextUtils.isEmpty(url)) {
192
+ call.reject("Invalid URL");
193
+ } else {
194
+ CookieManager cookieManager = CookieManager.getInstance();
195
+ String cookie = cookieManager.getCookie(url);
196
+ if (cookie != null) {
197
+ String[] cookies = cookie.split(";");
198
+ for (String c : cookies) {
199
+ String cookieName = c.substring(0, c.indexOf("="));
200
+ cookieManager.setCookie(
201
+ url,
202
+ cookieName + "=; Expires=Thu, 01 Jan 1970 00:00:01 GMT"
203
+ );
204
+ }
205
+ }
206
+ call.resolve();
207
+ }
208
+ }
209
+
210
+ @PluginMethod
211
+ public void getCookies(PluginCall call) {
212
+ String url = call.getString("url");
213
+ if (url == null || TextUtils.isEmpty(url)) {
214
+ call.reject("Invalid URL");
192
215
  } 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
- );
216
+ CookieManager cookieManager = CookieManager.getInstance();
217
+ String cookieString = cookieManager.getCookie(url);
218
+ if (cookieString != null) {
219
+ String[] cookiePairs = cookieString.split("; ");
220
+ JSObject result = new JSObject();
221
+ for (String cookie : cookiePairs) {
222
+ String[] parts = cookie.split("=", 2);
223
+ if (parts.length == 2) {
224
+ result.put(parts[0], parts[1]);
207
225
  }
208
226
  }
209
- call.resolve();
227
+ call.resolve(result);
210
228
  }
229
+ call.resolve(new JSObject());
211
230
  }
212
231
  }
213
232
 
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,75 @@
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
+ },
330
+ {
331
+ "name": "HttpCookie",
332
+ "slug": "httpcookie",
333
+ "docs": "",
334
+ "tags": [],
335
+ "methods": [],
336
+ "properties": [
337
+ {
338
+ "name": "url",
339
+ "tags": [],
340
+ "docs": "",
341
+ "complexTypes": [],
342
+ "type": "string | undefined"
343
+ },
344
+ {
345
+ "name": "key",
346
+ "tags": [],
347
+ "docs": "",
348
+ "complexTypes": [],
349
+ "type": "string"
350
+ },
351
+ {
352
+ "name": "value",
353
+ "tags": [],
354
+ "docs": "",
355
+ "complexTypes": [],
356
+ "type": "string"
357
+ }
358
+ ]
359
+ },
360
+ {
361
+ "name": "GetCookieOptions",
362
+ "slug": "getcookieoptions",
363
+ "docs": "",
364
+ "tags": [],
365
+ "methods": [],
366
+ "properties": [
367
+ {
368
+ "name": "url",
369
+ "tags": [],
370
+ "docs": "",
371
+ "complexTypes": [],
372
+ "type": "string"
373
+ },
374
+ {
375
+ "name": "includeHttpOnly",
376
+ "tags": [],
377
+ "docs": "",
378
+ "complexTypes": [],
379
+ "type": "boolean | undefined"
380
+ }
381
+ ]
382
+ },
278
383
  {
279
384
  "name": "OpenWebViewOptions",
280
385
  "slug": "openwebviewoptions",
@@ -695,6 +800,93 @@
695
800
  }
696
801
  ],
697
802
  "typeAliases": [
803
+ {
804
+ "name": "ClearCookieOptions",
805
+ "slug": "clearcookieoptions",
806
+ "docs": "",
807
+ "types": [
808
+ {
809
+ "text": "Omit<HttpCookie, 'key' | 'value'>",
810
+ "complexTypes": [
811
+ "Omit",
812
+ "HttpCookie"
813
+ ]
814
+ }
815
+ ]
816
+ },
817
+ {
818
+ "name": "Omit",
819
+ "slug": "omit",
820
+ "docs": "Construct a type with the properties of T except for those in type K.",
821
+ "types": [
822
+ {
823
+ "text": "Pick<T, Exclude<keyof T, K>>",
824
+ "complexTypes": [
825
+ "Pick",
826
+ "T",
827
+ "Exclude",
828
+ "K"
829
+ ]
830
+ }
831
+ ]
832
+ },
833
+ {
834
+ "name": "Pick",
835
+ "slug": "pick",
836
+ "docs": "From T, pick a set of properties whose keys are in the union K",
837
+ "types": [
838
+ {
839
+ "text": "{\r\n [P in K]: T[P];\r\n}",
840
+ "complexTypes": [
841
+ "K",
842
+ "T",
843
+ "P"
844
+ ]
845
+ }
846
+ ]
847
+ },
848
+ {
849
+ "name": "Exclude",
850
+ "slug": "exclude",
851
+ "docs": "Exclude from T those types that are assignable to U",
852
+ "types": [
853
+ {
854
+ "text": "T extends U ? never : T",
855
+ "complexTypes": [
856
+ "T",
857
+ "U"
858
+ ]
859
+ }
860
+ ]
861
+ },
862
+ {
863
+ "name": "Record",
864
+ "slug": "record",
865
+ "docs": "Construct a type with a set of properties K of type T",
866
+ "types": [
867
+ {
868
+ "text": "{\r\n [P in K]: T;\r\n}",
869
+ "complexTypes": [
870
+ "K",
871
+ "T"
872
+ ]
873
+ }
874
+ ]
875
+ },
876
+ {
877
+ "name": "GetCookieOptions",
878
+ "slug": "getcookieoptions",
879
+ "docs": "",
880
+ "types": [
881
+ {
882
+ "text": "Omit<HttpCookie, 'key' | 'value'>",
883
+ "complexTypes": [
884
+ "Omit",
885
+ "HttpCookie"
886
+ ]
887
+ }
888
+ ]
889
+ },
698
890
  {
699
891
  "name": "UrlChangeListener",
700
892
  "slug": "urlchangelistener",
@@ -30,6 +30,13 @@ 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
+ }
33
40
  export interface OpenOptions {
34
41
  /**
35
42
  * Target URL to load.
@@ -172,11 +179,17 @@ export interface InAppBrowserPlugin {
172
179
  */
173
180
  open(options: OpenOptions): Promise<any>;
174
181
  /**
175
- * Clear all cookies
182
+ * Clear cookies of url
176
183
  *
177
184
  * @since 0.5.0
178
185
  */
179
- clearCookies(): Promise<any>;
186
+ clearCookies(options: ClearCookieOptions): Promise<any>;
187
+ /**
188
+ * Get cookies for a specific URL.
189
+ * @param options The options, including the URL to get cookies for.
190
+ * @returns A promise that resolves with the cookies.
191
+ */
192
+ getCookies(options: GetCookieOptions): Promise<Record<string, string>>;
180
193
  close(): Promise<any>;
181
194
  /**
182
195
  * 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}\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 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);
@@ -50,8 +50,45 @@ public class InAppBrowserPlugin: CAPPlugin {
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
+
56
+ guard let url = URL(string: urlString), let hostName = url.host else {
57
+ call.reject("Invalid URL")
58
+ return
59
+ }
60
+ dataStore.httpCookieStore.getAllCookies { cookies in
61
+ let cookiesToDelete = cookies.filter { cookie in
62
+ cookie.domain == hostName || cookie.domain.hasSuffix(".\(hostName)") || hostName.hasSuffix(cookie.domain)
63
+ }
64
+
65
+ for cookie in cookiesToDelete {
66
+ dataStore.httpCookieStore.delete(cookie)
67
+ }
68
+
69
+ call.resolve()
70
+ }
71
+ }
72
+
73
+ @objc func getCookies(_ call: CAPPluginCall) {
74
+ let urlString = call.getString("url") ?? ""
75
+ let includeHttpOnly = call.getBool("includeHttpOnly") ?? true
76
+
77
+ guard let url = URL(string: urlString), let host = url.host else {
78
+ call.reject("Invalid URL")
79
+ return
80
+ }
81
+
82
+ WKWebsiteDataStore.default().httpCookieStore.getAllCookies { cookies in
83
+ var cookieDict = [String: String]()
84
+ for cookie in cookies {
85
+
86
+ if (includeHttpOnly || !cookie.isHTTPOnly) && (cookie.domain == host || cookie.domain.hasSuffix(".\(host)") || host.hasSuffix(cookie.domain)) {
87
+ cookieDict[cookie.name] = cookie.value
88
+ }
89
+ }
90
+ call.resolve(cookieDict)
91
+ }
55
92
  }
56
93
 
57
94
  @objc func openWebView(_ call: CAPPluginCall) {
@@ -128,7 +165,7 @@ public class InAppBrowserPlugin: CAPPlugin {
128
165
  self.navigationWebViewController?.navigationBar.isHidden = true
129
166
  }
130
167
  if showReloadButton {
131
- var toolbarItems = self.getToolbarItems(toolbarType: toolbarType)
168
+ let toolbarItems = self.getToolbarItems(toolbarType: toolbarType)
132
169
  self.webViewController?.leftNavigaionBarItemTypes = toolbarItems + [.reload]
133
170
  }
134
171
  if !self.isPresentAfterPageLoad {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "1.2.19",
3
+ "version": "1.2.20",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",