@capgo/capacitor-inappbrowser 8.6.15
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/CapgoCapacitorInappbrowser.podspec +17 -0
- package/LICENSE +373 -0
- package/Package.swift +28 -0
- package/README.md +1610 -0
- package/android/build.gradle +64 -0
- package/android/src/main/AndroidManifest.xml +22 -0
- package/android/src/main/assets/proxy-bridge.js +586 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/ActiveWebViewSupport.java +10 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/CustomSchemeInterceptSupport.java +51 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +1820 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/MobileAppBridgeScript.java +122 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/NativeProxyRule.java +128 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +725 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/ProxyBridge.java +93 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/ProxyRequestSupport.java +869 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/ProxyResponseRouting.java +35 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/SafeAreaInsetsSupport.java +28 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewCallbacks.java +42 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +6022 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewPermissionSupport.java +58 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/android/src/main/res/drawable/arrow_back_disabled.xml +9 -0
- package/android/src/main/res/drawable/arrow_back_enabled.xml +9 -0
- package/android/src/main/res/drawable/arrow_forward_disabled.xml +9 -0
- package/android/src/main/res/drawable/arrow_forward_enabled.xml +9 -0
- package/android/src/main/res/drawable/ic_clear_24px.xml +9 -0
- package/android/src/main/res/drawable/ic_refresh.xml +9 -0
- package/android/src/main/res/drawable/ic_share.xml +10 -0
- package/android/src/main/res/layout/activity_browser.xml +32 -0
- package/android/src/main/res/layout/bridge_layout_main.xml +15 -0
- package/android/src/main/res/layout/content_browser.xml +17 -0
- package/android/src/main/res/layout/tool_bar.xml +87 -0
- package/android/src/main/res/values/browser_theme.xml +3 -0
- package/android/src/main/res/values/colors.xml +5 -0
- package/android/src/main/res/values/dimens.xml +3 -0
- package/android/src/main/res/values/strings.xml +13 -0
- package/android/src/main/res/values/styles.xml +4 -0
- package/android/src/main/res/values/themes.xml +27 -0
- package/android/src/main/res/xml/file_paths.xml +14 -0
- package/dist/docs.json +3200 -0
- package/dist/esm/definitions.d.ts +1507 -0
- package/dist/esm/definitions.js +40 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +102 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +47 -0
- package/dist/esm/web.js +120 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +270 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +273 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/InAppBrowserPlugin/Enums.swift +65 -0
- package/ios/Sources/InAppBrowserPlugin/InAppBrowserPlugin.swift +1932 -0
- package/ios/Sources/InAppBrowserPlugin/ProxySchemeHandler.swift +1185 -0
- package/ios/Sources/InAppBrowserPlugin/WKWebView+SchemeHandling.swift +43 -0
- package/ios/Sources/InAppBrowserPlugin/WKWebViewController.swift +3032 -0
- package/package.json +139 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
package ee.forgr.capacitor_inappbrowser;
|
|
2
|
+
|
|
3
|
+
final class MobileAppBridgeScript {
|
|
4
|
+
|
|
5
|
+
static final String POST_MESSAGE_BRIDGE_NAME = "__capgoInAppBrowserPostMessageBridge";
|
|
6
|
+
|
|
7
|
+
private MobileAppBridgeScript() {}
|
|
8
|
+
|
|
9
|
+
static String create(boolean allowJavaScriptControl, boolean allowScreenshotsFromWebPage) {
|
|
10
|
+
String mobileAppExtras = "";
|
|
11
|
+
if (allowJavaScriptControl) {
|
|
12
|
+
mobileAppExtras = """
|
|
13
|
+
, hide: function() {
|
|
14
|
+
try {
|
|
15
|
+
window.AndroidInterface.hide();
|
|
16
|
+
} catch(e) {
|
|
17
|
+
console.error('Error in mobileApp.hide:', e);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
show: function() {
|
|
21
|
+
try {
|
|
22
|
+
window.AndroidInterface.show();
|
|
23
|
+
} catch(e) {
|
|
24
|
+
console.error('Error in mobileApp.show:', e);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
""";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
String screenshotBridge = allowScreenshotsFromWebPage
|
|
31
|
+
? """
|
|
32
|
+
,
|
|
33
|
+
takeScreenshot: function() {
|
|
34
|
+
return new Promise(function(resolve, reject) {
|
|
35
|
+
try {
|
|
36
|
+
var screenshotBridge = window.AndroidInterface || nativeBridge;
|
|
37
|
+
if (!screenshotBridge || !screenshotBridge.takeScreenshot) {
|
|
38
|
+
reject(new Error('Screenshot bridge is not available'));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
var requestId = 'screenshot_' + Date.now() + '_' + Math.random().toString(36).slice(2);
|
|
42
|
+
window.__capgoInAppBrowserPendingScreenshots[requestId] = { resolve: resolve, reject: reject };
|
|
43
|
+
screenshotBridge.takeScreenshot(requestId);
|
|
44
|
+
} catch(e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
"""
|
|
50
|
+
: "";
|
|
51
|
+
|
|
52
|
+
return String.format(
|
|
53
|
+
"""
|
|
54
|
+
(function() {
|
|
55
|
+
window.__capgoInAppBrowserPendingScreenshots = window.__capgoInAppBrowserPendingScreenshots || {};
|
|
56
|
+
window.__capgoInAppBrowserResolveScreenshot = window.__capgoInAppBrowserResolveScreenshot || function(payload) {
|
|
57
|
+
var pending = window.__capgoInAppBrowserPendingScreenshots[payload.requestId];
|
|
58
|
+
if (!pending) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
delete window.__capgoInAppBrowserPendingScreenshots[payload.requestId];
|
|
62
|
+
pending.resolve(payload.result);
|
|
63
|
+
};
|
|
64
|
+
window.__capgoInAppBrowserRejectScreenshot = window.__capgoInAppBrowserRejectScreenshot || function(payload) {
|
|
65
|
+
var pending = window.__capgoInAppBrowserPendingScreenshots[payload.requestId];
|
|
66
|
+
if (!pending) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
delete window.__capgoInAppBrowserPendingScreenshots[payload.requestId];
|
|
70
|
+
pending.reject(new Error(payload.message));
|
|
71
|
+
};
|
|
72
|
+
var postMessageBridge = window.%s;
|
|
73
|
+
var nativeBridge = window.AndroidInterface || window.mobileApp;
|
|
74
|
+
if (postMessageBridge || nativeBridge) {
|
|
75
|
+
window.mobileApp = {
|
|
76
|
+
postMessage: function(message) {
|
|
77
|
+
try {
|
|
78
|
+
var msg = typeof message === 'string' ? message : JSON.stringify(message);
|
|
79
|
+
if (typeof msg === 'undefined') {
|
|
80
|
+
msg = String(message);
|
|
81
|
+
}
|
|
82
|
+
if (postMessageBridge && postMessageBridge.postMessage) {
|
|
83
|
+
postMessageBridge.postMessage(msg);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
var fallbackBridge = window.AndroidInterface || nativeBridge;
|
|
87
|
+
if (fallbackBridge && fallbackBridge.postMessage) {
|
|
88
|
+
fallbackBridge.postMessage(msg);
|
|
89
|
+
}
|
|
90
|
+
} catch(e) {
|
|
91
|
+
console.error('Error in mobileApp.postMessage:', e);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
close: function() {
|
|
95
|
+
try {
|
|
96
|
+
var closeBridge = window.AndroidInterface || nativeBridge;
|
|
97
|
+
if (closeBridge && closeBridge.close) {
|
|
98
|
+
closeBridge.close();
|
|
99
|
+
}
|
|
100
|
+
} catch(e) {
|
|
101
|
+
console.error('Error in mobileApp.close:', e);
|
|
102
|
+
}
|
|
103
|
+
}%s%s
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
if (window.PrintInterface) {
|
|
107
|
+
window.print = function() {
|
|
108
|
+
try {
|
|
109
|
+
window.PrintInterface.print();
|
|
110
|
+
} catch(e) {
|
|
111
|
+
console.error('Error in print:', e);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
})();
|
|
116
|
+
""",
|
|
117
|
+
POST_MESSAGE_BRIDGE_NAME,
|
|
118
|
+
mobileAppExtras,
|
|
119
|
+
screenshotBridge
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
package ee.forgr.capacitor_inappbrowser;
|
|
2
|
+
|
|
3
|
+
import java.util.regex.Pattern;
|
|
4
|
+
import java.util.regex.PatternSyntaxException;
|
|
5
|
+
|
|
6
|
+
public class NativeProxyRule {
|
|
7
|
+
|
|
8
|
+
public enum Action {
|
|
9
|
+
CONTINUE,
|
|
10
|
+
CANCEL,
|
|
11
|
+
DELEGATE_TO_JS;
|
|
12
|
+
|
|
13
|
+
public static Action fromString(String value) {
|
|
14
|
+
if (value == null) {
|
|
15
|
+
return CONTINUE;
|
|
16
|
+
}
|
|
17
|
+
switch (value) {
|
|
18
|
+
case "cancel":
|
|
19
|
+
return CANCEL;
|
|
20
|
+
case "delegateToJs":
|
|
21
|
+
return DELEGATE_TO_JS;
|
|
22
|
+
default:
|
|
23
|
+
return CONTINUE;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private final String id;
|
|
29
|
+
private final Pattern urlPattern;
|
|
30
|
+
private final Pattern methodPattern;
|
|
31
|
+
private final Pattern headerPattern;
|
|
32
|
+
private final Pattern bodyPattern;
|
|
33
|
+
private final Pattern statusPattern;
|
|
34
|
+
private final Pattern responseHeaderPattern;
|
|
35
|
+
private final Pattern responseBodyPattern;
|
|
36
|
+
private final boolean mainFrameOnly;
|
|
37
|
+
private final Action action;
|
|
38
|
+
|
|
39
|
+
public NativeProxyRule(
|
|
40
|
+
String id,
|
|
41
|
+
Pattern urlPattern,
|
|
42
|
+
Pattern methodPattern,
|
|
43
|
+
Pattern headerPattern,
|
|
44
|
+
Pattern bodyPattern,
|
|
45
|
+
Pattern statusPattern,
|
|
46
|
+
Pattern responseHeaderPattern,
|
|
47
|
+
Pattern responseBodyPattern,
|
|
48
|
+
boolean mainFrameOnly,
|
|
49
|
+
Action action
|
|
50
|
+
) {
|
|
51
|
+
this.id = id;
|
|
52
|
+
this.urlPattern = urlPattern;
|
|
53
|
+
this.methodPattern = methodPattern;
|
|
54
|
+
this.headerPattern = headerPattern;
|
|
55
|
+
this.bodyPattern = bodyPattern;
|
|
56
|
+
this.statusPattern = statusPattern;
|
|
57
|
+
this.responseHeaderPattern = responseHeaderPattern;
|
|
58
|
+
this.responseBodyPattern = responseBodyPattern;
|
|
59
|
+
this.mainFrameOnly = mainFrameOnly;
|
|
60
|
+
this.action = action;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public String getId() {
|
|
64
|
+
return id;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public boolean isMainFrameOnly() {
|
|
68
|
+
return mainFrameOnly;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public Action getAction() {
|
|
72
|
+
return action;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public boolean matches(
|
|
76
|
+
String url,
|
|
77
|
+
String method,
|
|
78
|
+
String serializedHeaders,
|
|
79
|
+
String decodedBody,
|
|
80
|
+
boolean isMainFrame,
|
|
81
|
+
Integer statusCode,
|
|
82
|
+
String serializedResponseHeaders,
|
|
83
|
+
String decodedResponseBody
|
|
84
|
+
) {
|
|
85
|
+
if (mainFrameOnly && !isMainFrame) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
if (!matchesPattern(urlPattern, url)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
if (!matchesPattern(methodPattern, method)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
if (!matchesPattern(headerPattern, serializedHeaders)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
if (!matchesPattern(bodyPattern, decodedBody)) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
if (!matchesPattern(statusPattern, statusCode != null ? String.valueOf(statusCode) : null)) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
if (!matchesPattern(responseHeaderPattern, serializedResponseHeaders)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
if (!matchesPattern(responseBodyPattern, decodedResponseBody)) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private boolean matchesPattern(Pattern pattern, String value) {
|
|
113
|
+
if (pattern == null) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
if (value == null) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return pattern.matcher(value).find();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public static Pattern compilePattern(String raw) throws PatternSyntaxException {
|
|
123
|
+
if (raw == null || raw.isEmpty()) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return Pattern.compile(raw, Pattern.CASE_INSENSITIVE);
|
|
127
|
+
}
|
|
128
|
+
}
|