Skip to content

Commit

Permalink
Inject localUrlJS before bridgeJS
Browse files Browse the repository at this point in the history
  • Loading branch information
WIStudent committed Jun 21, 2021
1 parent d171a84 commit e46a0a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions android/capacitor/src/main/java/com/getcapacitor/Bridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -756,14 +756,14 @@ public <I, O> ActivityResultLauncher<I> registerForActivityResult(
private JSInjector getJSInjector() {
try {
String globalJS = JSExport.getGlobalJS(context, config.isLoggingEnabled(), isDevMode());
String localUrlJS = "window.WEBVIEW_SERVER_URL = '" + localUrl + "';";
String bridgeJS = JSExport.getBridgeJS(context);
String pluginJS = JSExport.getPluginJS(plugins.values());
String cordovaJS = JSExport.getCordovaJS(context);
String cordovaPluginsJS = JSExport.getCordovaPluginJS(context);
String cordovaPluginsFileJS = JSExport.getCordovaPluginsFileJS(context);
String localUrlJS = "window.WEBVIEW_SERVER_URL = '" + localUrl + "';";

return new JSInjector(globalJS, bridgeJS, pluginJS, cordovaJS, cordovaPluginsJS, cordovaPluginsFileJS, localUrlJS);
return new JSInjector(globalJS, localUrlJS, bridgeJS, pluginJS, cordovaJS, cordovaPluginsJS, cordovaPluginsFileJS);
} catch (Exception ex) {
Logger.error("Unable to export Capacitor JS. App will not function!", ex);
}
Expand Down
12 changes: 6 additions & 6 deletions android/capacitor/src/main/java/com/getcapacitor/JSInjector.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@
class JSInjector {

private String globalJS;
private String localUrlJS;
private String bridgeJS;
private String pluginJS;
private String cordovaJS;
private String cordovaPluginsJS;
private String cordovaPluginsFileJS;
private String localUrlJS;

public JSInjector(
String globalJS,
String localUrlJS
String bridgeJS,
String pluginJS,
String cordovaJS,
String cordovaPluginsJS,
String cordovaPluginsFileJS,
String localUrlJS
) {
this.globalJS = globalJS;
this.localUrlJS = localUrlJS;
this.bridgeJS = bridgeJS;
this.pluginJS = pluginJS;
this.cordovaJS = cordovaJS;
this.cordovaPluginsJS = cordovaPluginsJS;
this.cordovaPluginsFileJS = cordovaPluginsFileJS;
this.localUrlJS = localUrlJS;
}

/**
Expand All @@ -48,6 +48,8 @@ public String getScriptString() {
return (
globalJS +
"\n\n" +
localUrlJS +
"\n\n" +
bridgeJS +
"\n\n" +
pluginJS +
Expand All @@ -56,9 +58,7 @@ public String getScriptString() {
"\n\n" +
cordovaPluginsFileJS +
"\n\n" +
cordovaPluginsJS +
"\n\n" +
localUrlJS
cordovaPluginsJS
);
}

Expand Down

0 comments on commit e46a0a0

Please sign in to comment.