@fto-consult/expo-ui 3.6.1 → 4.0.1
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/appConfig.txt +4 -1
- package/babel.config.alias.js +11 -1
- package/bin/index.js +23 -17
- package/electron/app/desktopCapturer.js +123 -0
- package/electron/app/email.js +55 -0
- package/electron/app/file.js +501 -0
- package/electron/app/index.html +32 -0
- package/electron/app/index.js +19 -0
- package/electron/app/instance.js +46 -0
- package/electron/app/printer.js +52 -0
- package/electron/{src/config.js → config.js} +0 -0
- package/electron/{copyDir.js → copy.js} +6 -4
- package/electron/createDir.js +19 -3
- package/electron/createDirSync.js +31 -0
- package/electron/exec.js +1 -1
- package/electron/index.js +40 -12
- package/electron/package.app.json +44 -0
- package/{bin → electron}/parseArgs.js +5 -2
- package/electron/{src/pload.js → pload.js} +31 -18
- package/electron/postMessage.js +19 -0
- package/electron/preload.js +333 -0
- package/electron/{src/session.js → session.js} +0 -0
- package/package.json +6 -4
- package/readMe.md +16 -7
- package/src/components/Datagrid/Common/Common.js +11 -11
- package/src/components/Datagrid/Table/index.js +0 -1
- package/src/components/Table/index.js +2 -6
- package/src/index.js +62 -18
- package/electron/src/preload.js +0 -396
package/electron/src/preload.js
DELETED
|
@@ -1,396 +0,0 @@
|
|
|
1
|
-
(function(window) {
|
|
2
|
-
let showingExitApp = undefined;
|
|
3
|
-
const exec = require("../exec");
|
|
4
|
-
if(typeof window.isElectron != 'function'){
|
|
5
|
-
Object.defineProperties(window,{
|
|
6
|
-
ELECTRON : {
|
|
7
|
-
value : {},writable:false,override : false
|
|
8
|
-
},
|
|
9
|
-
isElectron : {
|
|
10
|
-
value : () => true,
|
|
11
|
-
override : false,
|
|
12
|
-
writable : false
|
|
13
|
-
},
|
|
14
|
-
getPouchdbElectron : {
|
|
15
|
-
value : (PouchDB,window,sqlPouch)=> {
|
|
16
|
-
window.sqlitePlugin = {openDatabase:require('websql')};
|
|
17
|
-
PouchDB.plugin(function CapacitorSqlitePlugin (PouchDB) {
|
|
18
|
-
PouchDB.adapter('node-sqlite', sqlPouch(), true)
|
|
19
|
-
});
|
|
20
|
-
return {adapter:"node-sqlite"};
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
})
|
|
24
|
-
}
|
|
25
|
-
const fs = require("fs");
|
|
26
|
-
let _app = require("./app.config");
|
|
27
|
-
require("./pload")(ELECTRON);
|
|
28
|
-
const {ipcRenderer} = require('electron')
|
|
29
|
-
let APP_NAME = defaultStr(_app.name).toUpperCase();
|
|
30
|
-
let path = require("path");
|
|
31
|
-
let getPath = function(pathName){
|
|
32
|
-
return ipcRenderer.sendSync("electron-get-path",pathName);
|
|
33
|
-
}
|
|
34
|
-
let APP_PATH = path.join(getPath("appData"),APP_NAME).toLowerCase();
|
|
35
|
-
let databasePath = path.join(APP_PATH,"databases");
|
|
36
|
-
let ROOT_APP_FOLDER = undefined;
|
|
37
|
-
let separator = (path.sep)
|
|
38
|
-
let DOWNLOADING_FILES= {};
|
|
39
|
-
if(typeof separator != 'string' || !separator){
|
|
40
|
-
separator = (()=>{
|
|
41
|
-
let filePath = databasePath;
|
|
42
|
-
var sepIndex = filePath.lastIndexOf('/');
|
|
43
|
-
if(sepIndex == -1){
|
|
44
|
-
sepIndex = filePath.lastIndexOf('\\');
|
|
45
|
-
}
|
|
46
|
-
// include the trailing separator
|
|
47
|
-
return filePath.substring(0, sepIndex+1);
|
|
48
|
-
})();
|
|
49
|
-
}
|
|
50
|
-
function createDirSync(targetDir, { isRelativeToScript = false } = {}) {
|
|
51
|
-
if(!targetDir || typeof targetDir != 'string') return false;
|
|
52
|
-
const sep = path.sep;
|
|
53
|
-
const initDir = path.isAbsolute(targetDir) ? sep : '';
|
|
54
|
-
const baseDir = isRelativeToScript ? __dirname : '.';
|
|
55
|
-
|
|
56
|
-
return targetDir.split(sep).reduce((parentDir, childDir) => {
|
|
57
|
-
const curDir = path.resolve(baseDir, parentDir, childDir);
|
|
58
|
-
try {
|
|
59
|
-
fs.mkdirSync(curDir);
|
|
60
|
-
} catch (err) {
|
|
61
|
-
if (err.code === 'EEXIST') { // curDir already exists!
|
|
62
|
-
return curDir;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// To avoid `EISDIR` error on Mac and `EACCES`-->`ENOENT` and `EPERM` on Windows.
|
|
66
|
-
if (err.code === 'ENOENT') { // Throw the original parentDir error on curDir `ENOENT` failure.
|
|
67
|
-
throw new Error(`EACCES: permission denied, mkdir '${parentDir}'`);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const caughtErr = ['EACCES', 'EPERM', 'EISDIR'].indexOf(err.code) > -1;
|
|
71
|
-
if (!caughtErr || caughtErr && curDir === path.resolve(targetDir)) {
|
|
72
|
-
throw err; // Throw if it's just the last created dir.
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return curDir;
|
|
77
|
-
}, initDir);
|
|
78
|
-
}
|
|
79
|
-
const Config = require('./config');
|
|
80
|
-
let confPath = process.env.ProgramData || process.env.ALLUSERSPROFILE;
|
|
81
|
-
if(confPath && typeof confPath =="string"){
|
|
82
|
-
if(fs.existsSync(confPath) && (_app.name) && typeof _app.name =='string'){
|
|
83
|
-
confPath = path.join(confPath,_app.name.toUpperCase());
|
|
84
|
-
if(!fs.existsSync(confPath)){
|
|
85
|
-
createDirSync(confPath);
|
|
86
|
-
}
|
|
87
|
-
if(fs.existsSync(confPath)){
|
|
88
|
-
ROOT_APP_FOLDER = confPath;
|
|
89
|
-
databasePath = path.join(confPath,"databases");
|
|
90
|
-
createDirSync(databasePath);
|
|
91
|
-
confPath = path.join(confPath,"CONFIG");
|
|
92
|
-
createDirSync(confPath);
|
|
93
|
-
}
|
|
94
|
-
} else confPath = undefined;
|
|
95
|
-
} else confPath = undefined;
|
|
96
|
-
let config = new Config({cwd:confPath});
|
|
97
|
-
if(typeof ELECTRON.getBackupPath !== 'function'){
|
|
98
|
-
let backupPathField = "_e_backupDataPath";
|
|
99
|
-
let cBackupPathField = "company"+backupPathField;
|
|
100
|
-
let dbPathField = "_electron_DBPathField";
|
|
101
|
-
|
|
102
|
-
Object.defineProperties(ELECTRON,{
|
|
103
|
-
getBackupPath : {
|
|
104
|
-
value : (p)=>{
|
|
105
|
-
let ePath = config.get(cBackupPathField);
|
|
106
|
-
let defPath = ROOT_APP_FOLDER || path.join(getPath("documents"),APP_NAME);
|
|
107
|
-
ELECTRON.COMPANY_BACKUP_PATH = defaultStr(ePath,defPath);
|
|
108
|
-
if(!fs.existsSync(ELECTRON.COMPANY_BACKUP_PATH)){
|
|
109
|
-
ELECTRON.COMPANY_BACKUP_PATH = defPath;
|
|
110
|
-
}
|
|
111
|
-
if(isNonNullString(p)){
|
|
112
|
-
return path.join(ELECTRON.COMPANY_BACKUP_PATH,p);
|
|
113
|
-
}
|
|
114
|
-
return ELECTRON.COMPANY_BACKUP_PATH;
|
|
115
|
-
},override:false,writable:false
|
|
116
|
-
},
|
|
117
|
-
getDatabasePath : {
|
|
118
|
-
value : ()=>{
|
|
119
|
-
let folder = APP.FOLDERS_MANAGER.getCurrent();
|
|
120
|
-
if(isObj(folder) && fs.existsSync(folder.databasePath)){
|
|
121
|
-
return databasePath;
|
|
122
|
-
}
|
|
123
|
-
let p = config.get(dbPathField);
|
|
124
|
-
if(fs.existsSync(p)){
|
|
125
|
-
databasePath = p
|
|
126
|
-
}
|
|
127
|
-
if(!fs.existsSync(databasePath)){
|
|
128
|
-
console.log(databasePath,' does not exists');
|
|
129
|
-
createDirSync(databasePath);
|
|
130
|
-
}
|
|
131
|
-
return databasePath;
|
|
132
|
-
},override:false,writable:false
|
|
133
|
-
},
|
|
134
|
-
setDatabasePath : {
|
|
135
|
-
value : (newPath)=>{
|
|
136
|
-
config.set(dbPathField,newPath)
|
|
137
|
-
},override:false,writable:false
|
|
138
|
-
},
|
|
139
|
-
setBackupPath : {
|
|
140
|
-
value : (newPath)=>{
|
|
141
|
-
newPath = defaultStr(newPath,ROOT_APP_FOLDER,path.join(getPath("documents"),APP_NAME));
|
|
142
|
-
ELECTRON.COMPANY_BACKUP_PATH = newPath;
|
|
143
|
-
config.set(cBackupPathField,ELECTRON.COMPANY_BACKUP_PATH)
|
|
144
|
-
},override:false,writable:false
|
|
145
|
-
},
|
|
146
|
-
showOpenDialog : {
|
|
147
|
-
value : (options)=>{
|
|
148
|
-
options = defaultObj(options);
|
|
149
|
-
return ipcRenderer.invoke("electron-show-open-dialog",options);
|
|
150
|
-
},override:false, writable:false
|
|
151
|
-
},
|
|
152
|
-
showSaveDialog : {
|
|
153
|
-
value : (options)=>{
|
|
154
|
-
options = defaultObj(options);
|
|
155
|
-
return ipcRenderer.invoke("electron-show-save-dialog",options);
|
|
156
|
-
},override:false, writable:false
|
|
157
|
-
},
|
|
158
|
-
unlinkDownloadingFile : {
|
|
159
|
-
value : (opts)=>{
|
|
160
|
-
opts = defaultObj(opts);
|
|
161
|
-
let p = opts.filePath+".download";
|
|
162
|
-
if(fs.existsSync(p)){
|
|
163
|
-
fs.unlink(p, function(err) {
|
|
164
|
-
if(err && err.code == 'ENOENT') {
|
|
165
|
-
// file doens't exist
|
|
166
|
-
console.info("File doesn't exist, won't remove it.");
|
|
167
|
-
} else if (err) {
|
|
168
|
-
console.error(err,"Error occurred while trying to remove file");
|
|
169
|
-
} else {
|
|
170
|
-
console.info(`removed`, p);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
},override : false, writable : false
|
|
175
|
-
},
|
|
176
|
-
DOWNLOADING_FILES : {value : DOWNLOADING_FILES, override : false, writable : false},
|
|
177
|
-
restartApp : {
|
|
178
|
-
value : ()=>{
|
|
179
|
-
ipcRenderer.sendSync("electron-restart-app")
|
|
180
|
-
}, override : false, writable : false
|
|
181
|
-
},
|
|
182
|
-
downloadFile : {
|
|
183
|
-
value : (opts) =>{
|
|
184
|
-
opts = defaultObj(opts);
|
|
185
|
-
opts.directory = defaultStr(opts.directory,ELECTRON.PATH.DOWNLOADS);
|
|
186
|
-
opts.fileName = defaultStr(opts.fileName,APP.getName().toUpperCase())
|
|
187
|
-
opts.filePath = path.join(opts.directory,opts.fileName);
|
|
188
|
-
opts.onProgress = defaultFunc(opts.onProgress,(percentage,chunk,remainingSize)=> {})
|
|
189
|
-
opts.maxAttempts = defaultDecimal(opts.maxAttempts,4);
|
|
190
|
-
opts.onError = defaultFunc(opts.onError,x =>x);
|
|
191
|
-
let {onResponse} = opts;
|
|
192
|
-
opts.onResponse = function(response){
|
|
193
|
-
let length = response.headers['content-length'];
|
|
194
|
-
if(!isDecimal(length)){
|
|
195
|
-
length = parseFloat(length) || 0;
|
|
196
|
-
}
|
|
197
|
-
if(isFunction(onResponse)){
|
|
198
|
-
onResponse({...response,
|
|
199
|
-
length,fileSize:length,
|
|
200
|
-
fileSizeInBytes:length,
|
|
201
|
-
fileSizeInKiloBytes : length/1024,
|
|
202
|
-
fileSizeInMegaBytes : length / (1024*1024)
|
|
203
|
-
})
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if(!isNonNullString(opts.url)) return Promise.reject({msg:'Ipossible de télécharger le fichier car l\'url est non définit'});
|
|
207
|
-
if(isObj(DOWNLOADING_FILES[opts.url]) && isPromise(DOWNLOADING_FILES[opts.url].promise)) {
|
|
208
|
-
return DOWNLOADING_FILES[opts.url];
|
|
209
|
-
}
|
|
210
|
-
opts.cloneFiles = defaultBool(opts.cloneFiles,false);//This will cause the downloader to re-write an existing file.
|
|
211
|
-
|
|
212
|
-
/*** If you want to completely skip downloading a file, when a file with the same name already exists, use config.skipExistingFileName = true */
|
|
213
|
-
opts.skipExistingFileName = defaultBool(opts.skipExistingFileName,false);
|
|
214
|
-
let Downloader = require('nodejs-file-downloader');
|
|
215
|
-
let downloader = new Downloader(opts);
|
|
216
|
-
let promise = downloader.download().then((result)=>{
|
|
217
|
-
return result;
|
|
218
|
-
}).catch((e)=>{
|
|
219
|
-
return e
|
|
220
|
-
//console.log(e," downloading file electron");
|
|
221
|
-
}).finally(()=>{
|
|
222
|
-
delete DOWNLOADING_FILES[opts.url];
|
|
223
|
-
});
|
|
224
|
-
DOWNLOADING_FILES[opts.url] = {
|
|
225
|
-
download : x=> promise,
|
|
226
|
-
promise,
|
|
227
|
-
context:downloader,
|
|
228
|
-
cancel : x => {
|
|
229
|
-
try {downloader.cancel();} catch(e){
|
|
230
|
-
console.log(e," canceled download");
|
|
231
|
-
} finally{
|
|
232
|
-
ELECTRON.unlinkDownloadingFile(opts);
|
|
233
|
-
delete DOWNLOADING_FILES[opts.url];
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
}
|
|
237
|
-
return DOWNLOADING_FILES[opts.url];
|
|
238
|
-
},override : false, writable : false
|
|
239
|
-
},
|
|
240
|
-
/*** le gestionnaire des configurations application electron :
|
|
241
|
-
* voir : https://github.com/sindresorhus/electron-store
|
|
242
|
-
*/
|
|
243
|
-
CONFIG : {
|
|
244
|
-
value : config, override:false,writable:false
|
|
245
|
-
},
|
|
246
|
-
databasePath : {
|
|
247
|
-
value : ()=>{
|
|
248
|
-
let path = ELECTRON.getDatabasePath();
|
|
249
|
-
return path;
|
|
250
|
-
},override:false,writable:false
|
|
251
|
-
},
|
|
252
|
-
is : {
|
|
253
|
-
value : true,override:false,writable : false
|
|
254
|
-
},
|
|
255
|
-
APP_PATH : {
|
|
256
|
-
value : APP_PATH,override:false,writable:false
|
|
257
|
-
},
|
|
258
|
-
PATH : {
|
|
259
|
-
value : {
|
|
260
|
-
...path,
|
|
261
|
-
SEPARATOR : separator,
|
|
262
|
-
SEP : separator,
|
|
263
|
-
get : getPath,
|
|
264
|
-
HOME : getPath("home"),
|
|
265
|
-
USERDATA : getPath("userData"),
|
|
266
|
-
/***
|
|
267
|
-
* Per-user application data directory, which by default points to:
|
|
268
|
-
* %APPDATA% on Windows
|
|
269
|
-
* $XDG_CONFIG_HOME or ~/.config on Linux
|
|
270
|
-
* ~/Library/Application Support on macOS
|
|
271
|
-
*/
|
|
272
|
-
APPDATA : getPath("appData"),
|
|
273
|
-
CACHE : getPath("cache"),
|
|
274
|
-
TEMP : getPath("temp"),//Temporary directory.
|
|
275
|
-
EXECUTABLE : getPath("exe"),//The current executable file.
|
|
276
|
-
EXE : getPath("exe"),//The current executable file.
|
|
277
|
-
DOCUMENTS : getPath("documents"),
|
|
278
|
-
DOWNLOADS : path.join(APP_PATH,"downloads"),
|
|
279
|
-
DESKTOP : getPath("desktop"),//The current user's Desktop directory.
|
|
280
|
-
}, override:false,writable:false
|
|
281
|
-
},
|
|
282
|
-
///retourne le chemin dont la chaine de caractère est passé en paramètre
|
|
283
|
-
getPath : {
|
|
284
|
-
value : getPath, override:false,writable:false
|
|
285
|
-
},
|
|
286
|
-
exec : {
|
|
287
|
-
value : exec,
|
|
288
|
-
},
|
|
289
|
-
updateSystemTheme : {
|
|
290
|
-
value : (theme)=>{
|
|
291
|
-
return ipcRenderer.invoke("electron-set-system-theme:toggle",theme);
|
|
292
|
-
},override:false, writable:false
|
|
293
|
-
},
|
|
294
|
-
})
|
|
295
|
-
}
|
|
296
|
-
if(!window.APP){
|
|
297
|
-
Object.defineProperties(window,{
|
|
298
|
-
APP : {
|
|
299
|
-
value : {},override:false,writable:false
|
|
300
|
-
}
|
|
301
|
-
})
|
|
302
|
-
}
|
|
303
|
-
ELECTRON.getBackupPath();
|
|
304
|
-
require("./app/index")(ELECTRON)
|
|
305
|
-
require('v8-compile-cache');
|
|
306
|
-
require("v8").setFlagsFromString('--expose_gc');
|
|
307
|
-
|
|
308
|
-
let _gc = x =>{
|
|
309
|
-
if(!isObj(window.APP) || !isFunction(window.APP.isInitialized)){
|
|
310
|
-
return null;
|
|
311
|
-
}
|
|
312
|
-
if(!window.APP.isInitialized()){
|
|
313
|
-
return null;
|
|
314
|
-
}
|
|
315
|
-
return require("vm").runInNewContext('gc');
|
|
316
|
-
}
|
|
317
|
-
Object.defineProperties(window,{
|
|
318
|
-
gc : {value:_gc,override:false,writable:false}
|
|
319
|
-
})
|
|
320
|
-
Object.defineProperties(ELECTRON,{
|
|
321
|
-
gc : {value:_gc,override:false,writable:false}
|
|
322
|
-
})
|
|
323
|
-
|
|
324
|
-
ipcRenderer.on('before-app-exit', (args) => {
|
|
325
|
-
let {notify,showConfirm} = APP.require("$dialog");
|
|
326
|
-
hidePreloader();
|
|
327
|
-
if(showingExitApp) return;
|
|
328
|
-
showingExitApp = true;
|
|
329
|
-
showConfirm({
|
|
330
|
-
title : 'Quittez l\'application',
|
|
331
|
-
message : 'Voulez vous vraiment quitter l\'application?',
|
|
332
|
-
yes : 'Oui',
|
|
333
|
-
no : 'Non',
|
|
334
|
-
onCancel : () =>{
|
|
335
|
-
showingExitApp = false;
|
|
336
|
-
},
|
|
337
|
-
onSuccess : ()=>{
|
|
338
|
-
showingExitApp = false;
|
|
339
|
-
let backupDataOnClose = true;
|
|
340
|
-
let promises = []
|
|
341
|
-
|
|
342
|
-
if(APP.COMPANY && APP.COMPANY.electronBackupDataOnClose !== undefined){
|
|
343
|
-
backupDataOnClose = APP.COMPANY.electronBackupDataOnClose;
|
|
344
|
-
}
|
|
345
|
-
if(backupDataOnClose){
|
|
346
|
-
promises.push(APP.exportData({}).then().catch((e)=>{
|
|
347
|
-
console.log(e,' on backup databases before exit');
|
|
348
|
-
notify.error("Une erreur est survenue pendant la sauvegarde des données!! : "+JSON.stringify(e))
|
|
349
|
-
}))
|
|
350
|
-
}
|
|
351
|
-
if(APP.COMPANY && defaultVal(APP.COMPANY.syncDataOnExit,0)){
|
|
352
|
-
let {sync} = APP.require("$database");
|
|
353
|
-
promises.push(sync.run({cancel:false}));
|
|
354
|
-
}
|
|
355
|
-
let exit = ()=>{
|
|
356
|
-
let disconectUserOnExit= true;
|
|
357
|
-
if(APP.COMPANY && APP.COMPANY.disconectUserOnExit !== undefined){
|
|
358
|
-
disconectUserOnExit = APP.COMPANY.disconectUserOnExit;
|
|
359
|
-
}
|
|
360
|
-
if(disconectUserOnExit){
|
|
361
|
-
Auth.doLogout();
|
|
362
|
-
}
|
|
363
|
-
let autoUpdater = APP.getAutoUpdater();
|
|
364
|
-
let canInstall = autoUpdater.canInstall();
|
|
365
|
-
autoUpdater.setInstallOnAppExit(false)
|
|
366
|
-
let ex = x=>ipcRenderer.send("close-main-render-process");
|
|
367
|
-
if(isObj(canInstall)){
|
|
368
|
-
if(canInstall.installOnExit){
|
|
369
|
-
return ELECTRON.installNewAppVersion(canInstall).finally(ex);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
ex();
|
|
373
|
-
}
|
|
374
|
-
Promise.all(promises).then(exit).catch((e)=>{
|
|
375
|
-
console.log(e,' exiting app');
|
|
376
|
-
exit();
|
|
377
|
-
}).finally(exit);
|
|
378
|
-
}
|
|
379
|
-
})
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
ipcRenderer.on("main-app-suspended",()=>{
|
|
383
|
-
APP.stopIDLE(true,true);
|
|
384
|
-
})
|
|
385
|
-
ipcRenderer.on("main-app-restaured",()=>{
|
|
386
|
-
APP.trackIDLE();
|
|
387
|
-
});
|
|
388
|
-
ipcRenderer.on('appReady',()=>{})
|
|
389
|
-
ipcRenderer.on("main-window-focus",()=>{
|
|
390
|
-
APP.runElectronAppStateChangedCallback({isActive:true})
|
|
391
|
-
})
|
|
392
|
-
ipcRenderer.on("main-window-blur",()=>{
|
|
393
|
-
APP.runElectronAppStateChangedCallback({});
|
|
394
|
-
})
|
|
395
|
-
})(window);
|
|
396
|
-
|