@fto-consult/expo-ui 7.5.43 → 7.5.45
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/bin/index.js +2 -3
- package/electron/index.js +26 -21
- package/electron/preload.js +3 -0
- package/package.json +1 -1
package/bin/index.js
CHANGED
@@ -60,7 +60,6 @@ program.command('electron')
|
|
60
60
|
const electronProjectRoot = path.resolve(projectRoot,"electron");
|
61
61
|
const opts = Object.assign({},typeof options.opts =='function'? options.opts() : options);
|
62
62
|
let {out,arch,url,build,platform,import:packageImport,icon} = opts;
|
63
|
-
//let {projectRoot} = opts;
|
64
63
|
if(projectRoot == dir){
|
65
64
|
throwError(`Invalid project root ${projectRoot}; project root must be different to ${dir}`);
|
66
65
|
}
|
@@ -84,7 +83,7 @@ program.command('electron')
|
|
84
83
|
const mainPackagePath = path.resolve(electronProjectRoot,"package.app.json");
|
85
84
|
try {
|
86
85
|
const mainPackageAppJSON = fs.existsSync(mainPackagePath)? require(mainPackagePath) : {};
|
87
|
-
writeFile(mainPackagePath,JSON.stringify({...packageObj,...mainPackageAppJSON,icon:icon||mainPackageAppJSON.icon||undefined},null,"\t"));
|
86
|
+
writeFile(mainPackagePath,JSON.stringify({...packageObj,...mainPackageAppJSON,name:packageObj.name,icon:icon||mainPackageAppJSON.icon||undefined},null,"\t"));
|
88
87
|
} catch{}
|
89
88
|
}
|
90
89
|
|
@@ -105,7 +104,7 @@ program.command('electron')
|
|
105
104
|
}
|
106
105
|
const start = x=>{
|
107
106
|
return new Promise((resolve,reject)=>{
|
108
|
-
cmd = `electron "${electronProjectRoot}"
|
107
|
+
cmd = `electron "${electronProjectRoot}" ${icon ? `--icon ${path.resolve(icon)}`:""} ${isValidUrl(url)? ` --url ${url}`:''}`; //--root ${electronProjectRoot}
|
109
108
|
exec({
|
110
109
|
cmd,
|
111
110
|
projectRoot : electronProjectRoot,
|
package/electron/index.js
CHANGED
@@ -16,45 +16,45 @@ const iconName = process.platform =="win32" ? "icon.ico" : process.platform =='d
|
|
16
16
|
|
17
17
|
program
|
18
18
|
.option('-u, --url <url>', 'L\'adresse url à ouvrir au lancement de l\'application')
|
19
|
-
|
19
|
+
//.option('-r, --root <projectRoot>', 'le chemin du project root de l\'application')
|
20
20
|
.option('-l, --icon [iconPath]', 'le chemin vers le dossier des icones de l\'application : (Dans ce dossier, doit contenir une image icon.ico pour window, icon.incs pour mac et icon.png pour linux)')
|
21
21
|
.parse();
|
22
22
|
|
23
23
|
const programOptions = program.opts();
|
24
24
|
const {url:pUrl,root:mainProjectRoot,icon} = programOptions;
|
25
|
-
let iconPath = icon && typeof icon =="string" && fs.existsSync(path.resolve(icon)) && path.resolve(icon) || undefined;
|
26
|
-
if(iconPath && fs.existsSync(path.resolve(iconPath,iconName))){
|
27
|
-
iconPath = path.resolve(iconPath,iconName);
|
28
|
-
}
|
29
25
|
|
30
|
-
const isAsar = (typeof require.main =="string" && require.main ||"").indexOf('app.asar') !== -1;
|
31
26
|
const distPath = path.join("dist",'index.html');
|
32
|
-
|
33
27
|
const processCWD = process.cwd();
|
34
28
|
const appPath = app.getAppPath();
|
35
|
-
const
|
36
|
-
const
|
37
|
-
const
|
38
|
-
const
|
39
|
-
|
40
|
-
|
29
|
+
const isAsar = appPath.indexOf('app.asar') !== -1;
|
30
|
+
const packageJSONPath = fs.existsSync(path.resolve(appPath,"package.app.json")) ? path.resolve(appPath,"package.app.json") : fs.existsSync(processCWD,"package.json")? path.resolve(processCWD,"package.json") : path.resolve(appPath,"package.json") ;
|
31
|
+
const packageJSON = fs.existsSync(packageJSONPath) ? Object.assign({},require(`${packageJSONPath}`)) : {};
|
32
|
+
const appName = typeof packageJSON.name =="string" && packageJSON.name || "";
|
33
|
+
|
34
|
+
let iconPath = icon && typeof icon =="string" && fs.existsSync(path.resolve(icon)) && path.resolve(icon) || undefined;
|
35
|
+
if(!iconPath && packageJSON.icon && typeof packageJSON.icon ==="string" && fs.existsSync(packageJSON.icon)){
|
36
|
+
iconPath = packageJSON.icon;
|
37
|
+
}
|
38
|
+
if(iconPath && fs.existsSync(path.resolve(iconPath,iconName))){
|
39
|
+
iconPath = path.resolve(iconPath,iconName);
|
40
|
+
}
|
41
41
|
|
42
42
|
// fermee automatiquement quand l'objet JavaScript sera garbage collected.
|
43
43
|
let mainWindow = undefined;
|
44
44
|
|
45
45
|
Menu.setApplicationMenu(null);
|
46
46
|
|
47
|
-
const indexFilePath = path.resolve(path.join(
|
47
|
+
const indexFilePath = path.resolve(path.join(appPath,distPath));
|
48
48
|
const mainProcessPath = path.resolve('processes',"main","index.js");
|
49
|
-
const mainProcessIndex =
|
49
|
+
const mainProcessIndex = fs.existsSync(path.resolve(appPath,mainProcessPath)) && path.resolve(appPath,mainProcessPath);
|
50
50
|
const mainProcessRequired = mainProcessIndex && require(`${mainProcessIndex}`);
|
51
|
-
//pour étendre les fonctionnalités au niveau du main proceess, bien vouloir écrire dans le fichier
|
51
|
+
//pour étendre les fonctionnalités au niveau du main proceess, bien vouloir écrire dans le fichier ../electron/main/index.js
|
52
52
|
const mainProcess = mainProcessRequired && typeof mainProcessRequired =='object'? mainProcessRequired : {};
|
53
53
|
const execPath = app.getPath ('exe') || process.execPath;
|
54
54
|
|
55
55
|
// Gardez une reference globale de l'objet window, si vous ne le faites pas, la fenetre sera
|
56
|
-
if(
|
57
|
-
throw {message:`Unable to start the application: index file located at [${indexFilePath}] does not exists : appPath = [${appPath}]
|
56
|
+
if(!isValidUrl(pUrl) && !fs.existsSync(indexFilePath)){
|
57
|
+
throw {message:`Unable to start the application: index file located at [${indexFilePath}] does not exists : appPath = [${appPath}], exec path is ${execPath}`}
|
58
58
|
}
|
59
59
|
|
60
60
|
const quit = ()=>{
|
@@ -351,12 +351,17 @@ function createWindow () {
|
|
351
351
|
event.returnValue = p;
|
352
352
|
return p;
|
353
353
|
});
|
354
|
+
ipcMain.on("get-app-path",(event,pathName)=>{
|
355
|
+
event.returnValue = appPath;
|
356
|
+
return appPath;
|
357
|
+
});
|
354
358
|
ipcMain.on("get-project-root",(event)=>{
|
355
|
-
event.returnValue =
|
359
|
+
event.returnValue = appPath;
|
356
360
|
return event.returnValue;
|
357
361
|
});
|
358
|
-
|
359
|
-
|
362
|
+
|
363
|
+
ipcMain.on("get-process-cwd",(event)=>{
|
364
|
+
event.returnValue = processCWD;
|
360
365
|
return event.returnValue ;
|
361
366
|
});
|
362
367
|
|
package/electron/preload.js
CHANGED