@fto-consult/expo-ui 7.4.25 → 7.4.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/electron/index.js +10 -2
- package/electron/preload.js +10 -14
- package/electron/tools.js +0 -0
- package/package.json +1 -1
package/electron/index.js
CHANGED
@@ -314,8 +314,8 @@ app.whenReady().then(() => {
|
|
314
314
|
})
|
315
315
|
|
316
316
|
ipcMain.on("electron-restart-app",x =>{app.relaunch();})
|
317
|
-
let tray = null;
|
318
|
-
let isJSON = function (json_string){
|
317
|
+
let tray = null;
|
318
|
+
let isJSON = function (json_string){
|
319
319
|
if(!json_string || typeof json_string != 'string') return false;
|
320
320
|
var text = json_string;
|
321
321
|
return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g, '')));
|
@@ -357,6 +357,14 @@ ipcMain.on("electron-get-path",(event,pathName)=>{
|
|
357
357
|
return p;
|
358
358
|
});
|
359
359
|
|
360
|
+
ipcMain.on("electron-get-package-json",(event)=>{
|
361
|
+
const packageJSON = path.resolve(projectRoot,"package.json");
|
362
|
+
if(fs.existsSync(packageJSON)){
|
363
|
+
return JSON.stringify(require(packageJSON));
|
364
|
+
}
|
365
|
+
return JSON.stringify({});
|
366
|
+
});
|
367
|
+
|
360
368
|
ipcMain.on("electron-get-media-access-status",(event,mediaType)=>{
|
361
369
|
let p = systemPreferences.getMediaAccessStatus(mediaType);
|
362
370
|
event.returnValue = p;
|
package/electron/preload.js
CHANGED
@@ -6,17 +6,12 @@ const path = require("path");
|
|
6
6
|
const fs = require("fs");
|
7
7
|
const isObj = x=>x && typeof x =='object' && !Array.isArray(x);
|
8
8
|
const isNonNullString = x=>x && typeof x =='string';
|
9
|
-
const
|
10
|
-
const
|
11
|
-
if(!fs.existsSync(packagePath)){
|
12
|
-
throw {message : "Chemin du fichier "+packagePath+ " introuvable"};
|
13
|
-
}
|
14
|
-
const _app = require(`${packagePath}`);
|
9
|
+
const packageJSONStr = ipcRenderer.sendSync("electron-get-package-json");
|
10
|
+
const _app = packageJSONStr ? JSON.parse(packageJSONStr) : {};
|
15
11
|
if(!_app || typeof _app !=='object' || typeof _app.name !=='string'){
|
16
12
|
throw {message : "Contenu du fichier "+packagePath+" invalide!! Veuillez spécifier un nom valide d'application, propriété <<name>> dudit fichier"}
|
17
13
|
}
|
18
14
|
const paths = require("./paths.json");
|
19
|
-
const projectRoot = paths.projectRoot || '';
|
20
15
|
const APP_NAME = _app.name.trim().toUpperCase();
|
21
16
|
let backupPathField = "_e_backupDataPath";
|
22
17
|
let cBackupPathField = "company"+backupPathField;
|
@@ -28,6 +23,7 @@ const getPath = function(pathName){
|
|
28
23
|
const APP_PATH = path.join(getPath("appData"),APP_NAME).toLowerCase();
|
29
24
|
let databasePath = path.join(APP_PATH,"databases");
|
30
25
|
let ROOT_APP_FOLDER = undefined;
|
26
|
+
let appBackupPathRef = undefined;
|
31
27
|
const separator = (path.sep)
|
32
28
|
if(typeof separator != 'string' || !separator){
|
33
29
|
separator = (()=>{
|
@@ -71,8 +67,8 @@ const setDatabasePath = (newPath)=>{
|
|
71
67
|
};
|
72
68
|
const setBackupPath = (newPath)=>{
|
73
69
|
newPath = typeof newPath =='string' && newPath || typeof ROOT_APP_FOLDER =='string' && ROOT_APP_FOLDER || path.join(getPath("documents"),APP_NAME);
|
74
|
-
|
75
|
-
config.set(cBackupPathField,
|
70
|
+
appBackupPathRef = newPath;
|
71
|
+
config.set(cBackupPathField,appBackupPathRef)
|
76
72
|
};
|
77
73
|
const APPRef = {
|
78
74
|
current : null,
|
@@ -105,14 +101,14 @@ const ELECTRON = {
|
|
105
101
|
return (p)=>{
|
106
102
|
const eePath = config.get(cBackupPathField);
|
107
103
|
const defPath = ROOT_APP_FOLDER || path.join(getPath("documents"),APP_NAME);
|
108
|
-
|
109
|
-
if(!fs.existsSync(
|
110
|
-
|
104
|
+
appBackupPathRef = typeof eePath =='string' && eePath || typeof defPath =='string' && defPath || '';
|
105
|
+
if(!fs.existsSync(appBackupPathRef)){
|
106
|
+
appBackupPathRef = defPath;
|
111
107
|
}
|
112
108
|
if(p && typeof (p) ==='string'){
|
113
|
-
return path.join(
|
109
|
+
return path.join(appBackupPathRef,p);
|
114
110
|
}
|
115
|
-
return
|
111
|
+
return appBackupPathRef;
|
116
112
|
};
|
117
113
|
},
|
118
114
|
get databasePath (){
|
File without changes
|