@capgo/inappbrowser 8.1.13 → 8.1.14

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
@@ -59,7 +59,7 @@ By default, the webview opens in fullscreen. You can set custom dimensions to co
59
59
  import { InAppBrowser } from '@capgo/inappbrowser'
60
60
 
61
61
  // Open with custom dimensions (400x600 at position 50,100)
62
- InAppBrowser.openWebView({
62
+ const { id } = await InAppBrowser.openWebView({
63
63
  url: "YOUR_URL",
64
64
  width: 400,
65
65
  height: 600,
@@ -69,6 +69,7 @@ InAppBrowser.openWebView({
69
69
 
70
70
  // Update dimensions at runtime
71
71
  InAppBrowser.updateDimensions({
72
+ id, // Optional, if omitted targets the active webview
72
73
  width: 500,
73
74
  height: 700,
74
75
  x: 100,
@@ -174,7 +175,10 @@ With this plugin you can send events from the main app to the inappbrowser and v
174
175
  #### Main app to inappbrowser, detail object is mendatory
175
176
 
176
177
  ```js
177
- InAppBrowser.postMessage({ detail: { message: "myMessage" } });
178
+ const { id } = await InAppBrowser.openWebView({ url: "YOUR_URL" });
179
+ InAppBrowser.postMessage({ id, detail: { message: "myMessage" } });
180
+ // Or broadcast to all open webviews
181
+ InAppBrowser.postMessage({ detail: { message: "broadcast" } });
178
182
  ```
179
183
 
180
184
  #### Receive event from native in the inappbrowser
@@ -195,7 +199,7 @@ window.mobileApp.postMessage({ detail: { message: "myMessage" } });
195
199
 
196
200
  ```js
197
201
  InAppBrowser.addListener("messageFromWebview", (event) => {
198
- console.log(event);
202
+ console.log(event.id, event.detail);
199
203
  });
200
204
  ```
201
205
 
@@ -209,11 +213,11 @@ window.mobileApp.close();
209
213
 
210
214
  <docgen-index>
211
215
 
212
- * [`goBack()`](#goback)
216
+ * [`goBack(...)`](#goback)
213
217
  * [`open(...)`](#open)
214
218
  * [`clearCookies(...)`](#clearcookies)
215
- * [`clearAllCookies()`](#clearallcookies)
216
- * [`clearCache()`](#clearcache)
219
+ * [`clearAllCookies(...)`](#clearallcookies)
220
+ * [`clearCache(...)`](#clearcache)
217
221
  * [`getCookies(...)`](#getcookies)
218
222
  * [`close(...)`](#close)
219
223
  * [`hide()`](#hide)
@@ -230,7 +234,7 @@ window.mobileApp.close();
230
234
  * [`addListener('browserPageLoaded', ...)`](#addlistenerbrowserpageloaded-)
231
235
  * [`addListener('pageLoadError', ...)`](#addlistenerpageloaderror-)
232
236
  * [`removeAllListeners()`](#removealllisteners)
233
- * [`reload()`](#reload)
237
+ * [`reload(...)`](#reload)
234
238
  * [`updateDimensions(...)`](#updatedimensions)
235
239
  * [Interfaces](#interfaces)
236
240
  * [Type Aliases](#type-aliases)
@@ -241,14 +245,18 @@ window.mobileApp.close();
241
245
  <docgen-api>
242
246
  <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
243
247
 
244
- ### goBack()
248
+ ### goBack(...)
245
249
 
246
250
  ```typescript
247
- goBack() => Promise<{ canGoBack: boolean; }>
251
+ goBack(options?: { id?: string | undefined; } | undefined) => Promise<{ canGoBack: boolean; }>
248
252
  ```
249
253
 
250
254
  Navigates back in the WebView's history if possible
251
255
 
256
+ | Param | Type |
257
+ | ------------- | ----------------------------- |
258
+ | **`options`** | <code>{ id?: string; }</code> |
259
+
252
260
  **Returns:** <code>Promise&lt;{ canGoBack: boolean; }&gt;</code>
253
261
 
254
262
  **Since:** 7.21.0
@@ -282,6 +290,7 @@ clearCookies(options: ClearCookieOptions) => Promise<any>
282
290
  ```
283
291
 
284
292
  Clear cookies of url
293
+ When `id` is omitted, applies to all open webviews.
285
294
 
286
295
  | Param | Type |
287
296
  | ------------- | ----------------------------------------------------------------- |
@@ -294,13 +303,18 @@ Clear cookies of url
294
303
  --------------------
295
304
 
296
305
 
297
- ### clearAllCookies()
306
+ ### clearAllCookies(...)
298
307
 
299
308
  ```typescript
300
- clearAllCookies() => Promise<any>
309
+ clearAllCookies(options?: { id?: string | undefined; } | undefined) => Promise<any>
301
310
  ```
302
311
 
303
312
  Clear all cookies
313
+ When `id` is omitted, applies to all open webviews.
314
+
315
+ | Param | Type |
316
+ | ------------- | ----------------------------- |
317
+ | **`options`** | <code>{ id?: string; }</code> |
304
318
 
305
319
  **Returns:** <code>Promise&lt;any&gt;</code>
306
320
 
@@ -309,13 +323,18 @@ Clear all cookies
309
323
  --------------------
310
324
 
311
325
 
312
- ### clearCache()
326
+ ### clearCache(...)
313
327
 
314
328
  ```typescript
315
- clearCache() => Promise<any>
329
+ clearCache(options?: { id?: string | undefined; } | undefined) => Promise<any>
316
330
  ```
317
331
 
318
332
  Clear cache
333
+ When `id` is omitted, applies to all open webviews.
334
+
335
+ | Param | Type |
336
+ | ------------- | ----------------------------- |
337
+ | **`options`** | <code>{ id?: string; }</code> |
319
338
 
320
339
  **Returns:** <code>Promise&lt;any&gt;</code>
321
340
 
@@ -348,6 +367,7 @@ close(options?: CloseWebviewOptions | undefined) => Promise<any>
348
367
  ```
349
368
 
350
369
  Close the webview.
370
+ When `id` is omitted, closes the active webview.
351
371
 
352
372
  | Param | Type |
353
373
  | ------------- | ------------------------------------------------------------------- |
@@ -388,7 +408,7 @@ Show a previously hidden webview.
388
408
  ### openWebView(...)
389
409
 
390
410
  ```typescript
391
- openWebView(options: OpenWebViewOptions) => Promise<any>
411
+ openWebView(options: OpenWebViewOptions) => Promise<{ id: string; }>
392
412
  ```
393
413
 
394
414
  Open url in a new webview with toolbars, and enhanced capabilities, like camera access, file access, listen events, inject javascript, bi directional communication, etc.
@@ -402,7 +422,7 @@ When you open a webview with this method, a JavaScript interface is automaticall
402
422
  | ------------- | ----------------------------------------------------------------- |
403
423
  | **`options`** | <code><a href="#openwebviewoptions">OpenWebViewOptions</a></code> |
404
424
 
405
- **Returns:** <code>Promise&lt;any&gt;</code>
425
+ **Returns:** <code>Promise&lt;{ id: string; }&gt;</code>
406
426
 
407
427
  **Since:** 0.1.0
408
428
 
@@ -412,14 +432,15 @@ When you open a webview with this method, a JavaScript interface is automaticall
412
432
  ### executeScript(...)
413
433
 
414
434
  ```typescript
415
- executeScript({ code }: { code: string; }) => Promise<void>
435
+ executeScript(options: { code: string; id?: string; }) => Promise<void>
416
436
  ```
417
437
 
418
438
  Injects JavaScript code into the InAppBrowser window.
439
+ When `id` is omitted, executes in all open webviews.
419
440
 
420
- | Param | Type |
421
- | --------- | ------------------------------ |
422
- | **`__0`** | <code>{ code: string; }</code> |
441
+ | Param | Type |
442
+ | ------------- | ------------------------------------------- |
443
+ | **`options`** | <code>{ code: string; id?: string; }</code> |
423
444
 
424
445
  --------------------
425
446
 
@@ -427,16 +448,17 @@ Injects JavaScript code into the InAppBrowser window.
427
448
  ### postMessage(...)
428
449
 
429
450
  ```typescript
430
- postMessage(options: { detail: Record<string, any>; }) => Promise<void>
451
+ postMessage(options: { detail: Record<string, any>; id?: string; }) => Promise<void>
431
452
  ```
432
453
 
433
454
  Sends an event to the webview(inappbrowser). you can listen to this event in the inappbrowser JS with window.addEventListener("messageFromNative", listenerFunc: (event: <a href="#record">Record</a>&lt;string, any&gt;) =&gt; void)
434
455
  detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects
435
456
  Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.
457
+ When `id` is omitted, broadcasts to all open webviews.
436
458
 
437
- | Param | Type |
438
- | ------------- | ------------------------------------------------------------------------- |
439
- | **`options`** | <code>{ detail: <a href="#record">Record</a>&lt;string, any&gt;; }</code> |
459
+ | Param | Type |
460
+ | ------------- | -------------------------------------------------------------------------------------- |
461
+ | **`options`** | <code>{ detail: <a href="#record">Record</a>&lt;string, any&gt;; id?: string; }</code> |
440
462
 
441
463
  --------------------
442
464
 
@@ -444,14 +466,15 @@ Your object has to be serializable to JSON, so no functions or other non-JSON-se
444
466
  ### setUrl(...)
445
467
 
446
468
  ```typescript
447
- setUrl(options: { url: string; }) => Promise<any>
469
+ setUrl(options: { url: string; id?: string; }) => Promise<any>
448
470
  ```
449
471
 
450
472
  Sets the URL of the webview.
473
+ When `id` is omitted, targets the active webview.
451
474
 
452
- | Param | Type |
453
- | ------------- | ----------------------------- |
454
- | **`options`** | <code>{ url: string; }</code> |
475
+ | Param | Type |
476
+ | ------------- | ------------------------------------------ |
477
+ | **`options`** | <code>{ url: string; id?: string; }</code> |
455
478
 
456
479
  **Returns:** <code>Promise&lt;any&gt;</code>
457
480
 
@@ -538,7 +561,7 @@ works with openWebView shareDisclaimer and closeModal
538
561
  ### addListener('messageFromWebview', ...)
539
562
 
540
563
  ```typescript
541
- addListener(eventName: 'messageFromWebview', listenerFunc: (event: { detail: Record<string, any>; }) => void) => Promise<PluginListenerHandle>
564
+ addListener(eventName: 'messageFromWebview', listenerFunc: (event: { id?: string; detail?: Record<string, any>; rawMessage?: string; }) => void) => Promise<PluginListenerHandle>
542
565
  ```
543
566
 
544
567
  Will be triggered when event is sent from webview(inappbrowser), to send an event to the main app use window.mobileApp.postMessage({ "detail": { "message": "myMessage" } })
@@ -547,10 +570,10 @@ Your object has to be serializable to JSON, no functions or other non-JSON-seria
547
570
 
548
571
  This method is inject at runtime in the webview
549
572
 
550
- | Param | Type |
551
- | ------------------ | --------------------------------------------------------------------------------------------- |
552
- | **`eventName`** | <code>'messageFromWebview'</code> |
553
- | **`listenerFunc`** | <code>(event: { detail: <a href="#record">Record</a>&lt;string, any&gt;; }) =&gt; void</code> |
573
+ | Param | Type |
574
+ | ------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
575
+ | **`eventName`** | <code>'messageFromWebview'</code> |
576
+ | **`listenerFunc`** | <code>(event: { id?: string; detail?: <a href="#record">Record</a>&lt;string, any&gt;; rawMessage?: string; }) =&gt; void</code> |
554
577
 
555
578
  **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
556
579
 
@@ -560,15 +583,15 @@ This method is inject at runtime in the webview
560
583
  ### addListener('browserPageLoaded', ...)
561
584
 
562
585
  ```typescript
563
- addListener(eventName: 'browserPageLoaded', listenerFunc: () => void) => Promise<PluginListenerHandle>
586
+ addListener(eventName: 'browserPageLoaded', listenerFunc: (event: { id?: string; }) => void) => Promise<PluginListenerHandle>
564
587
  ```
565
588
 
566
589
  Will be triggered when page is loaded
567
590
 
568
- | Param | Type |
569
- | ------------------ | -------------------------------- |
570
- | **`eventName`** | <code>'browserPageLoaded'</code> |
571
- | **`listenerFunc`** | <code>() =&gt; void</code> |
591
+ | Param | Type |
592
+ | ------------------ | ------------------------------------------------- |
593
+ | **`eventName`** | <code>'browserPageLoaded'</code> |
594
+ | **`listenerFunc`** | <code>(event: { id?: string; }) =&gt; void</code> |
572
595
 
573
596
  **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
574
597
 
@@ -578,15 +601,15 @@ Will be triggered when page is loaded
578
601
  ### addListener('pageLoadError', ...)
579
602
 
580
603
  ```typescript
581
- addListener(eventName: 'pageLoadError', listenerFunc: () => void) => Promise<PluginListenerHandle>
604
+ addListener(eventName: 'pageLoadError', listenerFunc: (event: { id?: string; }) => void) => Promise<PluginListenerHandle>
582
605
  ```
583
606
 
584
607
  Will be triggered when page load error
585
608
 
586
- | Param | Type |
587
- | ------------------ | ---------------------------- |
588
- | **`eventName`** | <code>'pageLoadError'</code> |
589
- | **`listenerFunc`** | <code>() =&gt; void</code> |
609
+ | Param | Type |
610
+ | ------------------ | ------------------------------------------------- |
611
+ | **`eventName`** | <code>'pageLoadError'</code> |
612
+ | **`listenerFunc`** | <code>(event: { id?: string; }) =&gt; void</code> |
590
613
 
591
614
  **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
592
615
 
@@ -606,14 +629,18 @@ Remove all listeners for this plugin.
606
629
  --------------------
607
630
 
608
631
 
609
- ### reload()
632
+ ### reload(...)
610
633
 
611
634
  ```typescript
612
- reload() => Promise<any>
635
+ reload(options?: { id?: string | undefined; } | undefined) => Promise<any>
613
636
  ```
614
637
 
615
638
  Reload the current web page.
616
639
 
640
+ | Param | Type |
641
+ | ------------- | ----------------------------- |
642
+ | **`options`** | <code>{ id?: string; }</code> |
643
+
617
644
  **Returns:** <code>Promise&lt;any&gt;</code>
618
645
 
619
646
  **Since:** 1.0.0
@@ -624,15 +651,16 @@ Reload the current web page.
624
651
  ### updateDimensions(...)
625
652
 
626
653
  ```typescript
627
- updateDimensions(options: DimensionOptions) => Promise<void>
654
+ updateDimensions(options: DimensionOptions & { id?: string; }) => Promise<void>
628
655
  ```
629
656
 
630
657
  Update the dimensions of the webview.
631
658
  Allows changing the size and position of the webview at runtime.
659
+ When `id` is omitted, targets the active webview.
632
660
 
633
- | Param | Type | Description |
634
- | ------------- | ------------------------------------------------------------- | --------------------------------------- |
635
- | **`options`** | <code><a href="#dimensionoptions">DimensionOptions</a></code> | Dimension options (width, height, x, y) |
661
+ | Param | Type | Description |
662
+ | ------------- | -------------------------------------------------------------------------------- | --------------------------------------- |
663
+ | **`options`** | <code><a href="#dimensionoptions">DimensionOptions</a> & { id?: string; }</code> | Dimension options (width, height, x, y) |
636
664
 
637
665
  --------------------
638
666
 
@@ -651,9 +679,10 @@ Allows changing the size and position of the webview at runtime.
651
679
 
652
680
  #### ClearCookieOptions
653
681
 
654
- | Prop | Type |
655
- | --------- | ------------------- |
656
- | **`url`** | <code>string</code> |
682
+ | Prop | Type | Description |
683
+ | --------- | ------------------- | -------------------------------------------------------------- |
684
+ | **`id`** | <code>string</code> | Target webview id. When omitted, applies to all open webviews. |
685
+ | **`url`** | <code>string</code> | |
657
686
 
658
687
 
659
688
  #### HttpCookie
@@ -675,9 +704,10 @@ Allows changing the size and position of the webview at runtime.
675
704
 
676
705
  #### CloseWebviewOptions
677
706
 
678
- | Prop | Type | Description | Default |
679
- | ---------------- | -------------------- | -------------------------------------------------------- | ----------------- |
680
- | **`isAnimated`** | <code>boolean</code> | Whether the webview closing is animated or not, ios only | <code>true</code> |
707
+ | Prop | Type | Description | Default |
708
+ | ---------------- | -------------------- | ------------------------------------------------------------------ | ----------------- |
709
+ | **`id`** | <code>string</code> | Target webview id to close. If omitted, closes the active webview. | |
710
+ | **`isAnimated`** | <code>boolean</code> | Whether the webview closing is animated or not, ios only | <code>true</code> |
681
711
 
682
712
 
683
713
  #### OpenWebViewOptions
@@ -762,6 +792,7 @@ Allows changing the size and position of the webview at runtime.
762
792
 
763
793
  | Prop | Type | Description | Since |
764
794
  | --------- | ------------------- | ------------------------- | ----- |
795
+ | **`id`** | <code>string</code> | Webview instance id. | |
765
796
  | **`url`** | <code>string</code> | Emit when the url changes | 0.0.1 |
766
797
 
767
798
 
@@ -769,6 +800,7 @@ Allows changing the size and position of the webview at runtime.
769
800
 
770
801
  | Prop | Type | Description | Since |
771
802
  | --------- | ------------------- | ------------------------------ | ----- |
803
+ | **`id`** | <code>string</code> | Webview instance id. | |
772
804
  | **`url`** | <code>string</code> | Emit when a button is clicked. | 0.0.1 |
773
805
 
774
806