@capgo/capacitor-inappbrowser 8.8.0 → 8.8.1
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/android/src/main/java/ee/forgr/capacitor_inappbrowser/CapgoInAppBrowserPlugin.java +1 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +10 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +18 -2
- package/ios/Sources/InAppBrowserPlugin/InAppBrowserPlugin.swift +1 -1
- package/package.json +1 -1
|
@@ -1143,6 +1143,7 @@ public class CapgoInAppBrowserPlugin extends Plugin implements WebViewDialog.Per
|
|
|
1143
1143
|
|
|
1144
1144
|
options.setShareDisclaimer(call.getObject("shareDisclaimer", null));
|
|
1145
1145
|
options.setPreShowScript(call.getString("preShowScript", null));
|
|
1146
|
+
options.setPreShowScriptInjectionTime(call.getString("preShowScriptInjectionTime", "pageLoad"));
|
|
1146
1147
|
options.setShareSubject(call.getString("shareSubject", null));
|
|
1147
1148
|
options.setToolbarType(call.getString("toolbarType", ""));
|
|
1148
1149
|
options.setPreventDeeplink(Boolean.TRUE.equals(call.getBoolean("preventDeeplink", false)));
|
|
@@ -168,6 +168,7 @@ public class Options {
|
|
|
168
168
|
private boolean ignoreUntrustedSSLError;
|
|
169
169
|
private boolean clientCertificatePrompt;
|
|
170
170
|
private String preShowScript;
|
|
171
|
+
private String preShowScriptInjectionTime = "pageLoad";
|
|
171
172
|
private String toolbarTextColor;
|
|
172
173
|
private Pattern proxyRequestsPattern = null;
|
|
173
174
|
private boolean proxyRequests = false;
|
|
@@ -617,6 +618,14 @@ public class Options {
|
|
|
617
618
|
this.preShowScript = preLoadScript;
|
|
618
619
|
}
|
|
619
620
|
|
|
621
|
+
public String getPreShowScriptInjectionTime() {
|
|
622
|
+
return preShowScriptInjectionTime;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
public void setPreShowScriptInjectionTime(String preShowScriptInjectionTime) {
|
|
626
|
+
this.preShowScriptInjectionTime = preShowScriptInjectionTime != null ? preShowScriptInjectionTime : "pageLoad";
|
|
627
|
+
}
|
|
628
|
+
|
|
620
629
|
public boolean getPreventDeeplink() {
|
|
621
630
|
return preventDeeplink;
|
|
622
631
|
}
|
|
@@ -753,6 +762,7 @@ public class Options {
|
|
|
753
762
|
copy.setIgnoreUntrustedSSLError(ignoreUntrustedSSLError);
|
|
754
763
|
copy.setClientCertificatePrompt(clientCertificatePrompt);
|
|
755
764
|
copy.setPreShowScript(preShowScript);
|
|
765
|
+
copy.setPreShowScriptInjectionTime(preShowScriptInjectionTime);
|
|
756
766
|
copy.setToolbarTextColor(toolbarTextColor);
|
|
757
767
|
copy.setProxyRequestsPattern(proxyRequestsPattern);
|
|
758
768
|
copy.setProxyRequests(proxyRequests);
|
|
@@ -377,6 +377,9 @@ public class WebViewDialog extends Dialog implements ProxyResponseRouting.ProxyR
|
|
|
377
377
|
|
|
378
378
|
Semaphore preShowSemaphore = null;
|
|
379
379
|
String preShowError = null;
|
|
380
|
+
// True when preShowScript was registered via WebViewCompat.addDocumentStartJavaScript;
|
|
381
|
+
// the blocking evaluateJavascript injection in onPageFinished is skipped in that case.
|
|
382
|
+
private boolean preShowInjectedAtDocumentStart = false;
|
|
380
383
|
|
|
381
384
|
public PermissionRequest currentPermissionRequest;
|
|
382
385
|
public static final int FILE_CHOOSER_REQUEST_CODE = 1000;
|
|
@@ -3409,6 +3412,14 @@ public class WebViewDialog extends Dialog implements ProxyResponseRouting.ProxyR
|
|
|
3409
3412
|
try {
|
|
3410
3413
|
injectDocumentStartPostMessageBridge();
|
|
3411
3414
|
WebViewCompat.addDocumentStartJavaScript(_webView, createMobileAppBridgeScript(), Collections.singleton("*"));
|
|
3415
|
+
// Honor preShowScriptInjectionTime: "documentStart" (matches iOS WKUserScript
|
|
3416
|
+
// .atDocumentStart). Runs before page scripts and persists across navigations,
|
|
3417
|
+
// so the blocking semaphore injection in onPageFinished is not needed.
|
|
3418
|
+
String preShowScript = _options.getPreShowScript();
|
|
3419
|
+
if (preShowScript != null && !preShowScript.isEmpty() && "documentStart".equals(_options.getPreShowScriptInjectionTime())) {
|
|
3420
|
+
WebViewCompat.addDocumentStartJavaScript(_webView, preShowScript, Collections.singleton("*"));
|
|
3421
|
+
preShowInjectedAtDocumentStart = true;
|
|
3422
|
+
}
|
|
3412
3423
|
} catch (Exception e) {
|
|
3413
3424
|
Log.e("InAppBrowser", "Error injecting document-start JavaScript interface: " + e.getMessage());
|
|
3414
3425
|
}
|
|
@@ -5392,7 +5403,10 @@ public class WebViewDialog extends Dialog implements ProxyResponseRouting.ProxyR
|
|
|
5392
5403
|
isInitialized = true;
|
|
5393
5404
|
_webView.clearHistory();
|
|
5394
5405
|
if (_options.isPresentAfterPageLoad()) {
|
|
5395
|
-
boolean usePreShowScript =
|
|
5406
|
+
boolean usePreShowScript =
|
|
5407
|
+
_options.getPreShowScript() != null &&
|
|
5408
|
+
!_options.getPreShowScript().isEmpty() &&
|
|
5409
|
+
!preShowInjectedAtDocumentStart;
|
|
5396
5410
|
if (!usePreShowScript) {
|
|
5397
5411
|
showAccordingToLayerModeOrFallback();
|
|
5398
5412
|
resolveOpenWebViewIfNeeded();
|
|
@@ -5419,7 +5433,9 @@ public class WebViewDialog extends Dialog implements ProxyResponseRouting.ProxyR
|
|
|
5419
5433
|
);
|
|
5420
5434
|
}
|
|
5421
5435
|
}
|
|
5422
|
-
} else if (
|
|
5436
|
+
} else if (
|
|
5437
|
+
_options.getPreShowScript() != null && !_options.getPreShowScript().isEmpty() && !preShowInjectedAtDocumentStart
|
|
5438
|
+
) {
|
|
5423
5439
|
executorService.execute(
|
|
5424
5440
|
new Runnable() {
|
|
5425
5441
|
@Override
|
|
@@ -98,7 +98,7 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
98
98
|
case aware = "AWARE"
|
|
99
99
|
case fakeVisible = "FAKE_VISIBLE"
|
|
100
100
|
}
|
|
101
|
-
private let pluginVersion: String = "8.8.
|
|
101
|
+
private let pluginVersion: String = "8.8.1"
|
|
102
102
|
public let identifier = "CapgoInAppBrowserPlugin"
|
|
103
103
|
public let jsName = "CapgoInAppBrowser"
|
|
104
104
|
public let pluginMethods: [CAPPluginMethod] = [
|