@capgo/capacitor-inappbrowser 8.18.0 → 8.19.0

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
@@ -1590,7 +1590,8 @@ See the README section "openSecureWindow (OAuth)" for full setup examples.
1590
1590
  | **`useSharedDataStore`** | <code>boolean</code> | Share the host Capacitor WebView's website data store (cookies, local storage, etc.). On iOS 17+, InAppBrowser uses an isolated plugin-owned `WKWebsiteDataStore` by default so host and browser data stay separate. Set this to `true` to use `WKWebsiteDataStore.default()` instead, which shares session cookies with the Capacitor host WebView. Useful for SSO / OIDC silent login when the IdP session was established in the main app WebView. Requires `persistWebViewData: true` (the default). When `persistWebViewData` is false, a non-persistent store is used and this option has no effect. On Android this is a no-op: cookies are already process-global via `CookieManager`. On Web this is a no-op. Warning: clearing cookies/cache for a webview opened with this flag can affect the host WebView on iOS, because both share the same store. `clearAllBrowsingData()` still skips the host store. | <code>false</code> | 8.13.6 |
1591
1591
  | **`clientCertificate`** | <code>'none' \| 'prompt'</code> | Controls Android TLS client certificate prompts during HTTPS handshakes. Use `prompt` to show the system certificate picker; omit or use `none` to cancel silently (default). | <code>"none"</code> | 8.7.5 |
1592
1592
  | **`clientCertificatePrompt`** | <code>boolean</code> | | | |
1593
- | **`handleDownloads`** | <code>boolean</code> | Automatically handles downloads triggered inside the webview without requiring a custom JavaScript bridge. When enabled: - Standard attachment responses are written to a temporary file. - `blob:` downloads are also captured when the platform supports them. - Previewable files reopen inside the in-app browser when possible. - Other files are handed off to the native preview or viewer flow. - `downloadCompleted` and `downloadFailed` events notify the host app about the saved file. | <code>false</code> | 8.6.0 |
1593
+ | **`handleDownloads`** | <code>boolean</code> | Automatically handles downloads triggered inside the webview without requiring a custom JavaScript bridge. When enabled: - Standard attachment responses are written to a temporary file. - `blob:` downloads are also captured when the platform supports them. - Previewable files reopen inside the in-app browser when possible (see `downloadPreview`). - Other files are handed off to the native preview or viewer flow. - `downloadCompleted` and `downloadFailed` events notify the host app about the saved file. | <code>false</code> | 8.6.0 |
1594
+ | **`downloadPreview`** | <code><a href="#downloadpreview">DownloadPreview</a></code> | Controls where managed downloads are previewed after saving. - `'inAppBrowser'` (default): Reopens previewable files (PDF, images, text, JSON) inside the same webview. - `'systemPreview'`: Opens the system Quick Look preview with share and Save to Files actions. iOS only; ignored on Android. Requires `handleDownloads: true`. | <code>"inAppBrowser"</code> | 8.19.0 |
1594
1595
  | **`shareDisclaimer`** | <code><a href="#disclaimeroptions">DisclaimerOptions</a></code> | Share options for the webview. When provided, shows a disclaimer dialog before sharing content. This is useful for: - Warning users about sharing sensitive information - Getting user consent before sharing - Explaining what will be shared - Complying with privacy regulations Note: shareSubject is required when using shareDisclaimer | | 0.1.0 |
1595
1596
  | **`toolbarType`** | <code><a href="#toolbartype">ToolBarType</a></code> | Toolbar type determines the appearance and behavior of the browser's toolbar - "activity": Shows a simple toolbar with just a close button and share button - "navigation": Shows a full navigation toolbar with back/forward buttons - "blank": Shows no toolbar - "": Default toolbar with close button | <code>ToolBarType.DEFAULT</code> | 0.1.0 |
1596
1597
  | **`shareSubject`** | <code>string</code> | Subject text for sharing. Required when using shareDisclaimer. This text will be used as the subject line when sharing content. | | 0.1.0 |
@@ -1956,6 +1957,13 @@ Construct a type with a set of properties K of type T
1956
1957
  <code>'click' | 'touchstart' | 'touchmove' | 'touchend' | 'touchcancel'</code>
1957
1958
 
1958
1959
 
