Skip to content

Commit cfad6c1

Browse files
author
Pietro Passarelli
committedApr 17, 2020
Adding notes
1 parent fae0628 commit cfad6c1

4 files changed

+122
-2
lines changed
 

‎.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ node_modules
110110

111111

112112
.idea
113-
Notes
113+
# Notes
114114

115-
notes.md
115+
# notes.md
116116

117117
.env
118118

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# name change - dpe to autoEdit 3
2+
Decide to change the name of the app to `autoEdit 3`, to use the `autoEdit.io` domain, and encourage `autoEdit2` users to move onto this version of the app.
3+
4+
However would rather avoid introducing breaking changes for existing `digital-paper-edit-electron` users.
5+
so in `package.json` the `name` of the app will remain to `digital-paper-edit-electron`. but will change the `productName`.
6+
7+
>`productName` String - As `name`, but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the name property.
8+
9+
[see electron builder docs for more details](https://www.electron.build/configuration/configuration#configuration)
10+
11+
in `package.json` added
12+
```json
13+
"productName":"autoEdit 3",
14+
```
15+
16+
and in `src/electron-main.js`, set the `userData` manually.
17+
18+
19+
`appData` on mac is `~/Library/Application Support`
20+
while `userData` is the folder within `appData`, which would default to `name` or `productName` in `package.json`
21+
22+
```js
23+
// set userData to use `digital-paper-edit-electron` to be backward compatible before name change from `digital-paper-edit-electron` to `autoEdit 3`;
24+
25+
// const userDataPath = app.getPath ('userData');
26+
const appData = app.getPath ('appData');
27+
app.setPath ('userData', path.join(appData,"digital-paper-edit-electron"));
28+
```
29+
30+
for more background info see
31+
32+
- [electron docs - `app.setPath(name, path)`](https://www.electronjs.org/docs/api/app#appsetpathname-path)
33+
- [stackoverflow- Electron: How to set a custom directory for user data (--user-data-dir)](https://stackoverflow.com/questions/48587035/electron-how-to-set-a-custom-directory-for-user-data-user-data-dir)
34+
- [electron docs - `app.getPath(name)`](https://github.com/electron/electron/blob/master/docs/api/app.md#appgetpathname)
35+
36+
37+
## side notes
38+
one concern is if someone downloads an electron build form `bbc/digital-paper-edit-electron` and wants to run it along side `autoEdit 3`.
39+
They'd be using the same `userData` folder.
40+
41+
However since `bbc/digital-paper-edit-electron` electron version is not being activly developed, in favour of a web version, this seems to be an edge case for now.
42+
43+
44+
Another note, is that keeping the name of the github repos to `digital-paper-edit-*` to avoid renaming all of the forks, might cause confusion amongst developers who might want to contribute to the project, so might need to add a note or explanation somewhere, or even link to this now. While at the user facing level, adjsuting the name in the user manual, and with the new landing page it should be fairly straightforward.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# node windows path parse join issue
2+
3+
Some notes about troubleshooting of node and path for windows electron from issue
4+
[bbc/digital-paper-edit-electron/issues/10](https://github.com/bbc/digital-paper-edit-electron/issues/10)
5+
6+
main issue is that when converting to audio, it tries write the new audio file at path destination with double `C:\C:\`.
7+
8+
9+
Most likely due to issues when parsing and re-building the destination path on widows.
10+
11+
12+
In `convertToAudio` the function `wavFileExtension`,
13+
14+
```js
15+
/**
16+
* Adding an helper function to force the file extension to be `.wav`
17+
* this also allows the file extension in output file name/path to be optional
18+
* @param {string} path - path to an audio file
19+
*/
20+
function wavFileExtension(filePath) {
21+
let audioFileOutputPath = filePath;
22+
// https://nodejs.org/api/path.html#path_path_parse_path
23+
const pathParsed = path.parse(audioFileOutputPath);
24+
if (pathParsed.ext !== '.wav') {
25+
audioFileOutputPath = path.join(pathParsed.root, pathParsed.dir, `${ pathParsed.name }.wav`);
26+
}
27+
28+
return audioFileOutputPath;
29+
}
30+
```
31+
32+
`path.parse`
33+
34+
>`> path.parse('/Users/userName/someFolder/file.mov')`
35+
36+
```js
37+
{
38+
root: '/',
39+
dir: '/Users/userName/someFolder',
40+
base: 'file.mov',
41+
ext: '.mov',
42+
name: 'file'
43+
}
44+
```
45+
46+
`path.join`
47+
48+
```js
49+
path.join(pathParsed.root, pathParsed.dir, `${ pathParsed.name }.wav`);
50+
```
51+
Adding root and dir on windows, it adds `C:\` twice.
52+
53+
54+
`path.format` could be a good way to tackle this, for now trying just by removing `.root` in `path.join`.
55+
56+
```js
57+
function wavFileExtension(filePath) {
58+
let audioFileOutputPath = filePath;
59+
const pathParsed = path.parse(audioFileOutputPath);
60+
if (pathParsed.ext !== '.wav') {
61+
audioFileOutputPath = path.join(pathParsed.dir, `${ pathParsed.name }.wav`);
62+
}
63+
64+
return audioFileOutputPath;
65+
}
66+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Electron and STT
2+
3+
offloading STT to a hidden window render process.
4+
5+
6+
more here
7+
8+
- https://medium.com/swlh/how-to-run-background-worker-processes-in-an-electron-app-e0dc310a93cc
9+
- https://www.electronjs.org/docs/api/ipc-main#ipcmain
10+
- https://www.electronjs.org/docs/api/ipc-main

0 commit comments

Comments
 (0)
Please sign in to comment.