Skip to content

Commit e328f7a

Browse files
authored
feat(electron): support for v7 (#172)
closes #162
1 parent 41a8c8e commit e328f7a

File tree

4 files changed

+70
-23
lines changed

4 files changed

+70
-23
lines changed

packages/electron-angular/src/schematics/application/_files/src/index.ts__tmpl__

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ const mainWindowSettings: Electron.BrowserWindowConstructorOptions = {
2424
focusable: true,
2525
fullscreenable: true,
2626
kiosk: false,
27+
// to hide title bar, uncomment:
28+
// titleBarStyle: 'hidden',
2729
webPreferences: {
28-
devTools: debugMode
30+
devTools: debugMode,
31+
nodeIntegration: debugMode
2932
}
3033
};
3134

@@ -48,7 +51,7 @@ function createWindow() {
4851
const sizes = screen.getPrimaryDisplay().workAreaSize;
4952

5053
if (debugMode) {
51-
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
54+
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true';
5255

5356
mainWindowSettings.width = 800;
5457
mainWindowSettings.height = 600;
@@ -98,10 +101,20 @@ function createWindow() {
98101
try {
99102
app.on('ready', createWindow);
100103

101-
app.on('window-all-closed', () => {
102-
if (process.platform !== 'darwin') {
103-
app.quit();
104-
}
104+
app.on('window-all-closed', quit);
105+
106+
ipcMain.on('quit', quit);
107+
108+
ipcMain.on('minimize', () => {
109+
win.minimize();
110+
});
111+
112+
ipcMain.on('maximize', () => {
113+
win.maximize();
114+
});
115+
116+
ipcMain.on('restore', () => {
117+
win.restore();
105118
});
106119

107120
app.on('activate', () => {
@@ -112,3 +125,9 @@ try {
112125
}
113126
});
114127
} catch (err) {}
128+
129+
function quit() {
130+
if (process.platform !== 'darwin') {
131+
app.quit();
132+
}
133+
}

packages/electron-angular/src/schematics/xplat/_files/core/services/electron.service.ts__tmpl__

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { LogService, WindowService } from '@<%= npmScope %>/core';
33
import { isElectron } from '@<%= npmScope %>/utils';
44
import * as childProcess from 'child_process';
55
import { ipcRenderer } from 'electron';
6+
import IpcRendererEvent = Electron.IpcRendererEvent;
67

78
@Injectable()
89
export class ElectronService {
9-
private _ipc: typeof ipcRenderer;
10+
private readonly _ipc: typeof ipcRenderer;
1011
private _childProcess: typeof childProcess;
1112

1213
constructor(private _log: LogService, private _win: WindowService) {
@@ -18,19 +19,27 @@ export class ElectronService {
1819
}
1920
}
2021

21-
public on(channel: string, listener: Function): void {
22+
on(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): void {
2223
if (!this._ipc) {
2324
return;
2425
}
2526

2627
this._ipc.on(channel, listener);
2728
}
2829

29-
public send(channel: string, ...args): void {
30+
send(channel: string, ...args): void {
3031
if (!this._ipc) {
3132
return;
3233
}
3334

3435
this._ipc.send(channel, ...args);
3536
}
37+
38+
sendSync(channel: string, ...args): void {
39+
if (!this._ipc) {
40+
return;
41+
}
42+
43+
this._ipc.sendSync(channel, ...args);
44+
}
3645
}

packages/electron/src/schematics/application/_files/src/index.ts__tmpl__

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ const mainWindowSettings: Electron.BrowserWindowConstructorOptions = {
2424
focusable: true,
2525
fullscreenable: true,
2626
kiosk: false,
27+
// to hide title bar, uncomment:
28+
// titleBarStyle: 'hidden',
2729
webPreferences: {
28-
devTools: debugMode
30+
devTools: debugMode,
31+
nodeIntegration: debugMode
2932
}
3033
};
3134

@@ -48,7 +51,7 @@ function createWindow() {
4851
const sizes = screen.getPrimaryDisplay().workAreaSize;
4952

5053
if (debugMode) {
51-
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
54+
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true';
5255

5356
mainWindowSettings.width = 800;
5457
mainWindowSettings.height = 600;
@@ -98,10 +101,20 @@ function createWindow() {
98101
try {
99102
app.on('ready', createWindow);
100103

101-
app.on('window-all-closed', () => {
102-
if (process.platform !== 'darwin') {
103-
app.quit();
104-
}
104+
app.on('window-all-closed', quit);
105+
106+
ipcMain.on('quit', quit);
107+
108+
ipcMain.on('minimize', () => {
109+
win.minimize();
110+
});
111+
112+
ipcMain.on('maximize', () => {
113+
win.maximize();
114+
});
115+
116+
ipcMain.on('restore', () => {
117+
win.restore();
105118
});
106119

107120
app.on('activate', () => {
@@ -112,3 +125,9 @@ try {
112125
}
113126
});
114127
} catch (err) {}
128+
129+
function quit() {
130+
if (process.platform !== 'darwin') {
131+
app.quit();
132+
}
133+
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
export const xplatVersion = '*';
2-
export const electronVersion = '^4.0.5';
3-
export const electronBuilderVersion = '^20.38.4';
4-
export const electronRebuildVersion = '~1.8.4';
2+
export const electronVersion = '^7.0.1';
3+
export const electronBuilderVersion = '^20.44.4';
4+
export const electronRebuildVersion = '~1.8.6';
55
export const electronInstallerDmgVersion = '~3.0.0';
6-
export const electronPackagerVersion = '~13.1.0';
7-
export const electronReloadVersion = '~1.4.0';
8-
export const electronStoreVersion = '~2.0.0';
9-
export const electronUpdaterVersion = '~4.0.6';
6+
export const electronPackagerVersion = '~14.1.0';
7+
export const electronReloadVersion = '~1.5.0';
8+
export const electronStoreVersion = '~5.1.0';
9+
export const electronUpdaterVersion = '~4.2.0';
1010
export const npmRunAllVersion = '^4.1.5';
11-
export const waitOnVersion = '~3.2.0';
11+
export const waitOnVersion = '~3.3.0';

0 commit comments

Comments
 (0)