@capgo/inappbrowser 7.3.2 → 7.4.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.
Files changed (29) hide show
  1. package/README.md +47 -41
  2. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +149 -41
  3. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +65 -22
  4. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewCallbacks.java +2 -0
  5. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +647 -92
  6. package/android/src/main/res/drawable/ic_share.xml +10 -0
  7. package/android/src/main/res/layout/activity_browser.xml +8 -0
  8. package/android/src/main/res/layout/tool_bar.xml +19 -7
  9. package/android/src/main/res/values/strings.xml +2 -0
  10. package/dist/docs.json +169 -35
  11. package/dist/esm/definitions.d.ts +222 -29
  12. package/dist/esm/definitions.js +12 -1
  13. package/dist/esm/definitions.js.map +1 -1
  14. package/dist/plugin.cjs.js +12 -1
  15. package/dist/plugin.cjs.js.map +1 -1
  16. package/dist/plugin.js +12 -1
  17. package/dist/plugin.js.map +1 -1
  18. package/ios/Plugin/InAppBrowserPlugin.swift +339 -44
  19. package/ios/Plugin/WKWebViewController.swift +478 -45
  20. package/package.json +1 -1
  21. package/ios/Plugin/Assets.xcassets/Back.imageset/Back.png +0 -0
  22. package/ios/Plugin/Assets.xcassets/Back.imageset/Back@2x.png +0 -0
  23. package/ios/Plugin/Assets.xcassets/Back.imageset/Back@3x.png +0 -0
  24. package/ios/Plugin/Assets.xcassets/Back.imageset/Contents.json +0 -26
  25. package/ios/Plugin/Assets.xcassets/Contents.json +0 -6
  26. package/ios/Plugin/Assets.xcassets/Forward.imageset/Contents.json +0 -26
  27. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward.png +0 -0
  28. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@2x.png +0 -0
  29. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@3x.png +0 -0
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <vector xmlns:android="http://schemas.android.com/apk/res/android"
3
+ android:width="24dp"
4
+ android:height="24dp"
5
+ android:viewportWidth="24"
6
+ android:viewportHeight="24">
7
+ <path
8
+ android:fillColor="#FFFFFF"
9
+ android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
10
+ </vector>
@@ -6,9 +6,17 @@
6
6
  android:layout_height="match_parent"
7
7
  tools:context="com.cap.browser.plugin.WebViewActivity">
8
8
 
9
+ <!-- Status bar color view that will be positioned at the top -->
10
+ <View
11
+ android:id="@+id/status_bar_color_view"
12
+ android:layout_width="match_parent"
13
+ android:layout_height="0dp"
14
+ android:background="@android:color/transparent" />
15
+
9
16
  <com.google.android.material.appbar.AppBarLayout
10
17
  android:layout_width="match_parent"
11
18
  android:layout_height="wrap_content"
19
+ android:layout_marginTop="0dp"
12
20
  android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
13
21
 
14
22
  <include
@@ -19,15 +19,15 @@
19
19
 
20
20
  <ImageButton
21
21
  android:id="@+id/buttonNearDone"
22
- android:layout_width="wrap_content"
23
- android:layout_height="wrap_content"
24
- android:layout_gravity="start"
25
- android:background="@android:color/transparent"
22
+ android:layout_width="48dp"
23
+ android:layout_height="48dp"
24
+ android:layout_gravity="end"
25
+ android:layout_marginEnd="8dp"
26
+ android:background="?attr/selectableItemBackgroundBorderless"
26
27
  android:contentDescription="@string/button_near_done"
28
+ android:padding="12dp"
27
29
  android:src="@drawable/ic_clear_24px"
28
- android:translationX="64px"
29
- tools:visibility="gone"
30
- />
30
+ android:visibility="gone" />
31
31
  <ImageButton
32
32
  android:id="@+id/reloadButton"
33
33
  android:layout_width="wrap_content"
@@ -50,6 +50,18 @@
50
50
  android:singleLine="false"
51
51
  android:textColor="#262626" />
52
52
 