1960
+ #### DownloadPreview
1961
+
1962
+ Where managed downloads are previewed after saving.
1963
+
1964
+ <code>'inAppBrowser' | 'systemPreview'</code>
1965
+
1966
+
1959
1967
  #### PreferredContentMode
1960
1968
 
1961
1969
  Web content rendering mode for managed WKWebViews on iOS.
@@ -81,7 +81,7 @@
81
81
  function resolveProxyBridgeUrl(rawUrl, baseUrl) {
82
82
  try {
83
83
  return new URL(rawUrl, baseUrl).href;
84
- } catch (_error) {
84
+ } catch (e) {
85
85
  return null;
86
86
  }
87
87
  }
@@ -130,7 +130,7 @@
130
130
  form.requestSubmit();
131
131
  }
132
132
  return;
133
- } catch (_error) {
133
+ } catch (e) {
134
134
  delete form.__capgoSkipNextProxySubmit;
135
135
  }
136
136
  }
@@ -168,7 +168,7 @@
168
168
  if (proxyRegexSource) {
169
169
  try {
170
170
  proxyRequestPattern = new RegExp(proxyRegexSource);
171
- } catch (_error) {
171
+ } catch (e) {
172
172
  proxyRequestPattern = null;
173
173
  }
174
174
  }
@@ -209,7 +209,7 @@
209
209
  if (url && !url.match(/^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//)) {
210
210
  try {
211
211
  return new URL(url, getDocumentBaseUrl()).href;
212
- } catch (_error) {
212
+ } catch (e) {
213
213
  return url;
214
214
  }
215
215
  }
@@ -289,7 +289,7 @@
289
289
  if (submitter instanceof HTMLElement) {
290
290
  try {
291
291
  return new FormData(form, submitter);
292
- } catch (_error) {
292
+ } catch (e) {
293
293
  }
294
294
  }
295
295
  return new FormData(form);
@@ -450,7 +450,7 @@
450
450
  let proxyUrl;
451
451
  try {
452
452
  proxyUrl = yield storeInterceptedRequest(url, method, headers, body, credentialsMode);
453
- } catch (_error) {
453
+ } catch (e) {
454
454
  return originalFetch.call(window, input, init);
455
455
  }
456
456
  const proxyResponse = yield originalFetch.call(globalThis, proxyUrl, {
@@ -1117,6 +1117,18 @@ public class CapgoInAppBrowserPlugin extends Plugin implements WebViewDialog.Per
1117
1117
  options.setAllowScreenshotsFromWebPage(Boolean.TRUE.equals(call.getBoolean("allowScreenshotsFromWebPage", false)));
1118
1118
  options.setCaptureConsoleLogs(Boolean.TRUE.equals(call.getBoolean("captureConsoleLogs", false)));
1119
1119
  options.setHandleDownloads(Boolean.TRUE.equals(call.getBoolean("handleDownloads", false)));
1120
+ String downloadPreview = call.getString("downloadPreview", "inAppBrowser");
1121
+ if (downloadPreview != null) {
1122
+ String normalizedDownloadPreview = downloadPreview.toLowerCase(Locale.ROOT);
1123
+ if ("inappbrowser".equals(normalizedDownloadPreview)) {
1124
+ options.setDownloadPreview("inAppBrowser");
1125
+ } else if ("systempreview".equals(normalizedDownloadPreview)) {
1126
+ options.setDownloadPreview("systemPreview");
1127
+ } else {
1128
+ call.reject("downloadPreview must be 'inAppBrowser' or 'systemPreview'");
1129
+ return;
1130
+ }
1131
+ }
1120
1132
 
1121
1133
  options.setPersistWebViewData(call.getBoolean("persistWebViewData", true));
1122
1134
  options.setClearCookiesOnOpen(Boolean.TRUE.equals(call.getBoolean("clearCookiesOnOpen", false)));
@@ -1394,7 +1406,10 @@ public class CapgoInAppBrowserPlugin extends Plugin implements WebViewDialog.Per
1394
1406
  availableResources.append(drawables[i].getName()).append(", ");
1395
1407
  }
1396
1408
  if (drawables.length > 10) {
1397
- availableResources.append("... (").append(drawables.length - 10).append(" more)");
1409
+ availableResources
1410
+ .append("... (")
1411
+ .append(drawables.length - 10)
1412
+ .append(" more)");
1398
1413
  }
1399
1414
  return availableResources;
1400
1415
  }
@@ -204,6 +204,8 @@ public class Options {
204
204
  private boolean allowScreenshotsFromWebPage = false;
205
205
  private boolean captureConsoleLogs = false;
206
206
  private boolean handleDownloads = false;
207
+ /** Accepted for API parity with iOS; Android already uses an external viewer for managed downloads. */
208
+ private String downloadPreview = "inAppBrowser";
207
209
  private boolean persistWebViewData = true;
208
210
  private boolean clearCookiesOnOpen = false;
209
211
  private boolean clearCacheOnOpen = false;
@@ -315,6 +317,14 @@ public class Options {
315
317
  this.handleDownloads = handleDownloads;
316
318
  }
317
319
 
320
+ public String getDownloadPreview() {
321
+ return downloadPreview;
322
+ }
323
+
324
+ public void setDownloadPreview(String downloadPreview) {
325
+ this.downloadPreview = downloadPreview;
326
+ }
327
+
318
328
  public boolean getPersistWebViewData() {
319
329
  return persistWebViewData;
320
330
  }
@@ -900,6 +910,7 @@ public class Options {
900
910
  copy.setAllowScreenshotsFromWebPage(allowScreenshotsFromWebPage);
901
911
  copy.setCaptureConsoleLogs(captureConsoleLogs);
902
912
  copy.setHandleDownloads(handleDownloads);
913
+ copy.setDownloadPreview(downloadPreview);
903
914
  copy.setInvisibilityMode(invisibilityMode);
904
915
  copy.setPopupWindowMode(true);
905
916
  copy.setHiddenPopupWindow(hiddenPopupWindow);
@@ -2373,7 +2373,7 @@ public class WebViewDialog extends ComponentDialog implements ProxyResponseRouti
2373
2373
  "Has camera permission: " +
2374
2374
  (activity != null &&
2375
2375
  activity.checkSelfPermission(android.Manifest.permission.CAMERA) ==
2376
- android.content.pm.PackageManager.PERMISSION_GRANTED)
2376
+ android.content.pm.PackageManager.PERMISSION_GRANTED)
2377
2377
  );
2378
2378
 
2379
2379
  // Check if the file chooser is already open
@@ -6824,22 +6824,19 @@ public class WebViewDialog extends ComponentDialog implements ProxyResponseRouti
6824
6824
  if (executorService.isShutdown()) {
6825
6825
  return;
6826
6826
  }
6827
- Thread shutdownThread = new Thread(
6828
- () -> {
6829
- try {
6830
- executorService.shutdown();
6831
- if (!executorService.awaitTermination(500, TimeUnit.MILLISECONDS)) {
6832
- executorService.shutdownNow();
6833
- }
6834
- } catch (InterruptedException e) {
6835
- Thread.currentThread().interrupt();
6827
+ Thread shutdownThread = new Thread(() -> {
6828
+ try {
6829
+ executorService.shutdown();
6830
+ if (!executorService.awaitTermination(500, TimeUnit.MILLISECONDS)) {
6836
6831
  executorService.shutdownNow();
6837
- } catch (Exception e) {
6838
- Log.e("InAppBrowser", "Error shutting down executor: " + e.getMessage());
6839
6832
  }
6840
- },
6841
- "InAppBrowser-ExecutorShutdown"
6842
- );
6833
+ } catch (InterruptedException e) {
6834
+ Thread.currentThread().interrupt();
6835
+ executorService.shutdownNow();
6836
+ } catch (Exception e) {
6837
+ Log.e("InAppBrowser", "Error shutting down executor: " + e.getMessage());
6838
+ }
6839
+ }, "InAppBrowser-ExecutorShutdown");
6843
6840
  shutdownThread.setDaemon(true);
6844
6841
  shutdownThread.start();
6845
6842
  }
package/dist/docs.json CHANGED
@@ -1684,10 +1684,28 @@
1684
1684
  "name": "since"
1685
1685
  }
