cordova-electron icon indicating copy to clipboard operation
cordova-electron copied to clipboard

Framework functions receive arguments boxed twice in an Array

Open goffioul opened this issue 3 years ago • 1 comments

I'm not sure this is intentional or not, but I don't see the reason for the arguments to be boxed twice in an array when reaching the main process of a framework plugin/element. That is:

  • cordova.exec transfers the array of argument to _cdvElectronIpc, which in turns send the array to the main process
  • the cdv-plugin-exec handler uses vararg for the last argument, which basically boxes the argument into another array
  • the framework function receives a single argument, which is then an array or arrays

Is this intentional?

goffioul avatar Nov 03 '21 19:11 goffioul

Hi, I noticed the same as I was working on upgrading an app from cordova-electron 1.x to 3.x

With 1.x I was able to access the main process using the options nodeIntegration = true and contextIsolation = false in browserWindow.webPreferences, but as this is not supported anymore in cordova-electron 3.x, I deep dived into the code to understand how it works and how can I create a plugin that runs in the main process.

I'm going to fork cordova-electron to try to this, and also to call the framework function with parameters (succes, fail, args) to make it more similar to "browser" platform and address the fact that if you have to run the error function, Electron returns a string wrapped in an Error object.

fabiofabbri84 avatar Jun 23 '22 12:06 fabiofabbri84