53
+ <ImageButton
54
+ android:id="@+id/shareButton"
55
+ android:layout_width="48dp"
56
+ android:layout_height="48dp"
57
+ android:layout_gravity="end"
58
+ android:layout_marginEnd="8dp"
59
+ android:background="?attr/selectableItemBackgroundBorderless"
60
+ android:contentDescription="@string/share_button"
61
+ android:padding="12dp"
62
+ android:src="@drawable/ic_share"
63
+ android:visibility="gone" />
64
+
53
65
  <ImageButton
54
66
  android:id="@+id/forwardButton"
55
67
  android:layout_width="wrap_content"
@@ -1,3 +1,4 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
1
2
  <resources>
2
3
  <string name="my_string">Just a simple string</string>
3
4
  <string name="title_activity_browser">BrowserActivity</string>
@@ -8,4 +9,5 @@
8
9
  <string name="back_button">Back Button</string>
9
10
  <string name="title">Title</string>
10
11
  <string name="forward_button">Forward Button</string>
12
+ <string name="share_button">Share</string>
11
13
  </resources>
package/dist/docs.json CHANGED
@@ -136,7 +136,7 @@
136
136
  "text": "0.1.0"
137
137
  }
138
138
  ],
139
- "docs": "Open url in a new webview with toolbars, and enhanced capabilities, like camera access, file access, listen events, inject javascript, bi directional communication, etc.",
139
+ "docs": "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\nJavaScript Interface:\nWhen 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",
140
140
  "complexTypes": [
141
141
  "OpenWebViewOptions"
142
142
  ],
@@ -468,8 +468,13 @@
468
468
  },
469
469
  {
470
470
  "name": "preventDeeplink",
471
- "tags": [],
472
- "docs": "",
471
+ "tags": [
472
+ {
473
+ "text": "0.1.0",
474
+ "name": "since"
475
+ }
476
+ ],
477
+ "docs": "if true the deeplink will not be opened, if false the deeplink will be opened when clicked on the link",
473
478
  "complexTypes": [],
474
479
  "type": "boolean | undefined"
475
480
  }
@@ -588,6 +593,10 @@
588
593
  {
589
594
  "text": "0.1.0",
590
595
  "name": "since"
596
+ },
597
+ {
598
+ "text": "\"https://capgo.app\"",
599
+ "name": "example"
591
600
  }
592
601
  ],
593
602
  "docs": "Target URL to load.",
@@ -600,6 +609,10 @@
600
609
  {
601
610
  "text": "0.1.0",
602
611
  "name": "since"
612
+ },
613
+ {
614
+ "text": "headers: {\n 'Custom-Header': 'test-value',\n 'Authorization': 'Bearer test-token'\n}\nTest URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/",
615
+ "name": "example"
603
616
  }
604
617
  ],
605
618
  "docs": "Headers to send with the request.",
@@ -614,6 +627,10 @@
614
627
  {
615
628
  "text": "6.1.0",
616
629
  "name": "since"
630
+ },
631
+ {
632
+ "text": "credentials: {\n username: 'test-user',\n password: 'test-pass'\n}\nTest URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/",
633
+ "name": "example"
617
634
  }
618
635
  ],
619
636
  "docs": "Credentials to send with the request and all subsequent requests for the same host.",
@@ -622,15 +639,35 @@
622
639
  ],
623
640
  "type": "Credentials"
624
641
  },
642
+ {
643
+ "name": "jsInterface",
644
+ "tags": [
645
+ {
646
+ "text": "// In your webpage loaded in the webview:\ndocument.getElementById('closeBtn').addEventListener('click', () => {\n window.mobileApp.close();\n});\n\n// Send data to the app\nwindow.mobileApp.postMessage({ action: 'login', data: { user: 'test' }});",
647
+ "name": "example"
648
+ },
649
+ {
650
+ "text": "6.10.0",
651
+ "name": "since"
652
+ }
653
+ ],
654
+ "docs": "JavaScript Interface:\nThe 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)",
655
+ "complexTypes": [],
656
+ "type": "undefined"
657
+ },
625
658
  {
626
659
  "name": "shareDisclaimer",
627
660
  "tags": [
628
661
  {
629
662
  "text": "0.1.0",
630
663
  "name": "since"
664
+ },
665
+ {
666
+ "text": "shareDisclaimer: {\n title: 'Disclaimer',\n message: 'This is a test disclaimer',\n confirmBtn: 'Accept',\n cancelBtn: 'Decline'\n}\nTest URL: https://capgo.app",
667
+ "name": "example"
631
668
  }
632
669
  ],
633
- "docs": "share options",
670
+ "docs": "Share options for the webview. When provided, shows a disclaimer dialog before sharing content.\nThis 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\nNote: shareSubject is required when using shareDisclaimer",
634
671
  "complexTypes": [
635
672
  "DisclaimerOptions"
636
673
  ],
@@ -646,9 +683,13 @@
646
683
  {
647
684
  "text": "ToolBarType.DEFAULT",
648
685
  "name": "default"
686
+ },
687
+ {
688
+ "text": "toolbarType: ToolBarType.ACTIVITY,\ntitle: 'Activity Toolbar Test'\nTest URL: https://capgo.app",
689
+ "name": "example"
649
690
  }
650
691
  ],