1686
1686
  ],
1687
- "docs": "Automatically handles downloads triggered inside the webview without requiring a custom JavaScript bridge.\n\nWhen enabled:\n- Standard attachment responses are written to a temporary file.\n- `blob:` downloads are also captured when the platform supports them.\n- Previewable files reopen inside the in-app browser when possible.\n- Other files are handed off to the native preview or viewer flow.\n- `downloadCompleted` and `downloadFailed` events notify the host app about the saved file.",
1687
+ "docs": "Automatically handles downloads triggered inside the webview without requiring a custom JavaScript bridge.\n\nWhen enabled:\n- Standard attachment responses are written to a temporary file.\n- `blob:` downloads are also captured when the platform supports them.\n- Previewable files reopen inside the in-app browser when possible (see `downloadPreview`).\n- Other files are handed off to the native preview or viewer flow.\n- `downloadCompleted` and `downloadFailed` events notify the host app about the saved file.",
1688
1688
  "complexTypes": [],
1689
1689
  "type": "boolean | undefined"
1690
1690
  },
1691
+ {
1692
+ "name": "downloadPreview",
1693
+ "tags": [
1694
+ {
1695
+ "text": "\"inAppBrowser\"",
1696
+ "name": "default"
1697
+ },
1698
+ {
1699
+ "text": "8.19.0",
1700
+ "name": "since"
1701
+ }
1702
+ ],
1703
+ "docs": "Controls where managed downloads are previewed after saving.\n\n- `'inAppBrowser'` (default): Reopens previewable files (PDF, images, text, JSON) inside the same webview.\n- `'systemPreview'`: Opens the system Quick Look preview with share and Save to Files actions. iOS only; ignored on Android.\n\nRequires `handleDownloads: true`.",
1704
+ "complexTypes": [
1705
+ "DownloadPreview"
1706
+ ],
1707
+ "type": "DownloadPreview"
1708
+ },
1691
1709
  {
1692
1710
  "name": "shareDisclaimer",
1693
1711
  "tags": [
@@ -3861,6 +3879,21 @@
3861
3879
  }
3862
3880
  ]
