Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(electron): add platform support #549

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
aa15a9c
Added cordova file functionality to electron
pjoriginal Dec 13, 2022
0b064fa
Ported complex implementation to a simpler one
pjoriginal Dec 22, 2022
2da7399
chore: update package-lock.json w/ cordova requirements
erisu Dec 23, 2022
493ba05
chore: fix lint errors w/ automatic correction
erisu Dec 23, 2022
bee2c3f
chore: fix lint error pathsPrefix not defined
erisu Dec 23, 2022
45f338a
chore: fix lint error Buffer is not defined
erisu Dec 23, 2022
2647245
chore: update path variable names
erisu Dec 23, 2022
ec604bc
chore: rename nodePath to path
erisu Dec 23, 2022
7e51bdd
chore: update electron app require block
erisu Dec 23, 2022
b5c2bce
chore: remove extra new line block
erisu Dec 23, 2022
327378a
chore: convert arrow function to standard function
erisu Dec 23, 2022
6d17241
chore: have argument parameter defined in passed in method parameter …
erisu Dec 23, 2022
9e1d8a1
chore: add missing apache license header
erisu Dec 23, 2022
bb46098
chore: various formatting and fix reject is not defined
erisu Dec 23, 2022
84104f0
chore: prepare comment blocks to document each method
erisu Dec 23, 2022
98382b6
Merge pull request #1 from erisu/electron3
pjoriginal Dec 23, 2022
c02a6a6
Simple lint fix
pjoriginal Dec 27, 2022
70025d3
Added documentation for functions
pjoriginal Dec 27, 2022
11ba47c
lint fixes
pjoriginal Dec 27, 2022
91776d8
Added new line to gitignore
pjoriginal Dec 27, 2022
c6fe360
Removed the require FileError since it's already in the global scope
pjoriginal Dec 28, 2022
3fdc474
Re-added the FileError Object
pjoriginal Dec 28, 2022
dc9f85b
Added documentation changes
pjoriginal Dec 28, 2022
da4f359
added the two required functions
pjoriginal Jan 29, 2023
dc0f411
fixed the tests that deleted root
pjoriginal Feb 27, 2023
0e07404
Fixed a few tests
pjoriginal Apr 17, 2023
e0b6184
fixed most tests and added required functionality
pjoriginal Apr 22, 2023
4b76361
Merge branch 'master' of https://github.com/apache/cordova-plugin-fil…
pjoriginal Apr 22, 2023
9012ee9
eslint fixes
pjoriginal Apr 25, 2023
fb0a2c8
updated tests and code
pjoriginal Apr 27, 2023
d8097d5
fixed linting
pjoriginal Apr 27, 2023
ca797e8
Merge https://github.com/apache/cordova-plugin-file into electron3
pjoriginal Dec 13, 2023
d9db774
fixed lint errors
pjoriginal Dec 13, 2023
e661af8
Updated Readme to include linux locations
pjoriginal Jan 19, 2024
0ee7b96
Updated files to accept new single array args
pjoriginal Feb 21, 2024
8826f72
Merge pull request #2 from pjoriginal/electron-nightly
pjoriginal Feb 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ Thumbs.db

/.project
node_modules

src/electron/node_modules
src/electron/package-lock.json
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Although the object is in the global scope, it is not available to applications
- OS X
- Windows*
- Browser
- Electron

\* _These platforms do not support `FileReader.readAsArrayBuffer` nor `FileWriter.write(blob)`._

Expand Down Expand Up @@ -233,6 +234,21 @@ If interfacing with the external file system is a requirement for your applicati
\* The OS may periodically clear this directory


### Electron File System Layout
Varies according to the Operating System. The installation method also has an impact on the file path and where it is installed. The file path will be different if you're running it using the command `cordova run electron --nobuild` (debug) or if you've published to a store and running the program through the app installed from the store. The list can be expanded.