651
- "docs": "Toolbar type",
692
+ "docs": "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",
652
693
  "complexTypes": [
653
694
  "ToolBarType"
654
695
  ],
@@ -660,9 +701,13 @@
660
701
  {
661
702
  "text": "0.1.0",
662
703
  "name": "since"
704
+ },
705
+ {
706
+ "text": "\"Share this page\"",
707
+ "name": "example"
663
708
  }
664
709
  ],
665
- "docs": "Share subject",
710
+ "docs": "Subject text for sharing. Required when using shareDisclaimer.\nThis text will be used as the subject line when sharing content.",
666
711
  "complexTypes": [],
667
712
  "type": "string | undefined"
668
713
  },
@@ -676,6 +721,10 @@
676
721
  {
677
722
  "text": "'New Window'",
678
723
  "name": "default"
724
+ },
725
+ {
726
+ "text": "\"Camera Test\"",
727
+ "name": "example"
679
728
  }
680
729
  ],
681
730
  "docs": "Title of the browser",
@@ -706,6 +755,10 @@
706
755
  {
707
756
  "text": "false",
708
757
  "name": "default"
758
+ },
759
+ {
760
+ "text": "activeNativeNavigationForWebview: true,\ndisableGoBackOnNativeApplication: true\nTest URL: https://capgo.app",
761
+ "name": "example"
709
762
  }
710
763
  ],
711
764
  "docs": "If true, active the native navigation within the webview, Android only",
@@ -718,9 +771,13 @@
718
771
  {
719
772
  "text": "false",
720
773
  "name": "default"
774
+ },
775
+ {
776
+ "text": "disableGoBackOnNativeApplication: true\nTest URL: https://capgo.app",
777
+ "name": "example"
721
778
  }
722
779
  ],
723
- "docs": "Disable the possibility to go back on native application,\nusefull to force user to stay on the webview, Android only",
780
+ "docs": "Disable the possibility to go back on native application,\nuseful to force user to stay on the webview, Android only",
724
781
  "complexTypes": [],
725
782
  "type": "boolean | undefined"
726
783
  },
@@ -734,9 +791,13 @@
734
791
  {
735
792
  "text": "false",
736
793
  "name": "default"
794
+ },
795
+ {
796
+ "text": "isPresentAfterPageLoad: true,\npreShowScript: \"await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });\"\nTest URL: https://capgo.app",
797
+ "name": "example"
737
798
  }
738
799
  ],
739
- "docs": "Open url in a new window fullscreen\n\nisPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.",
800
+ "docs": "Open url in a new window fullscreen\nisPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.",
740
801
  "complexTypes": [],
741
802
  "type": "boolean | undefined"
742
803
  },
@@ -774,6 +835,10 @@
774
835
  {
775
836
  "text": "false",
776
837
  "name": "default"
838
+ },
839
+ {
840
+ "text": "showReloadButton: true\nTest URL: https://capgo.app",
841
+ "name": "example"
777
842
  }
778
843
  ],
779
844
  "docs": "Shows a reload button that reloads the web page",
@@ -790,6 +855,10 @@
790
855
  {
791
856
  "text": "false",
792
857
  "name": "default"
858
+ },
859
+ {
860
+ "text": "closeModal: true,\ncloseModalTitle: 'Close Window',\ncloseModalDescription: 'Are you sure you want to close?',\ncloseModalOk: 'Yes, close',\ncloseModalCancel: 'No, stay'\nTest URL: https://capgo.app",
861
+ "name": "example"
793
862
  }
