@capgo/inappbrowser 6.12.0 → 6.13.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 +2 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +12 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +18 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +99 -3
- package/android/src/main/res/layout/content_browser.xml +10 -1
- package/android/src/main/res/values/themes.xml +27 -0
- package/dist/docs.json +40 -0
- package/dist/esm/definitions.d.ts +20 -0
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Plugin/InAppBrowserPlugin.swift +7 -0
- package/ios/Plugin/WKWebViewController.swift +21 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -490,6 +490,7 @@ Reload the current web page.
|
|
|
490
490
|
| **`url`** | <code>string</code> | Target URL to load. | | 0.1.0 |
|
|
491
491
|
| **`headers`** | <code><a href="#headers">Headers</a></code> | <a href="#headers">Headers</a> to send with the request. | | 0.1.0 |
|
|
492
492
|
| **`credentials`** | <code><a href="#credentials">Credentials</a></code> | <a href="#credentials">Credentials</a> to send with the request and all subsequent requests for the same host. | | 6.1.0 |
|
|
493
|
+
| **`materialPicker`** | <code>boolean</code> | materialPicker: if true, uses Material Design theme for date and time pickers on Android. This improves the appearance of HTML date inputs to use modern Material Design UI instead of the old style pickers. | <code>false</code> | 7.4.1 |
|
|
493
494
|
| **`jsInterface`** | | JavaScript Interface: The webview automatically injects a JavaScript interface providing: - `window.mobileApp.close()`: Closes the webview from JavaScript - `window.mobileApp.postMessage(obj)`: Sends a message to the app (listen via "messageFromWebview" event) | | 6.10.0 |
|
|
494
495
|
| **`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 |
|
|
495
496
|
| **`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 |
|
|
@@ -515,6 +516,7 @@ Reload the current web page.
|
|
|
515
516
|
| **`preShowScript`** | <code>string</code> | preShowScript: if isPresentAfterPageLoad is true and this variable is set the plugin will inject a script before showing the browser. This script will be run in an async context. The plugin will wait for the script to finish (max 10 seconds) | | 6.6.0 |
|
|
516
517
|
| **`proxyRequests`** | <code>string</code> | proxyRequests is a regex expression. Please see [this pr](https://github.com/Cap-go/capacitor-inappbrowser/pull/222) for more info. (Android only) | | 6.9.0 |
|
|
517
518
|
| **`buttonNearDone`** | <code>{ ios: { iconType: 'sf-symbol' \| 'asset'; icon: string; }; android: { iconType: 'asset' \| 'vector'; icon: string; width?: number; height?: number; }; }</code> | buttonNearDone allows for a creation of a custom button near the done/close button. The button is only shown when toolbarType is not "activity", "navigation", or "blank". For Android: - iconType must be "asset" - icon path should be in the public folder (e.g. "monkey.svg") - width and height are optional, defaults to 48dp - button is positioned at the end of toolbar with 8dp margin For iOS: - iconType can be "sf-symbol" or "asset" - for sf-symbol, icon should be the symbol name - for asset, icon should be the asset name | | 6.7.0 |
|
|
519
|
+
| **`textZoom`** | <code>number</code> | textZoom: sets the text zoom of the page in percent. Allows users to increase or decrease the text size for better readability. | <code>100</code> | 7.6.0 |
|
|
518
520
|
|
|
519
521
|
|
|
520
522
|
#### DisclaimerOptions
|
|
@@ -428,6 +428,12 @@ public class InAppBrowserPlugin
|
|
|
428
428
|
Boolean.TRUE.equals(call.getBoolean("ignoreUntrustedSSLError", false))
|
|
429
429
|
);
|
|
430
430
|
|
|
431
|
+
// Set text zoom if specified in options (default is 100)
|
|
432
|
+
Integer textZoom = call.getInt("textZoom");
|
|
433
|
+
if (textZoom != null) {
|
|
434
|
+
options.setTextZoom(textZoom);
|
|
435
|
+
}
|
|
436
|
+
|
|
431
437
|
String proxyRequestsStr = call.getString("proxyRequests");
|
|
432
438
|
if (proxyRequestsStr != null) {
|
|
433
439
|
try {
|
|
@@ -593,6 +599,12 @@ public class InAppBrowserPlugin
|
|
|
593
599
|
Boolean.TRUE.equals(call.getBoolean("isPresentAfterPageLoad", false))
|
|
594
600
|
);
|
|
595
601
|
options.setPluginCall(call);
|
|
602
|
+
|
|
603
|
+
// Set Material Design picker option
|
|
604
|
+
options.setMaterialPicker(
|
|
605
|
+
Boolean.TRUE.equals(call.getBoolean("materialPicker", false))
|
|
606
|
+
);
|
|
607
|
+
|
|
596
608
|
// options.getToolbarItemTypes().add(ToolbarItemType.RELOAD); TODO: fix this
|
|
597
609
|
options.setCallbacks(
|
|
598
610
|
new WebViewCallbacks() {
|
|
@@ -172,6 +172,24 @@ public class Options {
|
|
|
172
172
|
private String preShowScript;
|
|
173
173
|
private String toolbarTextColor;
|
|
174
174
|
private Pattern proxyRequestsPattern = null;
|
|
175
|
+
private boolean materialPicker = false;
|
|
176
|
+
private int textZoom = 100; // Default text zoom is 100%
|
|
177
|
+
|
|
178
|
+
public int getTextZoom() {
|
|
179
|
+
return textZoom;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
public void setTextZoom(int textZoom) {
|
|
183
|
+
this.textZoom = textZoom;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
public boolean getMaterialPicker() {
|
|
187
|
+
return materialPicker;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
public void setMaterialPicker(boolean materialPicker) {
|
|
191
|
+
this.materialPicker = materialPicker;
|
|
192
|
+
}
|
|
175
193
|
|
|
176
194
|
public Pattern getProxyRequestsPattern() {
|
|
177
195
|
return proxyRequestsPattern;
|
|
@@ -14,10 +14,8 @@ import android.graphics.Bitmap;
|
|
|
14
14
|
import android.graphics.Canvas;
|
|
15
15
|
import android.graphics.Color;
|
|
16
16
|
import android.graphics.Paint;
|
|
17
|
-
import android.graphics.Picture;
|
|
18
17
|
import android.graphics.PorterDuff;
|
|
19
18
|
import android.graphics.PorterDuffColorFilter;
|
|
20
|
-
import android.graphics.drawable.PictureDrawable;
|
|
21
19
|
import android.net.Uri;
|
|
22
20
|
import android.net.http.SslError;
|
|
23
21
|
import android.text.TextUtils;
|
|
@@ -91,6 +89,7 @@ public class WebViewDialog extends Dialog {
|
|
|
91
89
|
private final Context _context;
|
|
92
90
|
public Activity activity;
|
|
93
91
|
private boolean isInitialized = false;
|
|
92
|
+
private boolean datePickerInjected = false; // Track if we've injected date picker fixes
|
|
94
93
|
private final WebView capacitorWebView;
|
|
95
94
|
private final Map<String, ProxiedRequest> proxiedRequestsHashmap =
|
|
96
95
|
new HashMap<>();
|
|
@@ -121,7 +120,11 @@ public class WebViewDialog extends Dialog {
|
|
|
121
120
|
PermissionHandler permissionHandler,
|
|
122
121
|
WebView capacitorWebView
|
|
123
122
|
) {
|
|
124
|
-
|
|
123
|
+
// Use Material theme only if materialPicker is enabled
|
|
124
|
+
super(
|
|
125
|
+
context,
|
|
126
|
+
options.getMaterialPicker() ? R.style.InAppBrowserMaterialTheme : theme
|
|
127
|
+
);
|
|
125
128
|
this._options = options;
|
|
126
129
|
this._context = context;
|
|
127
130
|
this.permissionHandler = permissionHandler;
|
|
@@ -307,6 +310,52 @@ public class WebViewDialog extends Dialog {
|
|
|
307
310
|
_webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
|
|
308
311
|
_webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
|
|
309
312
|
|
|
313
|
+
// Set text zoom if specified in options
|
|
314
|
+
if (_options.getTextZoom() > 0) {
|
|
315
|
+
_webView.getSettings().setTextZoom(_options.getTextZoom());
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Fix for Android 15 (API 35) navigation bar overlap issue
|
|
319
|
+
if (android.os.Build.VERSION.SDK_INT >= 35) {
|
|
320
|
+
// Get the navigation bar space view
|
|
321
|
+
View navigationBarSpace = findViewById(R.id.navigation_bar_space);
|
|
322
|
+
|
|
323
|
+
if (navigationBarSpace != null) {
|
|
324
|
+
// Calculate navigation bar height
|
|
325
|
+
int navigationBarHeight = 0;
|
|
326
|
+
int navBarId = getContext()
|
|
327
|
+
.getResources()
|
|
328
|
+
.getIdentifier("navigation_bar_height", "dimen", "android");
|
|
329
|
+
|
|
330
|
+
if (navBarId > 0) {
|
|
331
|
+
navigationBarHeight = getContext()
|
|
332
|
+
.getResources()
|
|
333
|
+
.getDimensionPixelSize(navBarId);
|
|
334
|
+
|
|
335
|
+
// Set the height of the navigation bar space
|
|
336
|
+
navigationBarSpace.getLayoutParams().height = navigationBarHeight;
|
|
337
|
+
navigationBarSpace.requestLayout();
|
|
338
|
+
|
|
339
|
+
// Set the background color to match the toolbar or system theme
|
|
340
|
+
int navBarColor;
|
|
341
|
+
if (_options.getToolbarColor() != null && !_options.getToolbarColor().isEmpty()) {
|
|
342
|
+
try {
|
|
343
|
+
navBarColor = Color.parseColor(_options.getToolbarColor());
|
|
344
|
+
} catch (IllegalArgumentException e) {
|
|
345
|
+
// Default to system coloring if parsing fails
|
|
346
|
+
boolean isDarkTheme = isDarkThemeEnabled();
|
|
347
|
+
navBarColor = isDarkTheme ? Color.BLACK : Color.WHITE;
|
|
348
|
+
}
|
|
349
|
+
} else {
|
|
350
|
+
// Follow system theme
|
|
351
|
+
boolean isDarkTheme = isDarkThemeEnabled();
|
|
352
|
+
navBarColor = isDarkTheme ? Color.BLACK : Color.WHITE;
|
|
353
|
+
}
|
|
354
|
+
navigationBarSpace.setBackgroundColor(navBarColor);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
310
359
|
_webView.setWebViewClient(new WebViewClient());
|
|
311
360
|
|
|
312
361
|
_webView.setWebChromeClient(
|
|
@@ -390,6 +439,22 @@ public class WebViewDialog extends Dialog {
|
|
|
390
439
|
currentPermissionRequest = null;
|
|
391
440
|
}
|
|
392
441
|
}
|
|
442
|
+
|
|
443
|
+
// This method will be called at page load, a good place to inject customizations
|
|
444
|
+
@Override
|
|
445
|
+
public void onProgressChanged(WebView view, int newProgress) {
|
|
446
|
+
super.onProgressChanged(view, newProgress);
|
|
447
|
+
|
|
448
|
+
// When the page is almost loaded, inject our date picker customization
|
|
449
|
+
// Only if materialPicker option is enabled
|
|
450
|
+
if (
|
|
451
|
+
newProgress > 75 &&
|
|
452
|
+
!datePickerInjected &&
|
|
453
|
+
_options.getMaterialPicker()
|
|
454
|
+
) {
|
|
455
|
+
injectDatePickerFixes();
|
|
456
|
+
}
|
|
457
|
+
}
|
|
393
458
|
}
|
|
394
459
|
);
|
|
395
460
|
|
|
@@ -1735,4 +1800,35 @@ public class WebViewDialog extends Dialog {
|
|
|
1735
1800
|
}
|
|
1736
1801
|
return false;
|
|
1737
1802
|
}
|
|
1803
|
+
|
|
1804
|
+
private void injectDatePickerFixes() {
|
|
1805
|
+
if (_webView == null || datePickerInjected) {
|
|
1806
|
+
return;
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
datePickerInjected = true;
|
|
1810
|
+
|
|
1811
|
+
// This script adds minimal fixes for date inputs to use Material Design
|
|
1812
|
+
String script =
|
|
1813
|
+
"(function() {\n" +
|
|
1814
|
+
" // Find all date inputs\n" +
|
|
1815
|
+
" const dateInputs = document.querySelectorAll('input[type=\"date\"]');\n" +
|
|
1816
|
+
" dateInputs.forEach(input => {\n" +
|
|
1817
|
+
" // Ensure change events propagate correctly\n" +
|
|
1818
|
+
" let lastValue = input.value;\n" +
|
|
1819
|
+
" input.addEventListener('change', () => {\n" +
|
|
1820
|
+
" if (input.value !== lastValue) {\n" +
|
|
1821
|
+
" lastValue = input.value;\n" +
|
|
1822
|
+
" // Dispatch an input event to ensure frameworks detect the change\n" +
|
|
1823
|
+
" input.dispatchEvent(new Event('input', { bubbles: true }));\n" +
|
|
1824
|
+
" }\n" +
|
|
1825
|
+
" });\n" +
|
|
1826
|
+
" });\n" +
|
|
1827
|
+
"})();";
|
|
1828
|
+
|
|
1829
|
+
// Execute the script in the WebView
|
|
1830
|
+
_webView.post(() -> _webView.evaluateJavascript(script, null));
|
|
1831
|
+
|
|
1832
|
+
Log.d("InAppBrowser", "Applied minimal date picker fixes");
|
|
1833
|
+
}
|
|
1738
1834
|
}
|
|
@@ -11,6 +11,15 @@
|
|
|
11
11
|
<WebView
|
|
12
12
|
android:id="@+id/browser_view"
|
|
13
13
|
android:layout_width="match_parent"
|
|
14
|
-
android:layout_height="
|
|
14
|
+
android:layout_height="0dp"
|
|
15
|
+
app:layout_constraintTop_toTopOf="parent"
|
|
16
|
+
app:layout_constraintBottom_toTopOf="@id/navigation_bar_space"/>
|
|
17
|
+
|
|
18
|
+
<View
|
|
19
|
+
android:id="@+id/navigation_bar_space"
|
|
20
|
+
android:layout_width="match_parent"
|
|
21
|
+
android:layout_height="0dp"
|
|
22
|
+
android:background="@android:color/transparent"
|
|
23
|
+
app:layout_constraintBottom_toBottomOf="parent"/>
|
|
15
24
|
|
|
16
25
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
<!-- Base application theme with Material Components -->
|
|
4
|
+
<style name="InAppBrowserMaterialTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
|
|
5
|
+
<!-- Customize your theme here -->
|
|
6
|
+
<item name="colorPrimary">@android:color/holo_blue_dark</item>
|
|
7
|
+
<item name="colorPrimaryDark">@android:color/holo_blue_dark</item>
|
|
8
|
+
<item name="colorAccent">@android:color/holo_blue_dark</item>
|
|
9
|
+
|
|
10
|
+
<!-- Force Material Design date and time pickers -->
|
|
11
|
+
<item name="android:datePickerStyle">@style/MaterialDatePickerStyle</item>
|
|
12
|
+
<item name="android:timePickerStyle">@style/MaterialTimePickerStyle</item>
|
|
13
|
+
<item name="materialCalendarStyle">@style/Widget.MaterialComponents.MaterialCalendar</item>
|
|
14
|
+
<item name="materialCalendarFullscreenTheme">@style/ThemeOverlay.MaterialComponents.MaterialCalendar.Fullscreen</item>
|
|
15
|
+
<item name="materialCalendarTheme">@style/ThemeOverlay.MaterialComponents.MaterialCalendar</item>
|
|
16
|
+
</style>
|
|
17
|
+
|
|
18
|
+
<!-- Date Picker Style -->
|
|
19
|
+
<style name="MaterialDatePickerStyle" parent="@android:style/Widget.Material.DatePicker">
|
|
20
|
+
<item name="android:datePickerMode">calendar</item>
|
|
21
|
+
</style>
|
|
22
|
+
|
|
23
|
+
<!-- Time Picker Style -->
|
|
24
|
+
<style name="MaterialTimePickerStyle" parent="@android:style/Widget.Material.TimePicker">
|
|
25
|
+
<item name="android:timePickerMode">clock</item>
|
|
26
|
+
</style>
|
|
27
|
+
</resources>
|
package/dist/docs.json
CHANGED
|
@@ -639,6 +639,26 @@
|
|
|
639
639
|
],
|
|
640
640
|
"type": "Credentials"
|
|
641
641
|
},
|
|
642
|
+
{
|
|
643
|
+
"name": "materialPicker",
|
|
644
|
+
"tags": [
|
|
645
|
+
{
|
|
646
|
+
"text": "7.4.1",
|
|
647
|
+
"name": "since"
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
"text": "false",
|
|
651
|
+
"name": "default"
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
"text": "materialPicker: true\nTest URL: https://show-picker.glitch.me/demo.html",
|
|
655
|
+
"name": "example"
|
|
656
|
+
}
|
|
657
|
+
],
|
|
658
|
+
"docs": "materialPicker: if true, uses Material Design theme for date and time pickers on Android.\nThis improves the appearance of HTML date inputs to use modern Material Design UI instead of the old style pickers.",
|
|
659
|
+
"complexTypes": [],
|
|
660
|
+
"type": "boolean | undefined"
|
|
661
|
+
},
|
|
642
662
|
{
|
|
643
663
|
"name": "jsInterface",
|
|
644
664
|
"tags": [
|
|
@@ -1064,6 +1084,26 @@
|
|
|
1064
1084
|
"docs": "buttonNearDone allows for a creation of a custom button near the done/close button.\nThe button is only shown when toolbarType is not \"activity\", \"navigation\", or \"blank\".\n\nFor Android:\n- iconType must be \"asset\"\n- icon path should be in the public folder (e.g. \"monkey.svg\")\n- width and height are optional, defaults to 48dp\n- button is positioned at the end of toolbar with 8dp margin\n\nFor iOS:\n- iconType can be \"sf-symbol\" or \"asset\"\n- for sf-symbol, icon should be the symbol name\n- for asset, icon should be the asset name",
|
|
1065
1085
|
"complexTypes": [],
|
|
1066
1086
|
"type": "{ ios: { iconType: 'sf-symbol' | 'asset'; icon: string; }; android: { iconType: 'asset' | 'vector'; icon: string; width?: number | undefined; height?: number | undefined; }; } | undefined"
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
"name": "textZoom",
|
|
1090
|
+
"tags": [
|
|
1091
|
+
{
|
|
1092
|
+
"text": "7.6.0",
|
|
1093
|
+
"name": "since"
|
|
1094
|
+
},
|
|
1095
|
+
{
|
|
1096
|
+
"text": "100",
|
|
1097
|
+
"name": "default"
|
|
1098
|
+
},
|
|
1099
|
+
{
|
|
1100
|
+
"text": "textZoom: 120\nTest URL: https://capgo.app",
|
|
1101
|
+
"name": "example"
|
|
1102
|
+
}
|
|
1103
|
+
],
|
|
1104
|
+
"docs": "textZoom: sets the text zoom of the page in percent.\nAllows users to increase or decrease the text size for better readability.",
|
|
1105
|
+
"complexTypes": [],
|
|
1106
|
+
"type": "number | undefined"
|
|
1067
1107
|
}
|
|
1068
1108
|
]
|
|
1069
1109
|
},
|
|
@@ -131,6 +131,16 @@ export interface OpenWebViewOptions {
|
|
|
131
131
|
* Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/
|
|
132
132
|
*/
|
|
133
133
|
credentials?: Credentials;
|
|
134
|
+
/**
|
|
135
|
+
* materialPicker: if true, uses Material Design theme for date and time pickers on Android.
|
|
136
|
+
* This improves the appearance of HTML date inputs to use modern Material Design UI instead of the old style pickers.
|
|
137
|
+
* @since 7.4.1
|
|
138
|
+
* @default false
|
|
139
|
+
* @example
|
|
140
|
+
* materialPicker: true
|
|
141
|
+
* Test URL: https://show-picker.glitch.me/demo.html
|
|
142
|
+
*/
|
|
143
|
+
materialPicker?: boolean;
|
|
134
144
|
/**
|
|
135
145
|
* JavaScript Interface:
|
|
136
146
|
* The webview automatically injects a JavaScript interface providing:
|
|
@@ -384,6 +394,16 @@ export interface OpenWebViewOptions {
|
|
|
384
394
|
height?: number;
|
|
385
395
|
};
|
|
386
396
|
};
|
|
397
|
+
/**
|
|
398
|
+
* textZoom: sets the text zoom of the page in percent.
|
|
399
|
+
* Allows users to increase or decrease the text size for better readability.
|
|
400
|
+
* @since 7.6.0
|
|
401
|
+
* @default 100
|
|
402
|
+
* @example
|
|
403
|
+
* textZoom: 120
|
|
404
|
+
* Test URL: https://capgo.app
|
|
405
|
+
*/
|
|
406
|
+
textZoom?: number;
|
|
387
407
|
}
|
|
388
408
|
export interface InAppBrowserPlugin {
|
|
389
409
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAuBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAgBX;AAhBD,WAAY,WAAW;IACrB;;;OAGG;IACH,oCAAqB,CAAA;IACrB;;;OAGG;IACH,wCAAyB,CAAA;IACzB;;;OAGG;IACH,8BAAe,CAAA;AACjB,CAAC,EAhBW,WAAW,KAAX,WAAW,QAgBtB","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;\nexport type ButtonNearListener = (state: object) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n /**\n * Shows a simple toolbar with just a close button and share button\n * @since 0.1.0\n */\n ACTIVITY = \"activity\",\n /**\n * Shows a full navigation toolbar with back/forward buttons\n * @since 0.1.0\n */\n NAVIGATION = \"navigation\",\n /**\n * Shows no toolbar\n * @since 0.1.0\n */\n BLANK = \"blank\",\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 Credentials {\n username: string;\n password: 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 * Credentials to send with the request and all subsequent requests for the same host.\n * @since 6.1.0\n */\n credentials?: Credentials;\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 /**\n * if true the deeplink will not be opened, if false the deeplink will be opened when clicked on the link\n * @since 0.1.0\n */\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n /**\n * Title of the disclaimer dialog\n * @default \"Title\"\n */\n title: string;\n /**\n * Message shown in the disclaimer dialog\n * @default \"Message\"\n */\n message: string;\n /**\n * Text for the confirm button\n * @default \"Confirm\"\n */\n confirmBtn: string;\n /**\n * Text for the cancel button\n * @default \"Cancel\"\n */\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n * @example \"https://capgo.app\"\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n * @example\n * headers: {\n * 'Custom-Header': 'test-value',\n * 'Authorization': 'Bearer test-token'\n * }\n * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/\n */\n headers?: Headers;\n /**\n * Credentials to send with the request and all subsequent requests for the same host.\n * @since 6.1.0\n * @example\n * credentials: {\n * username: 'test-user',\n * password: 'test-pass'\n * }\n * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/\n */\n credentials?: Credentials;\n /**\n * JavaScript Interface:\n * The webview automatically injects a JavaScript interface providing:\n * - `window.mobileApp.close()`: Closes the webview from JavaScript\n * - `window.mobileApp.postMessage(obj)`: Sends a message to the app (listen via \"messageFromWebview\" event)\n *\n * @example\n * // In your webpage loaded in the webview:\n * document.getElementById('closeBtn').addEventListener('click', () => {\n * window.mobileApp.close();\n * });\n *\n * // Send data to the app\n * window.mobileApp.postMessage({ action: 'login', data: { user: 'test' }});\n *\n * @since 6.10.0\n */\n jsInterface?: never; // This property doesn't exist, it's just for documentation\n /**\n * Share options for the webview. When provided, shows a disclaimer dialog before sharing content.\n * This is useful for:\n * - Warning users about sharing sensitive information\n * - Getting user consent before sharing\n * - Explaining what will be shared\n * - Complying with privacy regulations\n *\n * Note: shareSubject is required when using shareDisclaimer\n * @since 0.1.0\n * @example\n * shareDisclaimer: {\n * title: 'Disclaimer',\n * message: 'This is a test disclaimer',\n * confirmBtn: 'Accept',\n * cancelBtn: 'Decline'\n * }\n * Test URL: https://capgo.app\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type determines the appearance and behavior of the browser's toolbar\n * - \"activity\": Shows a simple toolbar with just a close button and share button\n * - \"navigation\": Shows a full navigation toolbar with back/forward buttons\n * - \"blank\": Shows no toolbar\n * - \"\": Default toolbar with close button\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n * @example\n * toolbarType: ToolBarType.ACTIVITY,\n * title: 'Activity Toolbar Test'\n * Test URL: https://capgo.app\n */\n toolbarType?: ToolBarType;\n /**\n * Subject text for sharing. Required when using shareDisclaimer.\n * This text will be used as the subject line when sharing content.\n * @since 0.1.0\n * @example \"Share this page\"\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default 'New Window'\n * @example \"Camera Test\"\n */\n title?: string;\n /**\n * Background color of the browser\n * @since 0.1.0\n * @default BackgroundColor.BLACK\n */\n backgroundColor?: BackgroundColor;\n /**\n * If true, active the native navigation within the webview, Android only\n * @default false\n * @example\n * activeNativeNavigationForWebview: true,\n * disableGoBackOnNativeApplication: true\n * Test URL: https://capgo.app\n */\n activeNativeNavigationForWebview?: boolean;\n /**\n * Disable the possibility to go back on native application,\n * useful to force user to stay on the webview, Android only\n * @default false\n * @example\n * disableGoBackOnNativeApplication: true\n * Test URL: https://capgo.app\n */\n disableGoBackOnNativeApplication?: boolean;\n /**\n * Open url in a new window fullscreen\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 * @example\n * isPresentAfterPageLoad: true,\n * preShowScript: \"await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });\"\n * Test URL: https://capgo.app\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * Whether the website in the webview is inspectable or not, ios only\n * @default false\n */\n isInspectable?: boolean;\n /**\n * Whether the webview opening is animated or not, ios only\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 * @example\n * showReloadButton: true\n * Test URL: https://capgo.app\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 * @since 1.1.0\n * @default false\n * @example\n * closeModal: true,\n * closeModalTitle: 'Close Window',\n * closeModalDescription: 'Are you sure you want to close?',\n * closeModalOk: 'Yes, close',\n * closeModalCancel: 'No, stay'\n * Test URL: https://capgo.app\n */\n closeModal?: boolean;\n /**\n * CloseModalTitle: title of the confirm when user clicks on close button\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\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\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\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 * @since 1.2.5\n * @default true\n */\n visibleTitle?: boolean;\n /**\n * toolbarColor: color of the toolbar in hex format\n * @since 1.2.5\n * @default '#ffffff'\n * @example\n * toolbarColor: '#FF5733'\n * Test URL: https://capgo.app\n */\n toolbarColor?: string;\n /**\n * toolbarTextColor: color of the buttons and title in the toolbar in hex format\n * When set, it overrides the automatic light/dark mode detection for text color\n * @since 6.10.0\n * @default calculated based on toolbarColor brightness\n * @example\n * toolbarTextColor: '#FFFFFF'\n * Test URL: https://capgo.app\n */\n toolbarTextColor?: string;\n /**\n * showArrow: if true an arrow would be shown instead of cross for closing the window\n * @since 1.2.5\n * @default false\n * @example\n * showArrow: true\n * Test URL: https://capgo.app\n */\n showArrow?: boolean;\n /**\n * ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website.\n * @since 6.1.0\n * @default false\n */\n ignoreUntrustedSSLError?: boolean;\n /**\n * preShowScript: if isPresentAfterPageLoad is true and this variable is set the plugin will inject a script before showing the browser.\n * This script will be run in an async context. The plugin will wait for the script to finish (max 10 seconds)\n * @since 6.6.0\n * @example\n * preShowScript: \"await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });\"\n * Test URL: https://capgo.app\n */\n preShowScript?: string;\n /**\n * proxyRequests is a regex expression. Please see [this pr](https://github.com/Cap-go/capacitor-inappbrowser/pull/222) for more info. (Android only)\n * @since 6.9.0\n */\n proxyRequests?: string;\n /**\n * buttonNearDone allows for a creation of a custom button near the done/close button.\n * The button is only shown when toolbarType is not \"activity\", \"navigation\", or \"blank\".\n *\n * For Android:\n * - iconType must be \"asset\"\n * - icon path should be in the public folder (e.g. \"monkey.svg\")\n * - width and height are optional, defaults to 48dp\n * - button is positioned at the end of toolbar with 8dp margin\n *\n * For iOS:\n * - iconType can be \"sf-symbol\" or \"asset\"\n * - for sf-symbol, icon should be the symbol name\n * - for asset, icon should be the asset name\n * @since 6.7.0\n * @example\n * buttonNearDone: {\n * ios: {\n * iconType: 'sf-symbol',\n * icon: 'star.fill'\n * },\n * android: {\n * iconType: 'asset',\n * icon: 'public/monkey.svg',\n * width: 24,\n * height: 24\n * }\n * }\n * Test URL: https://capgo.app\n */\n buttonNearDone?: {\n ios: {\n iconType: \"sf-symbol\" | \"asset\";\n icon: string;\n };\n android: {\n iconType: \"asset\" | \"vector\";\n icon: string;\n width?: number;\n height?: number;\n };\n };\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 * Clear all cookies\n *\n * @since 6.5.0\n */\n clearAllCookies(): Promise<any>;\n\n /**\n * Clear cache\n *\n * @since 6.5.0\n */\n clearCache(): 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 the webview.\n */\n close(): Promise<any>;\n /**\n * Open url in a new webview with toolbars, and enhanced capabilities, like camera access, file access, listen events, inject javascript, bi directional communication, etc.\n *\n * JavaScript Interface:\n * When you open a webview with this method, a JavaScript interface is automatically injected that provides:\n * - `window.mobileApp.close()`: Closes the webview from JavaScript\n * - `window.mobileApp.postMessage(obj)`: Sends a message from the webview to the app\n *\n * @since 0.1.0\n */\n openWebView(options: OpenWebViewOptions): Promise<any>;\n /**\n * Injects JavaScript code into the InAppBrowser window.\n */\n executeScript({ code }: { code: string }): Promise<void>;\n /**\n * Sends an event to the webview(inappbrowser). you can listen to this event in the inappbrowser JS with window.addListener(\"messageFromNative\", listenerFunc: (event: Record<string, any>) => void)\n * detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.\n */\n postMessage(options: { detail: Record<string, any> }): Promise<void>;\n /**\n * Sets the URL of the webview.\n */\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>;\n\n addListener(\n eventName: \"buttonNearDoneClick\",\n listenerFunc: ButtonNearListener,\n ): Promise<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>;\n /**\n * Will be triggered when user clicks on confirm button when disclaimer is required\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"confirmBtnClicked\",\n listenerFunc: ConfirmBtnListener,\n ): Promise<PluginListenerHandle>;\n /**\n * 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\" } })\n * detail is the data you want to send to the main app, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, no functions or other non-JSON-serializable types are allowed.\n *\n * This method is inject at runtime in the webview\n */\n addListener(\n eventName: \"messageFromWebview\",\n listenerFunc: (event: { detail: Record<string, any> }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Will be triggered when page is loaded\n */\n addListener(\n eventName: \"browserPageLoaded\",\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Will be triggered when page load error\n */\n addListener(\n eventName: \"pageLoadError\",\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\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>;\n}\n\n/**\n * JavaScript APIs available in the InAppBrowser WebView.\n *\n * These APIs are automatically injected into all webpages loaded in the InAppBrowser WebView.\n *\n * @example\n * // Closing the webview from JavaScript\n * window.mobileApp.close();\n *\n * // Sending a message from webview to the native app\n * window.mobileApp.postMessage({ key: 'value' });\n *\n * @since 6.10.0\n */\nexport interface InAppBrowserWebViewAPIs {\n /**\n * mobileApp - Global object injected into the WebView providing communication with the native app\n */\n mobileApp: {\n /**\n * Close the WebView from JavaScript\n *\n * @example\n * // Add a button to close the webview\n * const closeButton = document.createElement('button');\n * closeButton.textContent = 'Close WebView';\n * closeButton.addEventListener('click', () => {\n * window.mobileApp.close();\n * });\n * document.body.appendChild(closeButton);\n *\n * @since 6.10.0\n */\n close(): void;\n\n /**\n * Send a message from the WebView to the native app\n * The native app can listen for these messages with the \"messageFromWebview\" event\n *\n * @param message Object to send to the native app\n * @example\n * // Send data to native app\n * window.mobileApp.postMessage({\n * action: 'dataSubmitted',\n * data: { username: 'test', email: 'test@example.com' }\n * });\n *\n * @since 6.10.0\n */\n postMessage(message: Record<string, any>): void;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAuBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAgBX;AAhBD,WAAY,WAAW;IACrB;;;OAGG;IACH,oCAAqB,CAAA;IACrB;;;OAGG;IACH,wCAAyB,CAAA;IACzB;;;OAGG;IACH,8BAAe,CAAA;AACjB,CAAC,EAhBW,WAAW,KAAX,WAAW,QAgBtB","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;\nexport type ButtonNearListener = (state: object) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n /**\n * Shows a simple toolbar with just a close button and share button\n * @since 0.1.0\n */\n ACTIVITY = \"activity\",\n /**\n * Shows a full navigation toolbar with back/forward buttons\n * @since 0.1.0\n */\n NAVIGATION = \"navigation\",\n /**\n * Shows no toolbar\n * @since 0.1.0\n */\n BLANK = \"blank\",\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 Credentials {\n username: string;\n password: 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 * Credentials to send with the request and all subsequent requests for the same host.\n * @since 6.1.0\n */\n credentials?: Credentials;\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 /**\n * if true the deeplink will not be opened, if false the deeplink will be opened when clicked on the link\n * @since 0.1.0\n */\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n /**\n * Title of the disclaimer dialog\n * @default \"Title\"\n */\n title: string;\n /**\n * Message shown in the disclaimer dialog\n * @default \"Message\"\n */\n message: string;\n /**\n * Text for the confirm button\n * @default \"Confirm\"\n */\n confirmBtn: string;\n /**\n * Text for the cancel button\n * @default \"Cancel\"\n */\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n * @example \"https://capgo.app\"\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n * @example\n * headers: {\n * 'Custom-Header': 'test-value',\n * 'Authorization': 'Bearer test-token'\n * }\n * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/\n */\n headers?: Headers;\n /**\n * Credentials to send with the request and all subsequent requests for the same host.\n * @since 6.1.0\n * @example\n * credentials: {\n * username: 'test-user',\n * password: 'test-pass'\n * }\n * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/\n */\n credentials?: Credentials;\n /**\n * materialPicker: if true, uses Material Design theme for date and time pickers on Android.\n * This improves the appearance of HTML date inputs to use modern Material Design UI instead of the old style pickers.\n * @since 7.4.1\n * @default false\n * @example\n * materialPicker: true\n * Test URL: https://show-picker.glitch.me/demo.html\n */\n materialPicker?: boolean;\n /**\n * JavaScript Interface:\n * The webview automatically injects a JavaScript interface providing:\n * - `window.mobileApp.close()`: Closes the webview from JavaScript\n * - `window.mobileApp.postMessage(obj)`: Sends a message to the app (listen via \"messageFromWebview\" event)\n *\n * @example\n * // In your webpage loaded in the webview:\n * document.getElementById('closeBtn').addEventListener('click', () => {\n * window.mobileApp.close();\n * });\n *\n * // Send data to the app\n * window.mobileApp.postMessage({ action: 'login', data: { user: 'test' }});\n *\n * @since 6.10.0\n */\n jsInterface?: never; // This property doesn't exist, it's just for documentation\n /**\n * Share options for the webview. When provided, shows a disclaimer dialog before sharing content.\n * This is useful for:\n * - Warning users about sharing sensitive information\n * - Getting user consent before sharing\n * - Explaining what will be shared\n * - Complying with privacy regulations\n *\n * Note: shareSubject is required when using shareDisclaimer\n * @since 0.1.0\n * @example\n * shareDisclaimer: {\n * title: 'Disclaimer',\n * message: 'This is a test disclaimer',\n * confirmBtn: 'Accept',\n * cancelBtn: 'Decline'\n * }\n * Test URL: https://capgo.app\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type determines the appearance and behavior of the browser's toolbar\n * - \"activity\": Shows a simple toolbar with just a close button and share button\n * - \"navigation\": Shows a full navigation toolbar with back/forward buttons\n * - \"blank\": Shows no toolbar\n * - \"\": Default toolbar with close button\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n * @example\n * toolbarType: ToolBarType.ACTIVITY,\n * title: 'Activity Toolbar Test'\n * Test URL: https://capgo.app\n */\n toolbarType?: ToolBarType;\n /**\n * Subject text for sharing. Required when using shareDisclaimer.\n * This text will be used as the subject line when sharing content.\n * @since 0.1.0\n * @example \"Share this page\"\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default 'New Window'\n * @example \"Camera Test\"\n */\n title?: string;\n /**\n * Background color of the browser\n * @since 0.1.0\n * @default BackgroundColor.BLACK\n */\n backgroundColor?: BackgroundColor;\n /**\n * If true, active the native navigation within the webview, Android only\n * @default false\n * @example\n * activeNativeNavigationForWebview: true,\n * disableGoBackOnNativeApplication: true\n * Test URL: https://capgo.app\n */\n activeNativeNavigationForWebview?: boolean;\n /**\n * Disable the possibility to go back on native application,\n * useful to force user to stay on the webview, Android only\n * @default false\n * @example\n * disableGoBackOnNativeApplication: true\n * Test URL: https://capgo.app\n */\n disableGoBackOnNativeApplication?: boolean;\n /**\n * Open url in a new window fullscreen\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 * @example\n * isPresentAfterPageLoad: true,\n * preShowScript: \"await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });\"\n * Test URL: https://capgo.app\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * Whether the website in the webview is inspectable or not, ios only\n * @default false\n */\n isInspectable?: boolean;\n /**\n * Whether the webview opening is animated or not, ios only\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 * @example\n * showReloadButton: true\n * Test URL: https://capgo.app\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 * @since 1.1.0\n * @default false\n * @example\n * closeModal: true,\n * closeModalTitle: 'Close Window',\n * closeModalDescription: 'Are you sure you want to close?',\n * closeModalOk: 'Yes, close',\n * closeModalCancel: 'No, stay'\n * Test URL: https://capgo.app\n */\n closeModal?: boolean;\n /**\n * CloseModalTitle: title of the confirm when user clicks on close button\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\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\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\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 * @since 1.2.5\n * @default true\n */\n visibleTitle?: boolean;\n /**\n * toolbarColor: color of the toolbar in hex format\n * @since 1.2.5\n * @default '#ffffff'\n * @example\n * toolbarColor: '#FF5733'\n * Test URL: https://capgo.app\n */\n toolbarColor?: string;\n /**\n * toolbarTextColor: color of the buttons and title in the toolbar in hex format\n * When set, it overrides the automatic light/dark mode detection for text color\n * @since 6.10.0\n * @default calculated based on toolbarColor brightness\n * @example\n * toolbarTextColor: '#FFFFFF'\n * Test URL: https://capgo.app\n */\n toolbarTextColor?: string;\n /**\n * showArrow: if true an arrow would be shown instead of cross for closing the window\n * @since 1.2.5\n * @default false\n * @example\n * showArrow: true\n * Test URL: https://capgo.app\n */\n showArrow?: boolean;\n /**\n * ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website.\n * @since 6.1.0\n * @default false\n */\n ignoreUntrustedSSLError?: boolean;\n /**\n * preShowScript: if isPresentAfterPageLoad is true and this variable is set the plugin will inject a script before showing the browser.\n * This script will be run in an async context. The plugin will wait for the script to finish (max 10 seconds)\n * @since 6.6.0\n * @example\n * preShowScript: \"await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });\"\n * Test URL: https://capgo.app\n */\n preShowScript?: string;\n /**\n * proxyRequests is a regex expression. Please see [this pr](https://github.com/Cap-go/capacitor-inappbrowser/pull/222) for more info. (Android only)\n * @since 6.9.0\n */\n proxyRequests?: string;\n /**\n * buttonNearDone allows for a creation of a custom button near the done/close button.\n * The button is only shown when toolbarType is not \"activity\", \"navigation\", or \"blank\".\n *\n * For Android:\n * - iconType must be \"asset\"\n * - icon path should be in the public folder (e.g. \"monkey.svg\")\n * - width and height are optional, defaults to 48dp\n * - button is positioned at the end of toolbar with 8dp margin\n *\n * For iOS:\n * - iconType can be \"sf-symbol\" or \"asset\"\n * - for sf-symbol, icon should be the symbol name\n * - for asset, icon should be the asset name\n * @since 6.7.0\n * @example\n * buttonNearDone: {\n * ios: {\n * iconType: 'sf-symbol',\n * icon: 'star.fill'\n * },\n * android: {\n * iconType: 'asset',\n * icon: 'public/monkey.svg',\n * width: 24,\n * height: 24\n * }\n * }\n * Test URL: https://capgo.app\n */\n buttonNearDone?: {\n ios: {\n iconType: \"sf-symbol\" | \"asset\";\n icon: string;\n };\n android: {\n iconType: \"asset\" | \"vector\";\n icon: string;\n width?: number;\n height?: number;\n };\n };\n /**\n * textZoom: sets the text zoom of the page in percent.\n * Allows users to increase or decrease the text size for better readability.\n * @since 7.6.0\n * @default 100\n * @example\n * textZoom: 120\n * Test URL: https://capgo.app\n */\n textZoom?: number;\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 * Clear all cookies\n *\n * @since 6.5.0\n */\n clearAllCookies(): Promise<any>;\n\n /**\n * Clear cache\n *\n * @since 6.5.0\n */\n clearCache(): 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 the webview.\n */\n close(): Promise<any>;\n /**\n * Open url in a new webview with toolbars, and enhanced capabilities, like camera access, file access, listen events, inject javascript, bi directional communication, etc.\n *\n * JavaScript Interface:\n * When you open a webview with this method, a JavaScript interface is automatically injected that provides:\n * - `window.mobileApp.close()`: Closes the webview from JavaScript\n * - `window.mobileApp.postMessage(obj)`: Sends a message from the webview to the app\n *\n * @since 0.1.0\n */\n openWebView(options: OpenWebViewOptions): Promise<any>;\n /**\n * Injects JavaScript code into the InAppBrowser window.\n */\n executeScript({ code }: { code: string }): Promise<void>;\n /**\n * Sends an event to the webview(inappbrowser). you can listen to this event in the inappbrowser JS with window.addListener(\"messageFromNative\", listenerFunc: (event: Record<string, any>) => void)\n * detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.\n */\n postMessage(options: { detail: Record<string, any> }): Promise<void>;\n /**\n * Sets the URL of the webview.\n */\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>;\n\n addListener(\n eventName: \"buttonNearDoneClick\",\n listenerFunc: ButtonNearListener,\n ): Promise<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>;\n /**\n * Will be triggered when user clicks on confirm button when disclaimer is required\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"confirmBtnClicked\",\n listenerFunc: ConfirmBtnListener,\n ): Promise<PluginListenerHandle>;\n /**\n * 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\" } })\n * detail is the data you want to send to the main app, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, no functions or other non-JSON-serializable types are allowed.\n *\n * This method is inject at runtime in the webview\n */\n addListener(\n eventName: \"messageFromWebview\",\n listenerFunc: (event: { detail: Record<string, any> }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Will be triggered when page is loaded\n */\n addListener(\n eventName: \"browserPageLoaded\",\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Will be triggered when page load error\n */\n addListener(\n eventName: \"pageLoadError\",\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\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>;\n}\n\n/**\n * JavaScript APIs available in the InAppBrowser WebView.\n *\n * These APIs are automatically injected into all webpages loaded in the InAppBrowser WebView.\n *\n * @example\n * // Closing the webview from JavaScript\n * window.mobileApp.close();\n *\n * // Sending a message from webview to the native app\n * window.mobileApp.postMessage({ key: 'value' });\n *\n * @since 6.10.0\n */\nexport interface InAppBrowserWebViewAPIs {\n /**\n * mobileApp - Global object injected into the WebView providing communication with the native app\n */\n mobileApp: {\n /**\n * Close the WebView from JavaScript\n *\n * @example\n * // Add a button to close the webview\n * const closeButton = document.createElement('button');\n * closeButton.textContent = 'Close WebView';\n * closeButton.addEventListener('click', () => {\n * window.mobileApp.close();\n * });\n * document.body.appendChild(closeButton);\n *\n * @since 6.10.0\n */\n close(): void;\n\n /**\n * Send a message from the WebView to the native app\n * The native app can listen for these messages with the \"messageFromWebview\" event\n *\n * @param message Object to send to the native app\n * @example\n * // Send data to native app\n * window.mobileApp.postMessage({\n * action: 'dataSubmitted',\n * data: { username: 'test', email: 'test@example.com' }\n * });\n *\n * @since 6.10.0\n */\n postMessage(message: Record<string, any>): void;\n };\n}\n"]}
|
|
@@ -461,6 +461,11 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
461
461
|
webViewController.websiteTitleInNavigationBar = call.getBool("visibleTitle", true)
|
|
462
462
|
webViewController.ignoreUntrustedSSLError = ignoreUntrustedSSLError
|
|
463
463
|
|
|
464
|
+
// Set text zoom if specified
|
|
465
|
+
if let textZoom = call.getInt("textZoom") {
|
|
466
|
+
webViewController.textZoom = textZoom
|
|
467
|
+
}
|
|
468
|
+
|
|
464
469
|
// Set closeModal properties after proper initialization
|
|
465
470
|
if closeModal {
|
|
466
471
|
webViewController.closeModal = true
|
|
@@ -524,6 +529,7 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
524
529
|
self.navigationWebViewController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: textColor]
|
|
525
530
|
webViewController.statusBarStyle = isDarkMode ? .lightContent : .darkContent
|
|
526
531
|
webViewController.updateStatusBarStyle()
|
|
532
|
+
|
|
527
533
|
}
|
|
528
534
|
|
|
529
535
|
self.navigationWebViewController?.modalPresentationStyle = .fullScreen
|
|
@@ -565,6 +571,7 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
565
571
|
navController.view.backgroundColor = backgroundColor
|
|
566
572
|
}
|
|
567
573
|
}
|
|
574
|
+
|
|
568
575
|
}
|
|
569
576
|
|
|
570
577
|
// We don't use the toolbar anymore, always hide it
|
|
@@ -330,6 +330,12 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
330
330
|
|
|
331
331
|
fileprivate var credentials: WKWebViewCredentials?
|
|
332
332
|
|
|
333
|
+
var textZoom: Int?
|
|
334
|
+
|
|
335
|
+
var capableWebView: WKWebView? {
|
|
336
|
+
return webView
|
|
337
|
+
}
|
|
338
|
+
|
|
333
339
|
deinit {
|
|
334
340
|
webView?.removeObserver(self, forKeyPath: estimatedProgressKeyPath)
|
|
335
341
|
if websiteTitleInNavigationBar {
|
|
@@ -775,6 +781,15 @@ public extension WKWebViewController {
|
|
|
775
781
|
self?.webView?.evaluateJavaScript(script, completionHandler: completion)
|
|
776
782
|
}
|
|
777
783
|
}
|
|
784
|
+
|
|
785
|
+
func applyTextZoom(_ zoomPercent: Int) {
|
|
786
|
+
let script = """
|
|
787
|
+
document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust = '\(zoomPercent)%';
|
|
788
|
+
document.getElementsByTagName('body')[0].style.textSizeAdjust = '\(zoomPercent)%';
|
|
789
|
+
"""
|
|
790
|
+
|
|
791
|
+
executeScript(script: script)
|
|
792
|
+
}
|
|
778
793
|
}
|
|
779
794
|
|
|
780
795
|
// MARK: - Fileprivate Methods
|
|
@@ -1398,6 +1413,12 @@ extension WKWebViewController: WKNavigationDelegate {
|
|
|
1398
1413
|
self.injectPreShowScript()
|
|
1399
1414
|
}
|
|
1400
1415
|
}
|
|
1416
|
+
|
|
1417
|
+
// Apply text zoom if set
|
|
1418
|
+
if let zoom = self.textZoom {
|
|
1419
|
+
applyTextZoom(zoom)
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1401
1422
|
didpageInit = true
|
|
1402
1423
|
updateBarButtonItems()
|
|
1403
1424
|
self.progressView?.progress = 0
|