@capgo/inappbrowser 6.14.0 → 6.15.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 +1 -0
- package/android/src/main/AndroidManifest.xml +12 -2
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +1 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +9 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +58 -1
- package/android/src/main/res/layout/tool_bar.xml +11 -8
- package/android/src/main/res/xml/file_paths.xml +14 -0
- package/dist/docs.json +11 -0
- package/dist/esm/definitions.d.ts +5 -0
- package/dist/esm/definitions.js +5 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/plugin.cjs.js +5 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +5 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/InAppBrowserPlugin.swift +23 -0
- package/ios/Plugin/WKWebViewController.swift +101 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -613,6 +613,7 @@ Construct a type with a set of properties K of type T
|
|
|
613
613
|
| Members | Value | Description | Since |
|
|
614
614
|
| ---------------- | ------------------------- | ---------------------------------------------------------------- | ----- |
|
|
615
615
|
| **`ACTIVITY`** | <code>"activity"</code> | Shows a simple toolbar with just a close button and share button | 0.1.0 |
|
|
616
|
+
| **`COMPACT`** | <code>"compact"</code> | Shows a simple toolbar with just a close button | 7.6.8 |
|
|
616
617
|
| **`NAVIGATION`** | <code>"navigation"</code> | Shows a full navigation toolbar with back/forward buttons | 0.1.0 |
|
|
617
618
|
| **`BLANK`** | <code>"blank"</code> | Shows no toolbar | 0.1.0 |
|
|
618
619
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
2
|
<queries>
|
|
4
3
|
<intent>
|
|
@@ -7,6 +6,17 @@
|
|
|
7
6
|
<data android:scheme="http" />
|
|
8
7
|
</intent>
|
|
9
8
|
</queries>
|
|
10
|
-
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
|
|
11
9
|
<uses-permission android:name="android.permission.CAMERA"/>
|
|
10
|
+
|
|
11
|
+
<application>
|
|
12
|
+
<provider
|
|
13
|
+
android:name="androidx.core.content.FileProvider"
|
|
14
|
+
android:authorities="${applicationId}.fileprovider"
|
|
15
|
+
android:exported="false"
|
|
16
|
+
android:grantUriPermissions="true">
|
|
17
|
+
<meta-data
|
|
18
|
+
android:name="android.support.FILE_PROVIDER_PATHS"
|
|
19
|
+
android:resource="@xml/file_paths" />
|
|
20
|
+
</provider>
|
|
21
|
+
</application>
|
|
12
22
|
</manifest>
|
|
@@ -450,6 +450,7 @@ public class InAppBrowserPlugin
|
|
|
450
450
|
options.setTitle(call.getString("title", ""));
|
|
451
451
|
}
|
|
452
452
|
options.setToolbarColor(call.getString("toolbarColor", "#ffffff"));
|
|
453
|
+
options.setBackgroundColor(call.getString("backgroundColor", "black"));
|
|
453
454
|
options.setToolbarTextColor(call.getString("toolbarTextColor"));
|
|
454
455
|
options.setArrow(Boolean.TRUE.equals(call.getBoolean("showArrow", false)));
|
|
455
456
|
options.setIgnoreUntrustedSSLError(
|
|
@@ -167,6 +167,7 @@ public class Options {
|
|
|
167
167
|
private PluginCall pluginCall;
|
|
168
168
|
private boolean VisibleTitle;
|
|
169
169
|
private String ToolbarColor;
|
|
170
|
+
private String BackgroundColor;
|
|
170
171
|
private boolean ShowArrow;
|
|
171
172
|
private boolean ignoreUntrustedSSLError;
|
|
172
173
|
private String preShowScript;
|
|
@@ -374,6 +375,14 @@ public class Options {
|
|
|
374
375
|
this.ToolbarColor = toolbarColor;
|
|
375
376
|
}
|
|
376
377
|
|
|
378
|
+
public String getBackgroundColor() {
|
|
379
|
+
return BackgroundColor;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
public void setBackgroundColor(String backgroundColor) {
|
|
383
|
+
this.BackgroundColor = backgroundColor;
|
|
384
|
+
}
|
|
385
|
+
|
|
377
386
|
public String getToolbarTextColor() {
|
|
378
387
|
return toolbarTextColor;
|
|
379
388
|
}
|
|
@@ -20,6 +20,9 @@ import android.net.Uri;
|
|
|
20
20
|
import android.net.http.SslError;
|
|
21
21
|
import android.os.Build;
|
|
22
22
|
import android.os.Environment;
|
|
23
|
+
import android.print.PrintAttributes;
|
|
24
|
+
import android.print.PrintDocumentAdapter;
|
|
25
|
+
import android.print.PrintManager;
|
|
23
26
|
import android.provider.MediaStore;
|
|
24
27
|
import android.text.TextUtils;
|
|
25
28
|
import android.util.Base64;
|
|
@@ -214,6 +217,44 @@ public class WebViewDialog extends Dialog {
|
|
|
214
217
|
}
|
|
215
218
|
}
|
|
216
219
|
|
|
220
|
+
public class PrintInterface {
|
|
221
|
+
|
|
222
|
+
private Context context;
|
|
223
|
+
private WebView webView;
|
|
224
|
+
|
|
225
|
+
public PrintInterface(Context context, WebView webView) {
|
|
226
|
+
this.context = context;
|
|
227
|
+
this.webView = webView;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@JavascriptInterface
|
|
231
|
+
public void print() {
|
|
232
|
+
// Run on UI thread since printing requires UI operations
|
|
233
|
+
((Activity) context).runOnUiThread(
|
|
234
|
+
new Runnable() {
|
|
235
|
+
@Override
|
|
236
|
+
public void run() {
|
|
237
|
+
// Create a print job from the WebView content
|
|
238
|
+
PrintManager printManager =
|
|
239
|
+
(PrintManager) context.getSystemService(Context.PRINT_SERVICE);
|
|
240
|
+
String jobName = "Document_" + System.currentTimeMillis();
|
|
241
|
+
|
|
242
|
+
PrintDocumentAdapter printAdapter;
|
|
243
|
+
|
|
244
|
+
// For API 21+ (Lollipop and above)
|
|
245
|
+
printAdapter = webView.createPrintDocumentAdapter(jobName);
|
|
246
|
+
|
|
247
|
+
printManager.print(
|
|
248
|
+
jobName,
|
|
249
|
+
printAdapter,
|
|
250
|
+
new PrintAttributes.Builder().build()
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
217
258
|
@SuppressLint({ "SetJavaScriptEnabled", "AddJavascriptInterface" })
|
|
218
259
|
public void presentWebView() {
|
|
219
260
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
@@ -317,6 +358,10 @@ public class WebViewDialog extends Dialog {
|
|
|
317
358
|
new PreShowScriptInterface(),
|
|
318
359
|
"PreShowScriptInterface"
|
|
319
360
|
);
|
|
361
|
+
_webView.addJavascriptInterface(
|
|
362
|
+
new PrintInterface(this._context, _webView),
|
|
363
|
+
"PrintInterface"
|
|
364
|
+
);
|
|
320
365
|
_webView.getSettings().setJavaScriptEnabled(true);
|
|
321
366
|
_webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
|
|
322
367
|
_webView.getSettings().setDatabaseEnabled(true);
|
|
@@ -328,6 +373,12 @@ public class WebViewDialog extends Dialog {
|
|
|
328
373
|
_webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
|
|
329
374
|
_webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
|
|
330
375
|
|
|
376
|
+
// Set web view background color
|
|
377
|
+
int backgroundColor = _options.getBackgroundColor().equals("white")
|
|
378
|
+
? Color.WHITE
|
|
379
|
+
: Color.BLACK;
|
|
380
|
+
_webView.setBackgroundColor(backgroundColor);
|
|
381
|
+
|
|
331
382
|
// Set text zoom if specified in options
|
|
332
383
|
if (_options.getTextZoom() > 0) {
|
|
333
384
|
_webView.getSettings().setTextZoom(_options.getTextZoom());
|
|
@@ -1031,7 +1082,13 @@ public class WebViewDialog extends Dialog {
|
|
|
1031
1082
|
" window.AndroidInterface.close(); " +
|
|
1032
1083
|
" } " +
|
|
1033
1084
|
" }; " +
|
|
1034
|
-
"}"
|
|
1085
|
+
"} " +
|
|
1086
|
+
// Override the window.print function to use our PrintInterface
|
|
1087
|
+
"window.print = function() { " +
|
|
1088
|
+
" if (window.PrintInterface) { " +
|
|
1089
|
+
" window.PrintInterface.print(); " +
|
|
1090
|
+
" } " +
|
|
1091
|
+
"};";
|
|
1035
1092
|
_webView.evaluateJavascript(script, null);
|
|
1036
1093
|
}
|
|
1037
1094
|
|
|
@@ -8,14 +8,17 @@
|
|
|
8
8
|
android:elevation="4dp"
|
|
9
9
|
app:titleTextColor="#262626">
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
<ImageButton
|
|
12
|
+
android:id="@+id/closeButton"
|
|
13
|
+
android:layout_width="wrap_content"
|
|
14
|
+
android:layout_height="wrap_content"
|
|
15
|
+
android:layout_gravity="start"
|
|
16
|
+
android:background="#eeeeef"
|
|
17
|
+
android:contentDescription="@string/close_button"
|
|
18
|
+
android:minWidth="38dp"
|
|
19
|
+
android:minHeight="38dp"
|
|
20
|
+
android:src="@drawable/ic_clear_24px"
|
|
21
|
+
android:translationX="-8dp" />
|
|
19
22
|
|
|
20
23
|
<ImageButton
|
|
21
24
|
android:id="@+id/buttonNearDone"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
|
+
<!-- Internal cache for most operations -->
|
|
4
|
+
<cache-path name="camera_captures" path="." />
|
|
5
|
+
|
|
6
|
+
<!-- External cache for fallback -->
|
|
7
|
+
<external-cache-path name="external_cache" path="." />
|
|
8
|
+
|
|
9
|
+
<!-- External files for additional compatibility -->
|
|
10
|
+
<external-files-path name="external_files" path="." />
|
|
11
|
+
|
|
12
|
+
<!-- Allow sharing app-specific files if needed -->
|
|
13
|
+
<files-path name="app_files" path="." />
|
|
14
|
+
</paths>
|
package/dist/docs.json
CHANGED
|
@@ -1231,6 +1231,17 @@
|
|
|
1231
1231
|
],
|
|
1232
1232
|
"docs": "Shows a simple toolbar with just a close button and share button"
|
|
1233
1233
|
},
|
|
1234
|
+
{
|
|
1235
|
+
"name": "COMPACT",
|
|
1236
|
+
"value": "\"compact\"",
|
|
1237
|
+
"tags": [
|
|
1238
|
+
{
|
|
1239
|
+
"text": "7.6.8",
|
|
1240
|
+
"name": "since"
|
|
1241
|
+
}
|
|
1242
|
+
],
|
|
1243
|
+
"docs": "Shows a simple toolbar with just a close button"
|
|
1244
|
+
},
|
|
1234
1245
|
{
|
|
1235
1246
|
"name": "NAVIGATION",
|
|
1236
1247
|
"value": "\"navigation\"",
|
|
@@ -28,6 +28,11 @@ export declare enum ToolBarType {
|
|
|
28
28
|
* @since 0.1.0
|
|
29
29
|
*/
|
|
30
30
|
ACTIVITY = "activity",
|
|
31
|
+
/**
|
|
32
|
+
* Shows a simple toolbar with just a close button
|
|
33
|
+
* @since 7.6.8
|
|
34
|
+
*/
|
|
35
|
+
COMPACT = "compact",
|
|
31
36
|
/**
|
|
32
37
|
* Shows a full navigation toolbar with back/forward buttons
|
|
33
38
|
* @since 0.1.0
|
package/dist/esm/definitions.js
CHANGED
|
@@ -10,6 +10,11 @@ export var ToolBarType;
|
|
|
10
10
|
* @since 0.1.0
|
|
11
11
|
*/
|
|
12
12
|
ToolBarType["ACTIVITY"] = "activity";
|
|
13
|
+
/**
|
|
14
|
+
* Shows a simple toolbar with just a close button
|
|
15
|
+
* @since 7.6.8
|
|
16
|
+
*/
|
|
17
|
+
ToolBarType["COMPACT"] = "compact";
|
|
13
18
|
/**
|
|
14
19
|
* Shows a full navigation toolbar with back/forward buttons
|
|
15
20
|
* @since 0.1.0
|
|
@@ -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 * 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 * preventDeeplink: if true, the deeplink will not be opened, if false the deeplink will be opened when clicked on the link. on IOS each schema need to be added to info.plist file under LSApplicationQueriesSchemes when false to make it work.\n * @since 0.1.0\n * @default false\n * @example\n * preventDeeplink: true\n * Test URL: https://aasa-tester.capgo.app/\n */\n preventDeeplink?: boolean;\n}\n\nexport interface InAppBrowserPlugin {\n /**\n * Open url in a new window fullscreen, on android it use chrome custom tabs, on ios it use SFSafariViewController\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({detail: {message: 'myMessage'}})`: Sends a message from the webview to the app, detail object is the data you want to send to the webview\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.addEventListener(\"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,WAqBX;AArBD,WAAY,WAAW;IACrB;;;OAGG;IACH,oCAAqB,CAAA;IACrB;;;OAGG;IACH,kCAAmB,CAAA;IACnB;;;OAGG;IACH,wCAAyB,CAAA;IACzB;;;OAGG;IACH,8BAAe,CAAA;AACjB,CAAC,EArBW,WAAW,KAAX,WAAW,QAqBtB","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 simple toolbar with just a close button\n * @since 7.6.8\n */\n COMPACT = \"compact\",\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 * 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 * preventDeeplink: if true, the deeplink will not be opened, if false the deeplink will be opened when clicked on the link. on IOS each schema need to be added to info.plist file under LSApplicationQueriesSchemes when false to make it work.\n * @since 0.1.0\n * @default false\n * @example\n * preventDeeplink: true\n * Test URL: https://aasa-tester.capgo.app/\n */\n preventDeeplink?: boolean;\n}\n\nexport interface InAppBrowserPlugin {\n /**\n * Open url in a new window fullscreen, on android it use chrome custom tabs, on ios it use SFSafariViewController\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({detail: {message: 'myMessage'}})`: Sends a message from the webview to the app, detail object is the data you want to send to the webview\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.addEventListener(\"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"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -14,6 +14,11 @@ exports.ToolBarType = void 0;
|
|
|
14
14
|
* @since 0.1.0
|
|
15
15
|
*/
|
|
16
16
|
ToolBarType["ACTIVITY"] = "activity";
|
|
17
|
+
/**
|
|
18
|
+
* Shows a simple toolbar with just a close button
|
|
19
|
+
* @since 7.6.8
|
|
20
|
+
*/
|
|
21
|
+
ToolBarType["COMPACT"] = "compact";
|
|
17
22
|
/**
|
|
18
23
|
* Shows a full navigation toolbar with back/forward buttons
|
|
19
24
|
* @since 0.1.0
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -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 /**\n * Shows a simple toolbar with just a close button and share button\n * @since 0.1.0\n */\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n /**\n * Shows a full navigation toolbar with back/forward buttons\n * @since 0.1.0\n */\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n /**\n * Shows no toolbar\n * @since 0.1.0\n */\n ToolBarType[\"BLANK\"] = \"blank\";\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 clearAllCookies() {\n console.log(\"clearAllCookies\");\n return Promise.resolve();\n }\n clearCache() {\n console.log(\"clearCache\");\n return Promise.resolve();\n }\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 executeScript({ code }) {\n console.log(\"code\", code);\n return code;\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 async postMessage(options) {\n console.log(\"postMessage\", options);\n return options;\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;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AACzC;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AAC7C;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACnC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;
|
|
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 /**\n * Shows a simple toolbar with just a close button and share button\n * @since 0.1.0\n */\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n /**\n * Shows a simple toolbar with just a close button\n * @since 7.6.8\n */\n ToolBarType[\"COMPACT\"] = \"compact\";\n /**\n * Shows a full navigation toolbar with back/forward buttons\n * @since 0.1.0\n */\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n /**\n * Shows no toolbar\n * @since 0.1.0\n */\n ToolBarType[\"BLANK\"] = \"blank\";\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 clearAllCookies() {\n console.log(\"clearAllCookies\");\n return Promise.resolve();\n }\n clearCache() {\n console.log(\"clearCache\");\n return Promise.resolve();\n }\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 executeScript({ code }) {\n console.log(\"code\", code);\n return code;\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 async postMessage(options) {\n console.log(\"postMessage\", options);\n return options;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BackgroundColor","ToolBarType","registerPlugin","WebPlugin"],"mappings":"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"}
|
package/dist/plugin.js
CHANGED
|
@@ -13,6 +13,11 @@ var capacitorInAppBrowser = (function (exports, core) {
|
|
|
13
13
|
* @since 0.1.0
|
|
14
14
|
*/
|
|
15
15
|
ToolBarType["ACTIVITY"] = "activity";
|
|
16
|
+
/**
|
|
17
|
+
* Shows a simple toolbar with just a close button
|
|
18
|
+
* @since 7.6.8
|
|
19
|
+
*/
|
|
20
|
+
ToolBarType["COMPACT"] = "compact";
|
|
16
21
|
/**
|
|
17
22
|
* Shows a full navigation toolbar with back/forward buttons
|
|
18
23
|
* @since 0.1.0
|
package/dist/plugin.js.map
CHANGED
|
@@ -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 /**\n * Shows a simple toolbar with just a close button and share button\n * @since 0.1.0\n */\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n /**\n * Shows a full navigation toolbar with back/forward buttons\n * @since 0.1.0\n */\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n /**\n * Shows no toolbar\n * @since 0.1.0\n */\n ToolBarType[\"BLANK\"] = \"blank\";\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 clearAllCookies() {\n console.log(\"clearAllCookies\");\n return Promise.resolve();\n }\n clearCache() {\n console.log(\"clearCache\");\n return Promise.resolve();\n }\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 executeScript({ code }) {\n console.log(\"code\", code);\n return code;\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 async postMessage(options) {\n console.log(\"postMessage\", options);\n return options;\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;IACA;IACA;IACA;IACA,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;IACzC;IACA;IACA;IACA;IACA,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;IAC7C;IACA;IACA;IACA;IACA,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACnC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;
|
|
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 /**\n * Shows a simple toolbar with just a close button and share button\n * @since 0.1.0\n */\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n /**\n * Shows a simple toolbar with just a close button\n * @since 7.6.8\n */\n ToolBarType[\"COMPACT\"] = \"compact\";\n /**\n * Shows a full navigation toolbar with back/forward buttons\n * @since 0.1.0\n */\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n /**\n * Shows no toolbar\n * @since 0.1.0\n */\n ToolBarType[\"BLANK\"] = \"blank\";\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 clearAllCookies() {\n console.log(\"clearAllCookies\");\n return Promise.resolve();\n }\n clearCache() {\n console.log(\"clearCache\");\n return Promise.resolve();\n }\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 executeScript({ code }) {\n console.log(\"code\", code);\n return code;\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 async postMessage(options) {\n console.log(\"postMessage\", options);\n return options;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BackgroundColor","ToolBarType","registerPlugin","WebPlugin"],"mappings":"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"}
|
|
@@ -368,6 +368,16 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
368
368
|
return
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
+
if self.bridge?.statusBarVisible == true {
|
|
372
|
+
let subviews = self.bridge?.webView?.superview?.subviews
|
|
373
|
+
if let emptyStatusBarIndex = subviews?.firstIndex(where: { $0.subviews.isEmpty }) {
|
|
374
|
+
if let emptyStatusBar = subviews?[emptyStatusBarIndex] {
|
|
375
|
+
webViewController.capacitorStatusBar = emptyStatusBar
|
|
376
|
+
emptyStatusBar.removeFromSuperview()
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
371
381
|
webViewController.source = .remote(url)
|
|
372
382
|
webViewController.leftNavigationBarItemTypes = []
|
|
373
383
|
|
|
@@ -484,6 +494,9 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
484
494
|
self.navigationWebViewController?.navigationBar.setValue(true, forKey: "hidesShadow")
|
|
485
495
|
self.navigationWebViewController?.toolbar.setShadowImage(UIImage(), forToolbarPosition: .any)
|
|
486
496
|
|
|
497
|
+
// Handle web view background color
|
|
498
|
+
webViewController.view.backgroundColor = backgroundColor
|
|
499
|
+
|
|
487
500
|
// Handle toolbar color
|
|
488
501
|
if let toolbarColor = call.getString("toolbarColor"), self.isHexColorCode(toolbarColor) {
|
|
489
502
|
// If specific color provided, use it
|
|
@@ -682,6 +695,16 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
682
695
|
return
|
|
683
696
|
}
|
|
684
697
|
|
|
698
|
+
if self.bridge?.statusBarVisible == true {
|
|
699
|
+
let subviews = self.bridge?.webView?.superview?.subviews
|
|
700
|
+
if let emptyStatusBarIndex = subviews?.firstIndex(where: { $0.subviews.isEmpty }) {
|
|
701
|
+
if let emptyStatusBar = subviews?[emptyStatusBarIndex] {
|
|
702
|
+
webViewController.capacitorStatusBar = emptyStatusBar
|
|
703
|
+
emptyStatusBar.removeFromSuperview()
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
685
708
|
webViewController.source = .remote(url)
|
|
686
709
|
webViewController.leftNavigationBarItemTypes = [.back, .forward, .reload]
|
|
687
710
|
webViewController.capBrowserPlugin = self
|
|
@@ -112,6 +112,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
112
112
|
var viewWasPresented = false
|
|
113
113
|
var preventDeeplink: Bool = false
|
|
114
114
|
var blankNavigationTab: Bool = false
|
|
115
|
+
var capacitorStatusBar: UIView?
|
|
115
116
|
|
|
116
117
|
internal var preShowSemaphore: DispatchSemaphore?
|
|
117
118
|
internal var preShowError: String?
|
|
@@ -276,9 +277,9 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
276
277
|
// Check if custom image is provided
|
|
277
278
|
if let image = activityBarButtonItemImage {
|
|
278
279
|
let button = UIBarButtonItem(image: image.withRenderingMode(.alwaysTemplate),
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
280
|
+
style: .plain,
|
|
281
|
+
target: self,
|
|
282
|
+
action: #selector(activityDidClick(sender:)))
|
|
282
283
|
|
|
283
284
|
// Apply tint from navigation bar or from tintColor property
|
|
284
285
|
if let tintColor = self.tintColor ?? self.navigationController?.navigationBar.tintColor {
|
|
@@ -290,8 +291,8 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
290
291
|
} else {
|
|
291
292
|
// Use system share icon
|
|
292
293
|
let button = UIBarButtonItem(barButtonSystemItem: .action,
|
|
293
|
-
|
|
294
|
-
|
|
294
|
+
target: self,
|
|
295
|
+
action: #selector(activityDidClick(sender:)))
|
|
295
296
|
|
|
296
297
|
// Apply tint from navigation bar or from tintColor property
|
|
297
298
|
if let tintColor = self.tintColor ?? self.navigationController?.navigationBar.tintColor {
|
|
@@ -343,6 +344,15 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
343
344
|
webView?.removeObserver(self, forKeyPath: #keyPath(WKWebView.url))
|
|
344
345
|
}
|
|
345
346
|
|
|
347
|
+
override open func viewDidDisappear(_ animated: Bool) {
|
|
348
|
+
super.viewDidDisappear(animated)
|
|
349
|
+
|
|
350
|
+
if let capacitorStatusBar = capacitorStatusBar {
|
|
351
|
+
self.capBrowserPlugin?.bridge?.webView?.superview?.addSubview(capacitorStatusBar)
|
|
352
|
+
self.capBrowserPlugin?.bridge?.webView?.frame.origin.y = capacitorStatusBar.frame.height
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
346
356
|
override open func viewDidLoad() {
|
|
347
357
|
super.viewDidLoad()
|
|
348
358
|
if self.webView == nil {
|
|
@@ -394,9 +404,9 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
394
404
|
|
|
395
405
|
// Create a properly tinted button
|
|
396
406
|
let buttonItem = UIBarButtonItem(image: buttonNearDoneIcon?.withRenderingMode(.alwaysTemplate),
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
407
|
+
style: .plain,
|
|
408
|
+
target: self,
|
|
409
|
+
action: #selector(buttonNearDoneDidClick))
|
|
400
410
|
buttonItem.tintColor = tintColor
|
|
401
411
|
|
|
402
412
|
// Add it to right items
|
|
@@ -434,7 +444,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
434
444
|
// Method to send a message from Swift to JavaScript
|
|
435
445
|
open func postMessageToJS(message: [String: Any]) {
|
|
436
446
|
if let jsonData = try? JSONSerialization.data(withJSONObject: message, options: []),
|
|
437
|
-
|
|
447
|
+
let jsonString = String(data: jsonData, encoding: .utf8) {
|
|
438
448
|
let script = "window.dispatchEvent(new CustomEvent('messageFromNative', { detail: \(jsonString) }));"
|
|
439
449
|
DispatchQueue.main.async {
|
|
440
450
|
self.webView?.evaluateJavaScript(script, completionHandler: nil)
|
|
@@ -468,7 +478,20 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
468
478
|
semaphore.signal()
|
|
469
479
|
} else if message.name == "close" {
|
|
470
480
|
closeView()
|
|
471
|
-
|
|
481
|
+
} else if message.name == "magicPrint" {
|
|
482
|
+
if let webView = self.webView {
|
|
483
|
+
let printController = UIPrintInteractionController.shared
|
|
484
|
+
|
|
485
|
+
let printInfo = UIPrintInfo(dictionary: nil)
|
|
486
|
+
printInfo.outputType = .general
|
|
487
|
+
printInfo.jobName = "Print Job"
|
|
488
|
+
|
|
489
|
+
printController.printInfo = printInfo
|
|
490
|
+
printController.printFormatter = webView.viewPrintFormatter()
|
|
491
|
+
|
|
492
|
+
printController.present(animated: true, completionHandler: nil)
|
|
493
|
+
}
|
|
494
|
+
}
|
|
472
495
|
}
|
|
473
496
|
|
|
474
497
|
func injectJavaScriptInterface() {
|
|
@@ -486,9 +509,17 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
486
509
|
};
|
|
487
510
|
}
|
|
488
511
|
"""
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
512
|
+
DispatchQueue.main.async {
|
|
513
|
+
self.webView?.evaluateJavaScript(script) { result, error in
|
|
514
|
+
if let error = error {
|
|
515
|
+
print("JavaScript evaluation error: \(error)")
|
|
516
|
+
} else if let result = result {
|
|
517
|
+
print("JavaScript result: \(result)")
|
|
518
|
+
} else {
|
|
519
|
+
print("JavaScript executed with no result")
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
492
523
|
}
|
|
493
524
|
|
|
494
525
|
open func initWebview(isInspectable: Bool = true) {
|
|
@@ -503,14 +534,35 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
503
534
|
userContentController.add(self, name: "preShowScriptError")
|
|
504
535
|
userContentController.add(self, name: "preShowScriptSuccess")
|
|
505
536
|
userContentController.add(self, name: "close")
|
|
537
|
+
userContentController.add(self, name: "magicPrint")
|
|
538
|
+
|
|
539
|
+
// Inject JavaScript to override window.print
|
|
540
|
+
let script = WKUserScript(
|
|
541
|
+
source: """
|
|
542
|
+
window.print = function() {
|
|
543
|
+
window.webkit.messageHandlers.magicPrint.postMessage('magicPrint');
|
|
544
|
+
};
|
|
545
|
+
""",
|
|
546
|
+
injectionTime: .atDocumentStart,
|
|
547
|
+
forMainFrameOnly: false
|
|
548
|
+
)
|
|
549
|
+
userContentController.addUserScript(script)
|
|
550
|
+
|
|
506
551
|
webConfiguration.allowsInlineMediaPlayback = true
|
|
507
552
|
webConfiguration.userContentController = userContentController
|
|
553
|
+
|
|
508
554
|
let webView = WKWebView(frame: .zero, configuration: webConfiguration)
|
|
509
555
|
|
|
510
|
-
if webView.responds(to: Selector(("setInspectable:"))) {
|
|
511
|
-
// Fix: https://stackoverflow.com/questions/76216183/how-to-debug-wkwebview-in-ios-16-4-1-using-xcode-14-2/76603043#76603043
|
|
512
|
-
webView.perform(Selector(("setInspectable:")), with: isInspectable)
|
|
513
|
-
}
|
|
556
|
+
// if webView.responds(to: Selector(("setInspectable:"))) {
|
|
557
|
+
// // Fix: https://stackoverflow.com/questions/76216183/how-to-debug-wkwebview-in-ios-16-4-1-using-xcode-14-2/76603043#76603043
|
|
558
|
+
// webView.perform(Selector(("setInspectable:")), with: isInspectable)
|
|
559
|
+
// }
|
|
560
|
+
|
|
561
|
+
if #available(iOS 16.4, *) {
|
|
562
|
+
webView.isInspectable = true
|
|
563
|
+
} else {
|
|
564
|
+
// Fallback on earlier versions
|
|
565
|
+
}
|
|
514
566
|
|
|
515
567
|
if self.blankNavigationTab {
|
|
516
568
|
// First add the webView to view hierarchy
|
|
@@ -1242,13 +1294,38 @@ fileprivate extension WKWebViewController {
|
|
|
1242
1294
|
// MARK: - WKUIDelegate
|
|
1243
1295
|
extension WKWebViewController: WKUIDelegate {
|
|
1244
1296
|
public func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {
|
|
1297
|
+
// Create a strong reference to the completion handler to ensure it's called
|
|
1298
|
+
let strongCompletionHandler = completionHandler
|
|
1299
|
+
|
|
1245
1300
|
// Ensure UI updates are on the main thread
|
|
1246
|
-
DispatchQueue.main.async {
|
|
1301
|
+
DispatchQueue.main.async { [weak self] in
|
|
1302
|
+
guard let self = self else {
|
|
1303
|
+
// View controller was deallocated
|
|
1304
|
+
strongCompletionHandler()
|
|
1305
|
+
return
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
// Check if view is available and ready for presentation
|
|
1309
|
+
guard self.view.window != nil, !self.isBeingDismissed, !self.isMovingFromParent else {
|
|
1310
|
+
print("[InAppBrowser] Cannot present alert - view not in window hierarchy or being dismissed")
|
|
1311
|
+
strongCompletionHandler()
|
|
1312
|
+
return
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1247
1315
|
let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert)
|
|
1248
1316
|
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
|
|
1249
|
-
|
|
1317
|
+
strongCompletionHandler()
|
|
1250
1318
|
}))
|
|
1251
|
-
|
|
1319
|
+
|
|
1320
|
+
// Try to present the alert
|
|
1321
|
+
do {
|
|
1322
|
+
self.present(alertController, animated: true, completion: nil)
|
|
1323
|
+
} catch {
|
|
1324
|
+
// This won't typically be triggered as present doesn't throw,
|
|
1325
|
+
// but adding as a safeguard
|
|
1326
|
+
print("[InAppBrowser] Error presenting alert: \(error)")
|
|
1327
|
+
strongCompletionHandler()
|
|
1328
|
+
}
|
|
1252
1329
|
}
|
|
1253
1330
|
}
|
|
1254
1331
|
}
|
|
@@ -1361,8 +1438,8 @@ extension WKWebViewController: WKNavigationDelegate {
|
|
|
1361
1438
|
|
|
1362
1439
|
public func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
|
1363
1440
|
if let credentials = credentials,
|
|
1364
|
-
|
|
1365
|
-
|
|
1441
|
+
challenge.protectionSpace.receivesCredentialSecurely,
|
|
1442
|
+
let url = webView.url, challenge.protectionSpace.host == url.host, challenge.protectionSpace.protocol == url.scheme, challenge.protectionSpace.port == url.port ?? (url.scheme == "https" ? 443 : url.scheme == "http" ? 80 : nil) {
|
|
1366
1443
|
let urlCredential = URLCredential(user: credentials.username, password: credentials.password, persistence: .none)
|
|
1367
1444
|
completionHandler(.useCredential, urlCredential)
|
|
1368
1445
|
} else if let bypassedSSLHosts = bypassedSSLHosts, bypassedSSLHosts.contains(challenge.protectionSpace.host) {
|
|
@@ -1374,8 +1451,8 @@ extension WKWebViewController: WKNavigationDelegate {
|
|
|
1374
1451
|
return
|
|
1375
1452
|
}
|
|
1376
1453
|
/* allows to open links with self-signed certificates
|
|
1377
|
-
|
|
1378
|
-
|
|
1454
|
+
Follow Apple's guidelines https://developer.apple.com/documentation/foundation/url_loading_system/handling_an_authentication_challenge/performing_manual_server_trust_authentication
|
|
1455
|
+
*/
|
|
1379
1456
|
guard let serverTrust = challenge.protectionSpace.serverTrust else {
|
|
1380
1457
|
completionHandler(.useCredential, nil)
|
|
1381
1458
|
return
|