@fto-consult/expo-ui 7.5.44 → 7.6.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/babel.config.alias.js +2 -1
- package/bin/index.js +0 -152
- package/bin/update-appex-chart.js +1 -1
- package/bin/update-pdfmake.js +1 -1
- package/bin/utils.js +1 -1
- package/copy-env-file.js +3 -6
- package/create-transpile-module-transformer.js +1 -1
- package/find-licenses.js +1 -1
- package/package.json +3 -4
- package/src/screens/Help/openLibraries.js +339 -1
- package/bin/init.js +0 -95
- package/electron/app/desktopCapturer.js +0 -123
- package/electron/app/email.js +0 -55
- package/electron/app/file.js +0 -501
- package/electron/app/index.html +0 -32
- package/electron/app/index.js +0 -19
- package/electron/app/instance.js +0 -46
- package/electron/create-index-file.js +0 -15
- package/electron/dependencies.js +0 -13
- package/electron/index.js +0 -556
- package/electron/init/index.js +0 -0
- package/electron/init/main.js +0 -55
- package/electron/init/renderer.js +0 -6
- package/electron/is-initialized.js +0 -11
- package/electron/pload.js +0 -88
- package/electron/preload.js +0 -461
- package/electron/tools.js +0 -0
- package/electron/utils/config.js +0 -30
- package/electron/utils/copy.js +0 -20
- package/electron/utils/createDir.js +0 -30
- package/electron/utils/createDirSync.js +0 -31
- package/electron/utils/debounce.js +0 -19
- package/electron/utils/dependencies.js +0 -10
- package/electron/utils/env.js +0 -80
- package/electron/utils/exec.js +0 -81
- package/electron/utils/getDirname.js +0 -14
- package/electron/utils/getIcon.js +0 -25
- package/electron/utils/index.js +0 -24
- package/electron/utils/isBase64.js +0 -14
- package/electron/utils/isDataURL.js +0 -13
- package/electron/utils/isValidUrl.js +0 -4
- package/electron/utils/json.js +0 -57
- package/electron/utils/parseArgs.js +0 -21
- package/electron/utils/paths.js +0 -11
- package/electron/utils/postMessage.js +0 -19
- package/electron/utils/replaceAll.js +0 -12
- package/electron/utils/session.js +0 -5
- package/electron/utils/uniqid.js +0 -33
- package/electron/utils/writeFile.js +0 -14
package/electron/index.js
DELETED
@@ -1,556 +0,0 @@
|
|
1
|
-
const { program } = require('commander');
|
2
|
-
const path = require("path");
|
3
|
-
const fs = require("fs");
|
4
|
-
const isValidUrl = require("./utils/isValidUrl");
|
5
|
-
|
6
|
-
const debounce = require("./utils/debounce");
|
7
|
-
const {app, BrowserWindow,Tray,Menu,MenuItem,globalShortcut,systemPreferences,powerMonitor,ipcMain,dialog, nativeTheme} = require('electron')
|
8
|
-
const session = require("./utils/session");
|
9
|
-
const {isJSON} = require("./utils/json");
|
10
|
-
|
11
|
-
const isObj = x => x && typeof x =='object';
|
12
|
-
|
13
|
-
let appIsReady = false;
|
14
|
-
|
15
|
-
const iconName = process.platform =="win32" ? "icon.ico" : process.platform =='darwin' ? "icon.incs" : "icon.png";
|
16
|
-
|
17
|
-
program
|
18
|
-
.option('-u, --url <url>', 'L\'adresse url à ouvrir au lancement de l\'application')
|
19
|
-
//.option('-r, --root <projectRoot>', 'le chemin du project root de l\'application')
|
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
|
-
.parse();
|
22
|
-
|
23
|
-
const programOptions = program.opts();
|
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
|
-
|
30
|
-
const distPath = path.join("dist",'index.html');
|
31
|
-
const processCWD = process.cwd();
|
32
|
-
const appPath = app.getAppPath();
|
33
|
-
const isAsar = appPath.indexOf('app.asar') !== -1;
|
34
|
-
const packageJSONPath = fs.existsSync(processCWD,"package.json")? path.resolve(processCWD,"package.json") : fs.existsSync(path.resolve(appPath,"package.app.json")) ? path.resolve(appPath,"package.app.json") : path.resolve(appPath,"package.json") ;
|
35
|
-
const packageJSON = fs.existsSync(packageJSONPath) ? Object.assign({},require(`${packageJSONPath}`)) : {};
|
36
|
-
const appName = typeof packageJSON.realAppName =='string' && packageJSON.realAppName || typeof packageJSON.name =="string" && packageJSON.name || "";
|
37
|
-
|
38
|
-
// fermee automatiquement quand l'objet JavaScript sera garbage collected.
|
39
|
-
let mainWindow = undefined;
|
40
|
-
|
41
|
-
Menu.setApplicationMenu(null);
|
42
|
-
|
43
|
-
const indexFilePath = path.resolve(path.join(appPath,distPath));
|
44
|
-
const mainProcessPath = path.resolve('processes',"main","index.js");
|
45
|
-
const mainProcessIndex = fs.existsSync(path.resolve(appPath,mainProcessPath)) && path.resolve(appPath,mainProcessPath);
|
46
|
-
const mainProcessRequired = mainProcessIndex && require(`${mainProcessIndex}`);
|
47
|
-
//pour étendre les fonctionnalités au niveau du main proceess, bien vouloir écrire dans le fichier ../electron/main/index.js
|
48
|
-
const mainProcess = mainProcessRequired && typeof mainProcessRequired =='object'? mainProcessRequired : {};
|
49
|
-
const execPath = app.getPath ('exe') || process.execPath;
|
50
|
-
|
51
|
-
// Gardez une reference globale de l'objet window, si vous ne le faites pas, la fenetre sera
|
52
|
-
if(!isValidUrl(pUrl) && !fs.existsSync(indexFilePath)){
|
53
|
-
throw {message:`Unable to start the application: index file located at [${indexFilePath}] does not exists : appPath = [${appPath}], exec path is ${execPath}`}
|
54
|
-
}
|
55
|
-
|
56
|
-
const quit = ()=>{
|
57
|
-
try {
|
58
|
-
app.quit();
|
59
|
-
} catch(e){
|
60
|
-
console.log(e," triing kit app")
|
61
|
-
}
|
62
|
-
}
|
63
|
-
|
64
|
-
//app.disableHardwareAcceleration();
|
65
|
-
|
66
|
-
function createBrowserWindow (options){
|
67
|
-
const {isMainWindow} = options;
|
68
|
-
options = Object.assign({},options);
|
69
|
-
const menu = options.menu;
|
70
|
-
options.webPreferences = isObj(options.webPreferences)? options.webPreferences : {};
|
71
|
-
options.webPreferences = {
|
72
|
-
sandbox: false,
|
73
|
-
webSecurity : true,
|
74
|
-
plugin:false,
|
75
|
-
autoHideMenuBar: true,
|
76
|
-
contextIsolation: true,
|
77
|
-
contentSecurityPolicy: `
|
78
|
-
default-src 'none';
|
79
|
-
script-src 'self';
|
80
|
-
img-src 'self' data:;
|
81
|
-
style-src 'self';
|
82
|
-
font-src 'self';
|
83
|
-
`,
|
84
|
-
...options.webPreferences,
|
85
|
-
devTools: typeof options.webPreferences.devTools === 'boolean'? options.webPreferences.devTools : false,
|
86
|
-
allowRunningInsecureContent: false,
|
87
|
-
nodeIntegration: false,
|
88
|
-
preload: options.preload ? options.preload : null,
|
89
|
-
}
|
90
|
-
if(options.modal && !options.parent && mainWindow){
|
91
|
-
options.parent = mainWindow;
|
92
|
-
}
|
93
|
-
if(typeof options.show ==='undefined'){
|
94
|
-
options.show = false;
|
95
|
-
}
|
96
|
-
let showOnLoad = options.showOnLoad ===true ? true : undefined;
|
97
|
-
if(showOnLoad){
|
98
|
-
options.show = false;
|
99
|
-
}
|
100
|
-
if(typeof mainProcess?.beforeCreateWindow =='function'){
|
101
|
-
const opts = Object.assign({},mainProcess.beforeCreateWindow(options));
|
102
|
-
options = {...options,...opts};
|
103
|
-
}
|
104
|
-
options.icon = options.icon || iconPath;
|
105
|
-
let window = new BrowserWindow(options);
|
106
|
-
if(!menu){
|
107
|
-
window.setMenu(null);
|
108
|
-
window.removeMenu();
|
109
|
-
window.setMenuBarVisibility(false)
|
110
|
-
window.setAutoHideMenuBar(true)
|
111
|
-
}
|
112
|
-
if(showOnLoad){
|
113
|
-
window.once('ready-to-show', () => {
|
114
|
-
window.show();
|
115
|
-
window.webContents.send("window-ready-to-show",JSON.stringify(options.readyToShowOptions));
|
116
|
-
});
|
117
|
-
}
|
118
|
-
window.on('closed', function() {
|
119
|
-
if(isMainWindow && typeof mainProcess?.onMainWindowClosed == "function"){
|
120
|
-
mainProcess.onMainWindowClosed(window);
|
121
|
-
}
|
122
|
-
window = null;
|
123
|
-
});
|
124
|
-
window.webContents.on('context-menu',clipboadContextMenu);
|
125
|
-
const url = isValidUrl(options.loadURL) || typeof options.loadURL ==='string' && options.loadURL.trim().startsWith("file://") ? options.loadURL : undefined;
|
126
|
-
if(url){
|
127
|
-
window.loadURL(url);
|
128
|
-
} else if(options.file && fs.existsSync(path.resolve(options.file))){
|
129
|
-
window.loadFile(path.resolve(options.file));
|
130
|
-
}
|
131
|
-
return window;
|
132
|
-
}
|
133
|
-
|
134
|
-
app.whenReady().then(() => {
|
135
|
-
createWindow();
|
136
|
-
const readOpts = {toggleDevTools,browserWindow:mainWindow,mainWindow:mainWindow};
|
137
|
-
if(typeof mainProcess.whenAppReady =='function'){
|
138
|
-
mainProcess.whenAppReady(readOpts);
|
139
|
-
}
|
140
|
-
globalShortcut.register('CommandOrControl+F12', () => {
|
141
|
-
return toggleDevTools();
|
142
|
-
});
|
143
|
-
app.on('activate', function () {
|
144
|
-
if (mainWindow == null || (BrowserWindow.getAllWindows().length === 0)) createWindow()
|
145
|
-
});
|
146
|
-
appIsReady = true;
|
147
|
-
});
|
148
|
-
|
149
|
-
function createWindow () {
|
150
|
-
// Créer le browser window
|
151
|
-
mainWindow = createBrowserWindow({
|
152
|
-
showOnLoad : false,
|
153
|
-
loadURL : undefined,
|
154
|
-
isMainWindow : true,
|
155
|
-
registerDevToolsCommand : false,
|
156
|
-
file : indexFilePath,
|
157
|
-
url : pUrl,
|
158
|
-
preload : path.resolve(__dirname,'preload.js'),
|
159
|
-
webPreferences : {
|
160
|
-
devTools : true,
|
161
|
-
}
|
162
|
-
});
|
163
|
-
const sOptions = {width: 500, height: 400, transparent: true, frame: false, alwaysOnTop: true};
|
164
|
-
const splash = typeof mainProcess.splashScreen ==='function'&& mainProcess.splashScreen(sOptions)
|
165
|
-
|| typeof mainProcess.splash ==='function' && mainProcess.splash(sOptions)
|
166
|
-
|| (mainProcess.splash instanceof BrowserWindow) && mainProcess.splash
|
167
|
-
|| (mainProcess.splashScreen instanceof BrowserWindow) && mainProcess.splashScreen;
|
168
|
-
null;
|
169
|
-
let hasInitWindows = false;
|
170
|
-
mainWindow.on('show', () => {
|
171
|
-
//mainWindow.blur();
|
172
|
-
setTimeout(() => {
|
173
|
-
mainWindow.focus();
|
174
|
-
mainWindow.moveTop();
|
175
|
-
mainWindow.webContents.focus();
|
176
|
-
if(!hasInitWindows){
|
177
|
-
hasInitWindows = true;
|
178
|
-
mainWindow.webContents.send('appReady');
|
179
|
-
}
|
180
|
-
}, 200);
|
181
|
-
});
|
182
|
-
|
183
|
-
mainWindow.on("focus",()=>{
|
184
|
-
if(mainWindow && hasInitWindows){
|
185
|
-
mainWindow.webContents.send("main-window-focus");
|
186
|
-
}
|
187
|
-
});
|
188
|
-
mainWindow.on("blur",()=>{
|
189
|
-
if(mainWindow && hasInitWindows){
|
190
|
-
mainWindow.webContents.send("main-window-blur");
|
191
|
-
}
|
192
|
-
});
|
193
|
-
mainWindow.once("ready-to-show",function(){
|
194
|
-
if(typeof mainProcess.onMainWindowReadyToShow ==='function'){
|
195
|
-
mainProcess.onMainWindowReadyToShow(mainWindow);
|
196
|
-
}
|
197
|
-
mainWindow.minimize()
|
198
|
-
try {
|
199
|
-
if(splash && splash instanceof BrowserWindow){
|
200
|
-
splash.destroy();
|
201
|
-
}
|
202
|
-
} catch{ }
|
203
|
-
mainWindow.restore();
|
204
|
-
mainWindow.show();
|
205
|
-
})
|
206
|
-
|
207
|
-
mainWindow.on('close', (e) => {
|
208
|
-
if (mainWindow) {
|
209
|
-
if(typeof mainProcess.onMainWindowClose == "function"){
|
210
|
-
mainProcess.onMainWindowClose(mainWindow);
|
211
|
-
}
|
212
|
-
e.preventDefault();
|
213
|
-
mainWindow.webContents.send('before-app-exit');
|
214
|
-
}
|
215
|
-
});
|
216
|
-
|
217
|
-
mainWindow.on('unresponsive', async () => {
|
218
|
-
const { response } = await dialog.showMessageBox({
|
219
|
-
title: "L'application a cessé de répondre",
|
220
|
-
message : 'Voulez vous relancer l\'application?',
|
221
|
-
buttons: ['Relancer', 'Arrêter'],
|
222
|
-
cancelId: 1
|
223
|
-
});
|
224
|
-
if (response === 0) {
|
225
|
-
mainWindow.forcefullyCrashRenderer()
|
226
|
-
mainWindow.reload()
|
227
|
-
} else {
|
228
|
-
mainWindow.forcefullyCrashRenderer()
|
229
|
-
app.exit();
|
230
|
-
}
|
231
|
-
});
|
232
|
-
|
233
|
-
// Émit lorsque la fenêtre est fermée.
|
234
|
-
mainWindow.on('closed', () => {
|
235
|
-
mainWindow = null
|
236
|
-
})
|
237
|
-
mainWindow.setMenu(null);
|
238
|
-
|
239
|
-
/*** les dimenssions de la fenêtre principale */
|
240
|
-
let mWindowSessinName = "mainWindowSizes";
|
241
|
-
let mWindowPositionSName = mWindowSessinName+"-positions";
|
242
|
-
let sizeW = session.get(mWindowSessinName);
|
243
|
-
if(!sizeW || typeof sizeW !== 'object'){
|
244
|
-
sizeW = {};
|
245
|
-
}
|
246
|
-
let sPositions = session.get(mWindowPositionSName);
|
247
|
-
if(!sPositions || typeof sPositions !=='object'){
|
248
|
-
sPositions = {};
|
249
|
-
}
|
250
|
-
let isNumber = x => typeof x =="number";
|
251
|
-
if(isNumber(sizeW.width) && isNumber(sizeW.height)){
|
252
|
-
mainWindow.setSize(sizeW.width,sizeW.height);
|
253
|
-
if(isNumber(sPositions.x) && isNumber(sPositions.y)){
|
254
|
-
mainWindow.setPosition(sPositions.x,sPositions.y);
|
255
|
-
}
|
256
|
-
}
|
257
|
-
const onWinResizeEv = debounce(function () {
|
258
|
-
if(mainWindow){
|
259
|
-
let wSize = mainWindow.getSize();
|
260
|
-
if(Array.isArray(wSize) && wSize.length == 2){
|
261
|
-
let [width,height] = wSize;
|
262
|
-
if(width && height){
|
263
|
-
session.set(mWindowSessinName,{width,height});
|
264
|
-
}
|
265
|
-
let [x,y] = mainWindow.getPosition();
|
266
|
-
session.set(mWindowPositionSName,{x,y});
|
267
|
-
}
|
268
|
-
}
|
269
|
-
}, 100);
|
270
|
-
mainWindow.off('resize',onWinResizeEv);
|
271
|
-
mainWindow.on('resize',onWinResizeEv);
|
272
|
-
mainWindow.off('move',onWinResizeEv);
|
273
|
-
mainWindow.on('move',onWinResizeEv);
|
274
|
-
if(typeof mainProcess.onCreateMainWindow =='function'){
|
275
|
-
mainProcess.onCreateMainWindow(mainWindow);
|
276
|
-
}
|
277
|
-
return mainWindow;
|
278
|
-
}
|
279
|
-
|
280
|
-
const toggleDevTools = (value)=>{
|
281
|
-
if(mainWindow !==null && mainWindow.webContents){
|
282
|
-
const isOpen= mainWindow.webContents.isDevToolsOpened();
|
283
|
-
value = value === undefined ? !isOpen : value;
|
284
|
-
if(value && !isOpen){
|
285
|
-
mainWindow.webContents.openDevTools();
|
286
|
-
return mainWindow.webContents.isDevToolsOpened();
|
287
|
-
} else {
|
288
|
-
if(isOpen) mainWindow.webContents.closeDevTools();
|
289
|
-
}
|
290
|
-
return mainWindow.webContents.isDevToolsOpened();
|
291
|
-
}
|
292
|
-
return false;
|
293
|
-
}
|
294
|
-
ipcMain.on("toggle-dev-tools",function(event,value) {
|
295
|
-
return toggleDevTools(value);
|
296
|
-
});
|
297
|
-
|
298
|
-
ipcMain.handle("create-browser-windows",function(event,options){
|
299
|
-
if(typeof options =='string'){
|
300
|
-
try {
|
301
|
-
const t = JSON.parse(options);
|
302
|
-
options = t;
|
303
|
-
} catch{}
|
304
|
-
}
|
305
|
-
options = Object.assign({},options);
|
306
|
-
createBrowserWindow(options);
|
307
|
-
});
|
308
|
-
|
309
|
-
ipcMain.on("restart-app",x =>{
|
310
|
-
app.relaunch();
|
311
|
-
});
|
312
|
-
let tray = null;
|
313
|
-
ipcMain.on("update-system-tray",(event,opts)=>{
|
314
|
-
opts = opts && typeof opts == 'object'? opts : {};
|
315
|
-
let {contextMenu,tooltip} = opts;
|
316
|
-
if(tray){
|
317
|
-
} else {
|
318
|
-
tray = new Tray();
|
319
|
-
}
|
320
|
-
if(!tooltip || typeof tooltip !=="string"){
|
321
|
-
tooltip = ""
|
322
|
-
}
|
323
|
-
tray.setToolTip(tooltip);
|
324
|
-
if(isJSON(contextMenu)){
|
325
|
-
contextMenu = JSON.parse(contextMenu);
|
326
|
-
}
|
327
|
-
if(Array.isArray(contextMenu) && contextMenu.length) {
|
328
|
-
let tpl = []
|
329
|
-
contextMenu.map((m,index)=>{
|
330
|
-
if(!m || typeof m !=='object') return;
|
331
|
-
m.click = (e)=>{
|
332
|
-
if(mainWindow && mainWindow.webContents) mainWindow.webContents.send("click-on-system-tray-menu-item",{
|
333
|
-
action : m.action && typeof m.action =='string'? m.action : undefined,
|
334
|
-
index,
|
335
|
-
menuItem : JSON.stringify(m),
|
336
|
-
})
|
337
|
-
}
|
338
|
-
tpl.push(m);
|
339
|
-
})
|
340
|
-
contextMenu = Menu.buildFromTemplate(tpl);
|
341
|
-
} else contextMenu = null;
|
342
|
-
tray.setContextMenu(contextMenu)
|
343
|
-
});
|
344
|
-
|
345
|
-
ipcMain.on("get-path",(event,pathName)=>{
|
346
|
-
const p = app.getPath(pathName);
|
347
|
-
event.returnValue = p;
|
348
|
-
return p;
|
349
|
-
});
|
350
|
-
ipcMain.on("get-app-path",(event,pathName)=>{
|
351
|
-
event.returnValue = appPath;
|
352
|
-
return appPath;
|
353
|
-
});
|
354
|
-
ipcMain.on("get-project-root",(event)=>{
|
355
|
-
event.returnValue = appPath;
|
356
|
-
return event.returnValue;
|
357
|
-
});
|
358
|
-
|
359
|
-
ipcMain.on("get-process-cwd",(event)=>{
|
360
|
-
event.returnValue = processCWD;
|
361
|
-
return event.returnValue ;
|
362
|
-
});
|
363
|
-
|
364
|
-
ipcMain.on("get-package.json",(event)=>{
|
365
|
-
event.returnValue = JSON.stringify(packageJSON);
|
366
|
-
return event.returnValue ;
|
367
|
-
});
|
368
|
-
|
369
|
-
ipcMain.on("get-app-name",(event)=>{
|
370
|
-
event.returnValue = appName;
|
371
|
-
return event.returnValue ;
|
372
|
-
});
|
373
|
-
|
374
|
-
ipcMain.on("get-media-access-status",(event,mediaType)=>{
|
375
|
-
let p = systemPreferences.getMediaAccessStatus(mediaType);
|
376
|
-
event.returnValue = p;
|
377
|
-
return p;
|
378
|
-
});
|
379
|
-
|
380
|
-
ipcMain.on("ask-for-media-access",(event,mediaType)=>{
|
381
|
-
systemPreferences.askForMediaAccess(mediaType);
|
382
|
-
});
|
383
|
-
|
384
|
-
ipcMain.on("get-app-icon",(event)=>{
|
385
|
-
event.returnValue = mainWindow != mainWindow && mainWindow.getIcon && mainWindow.getIcon();
|
386
|
-
});
|
387
|
-
ipcMain.on("set-app-icon",(event,iconPath)=>{
|
388
|
-
if(iconPath && mainWindow != null){
|
389
|
-
mainWindow.setIcon(iconPath);
|
390
|
-
event.returnValue = iconPath;
|
391
|
-
} else {
|
392
|
-
event.returnValue = null;
|
393
|
-
}
|
394
|
-
});
|
395
|
-
|
396
|
-
ipcMain.on('minimize-main-window', () => {
|
397
|
-
if(mainWindow !== null && mainWindow){
|
398
|
-
mainWindow.blur();
|
399
|
-
mainWindow.minimize();
|
400
|
-
}
|
401
|
-
})
|
402
|
-
ipcMain.on('restore-main-window', () => {
|
403
|
-
if(mainWindow && mainWindow !== null){
|
404
|
-
mainWindow.restore()
|
405
|
-
mainWindow.blur();
|
406
|
-
setTimeout(() => {
|
407
|
-
mainWindow.focus();
|
408
|
-
mainWindow.moveTop();
|
409
|
-
mainWindow.webContents.focus();
|
410
|
-
}, 200);
|
411
|
-
}
|
412
|
-
})
|
413
|
-
ipcMain.on('close-main-render-process', _ => {
|
414
|
-
if(mainWindow){
|
415
|
-
mainWindow.destroy();
|
416
|
-
}
|
417
|
-
mainWindow = null;
|
418
|
-
if(typeof gc =="function"){
|
419
|
-
gc();
|
420
|
-
}
|
421
|
-
quit();
|
422
|
-
});
|
423
|
-
|
424
|
-
const powerMonitorCallbackEvent = (action)=>{
|
425
|
-
if(!mainWindow || !mainWindow.webContents) return;
|
426
|
-
if(action =="suspend" || action =="lock-screen"){
|
427
|
-
mainWindow.webContents.send("main-app-suspended",action);
|
428
|
-
return;
|
429
|
-
}
|
430
|
-
mainWindow.webContents.send("main-app-restaured",action);
|
431
|
-
mainWindow.webContents.focus();
|
432
|
-
return null;
|
433
|
-
}
|
434
|
-
if(powerMonitor){
|
435
|
-
["suspend","resume","lock-screen","unlock-screen"].map((action)=>{
|
436
|
-
powerMonitor.on(action,(event)=>{
|
437
|
-
powerMonitorCallbackEvent(action,event);
|
438
|
-
})
|
439
|
-
})
|
440
|
-
}
|
441
|
-
ipcMain.on("set-main-window-title",(event,title)=>{
|
442
|
-
if(mainWindow !== null){
|
443
|
-
mainWindow.setTitle(title);
|
444
|
-
}
|
445
|
-
});
|
446
|
-
|
447
|
-
ipcMain.handle("show-open-dialog",function(event,options){
|
448
|
-
if(typeof options =="string"){
|
449
|
-
try {
|
450
|
-
const t = JSON.parse(options);
|
451
|
-
options = t;
|
452
|
-
} catch{}
|
453
|
-
}
|
454
|
-
if(!isObj(options)){
|
455
|
-
options = {};
|
456
|
-
}
|
457
|
-
return dialog.showOpenDialog(mainWindow,options)
|
458
|
-
})
|
459
|
-
|
460
|
-
ipcMain.handle("show-save-dialog",function(event,options){
|
461
|
-
if(!isObj(options)){
|
462
|
-
options = {};
|
463
|
-
}
|
464
|
-
return dialog.showSaveDialog(mainWindow,options)
|
465
|
-
});
|
466
|
-
|
467
|
-
ipcMain.on("is-dev-tools-open",function(event,value) {
|
468
|
-
if(mainWindow !==null && mainWindow.webContents){
|
469
|
-
return mainWindow.webContents.isDevToolsOpened();
|
470
|
-
}
|
471
|
-
return false;
|
472
|
-
});
|
473
|
-
|
474
|
-
ipcMain.on("window-set-progressbar",(event,interval)=>{
|
475
|
-
if(typeof interval !="number" || interval <0) interval = 0;
|
476
|
-
interval = Math.floor(interval);
|
477
|
-
if(mainWindow){
|
478
|
-
mainWindow.setProgressBar(interval);
|
479
|
-
}
|
480
|
-
});
|
481
|
-
|
482
|
-
/**** customisation des thèmes de l'application */
|
483
|
-
ipcMain.handle('set-system-theme:toggle', (event,theme) => {
|
484
|
-
theme = theme && typeof theme == "string"? theme : "light";
|
485
|
-
theme = theme.toLowerCase().trim();
|
486
|
-
if(theme !== 'system' && theme !=='dark'){
|
487
|
-
theme = "light";
|
488
|
-
}
|
489
|
-
nativeTheme.themeSource = theme;
|
490
|
-
session.set("os-theme",theme);
|
491
|
-
return nativeTheme.shouldUseDarkColors
|
492
|
-
});
|
493
|
-
|
494
|
-
ipcMain.handle('set-system-theme:dark-mode', (event) => {
|
495
|
-
nativeTheme.themeSource = 'dark';
|
496
|
-
return nativeTheme.shouldUseDarkColors;
|
497
|
-
});
|
498
|
-
ipcMain.handle('set-system-theme:light-mode', (event) => {
|
499
|
-
nativeTheme.themeSource = 'light';
|
500
|
-
return nativeTheme.shouldUseDarkColors;
|
501
|
-
});
|
502
|
-
|
503
|
-
|
504
|
-
ipcMain.handle('dark-mode:toggle', () => {
|
505
|
-
if (nativeTheme.shouldUseDarkColors) {
|
506
|
-
nativeTheme.themeSource = 'light'
|
507
|
-
} else {
|
508
|
-
nativeTheme.themeSource = 'dark'
|
509
|
-
}
|
510
|
-
return nativeTheme.shouldUseDarkColors
|
511
|
-
})
|
512
|
-
|
513
|
-
ipcMain.handle('dark-mode:system', () => {
|
514
|
-
nativeTheme.themeSource = 'system'
|
515
|
-
});
|
516
|
-
|
517
|
-
const clipboadContextMenu = (_, props) => {
|
518
|
-
if (props.isEditable || props.selectionText) {
|
519
|
-
const menu = new Menu();
|
520
|
-
if(props.selectionText){
|
521
|
-
menu.append(new MenuItem({ label: 'Copier', role: 'copy' }));
|
522
|
-
if(props.isEditable){
|
523
|
-
menu.append(new MenuItem({ label: 'Couper', role: 'cut' }));
|
524
|
-
}
|
525
|
-
}
|
526
|
-
if(props.isEditable){
|
527
|
-
menu.append(new MenuItem({ label: 'Coller', role: 'paste' }));
|
528
|
-
}
|
529
|
-
menu.popup();
|
530
|
-
}
|
531
|
-
};
|
532
|
-
|
533
|
-
// Quitte l'application quand toutes les fenêtres sont fermées.
|
534
|
-
app.on('window-all-closed', () => {
|
535
|
-
// Sur macOS, il est commun pour une application et leur barre de menu
|
536
|
-
// de rester active tant que l'utilisateur ne quitte pas explicitement avec Cmd + Q
|
537
|
-
if (process.platform !== 'darwin') {
|
538
|
-
quit();
|
539
|
-
}
|
540
|
-
});
|
541
|
-
|
542
|
-
if(mainProcess.enableSingleInstance !== false){
|
543
|
-
const gotTheLock = app.requestSingleInstanceLock()
|
544
|
-
if (appIsReady && !gotTheLock) {
|
545
|
-
quit();
|
546
|
-
} else {
|
547
|
-
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
548
|
-
// Someone tried to run a second instance, we should focus our window.
|
549
|
-
//pour plus tard il sera possible d'afficher la gestion multi fenêtre en environnement electron
|
550
|
-
if (mainWindow) {
|
551
|
-
if (mainWindow.isMinimized()) mainWindow.restore()
|
552
|
-
mainWindow.focus()
|
553
|
-
}
|
554
|
-
})
|
555
|
-
}
|
556
|
-
}
|
package/electron/init/index.js
DELETED
File without changes
|
package/electron/init/main.js
DELETED
@@ -1,55 +0,0 @@
|
|
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 = {
|
11
|
-
enableSingleInstance: true, // si l'application n'autorise qu'une seule instance active. ça sous entend qu'à l'instant t, une seule instance de l'application ne peut être exécutée sur le profil de l'utilisateur lambda
|
12
|
-
/**** cette fonction est appelée à chaque fois que l'on désire créer une instance du BrowserWindow
|
13
|
-
@param {object} BrowserWindowOptions
|
14
|
-
Lors de la création de la fenêtre principal, BrowserWindowOptions continent la propriété isMainWindow à true
|
15
|
-
la prop isMainWindow {boolean} spécifie s'il s'agit de la fenêtre principale
|
16
|
-
la prop isPDFWindow {boolean}, spécifie s'il s'agit de la fenêtre destinée à l'affichage d'un fichier pdf
|
17
|
-
l'objet retourné est utilisé pour étendre les options à utiliser pour la création du BrowserWidow
|
18
|
-
@return {object};
|
19
|
-
*/
|
20
|
-
beforeCreateWindow : function({isMainWindow,isPDFWindow,...BrowserWindowOptions}){
|
21
|
-
return {};
|
22
|
-
},
|
23
|
-
/*** exécutée lorsque l'évènement ready-to-show de la fenêtre principale BrowserWindow est appelée
|
24
|
-
@param {Instance of BrowserWindow} mainBrowserWindow
|
25
|
-
*/
|
26
|
-
onMainWindowReadyToShow : function(mainBrowserWindow){},
|
27
|
-
/**** exécutée lorsque l'évènement close de la fenêtre principale est appelée
|
28
|
-
@param {Instance of BrowserWindow} mainBrowserWindow
|
29
|
-
*/
|
30
|
-
onMainWindowClose : function(mainBrowserWindow){},
|
31
|
-
/**** exécutée lorsque l'évènement closed de la fenêtre principale est appélée
|
32
|
-
@param {InstanceOf BrowserWindow} mainBrowserWindow
|
33
|
-
*/
|
34
|
-
onMainWindowClosed : function(mainBrowserWindow){},
|
35
|
-
/*****
|
36
|
-
must return an Instance of Browser window
|
37
|
-
width: 500, height: 400, transparent: true, frame: false, alwaysOnTop: true
|
38
|
-
@param {width{number|500},{height{number|400}},transparent{boolean|true}, frame{boolean|false}, alwaysOnTop{boolean|true}}
|
39
|
-
@return {InstanceOf(BrowserWindow)}
|
40
|
-
*/
|
41
|
-
splashScreen : function({width, height, transparent, frame, alwaysOnTop}){
|
42
|
-
return null;
|
43
|
-
},
|
44
|
-
/*** this function is called when app is ready
|
45
|
-
toggleDevTools : {function},la fonction permettant de toggle les outils de developements
|
46
|
-
browserWindow|mainWindow : {BrowserWindow}, le browser window principal de l'application
|
47
|
-
*/
|
48
|
-
whenAppReady : function({toggleDevTools,browserWindow,mainWindow}){},
|
49
|
-
/*** exécutée une fois que la fonction createWindow est appelée pour créer le main Browser window de l'application
|
50
|
-
@param {InstanceOf BrowserWindow} mainBrowserWindow
|
51
|
-
*/
|
52
|
-
onCreateMainWindow : function(mainBrowserWindow){
|
53
|
-
|
54
|
-
}
|
55
|
-
}
|
@@ -1,11 +0,0 @@
|
|
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,'processes',"main","index.js"))
|
9
|
-
&& fs.existsSync(path.resolve(projectRoot,'processes',"renderer","index.js"))
|
10
|
-
&& true || false;
|
11
|
-
}
|