apache / cordova-electron Goto Github PK
View Code? Open in Web Editor NEWApache Cordova Electron
License: Apache License 2.0
Apache Cordova Electron
License: Apache License 2.0
I'm using cordova-electron 1.1.0 with cordova 9.0.0 (on windows).
Everytime I add a plugin, I receive this warning:
"[Cordova Electron] The built package size may be larger than necessary."
What does it mean? And what are the implications?
Apache Cordova uses GitHub Issues as a feature request and bug tracker only.
For usage and support questions, please check out the resources below. Thanks!
You can get answers to your usage and support questions about Apache Cordova on:
cordova
If you are using a tool that uses Cordova internally, like e.g. Ionic, check their support channels:
Maybe I misunderstood something, but no matter what I change in :
platform_www/cdv-electron-settings.json
e.g.:
{
"browserWindow": {
"height": 600,
"webPreferences":{
"devTools": false,
"nodeIntegration": false
},
"width": 1000
}
}
the command
cordova run electron
always uses it's default values (and thus shows devtools). I can only avoid that, if I comment the line mainWindow.webContents.openDevTools();
in index.js
Am I missing something, or is this a bug?
Cordova 9.0.0
MacOS 10.14.4
node v11.7.0
I'm trying to access to electron variables, but they seem to be undefined. NodeIntegration is set to true and i can access "desktopCapturer", but "app" and "dialog" is undefined.
Am i unable to access these or is there a trick that i dont know?
Thanks!
Stack Overflow-Link to my related question
https://stackoverflow.com/questions/58164188/requireelectron-app-is-undefined-how-to-solve-this
During the review of #121 I noticed that the tests in the describe('module.exports.prepare method'
block in tests/spec/unit/templates/cordova/lib/prepare.spec.js
were in pretty bad shape.
Funky stuff going on there:
this
Changing the path of the index.html has no effect. For example changing
<content src="index.html" />
to
<content src="index2.html" />
still starts the original index.html although index2.html is in the folder besides index.html.
When starting the application for the platform electron, the index2.html file should be displayed.
When starting the application for the platform electron, the displayed html file is not index2.html but the default index.html instead.
Template cordova project, created by running cordova create testProject
, then creating f.e. a file called index2.html next to the index.html, then changing the content path in config.xml to <content src="index2.html" />
Developing on windows for the electron platform
Electron
When creating an Electron app there is currently no functionality to add a custom app icon.
Implement functionality to support the ability to change app icons.
I believe it is important to at least support .png icons to be consistent with our existing platforms.
The Electron also supports .ico format for Windows and .icns for macOS, but I think this is not as crucial and can be implemented later.
As well, change the default Electron app icon to Cordova logo, if a user does not define any icons.
I have created a cordova plugin that works on cordova android and for electron I have a nodejs file that performs the same task as the plugin of cordova but for Desktop app . Is there a way to wrap the cordova plugin api and the node js file in electron and we can load the plugin based on the type ( ie if its cordova the cordova plugin api will be loaded and if it is electron the nodejs will be loaded)? The search got me here but I cant find any documentation about the usage. Any help will be appreciated. Thank you in advance.
To build a tar.gz package for linux/arm7
The build process fails with a 404 error when trying to download electron-v4.2.12-linux-arm.zip
cordova build electron
Raspbian Buster on Raspberry Pi 4 / 4GB (same result under Windows 10)
Cordova: 9.0.0 ([email protected])
Platforms: electron 1.1.1
OS: Raspbian Buster
Output of cordova build electron:
• electron-builder version=20.44.4
• writing effective config file=platforms/electron/build/builder-effective-config.yaml
• installing production dependencies platform=linux arch=armv7l appDir=/home/pi/cordova/myApp/platforms/electron/www
Error: npm exited with code 1
Output:
> [email protected] postinstall /home/pi/cordova/myApp/platforms/electron/www/node_modules/ejs
> node ./postinstall.js
Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)
> [email protected] postinstall /home/pi/cordova/myApp/platforms/electron/www/node_modules/electron
> node install.js
Downloading tmp-3657-0-electron-v4.2.12-linux-arm.zip
Error: GET https://github.com/electron/electron/releases/download/v4.2.12/electron-v4.2.12-linux-arm.zip returned 404
Error output:
/home/pi/cordova/myApp/platforms/electron/www/node_modules/electron/install.js:49
throw err
^
Error: Failed to find Electron v4.2.12 for linux-arm at https://github.com/electron/electron/releases/download/v4.2.12/electron-v4.2.12-linux-arm.zip
at Request.<anonymous> (/home/pi/cordova/myApp/platforms/electron/www/node_modules/nugget/index.js:169:61)
at Request.emit (events.js:189:13)
at Request.onRequestResponse (/home/pi/cordova/myApp/platforms/electron/www/node_modules/request/request.js:1066:10)
at ClientRequest.emit (events.js:189:13)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
at TLSSocket.socketOnData (_http_client.js:442:20)
at TLSSocket.emit (events.js:189:13)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
build.json contains:
{
"electron": {
"linux": {
"package": [
"tar.gz"
],
"arch": [
"armv7l"
]
}
}
}
When building electron on OS X none of the files from www are being copied into the application package.
When running "cordova run electron --nobuild" or "cordova run electron" everything works fine, but the electron application is referencing files that are outside of the application package. For example if I view the URL for the main index.html file it points here:
file:///Users/username/Development/projectname/platforms/electron/www/index.html
When I run "cordova build electron --release" then launch the .app file none of the assets are loaded, and if I right-click on the .app file and "Show Package Contents" none of the files from "www" are anywhere to be found within the package.
Seemingly, the entire contents of the "www" directory should be copied into the application package.
As described above, none of the contents of the "www" directory end up in the application package.
OS X 10.14.6
cordova 9.0.0 ([email protected])
platforms:
electron 1.1.1
ios 5.0.1
plugins:
cordova-plugin-console 1.1.0
cordova-plugin-device 2.0.3
cordova-plugin-file 6.0.2
cordova-plugin-media 5.0.3
cordova-plugin-splashscreen 5.0.3
cordova-plugin-whitelist 1.3.4
When running tests temp
folder should be created and removed afterwards.
When running tests temp
folder is being created, but not deleted afterwards.
When testing the API's functionality temp
folder is created. However, after the tests finish it's not deleted. We probably should delete that after we finish testing.
npm t
Html doesnt support transparency
even with:
frame:false.
transparent:true
in settings file.
Id like a fully transparent window but for some reason the background is always white.
Even with transparent set to true
Make window transparent.
Its fully opaque with white
Js files not found in electron build
Successfully load js on Linux deb package
Fail to load build js files
runtime-es2015.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
polyfills-es2015.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
styles-es2015.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
cordova.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
vendor-es2015.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
main-es2015.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
Ionic cordova Electron
Ubuntu 16
When signing the build it fails due to electron config and developer ID issues that I believe are related to the new notarizing bug for new mac os
To properly build a release.
I have a proper Developer ID Certificate from apple all setup
cordova build electron
[Cordova Electron] The built package size may be larger than necessary. Please run with --verbose for more details.
• electron-builder version=20.44.4
• writing effective config file=platforms/electron/build/builder-effective-config.yaml
• installing production dependencies platform=darwin arch=x64 appDir=/Users/projects/${PROJECT}/tool_app/platforms/electron/www
• packaging platform=darwin arch=x64 electron=4.0.1 appOutDir=platforms/electron/build/mac
• packaging platform=mas arch=x64 electron=4.0.1 appOutDir=platforms/electron/build/mas
• signing file=platforms/electron/build/mac/Home.app identityName=Developer ID Application: Ltd (*******) identityHash=3B6331A34403D9BE4845BF4ED19BD1E326ED0468 provisioningProfile=salestool.provisionprofile
• signing file=platforms/electron/build/mas/Home.app identityName=Developer ID Application: Ltd (********) identityHash=3B6331A34403D9BE4845BF4ED19BD1E326ED0468 provisioningProfile=salestool.provisionprofile
{ Error: Command failed: spctl --assess --type execute --verbose --ignore-cache --no-cache /Users/projects/${PROJECT}/tool_app/platforms/electron/build/mas/Home.app
/Users/projects/${PROJECT}/tool_app/platforms/electron/build/mas/Home.app: rejected
source=Unnotarized Developer ID
Cordova 9.0.0
Platform Electron 1.1.1
cordova build electron && cordova build electron --release
Electron
This article might point to help, but i couldnt get it to work:
https://kilianvalkhof.com/2019/electron/notarizing-your-electron-application/
Here's some question about bundling node_modules
. I can't find anything in the documentation:
How can I have cordova - electron bundle all required node_modules into the application (so that a user doesn't need node and it's modules installed)?
Do I need to install electron-packager on top of cordova-electron? Do I need to run hooks?
And how would I do this, if I need to require some stuff in the platform_www (renderer)?
Is there some 'best practices' or a demo-project to see how that works?
Any hint appreciated!
When target=app
and target=installer
icons both are configured, installer file should display target=installer
icon and installed application executable file should have target=app
icon
Currently, target=app
icon is only visible in the title bar and application executable shows target=installer
icon
I tried the officially documented way of configuring icons and I also tried copying necessary icons to build resources folder myself but neither way worked.
Building and running on Windows 10
Windows 10 Pro 1903
Cordova: 9.0.0
Cordova-electron: 1.1.0
Ionic: 3.9.2
File {project_root}/platforms/electron/build/HelloWorld-1.0.0.deb
Error: Please specify author 'email' in the application package.json
Using custom build configuration {project_root}/build.json
:
{
"electron": {
"linux": {
"package": [
"deb"
],
"arch": ["x64"]
}
}
}
Using project configuration {project_root}/package.json
:
{
"name": "com.example.hello",
"displayName": "HelloWorld",
"version": "1.0.0",
"description": "A sample Apache Cordova application that responds to the deviceready event.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"ecosystem:cordova"
],
"author": {
"name": "Test",
"email": "[email protected]",
"url": "https://test.com"
},
"contributors": [
{
"name": "test",
"email": "[email protected]",
"url": "https://test.com"
}
],
"license": "Apache-2.0",
"dependencies": {
"cordova-android": "^8.0.0",
"cordova-browser": "^6.0.0",
"cordova-electron": "^1.0.2",
"cordova-ios": "^5.0.1",
"cordova-osx": "^5.0.0",
"cordova-plugin-network-information": "^2.0.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-windows": "^7.0.0"
},
"devDependencies": {
"cordova-plugin-whitelist": "^1.3.3"
},
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-network-information": {},
"cordova-plugin-splashscreen": {}
},
"platforms": [
"ios",
"android",
"electron",
"browser",
"osx",
"windows"
]
}
}
Then building the application.
cordova build electron --release --device
macOS High Sierra 10.13.6
Codova v9.0.0 and Electron v1.0.2
I switched into 1.1.0
,made icon.png
[email protected]
[email protected]
and [email protected]
all set in config.xml and the res/electron folder, than build for windows on my computer that runs MacOS 10.14
.
However when I use win8.1 and turn the layout style into List
, it turned back into default icon. Is it an issue, or maybe I did sth wrong? (I would assume you will get the same result on Win10)
In all of layout styles, will find custom icon.
On Win8.1, In Large Icons
layout style, it's all OK.
But for some reasons, I changed into List
style and it began to show the default icon.(also on Details
and Tiles
)
On MacOS 10.14 everything is OK and just perfect.
icon.png
[email protected]
[email protected]
and [email protected]
are all set in config.xml and the res/electron folder
command
MyMac:app we$ cordova build electron
• electron-builder version=20.44.4
• writing effective config file=platforms/electron/build/builder-effective-config.yaml
• installing production dependencies platform=darwin arch=x64 appDir=/Users/we/Documents/GitHub/mydir/app/platforms/electron/www
• packaging platform=darwin arch=x64 electron=4.0.1 appOutDir=platforms/electron/build/mac
• skipped macOS application code signing reason=cannot find valid "Developer ID Application" identity or custom non-Apple code signing certificate, see https://electron.build/code-signing allIdentities=
1) XXX
2) XXX
2 identities found
Valid identities only
0 valid identities found
• building target=DMG arch=x64 file=platforms/electron/build/MyName-1.0.0.dmg
• no native production dependencies
• packaging platform=win32 arch=x64 electron=4.0.1 appOutDir=platforms/electron/build/win-unpacked
• building target=zip arch=x64 file=platforms/electron/build/MyName-1.0.0-win.zip
• building block map blockMapFile=platforms/electron/build/MyName-1.0.0.dmg.blockmap
build.json
{
"electron": {
"mac": {
"package": [ "dmg" ],
"arch": [ "x64" ]
},"windows": {
"package": [ "zip" ],
"arch": [ "x64" ]
}
}
}
config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.mycompany.myname" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>MyName</name>
<description>
MyDesc
</description>
<author email="[email protected]" href="http://mysite.com">
Author
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<platform name="electron">
<icon src="res/electron/icon.png" />
<icon src="res/electron/[email protected]" />
<icon src="res/electron/[email protected]" />
<icon src="res/electron/[email protected]" />
<icon src="res/electron/[email protected]" target="installer" />
<preference name="ElectronSettingsFilePath" value="res/electron/settings.json" />
</platform>
</widget>
Node 10.16.0
Cordova 9.0.0 ([email protected])
cordova-electron 1.1.0
Building Computer: MacOS 10.14 Mojave
Testing Computer: Win 8.1
See Above.
Thanks a lot.
Icons not matching requirements should be ignored and should not break the build if at least one correct icon is found.
Currently the following configuration in the config.xml
would break the build:
...
<platform name="electron">
<icon src="/res/electron/icon256.png" width="256" height="256"/>
<icon src="/res/electron/icon512.png" width="512" height="512"/>
</platform>
...
Although there's one correct icon defined, during the prepare
procedure, it would throw a CordovaError
and would break the build.
Is it possibile to customize the exe name?
Now it's always "<app_name> Setup.exe". But every time I need to rename it by removing spaces (on our storage space in names don't work very well...) and adding the version number to the end to identify the app version... So if it'd be possible to automize this process giving a custom name to the exe file produced, it would be usefull!
Thank you!
Using the Framework7 CLI to run "framework7 cordova build electron" from the command line, it successfully creates the EXE however it fails to load.
There is a broken link where the logo would be and instead the web inspector appears and the following error is in the console: Failed to load resource: net::ERR_FILE_NOT_FOUND logo1.png
The EXE to load without any errors.
Error as described above
This is my first Electron application that was created via the Framework7 CLI. This is the out of the box sample that I am trying with.
framework7 create --ui
framework7 cordova build electron
PC - Windows 10 64 Bit
Cordova: 9.0.0 ([email protected])
Other Frameworks: Framework7 3.0.5
Windows 10 64 Bit
Cordova's documentation stresses that we need to wait for the deviceready
event before doing anything:
The deviceready event fires when Cordova is fully loaded. This event is essential to any application. It signals that Cordova's device APIs have loaded and are ready to access.
However, this does not hold for cordova-electron.
Fire the deviceready
event anyway, so the same code can be used across all Cordova platforms.
Or at least update the core documentation to mention that we must not wait for deviceready
on the Electron platform.
Write platform-specific code to either wait for deviceready
, or not.
When using a build.json file to customize the build output, the installer icon defined in config.xml is ignored.
The installer icon is used for the executables generated.
Default electron icon is used for the executables generated.
Define electron platform in config,xml with an installer icon, e.g.:
<platform name="electron">
...
<icon src="res/electron/installer.png" target="installer" />
</platform>
Build app for electron, the file platforms/electron/build/builder-effective-config.yaml
contains the following lin (in win
section):
icon: installer.png
Now create a build.json file with the following content:
{
"electron": {
"windows": {
"package": [ "zip" ]
}
}
}
Build the app again for electron. The file platforms/electron/build/builder-effective-config.yaml
does not have the icon defined anymore and electron-builder complains with:
• default Electron icon is used reason=application icon is not set
Windows 10
cordova 9.0.0
cordova-electron 1.0.2
Users can install splash screen plugin, place the splash screen image anywhere in the resources
folder and define its location in the config.xml
. The splash screen then gets copied to the {project_root}/platfroms/electron/www
folder. New splash screen image location defined in the {project_root}/platfroms/electron/config.xml
.
The splash screen for browser and electron only worked when the images were placed in the {project_root}/www/
folder. However, if you build for other platforms, you probably do not want your splash screen to reside in the {project_root}/www/
.
Install the splash screen plugin, add an image and define it in the config.xml
. Now try running the application.
electron
https://cordova.apache.org/docs/en/latest/reference/cordova-cli/index.html#supported-platforms
[ERROR] Error initializing Version Plugin: Missing Command Error
Run electron and skip non electron-compatible plugin.
Error popup at start.
Working android/ios app. Added latest electron platform to test. Added settings.json to have fullscreen browser. Get error popup at start.
cordova run electron
windows 10 x64
[email protected]
[email protected]
To improve usability and give users more insights about the errors and wrong configurations that they have or should provide.
Emit info or warm messages using event emitter. For example:
emit('warn', `The provided provisioning profile does not exist in the given path.`);
This will not change or break anything for existing users.
When a local plugin is added to a cordova application by using cordova plugin add ..\my-plugin\
the building of the application for the electron platform 'succeeds' with the following error:
773 verbose stack Error: ENOENT: no such file or directory, open 'C:\Users\Jonas\Documents\test\proj\platforms\electron\my-plugin\package.json'
774 verbose cwd C:\Users\Jonas\Documents\test\proj\platforms\electron\www
775 verbose Windows_NT 10.0.18362
776 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "--production" "--cache-min" "999999999"
777 verbose node v10.16.0
778 verbose npm v6.9.0
779 error code ENOLOCAL
780 error Could not install from "..\my-plugin" as it does not contain a package.json file.
Here the full log: 2019-07-07T16_07_02_974Z-debug.log
It seems like the package.json is not found because it is searched for in the wrong folder. Instead of \electron\my-plugin\package.json the plugin is located in \electron\www\plugins\my-plugin\package.json.
The build process should not show an error because a package.json is there
The build process shows an error that the package.json cant be found
The plugin is added and works fine (as far as i can see), but the error message is still there. This error does not occur on other platforms f.e. Android.
Creating standard cordova application with cordova create proj
and standard plugin created by plugman create --name my-plugin --plugin_id my-plugin-jssoft --plugin_version 0.0.1
then adding the plugin using cordova plugin add ..\my-plugin\
Windows
Electron
PR Create electron settings json #8 missing unit tests and documentation update.
Update the documentation and implement unit tests.
The app cannot build properly due to an error, apparently, when process the "package.json" file.
The app must be successfully build, even if there are some nodejs / electron modules dependencies.
When the app starts to build, a "package.json" file is prepared with lot of modules inside the "dependencies" key of the JSON file.
For simplification, below is a "package.json" which only contains one dependency, however, even with this one, the app cannot be build properly.
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"7zip-bin": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/7zip-bin/-/7zip-bin-4.1.0.tgz",
"integrity": "sha512-AsnBZN3a8/JcNt+KPkGGODaA4c7l3W5+WpeKgGSbstSLxqWtTXqd1ieJGBQ8IFCtRg8DmmKUcSkIkUc0A4p3YA=="
}
}
}
The first line of the error than appear (sorry, I try, but can't insert here more error output without break the apparence of the post dramatically...) is the below one:
node_modules.Dependency.Dependencies: ReadString: expects " or n, but found {, error found in #10 byte of ...|ip-bin
If we manually remove the dependencies, that is, if we prepare the "package.json" file like below:
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {}
}
Then the app build successfully, however, I think the dependencies means "node/electron modules ready to be used", and, certainly, we want to use some of these modules... so can't simply remove the dependencies from the "package.json" file.
I am not sure if this problem is just for me... I try updating node js, use the latest Cordova version and the latest Cordova Electron version too.
In fact I always can reproduce the problem, however, as I mentioned above, I am not sure if this problem is just for me or what... :-(
I try to compile the app in Windows 10 64 bits.
Cordova version: 9.0.0
Cordova Electron version: 1.1.1
When I build for electron, the bottom portion of the electron.json file is prepended to the top of my index.html file, resulting in errors: aside from the ugly text, the CSP won't load since the browser thinks it's outside the HEAD block.
The bottom of the build.json file prepended to top of INDEX.HTML.
(buffer size issue?)
The index.html file should be copied as is.
With JSON prepended to top of INDEX.HTML, the browser can't load the CSP, so no js gets loaded.
cordova build electron --debug
MacOS (10.15.1)
CDV-CLI 9.0
android 8.1.0
ios 5.1.0
electron 1.1.1
XCode 11.2.1
The appx (Windows Store) package should have my app icon set as its icon.
If what's below isn't the correct way to configure this for Electron, the correct solution should ideally be documented.
My configuration below and icons are ignored; the default Electron icons are used instead.
<icon src="res/icon/windows/StoreLogo.png" target="StoreLogo" />
<icon src="res/icon/windows/SmallLogo.png" target="Square30x30Logo" />
<icon src="res/icon/windows/Square44x44Logo.png" target="Square44x44Logo" />
<icon src="res/icon/windows/Square70x70Logo.png" target="Square70x70Logo" />
<icon src="res/icon/windows/Square71x71Logo.png" target="Square71x71Logo" />
<icon src="res/icon/windows/Square150x150Logo.png" target="Square150x150Logo" />
<icon src="res/icon/windows/Square310x310Logo.png" target="Square310x310Logo" />
<icon src="res/icon/windows/Wide310x150Logo.png" target="Wide310x150Logo" />
You can unzip the appx file and see that only the default Electron icons appear under assets.
cordova build electron
macOS 10.14.6
Cordova 9.0.0
Building for Windows from the latest macOS with cordova-electron fails.
However, as of v21.1.1, it seems that electron-builder adds supports for this (via Parallels).
Update electron-builder from ^20.38.4
to the latest version.
User should be able to pass through gatekeeperAssess: false, as well as any abitrary, valid electron-config option (as per: https://www.electron.build/configuration/mac).
electron-builder build() function does not receive options such as gatekeeperAssess.
Likely a problem with this file picking what options to pass through:
cordova prepare
failed when dependencies
property missing from package.json
➜ cordova-electron-demo cordova prepare electron
Cannot convert undefined or null to object
It should run successfully even if the dependencies
is missing.
It is failed to find the property and try to read from it.
package.json
to match following:{
"name": "template-electron",
"displayName": "template-electron",
"version": "1.0.0",
"description": "A sample cordova-electron app",
"author": "Foobar",
"keywords": [
"cordova",
"electron"
],
"devDependencies": {
"cordova-electron": "^1.1.0",
"cordova-plugin-whitelist": "^1.3.4"
},
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {}
},
"platforms": [
"electron"
]
}
}
cordova prepare electron
Environment:
OS: darwin
Node: v10.15.3
npm: 6.4.1
[email protected] with:
[email protected]
[email protected]
[email protected]
[email protected]
Plugins:
cordova-plugin-whitelist
Installer icon is set in the {project_root}/platforms/electron/build/builder-effective-config.yaml
file when using a custom build configuration.
Installer icon is noot in the {project_root}/platforms/electron/build/builder-effective-config.yaml
file, using default Electron icon.
Using custom build configuration{project_root}/build.json
:
{
"electron": {
"mac": {
"package": [
"tar.gz",
"dmg",
"zip"
],
"arch": ["x64"]
}
}
}
Then building the application.
cordova build electron
All platforms.
Codova v9.0.0 and Electron v1.0.2
electron-userland/electron-builder#2815
I should be able to install my own wanted version of electron-builder
Because of line 28 in the package.json it installs currently electron-builder 20.44.4
It has a problem with nix not being able to find a file in app.asar
Exit code: 103. Command failed: C:\Users\tideman\AppData\Local\electron-builder\Cache\wix\wix-4.0.0.5512.2\light.exe -out C:\Users\tideman\repos\xx\platforms\electron\build\xxxx 2.5.0 ia32.msi -v -spdb -sw1076 -dappDir=C:\Users\tideman\repos\xxx\platforms\electron\build\win-ia32-unpacked -pedantic -wx project.wixobj
C:\Users\tideman\repos\xxx\platforms\electron\build__msi-ia32\project.wxs(397) : error LGHT0103 : The system cannot find the file 'C:\Users\tideman\repos\xxx\platforms\electron\build\win-ia32-unpacked\resources\app.asar.unpacked\node_modules\closure-util.deps\library\947e46b02fd5e472c2d
aa86669c09303ca3e7033\third_party\closure\goog\mochikit\async\deferred_async_test.js'.
WiX Toolset Linker version 4.0.0.5512
Copyright (c) .NET Foundation and contributors. All rights reserved.
user gesture interaction (autoplay policy)
The main electron documentation states that autoplayPolicy
defaults to no-user-gesture-required
which unfortunately isn't the case (see here and search for autoplay ).
Actively setting it to "autoplayPolicy":"no-user-gesture-required"
in the webPreferences
has no effect either.
Fortunately this can be overcome by a hack described below.
Sound is playing without a user interaction.
Sound is only playing with a user interaction.
I wanted to document both problem and workaround in this issue.
The workaround is based on this part of the docs and this issue:
Add
app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');`
after
('const { app, BrowserWindow } = require('electron');')
around line 23 of platforms/electron/platform_www/cdv-electron-main.js
.
This effectively adds a command line switch to Chromium.
Take the default cordova application, add the cordova-plugin-media
and put this code in the onDeviceReady
method:
setTimeout(function () {
var myMedia = new Media("https://kozco.com/tech/piano2-Audacity1.2.5.mp3")
myMedia.play({ numberOfLoops: 2 })
}, 2000)
The sound will play, but only if you click the window within the first seconds.
If not, the console shows the infamous 'user interaction required' error.
Mac OS 10.13.6 (High Sierra)
Cordova CLI
navigator.geolocation.getCurrentPosition always respond PositionError {code: 2, message: ""} in cordova electron builds.
When using navigator.geolocation.getCurrentPosition, it is expected to have coordinates' information of the current position.
It responds PositionError {code: 2, message: ""} .
https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition. Here is the usage of navigator.geolocation.getCurrentPosition.
navigator.geolocation.getCurrentPosition((position:any)->{console.log(position)}, err=>{console.log(err)})
Always responds PositionError {code: 2, message: ""} in Cordova Electron builds.
I was developing in win 10.
"cordova": "^9.0.0",
"cordova-android": "^7.1.1",
"cordova-browser": "^5.0.4",
"cordova-electron": "^1.0.0",
"cordova-plugin-camera": "^4.0.3",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-file": "^6.0.1",
"cordova-plugin-googlemaps": "^2.4.4",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-windows": "^6.0.0",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-googlemaps": {
"API_KEY_FOR_ANDROID": "AIzaSyCffmP_1430l9aB4RCd2H4gWBN7nDvVxBQ",
"PLAY_SERVICES_VERSION": "15.0.1",
"ANDROID_SUPPORT_V4_VERSION": "27.+"
},
"cordova-plugin-camera": {},
"cordova-plugin-file": {}
},
"platforms": [
"android",
"browser",
"windows",
"electron"
]
}
You can not use const { app } = require('electron')
or const fs = require('fs')
in plugins because require
is overriden
There is no way to change an application category for Linux targets. It will always be set to a default value - "Utility".
Output in the terminal, when building for a Linux target:
• application Linux category is set to default "Utility" reason=linux.category is not set and cannot map from macOS docs=https://www.electron.build/configuration/linux
Allow user to set the application category
in the build.json
file.
For instance, like this:
{
"electron": {
"linux": {
"package": [
"tar.gz"
],
"arch": ["x64"],
"category": "Game"
}
}
}
Custom build allows the user to define package and its set of options instructing electron-builder on how it should build that package.
For example:
For the DMG package, you can provide a set of options on how to build the DMG package. Such as background, format and etc. Please, find out more in the Electron Builder documentation.
All additional package options are ignored.
Create a custom build.json
file in the root directory.
{
"electron": {
"macos": {
"package": [
{
"dmg": { "backgroundColor": "#000000" }
}
],
"arch": ["x64"]
}
}
}
Run the following command:
cordova build electron
Right now we only append a few options for mac
, linux
and win
such as target, icon and etc. This limits the functionality and possibilities a user can leverage which electron-builder
has.
Allow users to append all possible options that are supported by electron-builder
. As well as, allow to use the same syntax and structure as in electron-builder
configuration.
Submitting the generated package to the Snap store should succeed.
Preparing to push 'cyph.snap'.
After pushing, an attempt will be made to release to 'stable'
Generating delta for 'cyph.snap'.
Pushing 'cyph.snap.xdelta3' [=========================================================================================================================================] 100%
Processing...|
Error while processing...
The store was unable to accept this snap.
- checksums do not match. Please ensure the snap is created with either 'snapcraft pack <DIR>' (using snapcraft >= 2.38) or 'mksquashfs <dir> <snap> -noappend -comp xz -all-root -no-xattrs -no-fragments'. If using electron-builder, please upgrade to latest stable (>= 20.14.7). See https://forum.snapcraft.io/t/automated-reviews-and-snapcraft-2-38/4982/17 for details.
- found errors in file output: unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Electron Framework -> Versions/Current/Electron Framework', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Libraries -> Versions/Current/Libraries', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Resources -> Versions/Current/Resources', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/Current -> A', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/Mantle.framework/Headers -> Versions/Current/Headers', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/Mantle.framework/Mantle -> Versions/Current/Mantle', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/Mantle.framework/Modules -> Versions/Current/Modules', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/Mantle.framework/Resources -> Versions/Current/Resources', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/Mantle.framework/Versions/Current -> A', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/ReactiveCocoa.framework/Headers -> Versions/Current/Headers', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/ReactiveCocoa.framework/Modules -> Versions/Current/Modules', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/ReactiveCocoa.framework/ReactiveCocoa -> Versions/Current/ReactiveCocoa', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/ReactiveCocoa.framework/Resources -> Versions/Current/Resources', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/ReactiveCocoa.framework/Versions/Current -> A', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/Squirrel.framework/Headers -> Versions/Current/Headers', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/Squirrel.framework/Modules -> Versions/Current/Modules', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/Squirrel.framework/Resources -> Versions/Current/Resources', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/Squirrel.framework/Squirrel -> Versions/Current/Squirrel', unusual mode 'rwxr-xr-x' for symlink './resources/app.asar.unpacked/node_modules/electron/dist/Electron.app/Contents/Frameworks/Squirrel.framework/Versions/Current -> A'
Message from Canonical's manual review:
Note that the problem seems to be that there are many symlinks in the snap that have unusual permissions of 0755. If you adjust these to use the normal 0777 permissions, your snap will likely pass automated review.
Manually running chmod -R 777 .
before building has no effect.
cordova build electron ; snapcraft push --release=stable platforms/electron/build/*.snap
macOS 10.14.6
Cordova 9.0.0
sudo cordova run electon
Downloading tmp-6315-0-electron-v4.2.12-darwin-x64.zip
Error: EACCES: permission denied, open '/Users/eric/Library/Caches/electron/tmp-6315-0-electron-v4.2.12-darwin-x64.zip
MacOSX 10.15.1
Cordova@9
[email protected]
[email protected] (global install)
What are the differences between this and regular Cordova?
My setup looks like this:
config.xml
<platform name="electron">
<preference name="ElectronSettingsFilePath" value="www/platforms/electron.json" />
<icon src="www/assets/img/icon.png" />
</platform>
www/platforms/electron.json
"browserWindow": {
"width": 1280,
"height": 720,
"resizable": false,
"fullscreen": true,
"webPreferences": {
"devTools" : false,
"plugins" : true
}
},
"build": {
"asar": false,
"electronVersion": "2.0.18",
"electronDownload": {
"version": "2.0.18"
}
}
Sadly "devTools" : false is getting ignored, same for the electron-Version. As I can read in the docs, I need --release to have no devTools, but how can I change the used electronVersion?
When I run "cordova build electron" I'm getting this summary:
• electron-builder version=20.44.4
• writing effective config file=platforms\electron\build\builder-effective-config.yaml
• installing production dependencies platform=win32 arch=x64 appDir=...
• packaging platform=win32 arch=x64 electron=4.0.1 appOutDir=...
But where can I change the options for the electron(version), appDir etc?
Thank you for your help
GPS Location does not work
Using navigator.geolocation.getCurrentPosition() or navigator.geolocation.watchPosition() does work as intendent.
The first call return a PositionError, all calls after that do not return anything and result in a timeout.
This issue is know to electron and is fixed in electron 5.x but is not going to be fixed for electron
An updgrade to electron 5.x would therefore be needed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.