_Note: The current Linux file paths are tested in Ubuntu and might be different depending on the distribution of linux_
| Device Path | `cordova.file.*` | r/w? | persistent? | OS clears | private |
|:------------------------------------------------------|:----------------------------|:----:|:-----------:|:---------:|:-------:|
| __Windows:__<br />_Debug:_ `{cwd}\\platforms\\electron`<br />_Installer:_`~\\AppData\\Local\\Programs\\{appId}`<br />__Linux:__ <br>_Debug:_ `{cwd}/platforms/electron`<br />_Package Installer:_ `/opt/{appName}/resources`<br /> __Mac:__<br />_Debug:_ `{cwd}/platforms/electron`<br />_Installer:_`/Applications/{appName.app}/Contents/Resources` | applicationDirectory | r | N/A | N/A | Yes |
| __Windows__: <br />_Debug:_ `~\\AppData\\Roaming\\Electron\\`<br />_Installer:_`~\\AppData\\Local\\Programs\\{appId}`<br />__Linux:__<br>_Debug:_ `~/.config/Electron/`<br />_Package Installer:_ `~/.config/{appId}/`<br /> __Mac:__ `~/Library/Application Support/{appId}` | dataDirectory | r/w | Yes | No | Yes |
| __Windows__: <br />_Debug:_ `~\\AppData\\Roaming\\`<br />_Installer:_`~\\AppData\\Roaming\\`<br /> __Linux:__<br> _Debug:_ `~/.cache/`<br />_Installer:_`~/.cache/`<br /> __Mac:__ `~/Library/Caches` | cacheDirectory | r/w | No | Yes\* | Yes |
| __Windows__: <br />_Debug:_ `~\\AppData\\Local\\Temp\\`<br />_Installer:_`~\AppData\\Local\\Temp\\`<br />__Linux:__<br>_Debug:_ `/tmp/`<br />_Package Installer:_ `/tmp/`<br /> __Mac:__ `varies` | tempDirectory | r/w | No | Yes\* | Yes |
| Windows: `~\\Documents` <br />Linux: `~/Documents/`<br /> Mac: `~/Documents` | documentsDirectory | - | - | - | - |

\* The OS may periodically clear this directory


## Android Quirks

### Android Persistent storage location
Expand Down Expand Up @@ -393,6 +409,10 @@ should be in the form `filesystem:file:///persistent/somefile.txt` as opposed to
- INVALID_MODIFICATION_ERR (code: 9) is thrown instead of NO_MODIFICATION_ALLOWED_ERR(code: 6) on trying to call removeRecursively on the root file system.
- INVALID_MODIFICATION_ERR (code: 9) is thrown instead of NOT_FOUND_ERR(code: 1) on trying to moveTo directory that does not exist.

### Electron quirks
- When using `cordova run electron`, the applicationDirectory is the electron platforms directory in the cordova project. i.e. `path/to/your/cordova/code/plaforms/electron/`
- When using a debug version, electron may switch to using the folder `Electron` instead of the folder `{appId}` as your dataDirectory.

### IndexedDB-based impl quirks (Firefox and IE)
- `.` and `..` are not supported.
- IE does not support `file:///`-mode; only hosted mode is supported (http://localhost:xxxx).
Expand Down
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"platforms": [
"android",
"browser",
"electron",
"ios",
"osx",
"windows"
Expand All @@ -23,7 +24,8 @@
"cordova-browser",
"cordova-ios",
"cordova-osx",
"cordova-windows"
"cordova-windows",
"cordova-electron"
],
"scripts": {
"test": "npm run lint",
Expand All @@ -37,7 +39,8 @@
"cordova-android": ">=6.3.0"
},
"7.0.0": {
"cordova-android": ">=10.0.0"
"cordova-android": ">=10.0.0",
"cordova-electron": ">=3.0.0"
},
"8.0.0": {
"cordova-android": ">=12.0.0"
Expand Down
9 changes: 9 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,13 @@ to config.xml in order for the application to find previously stored files.
</js-module>
</platform>


<platform name="electron">
<framework src="src/electron" />

<js-module src="www/fileSystemPaths.js" name="fileSystemPaths">
<merges target="cordova" />
<runs />
</js-module>
</platform>
</plugin>
Loading
Loading