794
863
  ],
795
864
  "docs": "CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately.",
@@ -808,7 +877,7 @@
808
877
  "name": "default"
809
878
  }
810
879
  ],
811
- "docs": "CloseModalTitle: title of the confirm when user clicks on close button, only on IOS",
880
+ "docs": "CloseModalTitle: title of the confirm when user clicks on close button",
812
881
  "complexTypes": [],
813
882
  "type": "string | undefined"
814
883
  },
@@ -824,7 +893,7 @@
824
893
  "name": "default"
825
894
  }
826
895
  ],
827
- "docs": "CloseModalDescription: description of the confirm when user clicks on close button, only on IOS",
896
+ "docs": "CloseModalDescription: description of the confirm when user clicks on close button",
828
897
  "complexTypes": [],
829
898
  "type": "string | undefined"
830
899
  },
@@ -840,7 +909,7 @@
840
909
  "name": "default"
841
910
  }
842
911
  ],
843
- "docs": "CloseModalOk: text of the confirm button when user clicks on close button, only on IOS",
912
+ "docs": "CloseModalOk: text of the confirm button when user clicks on close button",
844
913
  "complexTypes": [],
845
914
  "type": "string | undefined"
846
915
  },
@@ -856,7 +925,7 @@
856
925
  "name": "default"
857
926
  }
858
927
  ],
859
- "docs": "CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS",
928
+ "docs": "CloseModalCancel: text of the cancel button when user clicks on close button",
860
929
  "complexTypes": [],
861
930
  "type": "string | undefined"
862
931
  },
@@ -884,14 +953,38 @@
884
953
  "name": "since"
885
954
  },
886
955
  {
887
- "text": "'#ffffff''",
956
+ "text": "'#ffffff'",
888
957
  "name": "default"
958
+ },
959
+ {
960
+ "text": "toolbarColor: '#FF5733'\nTest URL: https://capgo.app",
961
+ "name": "example"
889
962
  }
890
963
  ],
891
964
  "docs": "toolbarColor: color of the toolbar in hex format",
892
965
  "complexTypes": [],
893
966
  "type": "string | undefined"
894
967
  },
968
+ {
969
+ "name": "toolbarTextColor",
970
+ "tags": [
971
+ {
972
+ "text": "6.10.0",
973
+ "name": "since"
974
+ },
975
+ {
976
+ "text": "calculated based on toolbarColor brightness",
977
+ "name": "default"
978
+ },
979
+ {
980
+ "text": "toolbarTextColor: '#FFFFFF'\nTest URL: https://capgo.app",
981
+ "name": "example"
982
+ }
983
+ ],
984
+ "docs": "toolbarTextColor: color of the buttons and title in the toolbar in hex format\nWhen set, it overrides the automatic light/dark mode detection for text color",
985
+ "complexTypes": [],
986
+ "type": "string | undefined"
987
+ },
895
988
  {
896
989
  "name": "showArrow",
897
990
  "tags": [
@@ -902,6 +995,10 @@
902
995
  {
903
996
  "text": "false",
904
997
  "name": "default"
998
+ },
999
+ {
1000
+ "text": "showArrow: true\nTest URL: https://capgo.app",
1001
+ "name": "example"
905
1002
  }
906
1003
  ],
907
1004
  "docs": "showArrow: if true an arrow would be shown instead of cross for closing the window",
@@ -930,6 +1027,10 @@
930
1027
  {
931
1028
  "text": "6.6.0",
932
1029
  "name": "since"
1030
+ },
1031
+ {
1032
+ "text": "preShowScript: \"await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });\"\nTest URL: https://capgo.app",
1033
+ "name": "example"
933
1034
  }
934
1035
  ],
935
1036
  "docs": "preShowScript: if isPresentAfterPageLoad is true and this variable is set the plugin will inject a script before showing the browser.\nThis script will be run in an async context. The plugin will wait for the script to finish (max 10 seconds)",
