@fto-consult/expo-ui 4.0.4 → 4.2.0
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/babel.config.alias.js +3 -3
- package/bin/index.js +60 -14
- package/bin/init.js +82 -0
- package/bin/package.js +59 -0
- package/electron/app/instance.js +1 -1
- package/electron/create-index-file.js +13 -0
- package/electron/dependencies.js +11 -0
- package/electron/index.js +71 -58
- package/electron/init/index.js +0 -0
- package/electron/init/main.js +10 -0
- package/electron/init/renderer.js +6 -0
- package/electron/is-initialized.js +12 -0
- package/electron/package.json +32 -0
- package/electron/pload.js +2 -2
- package/electron/preload.js +4 -4
- package/electron/{config.js → utils/config.js} +0 -0
- package/electron/{copy.js → utils/copy.js} +0 -0
- package/electron/{createDir.js → utils/createDir.js} +0 -0
- package/electron/{createDirSync.js → utils/createDirSync.js} +0 -0
- package/electron/{exec.js → utils/exec.js} +5 -2
- package/electron/{getDirname.js → utils/getDirname.js} +0 -0
- package/electron/utils/getIcon.js +25 -0
- package/electron/{parseArgs.js → utils/parseArgs.js} +0 -0
- package/electron/{postMessage.js → utils/postMessage.js} +0 -0
- package/electron/{session.js → utils/session.js} +0 -0
- package/electron/{writeFile.js → utils/writeFile.js} +0 -0
- package/package.json +3 -7
- package/readMe.md +8 -3
- package/src/components/Countries/resources/countries-normalized.json +1987 -1987
- package/src/components/Countries/resources/countries-with-not-extra.json +1211 -1211
- package/src/components/Countries/resources/countries.sql +243 -243
- package/src/components/Form/Fields/SelectTableData/Component.js +1 -1
- package/src/layouts/Screen/TableData.js +7 -1
- package/src/navigation/utils.js +2 -1
- package/src/screens/Auth/PermLine.js +195 -0
- package/src/screens/Auth/PermLines.js +102 -355
- package/src/screens/Auth/PermText.js +62 -0
- package/src/screens/Auth/index.js +3 -1
- package/src/screens/Auth/utils.js +36 -1
- package/electron/getIcon.js +0 -24
- package/electron/package.app.json +0 -44
package/babel.config.alias.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
2
|
const fs = require("fs");
|
|
3
|
-
const writeFile = require("./electron/writeFile");
|
|
3
|
+
const writeFile = require("./electron/utils/writeFile");
|
|
4
4
|
module.exports = (opts)=>{
|
|
5
5
|
const dir = path.resolve(__dirname);
|
|
6
6
|
const base = opts.base || process.cwd();
|
|
@@ -133,14 +133,14 @@ module.exports = (opts)=>{
|
|
|
133
133
|
const l1 = path.resolve($assets,"logo.png"), l2 = path.resolve($assets,"logo.png");
|
|
134
134
|
const logoPath = fs.existsSync(l1)? l1 : fs.existsSync(l2)? l2 : undefined;
|
|
135
135
|
const ePath = path.resolve(electronAssetsPath,"images","logo.png");
|
|
136
|
-
if(logoPath && require("./electron/createDir")(ePath)){
|
|
136
|
+
if(logoPath && require("./electron/utils/createDir")(ePath)){
|
|
137
137
|
fs.copyFileSync(logoPath,ePath,fs.constants.COPYFILE_FICLONE);
|
|
138
138
|
electronPaths.logo = logoPath;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
const jsonPath = path.resolve(base,'package.json');
|
|
142
142
|
if(fs.existsSync(jsonPath)){
|
|
143
|
-
require("./electron/copy")(jsonPath,path.resolve(dir,"electron","package.
|
|
143
|
+
require("./electron/utils/copy")(jsonPath,path.resolve(dir,"electron","package.json"));
|
|
144
144
|
}
|
|
145
145
|
///on sauvegarde les chemins des fichiers utiles, qui seront utilisées par la variable electron plus tard
|
|
146
146
|
writeFile(path.resolve(dir,"electron","paths.json"),JSON.stringify(electronPaths));
|
package/bin/index.js
CHANGED
|
@@ -5,24 +5,31 @@ process.on('unhandledRejection', err => {
|
|
|
5
5
|
throw err;
|
|
6
6
|
});
|
|
7
7
|
const supportedScript = {
|
|
8
|
+
"init" : true, //initialize electron app
|
|
8
9
|
"start" : true,//start electron
|
|
9
10
|
"build" : true, //script pour faire un build
|
|
11
|
+
"package" : true, ///script pour le packagin de l'application
|
|
10
12
|
}
|
|
13
|
+
const createDir = require("../electron/utils/createDir");
|
|
14
|
+
const writeFile = require("../electron/utils/writeFile");
|
|
15
|
+
const copy = require("../electron/utils/copy");
|
|
11
16
|
const path= require("path");
|
|
12
17
|
const fs = require("fs");
|
|
13
18
|
const dir = path.resolve(__dirname);
|
|
14
19
|
const electronDir = path.resolve(dir, "..","electron");
|
|
15
|
-
const exec = require("../electron/exec");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
const exec = require("../electron/utils/exec");
|
|
21
|
+
const projectRoot = path.resolve(process.cwd());
|
|
22
|
+
if(projectRoot == dir){
|
|
23
|
+
throw `Invalid project root ${projectRoot}; project root must be different to ${dir}`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const parsedArgs = require("../electron/utils/parseArgs")(null,supportedScript);
|
|
20
27
|
if(!parsedArgs.script || !(parsedArgs.script in supportedScript)){
|
|
21
28
|
console.error ("Erreur : script invalide, vous devez spécifier script figurant parmi les script : ["+Object.keys(supportedScript).join(", ")+"]");
|
|
22
29
|
process.exit();
|
|
23
30
|
}
|
|
24
|
-
const {script} = parsedArgs;
|
|
25
31
|
let cmd = null;
|
|
32
|
+
const script = parsedArgs.script;
|
|
26
33
|
/****
|
|
27
34
|
* 1. installer electron globallement : npm i -g electron@latest
|
|
28
35
|
* cmde : [cmd] start electron config=[path-to-config-relative-to-project-dir]
|
|
@@ -39,9 +46,26 @@ if(parsedArgs.electron){
|
|
|
39
46
|
if(typeof paths !=='object' || !paths || !paths.projectRoot){
|
|
40
47
|
throw "Fichiers des chemins d'application invalide!!! merci d'exécuter l'application en environnement web|android|ios puis réessayez"
|
|
41
48
|
}
|
|
42
|
-
|
|
49
|
+
/**** le project root d'où a été lancé le script electron doit être le même que celui de l'application principale */
|
|
50
|
+
if(projectRoot !== paths.projectRoot){
|
|
51
|
+
throw `main app project root ${paths.projectRoot} must be equals to ${projectRoot} in which you want to generate electron app`;
|
|
52
|
+
}
|
|
53
|
+
const electronProjectRoot = path.resolve(projectRoot,"electron");
|
|
54
|
+
const isElectionInitialized = require("../electron/is-initialized")(electronProjectRoot);
|
|
55
|
+
if(!isElectionInitialized || script =='init'){
|
|
56
|
+
if(script !=='init'){
|
|
57
|
+
console.log("initializing electron application before ....");
|
|
58
|
+
}
|
|
59
|
+
return require("./init")({
|
|
60
|
+
projectRoot,
|
|
61
|
+
electronDir,
|
|
62
|
+
electronProjectRoot,
|
|
63
|
+
paths,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
require("../electron/create-index-file")(electronProjectRoot);
|
|
43
67
|
const out = parsedArgs.out || parsedArgs["output-dir"];
|
|
44
|
-
const outDir = out && path.dirname(out) && path.resolve(projectRoot,path.dirname(out),"electron") || path.resolve(
|
|
68
|
+
const outDir = out && path.dirname(out) && path.resolve(projectRoot,path.dirname(out),"electron") || path.resolve(electronProjectRoot,"bin")
|
|
45
69
|
if(!createDir(outDir)){
|
|
46
70
|
throw "Impossible de créer le répertoire <<"+outDir+">> du fichier binaire!!";
|
|
47
71
|
}
|
|
@@ -51,16 +75,17 @@ if(parsedArgs.electron){
|
|
|
51
75
|
console.warn("Logo de l'application innexistant!! Vous devez spécifier le logo de votre application, fichier ["+(logoPath)+"]")
|
|
52
76
|
}
|
|
53
77
|
}
|
|
54
|
-
const buildOutDir = path.resolve(
|
|
78
|
+
const buildOutDir = path.resolve(electronProjectRoot,"dist");
|
|
55
79
|
const indexFile = path.resolve(buildOutDir,"index.html");
|
|
56
80
|
const webBuildDir = path.resolve(projectRoot,"web-build");
|
|
81
|
+
const packagePath = path.resolve(projectRoot,"package.json");
|
|
57
82
|
const url = parsedArgs.url && parsedArgs.url.trim() || "";
|
|
58
83
|
const start = x=>{
|
|
59
84
|
return new Promise((resolve,reject)=>{
|
|
60
|
-
cmd = "electron "+
|
|
85
|
+
cmd = "electron "+electronProjectRoot+" url="+url;
|
|
61
86
|
exec({
|
|
62
87
|
cmd,
|
|
63
|
-
projectRoot :
|
|
88
|
+
projectRoot : electronProjectRoot,
|
|
64
89
|
}).finally(()=>{
|
|
65
90
|
console.log("ant to exit");
|
|
66
91
|
})
|
|
@@ -73,12 +98,13 @@ if(parsedArgs.electron){
|
|
|
73
98
|
const promise = new Promise((resolve,reject)=>{
|
|
74
99
|
const next = ()=>{
|
|
75
100
|
if(fs.existsSync(webBuildDir)){
|
|
76
|
-
return
|
|
101
|
+
return copy(webBuildDir,buildOutDir).catch(reject).then(resolve);
|
|
77
102
|
} else {
|
|
78
103
|
reject("dossier web-build exporté par electron innexistant!!");
|
|
79
104
|
}
|
|
80
105
|
}
|
|
81
106
|
if(!url && (parsedArgs.compile || !fs.existsSync(path.resolve(webBuildDir,"index.html")))){
|
|
107
|
+
console.log("exporting expo web app ...");
|
|
82
108
|
cmd = "npx expo export:web";
|
|
83
109
|
return exec({cmd,projectRoot}).then(next).catch(reject);
|
|
84
110
|
}
|
|
@@ -88,12 +114,32 @@ if(parsedArgs.electron){
|
|
|
88
114
|
if(!fs.existsSync(buildOutDir) || !fs.existsSync(indexFile)){
|
|
89
115
|
throw "répertoire d'export web invalide où innexistant ["+buildOutDir+"]"
|
|
90
116
|
}
|
|
91
|
-
switch(script){
|
|
117
|
+
switch(parsedArgs.script){
|
|
92
118
|
case "start":
|
|
93
119
|
return start();
|
|
94
120
|
break;
|
|
95
121
|
case "build":
|
|
96
122
|
break;
|
|
123
|
+
default :
|
|
124
|
+
if(!fs.existsSync(packagePath)){
|
|
125
|
+
throw "package.json file does not exist in "+projectRoot+". please make jure that your have running package script in expo root application";
|
|
126
|
+
}
|
|
127
|
+
const packageObj = require(`${packagePath}`);
|
|
128
|
+
const electronPackage = require(`${path.resolve(electronProjectRoot,'package.json')}`);
|
|
129
|
+
electronPackage.name = packageObj.name;
|
|
130
|
+
electronPackage.version = packageObj.version;
|
|
131
|
+
//copying package json in build folder
|
|
132
|
+
writeFile(path.resolve(electronProjectRoot,"package.json"),JSON.stringify(electronPackage,null,"\t"));
|
|
133
|
+
const platform = parsedArgs.platform || process.platform;
|
|
134
|
+
console.log("packaing app from ",electronProjectRoot);
|
|
135
|
+
return require("./package")({
|
|
136
|
+
src : electronProjectRoot,
|
|
137
|
+
dist : path.resolve(outDir,platform),
|
|
138
|
+
platform,
|
|
139
|
+
arch : parsedArgs.arch || undefined,
|
|
140
|
+
projectRoot : electronProjectRoot,
|
|
141
|
+
});
|
|
142
|
+
break;
|
|
97
143
|
}
|
|
98
144
|
}).catch((e)=>{
|
|
99
145
|
console.log(e," is cathing ggg");
|
|
@@ -102,4 +148,4 @@ if(parsedArgs.electron){
|
|
|
102
148
|
});
|
|
103
149
|
} else {
|
|
104
150
|
process.exit();
|
|
105
|
-
}
|
|
151
|
+
}
|
package/bin/init.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const path= require("path");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const dir = path.resolve(__dirname);
|
|
4
|
+
const exec = require("../electron/utils/exec");
|
|
5
|
+
const createDir = require("../electron/utils/createDir");
|
|
6
|
+
const writeFile = require("../electron/utils/writeFile");
|
|
7
|
+
const copy = require("../electron/utils/copy");
|
|
8
|
+
const electronDir = path.resolve(__dirname,"..","electron");
|
|
9
|
+
const createIndexFile = require("../electron/create-index-file");
|
|
10
|
+
|
|
11
|
+
module.exports = ({
|
|
12
|
+
projectRoot,
|
|
13
|
+
electronProjectRoot,
|
|
14
|
+
paths,
|
|
15
|
+
})=>{
|
|
16
|
+
return new Promise((resolve,reject)=>{
|
|
17
|
+
//make shure electron project root exists
|
|
18
|
+
if(!createDir(electronProjectRoot)){
|
|
19
|
+
throw "Unable to create electron project root directory at "+electronProjectRoot;
|
|
20
|
+
}
|
|
21
|
+
const projectRootPackage = require(`${path.resolve(projectRoot,'package.json')}`);
|
|
22
|
+
const dependencies = require("../electron/dependencies");
|
|
23
|
+
const electronProjectRootPackage = path.resolve(electronProjectRoot,"package.json");
|
|
24
|
+
projectRootPackage.dependencies = dependencies.main;
|
|
25
|
+
projectRootPackage.devDependencies = dependencies.dev;
|
|
26
|
+
projectRootPackage.scripts = {
|
|
27
|
+
"compile" : "npx expo-ui electron compile",
|
|
28
|
+
"start" : "npx expo-ui electron start",
|
|
29
|
+
"compile2start" : "npx expo-ui electron start compile",
|
|
30
|
+
"package" : "npx expo-ui electron package",
|
|
31
|
+
"compile2package" : "npx expo-ui electron package compile"
|
|
32
|
+
}
|
|
33
|
+
writeFile(electronProjectRootPackage,JSON.stringify(projectRootPackage,null,'\t'));
|
|
34
|
+
if(!fs.existsSync(electronProjectRootPackage)){
|
|
35
|
+
throw `unable to create ${electronProjectRootPackage} file`;
|
|
36
|
+
}
|
|
37
|
+
const mainFolder = path.resolve(electronProjectRoot,"main");
|
|
38
|
+
const rendererFolder = path.resolve(electronProjectRoot,"renderer");
|
|
39
|
+
if(!createDir(mainFolder)){
|
|
40
|
+
throw `unable to create main process folder at ${mainFolder}`
|
|
41
|
+
}
|
|
42
|
+
if(!createDir(rendererFolder)){
|
|
43
|
+
throw `unable to create renderer process folder at ${rendererFolder}`;
|
|
44
|
+
}
|
|
45
|
+
const mainFolderIndex = path.resolve(mainFolder,"index.js");
|
|
46
|
+
const rendererFolderIndex = path.resolve(rendererFolder,"index.js");
|
|
47
|
+
if(!fs.existsSync(mainFolderIndex)){
|
|
48
|
+
copy(path.resolve(electronDir,"init","main.js"),mainFolderIndex);
|
|
49
|
+
}
|
|
50
|
+
if(!fs.existsSync(rendererFolderIndex)){
|
|
51
|
+
copy(path.resolve(electronDir,"init","renderer.js"),rendererFolderIndex);
|
|
52
|
+
}
|
|
53
|
+
createIndexFile(electronProjectRoot);
|
|
54
|
+
/**** copying all electron utils files */
|
|
55
|
+
const utilsPath = path.resolve(electronProjectRoot,"utils");
|
|
56
|
+
copy(path.resolve(electronDir,"utils"),utilsPath);
|
|
57
|
+
console.log("installing package dependencies ...");
|
|
58
|
+
return exec({
|
|
59
|
+
cmd : "npm install",// --prefix "+electronProjectRoot,
|
|
60
|
+
projectRoot : electronProjectRoot,
|
|
61
|
+
}).then((a)=>{
|
|
62
|
+
return resolve(a);
|
|
63
|
+
console.log("initializing with electron-forge ....");
|
|
64
|
+
return exec({
|
|
65
|
+
cmd : `npx electron-forge import`,
|
|
66
|
+
}).then(resolve);
|
|
67
|
+
}).catch(reject);
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const copyExtra = (path2)=>{
|
|
72
|
+
fs.readdirSync(path2).forEach((file) => {
|
|
73
|
+
if(!file || file.toLowerCase() =="dist") return;
|
|
74
|
+
file = path.join(path2,file);
|
|
75
|
+
const stat = fs.statSync(file);
|
|
76
|
+
if(stat.isDirectory()){
|
|
77
|
+
return copyExtra(file);
|
|
78
|
+
}
|
|
79
|
+
if(!stat.isFile() || file === indexFile) return;
|
|
80
|
+
extraResource.push(file);
|
|
81
|
+
});
|
|
82
|
+
}
|
package/bin/package.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const getIcon = require("../electron/utils/getIcon");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const defaultFunc = (cb,cb2) => typeof cb =='function' ? cb : typeof cb2 ==='function'? cb2 : x=> x;
|
|
4
|
+
const paths = require("../electron/paths.json");
|
|
5
|
+
const images = paths.$images, assets = paths.$assets, logo = paths.logo;
|
|
6
|
+
const createDir = require("../electron/utils/createDir");
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const getDirname = require("../electron/utils/getDirname");
|
|
9
|
+
const copy = require("../electron/utils/copy");
|
|
10
|
+
|
|
11
|
+
/***@see : https://electron.github.io/electron-packager/main/interfaces/electronpackager.options.html */
|
|
12
|
+
module.exports = function package(opts){
|
|
13
|
+
opts = typeof opts =="object" && !Array.isArray(opts) && opts || {};
|
|
14
|
+
const {projectRoot:pRoot,...options} = opts;
|
|
15
|
+
options.dir = typeof options.dir =='string' && options.dir || typeof options.srcDir =='string' && options.srcDir || typeof options.src =='string' && options.src || undefined;
|
|
16
|
+
const projectRoot = pRoot || options.dir;
|
|
17
|
+
if(typeof projectRoot !='string' || !projectRoot || !fs.existsSync(projectRoot)){
|
|
18
|
+
return Promise.reject({
|
|
19
|
+
message :'projectRoot not defined!! or its invalid '+projectRoot
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
const packagerPath = path.resolve(projectRoot,"node_modules","electron-packager");
|
|
23
|
+
if(!fs.existsSync(packagerPath)){
|
|
24
|
+
return Promise.reject({
|
|
25
|
+
message : "packager module not found!! you must initialize your project before to package it; packager path : "+packagerPath,
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
const packager = require(`${packagerPath}`);
|
|
29
|
+
options.afterAsar = defaultFunc(options.afterAsar,()=>{});
|
|
30
|
+
options.afterComplete = defaultFunc(options.afterComplete,()=>{});
|
|
31
|
+
options.afterCopy = defaultFunc(options.afterCopy);
|
|
32
|
+
options.appVersion = typeof options.appVersion =='string' && options.appVersion || typeof options.version =='string' && options.version || undefined;
|
|
33
|
+
options.arch = typeof options.arch =='string' && options.arch || process.arch;
|
|
34
|
+
options.asar = typeof options.asar =='boolean'? options.asar : true;
|
|
35
|
+
return new Promise((resolve,reject)=>{
|
|
36
|
+
if(!options.dir || !fs.existsSync(options.dir)){
|
|
37
|
+
return reject({message:"Repertoire source ["+options.dir+"] innexistant!! Veuillez spécifier un répertoire source valide"});
|
|
38
|
+
}
|
|
39
|
+
options.out = typeof options.out =="string" && options.out || typeof options.distDir =="string" && options.distDir || typeof options.dist =='string' && options.dist || undefined;
|
|
40
|
+
if(options.out){
|
|
41
|
+
createDir(options.out);
|
|
42
|
+
}
|
|
43
|
+
options.overwrite = typeof options.overwrite =='boolean'? options.overwrite : true;
|
|
44
|
+
options.platform = typeof options.platform =='string' && options.platform || process.platform;
|
|
45
|
+
options.prune = typeof options.prune =='boolean'? options.prune : true;
|
|
46
|
+
options.quiet = typeof options.quiet =='boolean'? options.quiet : false;
|
|
47
|
+
options.tmpdir = options.tmpdir === false ? false : typeof options.tmpdir =='string' && options.tmpdir || undefined;
|
|
48
|
+
options.icon = options.icon && typeof options.icon =='string' && fs.existsSync(options.icon) && options.icon || getIcon([
|
|
49
|
+
logo && fs.existsSync(logo) && getDirname(logo),
|
|
50
|
+
images && getDirname(images) || '',
|
|
51
|
+
assets && getDirname(assets) || '',
|
|
52
|
+
options.dir && getDirname(options.dir)
|
|
53
|
+
]);
|
|
54
|
+
return packager(options).then((appPaths)=>{
|
|
55
|
+
console.log(`Electron app bundles created at : ${appPaths.join("\n")}`);
|
|
56
|
+
resolve(appPaths);
|
|
57
|
+
}).catch(reject);
|
|
58
|
+
})
|
|
59
|
+
}
|
package/electron/app/instance.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const writeFile = require("../electron/utils/writeFile");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
module.exports = (electronProjectRoot)=>{
|
|
6
|
+
if(!electronProjectRoot || typeof electronProjectRoot !='string' || !fs.existsSync(electronProjectRoot)){
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const indexPath = path.resolve(electronProjectRoot,"index.js");
|
|
10
|
+
const electronDir = path.resolve(__dirname,"..","electron");
|
|
11
|
+
writeFile(indexPath,`module.exports = require("${path.resolve(electronDir,'index.js').split(path.sep).join("/")}");`);
|
|
12
|
+
return indexPath;
|
|
13
|
+
}
|
package/electron/index.js
CHANGED
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
const {app, BrowserWindow,Tray,Menu,MenuItem,systemPreferences,powerMonitor,dialog, nativeTheme} = require('electron')
|
|
2
|
-
const appConfig = {}
|
|
3
|
-
const session = require("./session");
|
|
1
|
+
const {app, BrowserWindow,Tray,Menu,MenuItem,globalShortcut,systemPreferences,powerMonitor,ipcMain,dialog, nativeTheme} = require('electron')
|
|
2
|
+
const appConfig = {};
|
|
3
|
+
const session = require("./utils/session");
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const ePath = path.resolve(__dirname);
|
|
7
|
-
const getDirname = require("./getDirname");
|
|
8
7
|
if(!fs.existsSync(path.resolve(ePath,"paths.json"))){
|
|
9
8
|
throw {message : 'Chemin de noms, fichier paths.json introuvable!! Exécutez l\'application en enviornnement web|mobile|android|ios puis re-essayez'}
|
|
10
9
|
}
|
|
11
10
|
const paths = require("./paths.json");
|
|
12
|
-
const images = paths.$images, assets = paths.$assets, logo = paths.logo;
|
|
13
11
|
const projectRoot = paths.projectRoot || '';
|
|
14
12
|
const electronProjectRoot = projectRoot && fs.existsSync(path.resolve(projectRoot,"electron")) && path.resolve(projectRoot,"electron") || null;
|
|
15
|
-
const mainProcessIndex = electronProjectRoot && fs.existsSync(path.resolve(electronProjectRoot,"main.
|
|
13
|
+
const mainProcessIndex = electronProjectRoot && fs.existsSync(path.resolve(electronProjectRoot,"main","index.js")) && path.resolve(electronProjectRoot,"main","index.js");
|
|
16
14
|
const mainProcessRequired = mainProcessIndex && require(`${mainProcessIndex}`);
|
|
17
|
-
//pour étendre les fonctionnalités au niveau du main proceess, bien vouloir écrire dans le fichier projectRoot/electron/main.
|
|
15
|
+
//pour étendre les fonctionnalités au niveau du main proceess, bien vouloir écrire dans le fichier projectRoot/electron/main/index.js
|
|
18
16
|
const mainProcess = mainProcessRequired && typeof mainProcessRequired =='object'? mainProcessRequired : {};
|
|
19
17
|
// Gardez une reference globale de l'objet window, si vous ne le faites pas, la fenetre sera
|
|
20
18
|
// fermee automatiquement quand l'objet JavaScript sera garbage collected.
|
|
21
19
|
let win = undefined;
|
|
22
|
-
const icon = require("./getIcon")(
|
|
23
|
-
logo && fs.existsSync(logo) && getDirname(logo),
|
|
24
|
-
images && getDirname(images) || '',
|
|
25
|
-
assets && getDirname(assets) || '',
|
|
26
|
-
);
|
|
27
20
|
Menu.setApplicationMenu(null);
|
|
28
|
-
|
|
21
|
+
|
|
22
|
+
const clipboadContextMenu = (_, props) => {
|
|
29
23
|
if (props.isEditable || props.selectionText) {
|
|
30
24
|
const menu = new Menu();
|
|
31
25
|
if(props.selectionText){
|
|
@@ -40,9 +34,9 @@ let clipboadContextMenu = (_, props) => {
|
|
|
40
34
|
menu.popup();
|
|
41
35
|
}
|
|
42
36
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
const log = (message)=>{
|
|
38
|
+
return win != null && win && win.webContents.send("console.log",message);
|
|
39
|
+
}
|
|
46
40
|
const setOSTheme = (theme) => {
|
|
47
41
|
theme = theme && typeof theme == "string"? theme : "light";
|
|
48
42
|
theme = theme.toLowerCase().trim();
|
|
@@ -64,7 +58,6 @@ function createBrowserWindow (options){
|
|
|
64
58
|
...options.webPreferences,
|
|
65
59
|
contextIsolation: true,
|
|
66
60
|
devTools: typeof options.webPreferences.devTools === 'boolean'? options.webPreferences.devTools : false,
|
|
67
|
-
icon,
|
|
68
61
|
webSecurity : true,
|
|
69
62
|
autoHideMenuBar: true,
|
|
70
63
|
allowRunningInsecureContent: false,
|
|
@@ -89,7 +82,7 @@ function createBrowserWindow (options){
|
|
|
89
82
|
if(showOnLoad){
|
|
90
83
|
options.show = false;
|
|
91
84
|
}
|
|
92
|
-
if(
|
|
85
|
+
if(typeof mainProcess.beforeCreateWindow =='function'){
|
|
93
86
|
mainProcess.beforeCreateWindow(options);
|
|
94
87
|
}
|
|
95
88
|
let _win = new BrowserWindow(options);
|
|
@@ -113,7 +106,7 @@ function createBrowserWindow (options){
|
|
|
113
106
|
});
|
|
114
107
|
return _win;
|
|
115
108
|
}
|
|
116
|
-
const args = require("./parseArgs")();
|
|
109
|
+
const args = require("./utils/parseArgs")();
|
|
117
110
|
function createWindow () {
|
|
118
111
|
// Créer le browser window
|
|
119
112
|
win = createBrowserWindow({
|
|
@@ -124,17 +117,13 @@ function createWindow () {
|
|
|
124
117
|
devTools : true,
|
|
125
118
|
}
|
|
126
119
|
});
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
width: 500, height: 400, transparent: true, frame: false, alwaysOnTop: true});
|
|
135
|
-
let copyRight = appConfig.name+" version "+appConfig.version+". "+appConfig.copyRight;
|
|
136
|
-
copyRight = encodeURI(copyRight);
|
|
137
|
-
//splash.loadURL(`file://${__dirname}/splash/index.html?copyRight=${copyRight}`);
|
|
120
|
+
|
|
121
|
+
const sOptions = {width: 500, height: 400, transparent: true, frame: false, alwaysOnTop: true};
|
|
122
|
+
const splash = typeof mainProcess.splashScreen ==='function'&& mainProcess.splashScreen(sOptions)
|
|
123
|
+
|| typeof mainProcess.splash ==='function' && mainProcess.splash(sOptions)
|
|
124
|
+
|| (mainProcess.splash instanceof BrowserWindow) && mainProcess.splash
|
|
125
|
+
|| (mainProcess.splashScreen instanceof BrowserWindow) && mainProcess.splashScreen;
|
|
126
|
+
null;
|
|
138
127
|
let hasInitWindows = false;
|
|
139
128
|
win.on('show', () => {
|
|
140
129
|
//win.blur();
|
|
@@ -163,8 +152,11 @@ function createWindow () {
|
|
|
163
152
|
|
|
164
153
|
win.once("ready-to-show",function(){
|
|
165
154
|
win.minimize()
|
|
166
|
-
|
|
167
|
-
|
|
155
|
+
try {
|
|
156
|
+
if(splash && splash instanceof BrowserWindow){
|
|
157
|
+
splash.destroy();
|
|
158
|
+
}
|
|
159
|
+
} catch{ }
|
|
168
160
|
win.restore();
|
|
169
161
|
win.show();
|
|
170
162
|
//log(icon," is consooleeeee")
|
|
@@ -179,7 +171,7 @@ function createWindow () {
|
|
|
179
171
|
if(args.url){
|
|
180
172
|
win.loadURL(args.url);
|
|
181
173
|
} else {
|
|
182
|
-
win.loadFile(path.resolve(path.join(
|
|
174
|
+
win.loadFile(path.resolve(path.join(electronProjectRoot,"dist",'index.html')))
|
|
183
175
|
}
|
|
184
176
|
|
|
185
177
|
win.on('unresponsive', async () => {
|
|
@@ -199,7 +191,7 @@ function createWindow () {
|
|
|
199
191
|
})
|
|
200
192
|
|
|
201
193
|
// Ouvre les DevTools.
|
|
202
|
-
win.webContents.openDevTools()
|
|
194
|
+
//win.webContents.openDevTools()
|
|
203
195
|
|
|
204
196
|
// Émit lorsque la fenêtre est fermée.
|
|
205
197
|
win.on('closed', () => {
|
|
@@ -243,8 +235,12 @@ function createWindow () {
|
|
|
243
235
|
win.on('resize',onWinResizeEv);
|
|
244
236
|
win.off('move',onWinResizeEv);
|
|
245
237
|
win.on('move',onWinResizeEv);
|
|
238
|
+
if(mainProcess && typeof mainProcess =='object' && typeof mainProcess.onCreateWindow =='function'){
|
|
239
|
+
mainProcess.onCreateWindow(win);
|
|
240
|
+
}
|
|
246
241
|
}
|
|
247
|
-
|
|
242
|
+
|
|
243
|
+
const quit = ()=>{
|
|
248
244
|
try {
|
|
249
245
|
app.quit();
|
|
250
246
|
} catch(e){
|
|
@@ -260,19 +256,42 @@ app.on('window-all-closed', () => {
|
|
|
260
256
|
}
|
|
261
257
|
})
|
|
262
258
|
|
|
259
|
+
const toggleDevTools = (value)=>{
|
|
260
|
+
if(win !==null && win.webContents){
|
|
261
|
+
const isOpen= win.webContents.isDevToolsOpened();
|
|
262
|
+
value = value === undefined ? !isOpen : value;
|
|
263
|
+
if(value && !isOpen){
|
|
264
|
+
win.webContents.openDevTools();
|
|
265
|
+
return win.webContents.isDevToolsOpened();
|
|
266
|
+
} else {
|
|
267
|
+
if(isOpen) win.webContents.closeDevTools();
|
|
268
|
+
}
|
|
269
|
+
return win.webContents.isDevToolsOpened();
|
|
270
|
+
}
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
ipcMain.on("electron-toggle-dev-tools",function(event,value) {
|
|
274
|
+
return toggleDevTools(value);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
|
|
263
278
|
app.whenReady().then(() => {
|
|
264
|
-
|
|
279
|
+
if(typeof mainProcess.whenReady =='function'){
|
|
280
|
+
mainProcess.whenReady();
|
|
281
|
+
} else if(typeof mainProcess.appOnReady =='function'){
|
|
282
|
+
mainProcess.appOnReady();
|
|
283
|
+
}
|
|
284
|
+
globalShortcut.register('CommandOrControl+F12', () => {
|
|
285
|
+
toggleDevTools();
|
|
286
|
+
});
|
|
287
|
+
}).then(()=>{
|
|
265
288
|
createWindow();
|
|
266
289
|
app.on('activate', function () {
|
|
267
290
|
if (win == null || (BrowserWindow.getAllWindows().length === 0)) createWindow()
|
|
268
291
|
});
|
|
269
292
|
})
|
|
270
293
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
ipcMain.on("electron-restart-app",x =>{
|
|
274
|
-
app.relaunch();
|
|
275
|
-
})
|
|
294
|
+
ipcMain.on("electron-restart-app",x =>{app.relaunch();})
|
|
276
295
|
let tray = null;
|
|
277
296
|
let isJSON = function (json_string){
|
|
278
297
|
if(!json_string || typeof json_string != 'string') return false;
|
|
@@ -284,7 +303,7 @@ ipcMain.on("update-system-tray",(event,opts)=>{
|
|
|
284
303
|
let {contextMenu,tooltip} = opts;
|
|
285
304
|
if(tray){
|
|
286
305
|
} else {
|
|
287
|
-
tray = new Tray(
|
|
306
|
+
tray = new Tray();
|
|
288
307
|
}
|
|
289
308
|
if(!tooltip || typeof tooltip !=="string"){
|
|
290
309
|
tooltip = ""
|
|
@@ -327,8 +346,15 @@ ipcMain.on("electron-ask-for-media-access",(event,mediaType)=>{
|
|
|
327
346
|
});
|
|
328
347
|
|
|
329
348
|
ipcMain.on("electron-get-app-icon",(event)=>{
|
|
330
|
-
event.returnValue =
|
|
331
|
-
|
|
349
|
+
event.returnValue = win != win && win.getIcon && win.getIcon();
|
|
350
|
+
});
|
|
351
|
+
ipcMain.on("electron-set-app-icon",(event,iconPath)=>{
|
|
352
|
+
if(iconPath && win != null){
|
|
353
|
+
win.setIcon(iconPath);
|
|
354
|
+
event.returnValue = iconPath;
|
|
355
|
+
} else {
|
|
356
|
+
event.returnValue = null;
|
|
357
|
+
}
|
|
332
358
|
});
|
|
333
359
|
|
|
334
360
|
ipcMain.on('minimize-main-window', () => {
|
|
@@ -449,20 +475,7 @@ ipcMain.on("electron-is-dev-tools-open",function(event,value) {
|
|
|
449
475
|
}
|
|
450
476
|
return false;
|
|
451
477
|
})
|
|
452
|
-
|
|
453
|
-
if(win !==null && win.webContents){
|
|
454
|
-
const isOpen= win.webContents.isDevToolsOpened();
|
|
455
|
-
value = value === undefined ? !isOpen : value;
|
|
456
|
-
if(value && !isOpen){
|
|
457
|
-
win.webContents.openDevTools();
|
|
458
|
-
return win.webContents.isDevToolsOpened();
|
|
459
|
-
} else {
|
|
460
|
-
if(isOpen) win.webContents.closeDevTools();
|
|
461
|
-
}
|
|
462
|
-
return win.webContents.isDevToolsOpened();
|
|
463
|
-
}
|
|
464
|
-
return false;
|
|
465
|
-
})
|
|
478
|
+
|
|
466
479
|
|
|
467
480
|
ipcMain.on("electron-window-set-progressbar",(event,interval)=>{
|
|
468
481
|
if(typeof interval !="number" || interval <0) interval = 0;
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**** auto generated file
|
|
2
|
+
* in this file, you can add all main process code you want for your electron application
|
|
3
|
+
* @export||@return {object}, with properties like this :
|
|
4
|
+
* {
|
|
5
|
+
* splash || splashScreen {function|| instanceOf(BrowserWindow)}, if function, must return an instanceOf BrowserWindow wich will use as application splashcreen
|
|
6
|
+
* whenReady || appOnReady {function}, function called when electron app is ready
|
|
7
|
+
* }
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
module.exports = {}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
/*** check if electron is initialized at project root */
|
|
4
|
+
module.exports = (projectRoot)=>{
|
|
5
|
+
projectRoot = typeof projectRoot =='string' && projectRoot && fs.existsSync(projectRoot) && projectRoot || process.cwd();
|
|
6
|
+
return fs.existsSync(path.resolve(projectRoot,"node_modules")) && fs.existsSync(path.resolve(projectRoot,"index.js"))
|
|
7
|
+
&& fs.existsSync(path.resolve(projectRoot,"package.json"))
|
|
8
|
+
&& fs.existsSync(path.resolve(projectRoot,"main"))
|
|
9
|
+
&& fs.existsSync(path.resolve(projectRoot,"renderer"))
|
|
10
|
+
|
|
11
|
+
&& true || false;
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sage-ftc",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Accès distant aux données commerciales et comptables Sage100C de partout",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "test",
|
|
8
|
+
"start": "npx expo start",
|
|
9
|
+
"start-c": "npx expo start -c",
|
|
10
|
+
"build": "npx expo export:web",
|
|
11
|
+
"electron": "node ./expo-ui/bin start electron url=http://localhost:19006/",
|
|
12
|
+
"build-android": "eas build --clear-cache -p android --profile preview",
|
|
13
|
+
"delete-node-modules": "rimraf ./**/node_modules",
|
|
14
|
+
"package": "node ./expo-ui/bin package compile2"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/borispipo/sage-ftc.git"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"XposeFTC",
|
|
22
|
+
"Sage100C",
|
|
23
|
+
"Accès",
|
|
24
|
+
"distant"
|
|
25
|
+
],
|
|
26
|
+
"author": "BorisFouomene@fto-consulting",
|
|
27
|
+
"license": "UNLICENCED",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/borispipo/sage-ftc/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "./"
|
|
32
|
+
}
|