@capgo/inappbrowser 7.10.8 → 7.10.9
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.
|
@@ -1119,10 +1119,10 @@ public class WebViewDialog extends Dialog {
|
|
|
1119
1119
|
JSONObject jsonObject = new JSONObject();
|
|
1120
1120
|
jsonObject.put("detail", detail);
|
|
1121
1121
|
String jsonDetail = jsonObject.toString();
|
|
1122
|
-
String script =
|
|
1123
|
-
"window.dispatchEvent(new CustomEvent('messageFromNative', "
|
|
1124
|
-
jsonDetail
|
|
1125
|
-
|
|
1122
|
+
String script = String.format(
|
|
1123
|
+
"window.dispatchEvent(new CustomEvent('messageFromNative', %s));",
|
|
1124
|
+
jsonDetail
|
|
1125
|
+
);
|
|
1126
1126
|
_webView.post(() -> {
|
|
1127
1127
|
if (_webView != null) {
|
|
1128
1128
|
_webView.evaluateJavascript(script, null);
|
|
@@ -1148,56 +1148,58 @@ public class WebViewDialog extends Dialog {
|
|
|
1148
1148
|
|
|
1149
1149
|
try {
|
|
1150
1150
|
String script =
|
|
1151
|
-
"
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1151
|
+
"""
|
|
1152
|
+
(function() {
|
|
1153
|
+
if (window.AndroidInterface) {
|
|
1154
|
+
// Create mobileApp object for backward compatibility
|
|
1155
|
+
if (!window.mobileApp) {
|
|
1156
|
+
window.mobileApp = {
|
|
1157
|
+
postMessage: function(message) {
|
|
1158
|
+
try {
|
|
1159
|
+
var msg = typeof message === 'string' ? message : JSON.stringify(message);
|
|
1160
|
+
window.AndroidInterface.postMessage(msg);
|
|
1161
|
+
} catch(e) {
|
|
1162
|
+
console.error('Error in mobileApp.postMessage:', e);
|
|
1163
|
+
}
|
|
1164
|
+
},
|
|
1165
|
+
close: function() {
|
|
1166
|
+
try {
|
|
1167
|
+
window.AndroidInterface.close();
|
|
1168
|
+
} catch(e) {
|
|
1169
|
+
console.error('Error in mobileApp.close:', e);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
}
|
|
1174
|
+
// Also provide direct window methods for convenience
|
|
1175
|
+
window.postMessage = function(data) {
|
|
1176
|
+
try {
|
|
1177
|
+
var message = typeof data === 'string' ? data : JSON.stringify(data);
|
|
1178
|
+
window.AndroidInterface.postMessage(message);
|
|
1179
|
+
} catch(e) {
|
|
1180
|
+
console.error('Error in postMessage:', e);
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1183
|
+
window.close = function() {
|
|
1184
|
+
try {
|
|
1185
|
+
window.AndroidInterface.close();
|
|
1186
|
+
} catch(e) {
|
|
1187
|
+
console.error('Error in close:', e);
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
// Override window.print function to use our PrintInterface
|
|
1192
|
+
if (window.PrintInterface) {
|
|
1193
|
+
window.print = function() {
|
|
1194
|
+
try {
|
|
1195
|
+
window.PrintInterface.print();
|
|
1196
|
+
} catch(e) {
|
|
1197
|
+
console.error('Error in print:', e);
|
|
1198
|
+
}
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
})();
|
|
1202
|
+
""";
|
|
1201
1203
|
|
|
1202
1204
|
_webView.post(() -> {
|
|
1203
1205
|
if (_webView != null) {
|
|
@@ -1227,12 +1229,20 @@ public class WebViewDialog extends Dialog {
|
|
|
1227
1229
|
return;
|
|
1228
1230
|
}
|
|
1229
1231
|
|
|
1230
|
-
String script =
|
|
1231
|
-
"
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1232
|
+
String script = String.format(
|
|
1233
|
+
"""
|
|
1234
|
+
async function preShowFunction() {
|
|
1235
|
+
%s
|
|
1236
|
+
}
|
|
1237
|
+
preShowFunction()
|
|
1238
|
+
.then(() => window.PreShowScriptInterface.success())
|
|
1239
|
+
.catch(err => {
|
|
1240
|
+
console.error('Pre show error', err);
|
|
1241
|
+
window.PreShowScriptInterface.error(JSON.stringify(err, Object.getOwnPropertyNames(err)));
|
|
1242
|
+
});
|
|
1243
|
+
""",
|
|
1244
|
+
_options.getPreShowScript()
|
|
1245
|
+
);
|
|
1236
1246
|
|
|
1237
1247
|
Log.i(
|
|
1238
1248
|
"InjectPreShowScript",
|
|
@@ -2214,8 +2224,44 @@ public class WebViewDialog extends Dialog {
|
|
|
2214
2224
|
)
|
|
2215
2225
|
);
|
|
2216
2226
|
}
|
|
2227
|
+
String jsTemplate =
|
|
2228
|
+
"""
|
|
2229
|
+
try {
|
|
2230
|
+
function getHeaders() {
|
|
2231
|
+
const h = {};
|
|
2232
|
+
%s
|
|
2233
|
+
return h;
|
|
2234
|
+
}
|
|
2235
|
+
window.InAppBrowserProxyRequest(new Request(atob('%s'), {
|
|
2236
|
+
headers: getHeaders(),
|
|
2237
|
+
method: '%s'
|
|
2238
|
+
})).then(async (res) => {
|
|
2239
|
+
Capacitor.Plugins.InAppBrowser.lsuakdchgbbaHandleProxiedRequest({
|
|
2240
|
+
ok: true,
|
|
2241
|
+
result: (!!res ? {
|
|
2242
|
+
headers: Object.fromEntries(res.headers.entries()),
|
|
2243
|
+
code: res.status,
|
|
2244
|
+
body: (await res.text())
|
|
2245
|
+
} : null),
|
|
2246
|
+
id: '%s'
|
|
2247
|
+
});
|
|
2248
|
+
}).catch((e) => {
|
|
2249
|
+
Capacitor.Plugins.InAppBrowser.lsuakdchgbbaHandleProxiedRequest({
|
|
2250
|
+
ok: false,
|
|
2251
|
+
result: e.toString(),
|
|
2252
|
+
id: '%s'
|
|
2253
|
+
});
|
|
2254
|
+
});
|
|
2255
|
+
} catch (e) {
|
|
2256
|
+
Capacitor.Plugins.InAppBrowser.lsuakdchgbbaHandleProxiedRequest({
|
|
2257
|
+
ok: false,
|
|
2258
|
+
result: e.toString(),
|
|
2259
|
+
id: '%s'
|
|
2260
|
+
});
|
|
2261
|
+
}
|
|
2262
|
+
""";
|
|
2217
2263
|
String s = String.format(
|
|
2218
|
-
|
|
2264
|
+
jsTemplate,
|
|
2219
2265
|
headers,
|
|
2220
2266
|
toBase64(request.getUrl().toString()),
|
|
2221
2267
|
request.getMethod(),
|
|
@@ -2598,21 +2644,22 @@ public class WebViewDialog extends Dialog {
|
|
|
2598
2644
|
|
|
2599
2645
|
// Clear file inputs for security/privacy before destroying WebView
|
|
2600
2646
|
try {
|
|
2601
|
-
|
|
2602
|
-
"
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2647
|
+
String clearInputsScript =
|
|
2648
|
+
"""
|
|
2649
|
+
(function() {
|
|
2650
|
+
try {
|
|
2651
|
+
var inputs = document.querySelectorAll('input[type="file"]');
|
|
2652
|
+
for (var i = 0; i < inputs.length; i++) {
|
|
2653
|
+
inputs[i].value = '';
|
|
2654
|
+
}
|
|
2655
|
+
return true;
|
|
2656
|
+
} catch(e) {
|
|
2657
|
+
console.log('Error clearing file inputs:', e);
|
|
2658
|
+
return false;
|
|
2659
|
+
}
|
|
2660
|
+
})();
|
|
2661
|
+
""";
|
|
2662
|
+
_webView.evaluateJavascript(clearInputsScript, null);
|
|
2616
2663
|
} catch (Exception e) {
|
|
2617
2664
|
Log.w(
|
|
2618
2665
|
"InAppBrowser",
|