@@ -954,11 +1055,15 @@
954
1055
  {
955
1056
  "text": "6.7.0",
956
1057
  "name": "since"
1058
+ },
1059
+ {
1060
+ "text": "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}\nTest URL: https://capgo.app",
1061
+ "name": "example"
957
1062
  }
958
1063
  ],
959
- "docs": "buttonNearDone allows for a creation of a custom button. Please see [buttonNearDone.md](/buttonNearDone.md) for more info.",
1064
+ "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",
960
1065
  "complexTypes": [],
961
- "type": "{ ios: { iconType: 'sf-symbol' | 'asset'; icon: string; }; android: { iconType: 'asset'; icon: string; width?: number | undefined; height?: number | undefined; }; } | undefined"
1066
+ "type": "{ ios: { iconType: 'sf-symbol' | 'asset'; icon: string; }; android: { iconType: 'asset' | 'vector'; icon: string; width?: number | undefined; height?: number | undefined; }; } | undefined"
962
1067
  }
963
1068
  ]
964
1069
  },
@@ -971,29 +1076,49 @@
971
1076
  "properties": [
972
1077
  {
973
1078
  "name": "title",
974
- "tags": [],
975
- "docs": "",
1079
+ "tags": [
1080
+ {
1081
+ "text": "\"Title\"",
1082
+ "name": "default"
1083
+ }
1084
+ ],
1085
+ "docs": "Title of the disclaimer dialog",
976
1086
  "complexTypes": [],
977
1087
  "type": "string"
978
1088
  },
979
1089
  {
980
1090
  "name": "message",
981
- "tags": [],
982
- "docs": "",
1091
+ "tags": [
1092
+ {
1093
+ "text": "\"Message\"",
1094
+ "name": "default"
1095
+ }
1096
+ ],
1097
+ "docs": "Message shown in the disclaimer dialog",
983
1098
  "complexTypes": [],
984
1099
  "type": "string"
985
1100
  },
986
1101
  {
987
1102
  "name": "confirmBtn",
988
- "tags": [],
989
- "docs": "",
1103
+ "tags": [
1104
+ {
1105
+ "text": "\"Confirm\"",
1106
+ "name": "default"
1107
+ }
1108
+ ],
1109
+ "docs": "Text for the confirm button",
990
1110
  "complexTypes": [],
991
1111
  "type": "string"
992
1112
  },
993
1113
  {
994
1114
  "name": "cancelBtn",
995
- "tags": [],
996
- "docs": "",
1115
+ "tags": [
1116
+ {
1117
+ "text": "\"Cancel\"",
1118
+ "name": "default"
1119
+ }
1120
+ ],
1121
+ "docs": "Text for the cancel button",
997
1122
  "complexTypes": [],
998
1123
  "type": "string"
999
1124
  }
@@ -1066,26 +1191,35 @@
1066
1191
  {
1067
1192
  "name": "ACTIVITY",
1068
1193
  "value": "\"activity\"",
1069
- "tags": [],
1070
- "docs": ""
1194
+ "tags": [
1195
+ {
1196
+ "text": "0.1.0",
1197
+ "name": "since"
1198
+ }
1199
+ ],
1200
+ "docs": "Shows a simple toolbar with just a close button and share button"
1071
1201
  },
1072
1202
  {
1073
1203
  "name": "NAVIGATION",
1074
1204
  "value": "\"navigation\"",
1075
- "tags": [],
1076
- "docs": ""
1205
+ "tags": [
1206
+ {
1207
+ "text": "0.1.0",
1208
+ "name": "since"
1209
+ }
1210
+ ],
1211
+ "docs": "Shows a full navigation toolbar with back/forward buttons"
1077
1212
  },
1078
1213
  {
1079
1214
  "name": "BLANK",
1080
1215
  "value": "\"blank\"",
1081
- "tags": [],
1082
- "docs": ""
1083
- },
1084
- {
1085
- "name": "DEFAULT",
1086
- "value": "\"\"",
1087
- "tags": [],
1088
- "docs": ""
1216
+ "tags": [
1217
+ {
1218
+ "text": "0.1.0",
1219
+ "name": "since"
1220
+ }
1221
+ ],
1222
+ "docs": "Shows no toolbar"
1089
1223
  }
1090
1224
  ]
1091
1225
  },