3863
3881
  },
3882
+ {
3883
+ "name": "DownloadPreview",
3884
+ "slug": "downloadpreview",
3885
+ "docs": "Where managed downloads are previewed after saving.",
3886
+ "types": [
3887
+ {
3888
+ "text": "'inAppBrowser'",
3889
+ "complexTypes": []
3890
+ },
3891
+ {
3892
+ "text": "'systemPreview'",
3893
+ "complexTypes": []
3894
+ }
3895
+ ]
3896
+ },
3864
3897
  {
3865
3898
  "name": "PreferredContentMode",
3866
3899
  "slug": "preferredcontentmode",
@@ -331,6 +331,12 @@ export interface ConsoleMessageEvent {
331
331
  * @since 8.6.0
332
332
  */
333
333
  export type DownloadHandledBy = 'inAppBrowser' | 'systemPreview' | 'external';
334
+ /**
335
+ * Where managed downloads are previewed after saving.
336
+ *
337
+ * @since 8.19.0
338
+ */
339
+ export type DownloadPreview = 'inAppBrowser' | 'systemPreview';
334
340
  /**
335
341
  * Event emitted after a managed download is saved locally.
336
342
  *
@@ -822,7 +828,7 @@ export interface OpenWebViewOptions {
822
828
  * When enabled:
823
829
  * - Standard attachment responses are written to a temporary file.
824
830
  * - `blob:` downloads are also captured when the platform supports them.
825
- * - Previewable files reopen inside the in-app browser when possible.
831
+ * - Previewable files reopen inside the in-app browser when possible (see `downloadPreview`).
826
832
  * - Other files are handed off to the native preview or viewer flow.
827
833
  * - `downloadCompleted` and `downloadFailed` events notify the host app about the saved file.
828
834
  *
@@ -830,6 +836,18 @@ export interface OpenWebViewOptions {
830
836
  * @since 8.6.0
831
837
  */
832
838
  handleDownloads?: boolean;
839
+ /**
840
+ * Controls where managed downloads are previewed after saving.
841
+ *
842
+ * - `'inAppBrowser'` (default): Reopens previewable files (PDF, images, text, JSON) inside the same webview.
843
+ * - `'systemPreview'`: Opens the system Quick Look preview with share and Save to Files actions. iOS only; ignored on Android.
844
+ *
845
+ * Requires `handleDownloads: true`.
846
+ *
847
+ * @default "inAppBrowser"
848
+ * @since 8.19.0
849
+ */
850
+ downloadPreview?: DownloadPreview;
833
851
  /**
834
852
  * Share options for the webview. When provided, shows a disclaimer dialog before sharing content.
835
853
  * This is useful for: