Skip to content

Commit db6bed4

Browse files
fix memory leak and remove package
1 parent 80d160a commit db6bed4

File tree

6 files changed

+15
-68
lines changed

6 files changed

+15
-68
lines changed

ElectronNET.Host/api/browserWindows.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/browserWindows.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/browserWindows.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
204204
window = app['mainWindow'];
205205
if (window) {
206206
window.reload();
207+
windows.push(window);
208+
electronSocket.emit('BrowserWindowCreated', window.id);
209+
return;
207210
}
208211
} else {
209212
window = new BrowserWindow(options);

ElectronNET.Host/main.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const path = require('path');
44
const cProcess = require('child_process').spawn;
55
const portscanner = require('portscanner');
66
const imageSize = require('image-size');
7-
const chalk = require('chalk');
87
let io, server, browserWindows, ipc, apiProcess, loadURL;
98
let appApi, menu, dialogApi, notification, tray, webContents;
109
let globalShortcut, shellApi, screen, clipboard, autoUpdater;
@@ -56,7 +55,7 @@ app.on('ready', () => {
5655

5756
// hostname needs to belocalhost, otherwise Windows Firewall will be triggered.
5857
portscanner.findAPortNotInUse(8000, 65535, 'localhost', function (error, port) {
59-
console.log(chalk.blue('Electron Socket IO Port: ' + port));
58+
console.log('Electron Socket IO Port: ' + port);
6059
startSocketApiBridge(port);
6160
});
6261

@@ -76,8 +75,8 @@ function startSplashScreen() {
7675
let imageFile = path.join(currentBinPath, manifestJsonFile.splashscreen.imageFile);
7776
imageSize(imageFile, (error, dimensions) => {
7877
if (error) {
79-
console.log(chalk.bold.red(`load splashscreen error:`));
80-
console.log(chalk.bold.red(error));
78+
console.log(`load splashscreen error:`);
79+
console.error(error);
8180

8281
throw new Error(error.message);
8382
}
@@ -118,7 +117,7 @@ function startSocketApiBridge(port) {
118117

119118
server.listen(port, 'localhost');
120119
server.on('listening', function () {
121-
console.log(chalk.bgGreenBright('Electron Socket started on port %s at %s', server.address().port, server.address().address));
120+
console.log('Electron Socket started on port %s at %s', server.address().port, server.address().address);
122121
// Now that socket connection is established, we can guarantee port will not be open for portscanner
123122
if (watchable) {
124123
startAspCoreBackendWithWatch(port);
@@ -137,7 +136,7 @@ function startSocketApiBridge(port) {
137136
// otherwise it will fire the same event multiple depends how many time
138137
// live reload watch happen.
139138
socket.on('disconnect', function () {
140-
console.log(chalk.bold.red('Got disconnect!'));
139+
console.log('Got disconnect!');
141140
delete require.cache[require.resolve('./api/app')];
142141
delete require.cache[require.resolve('./api/browserWindows')];
143142
delete require.cache[require.resolve('./api/commandLine')];
@@ -157,7 +156,7 @@ function startSocketApiBridge(port) {
157156

158157
global['electronsocket'] = socket;
159158
global['electronsocket'].setMaxListeners(0);
160-
console.log(chalk.bold.bgCyan('ASP.NET Core Application connected...', 'global.electronsocket', global['electronsocket'].id, new Date()));
159+
console.log('ASP.NET Core Application connected...', 'global.electronsocket', global['electronsocket'].id, new Date());
161160

162161
appApi = require('./api/app')(socket, app);
163162
browserWindows = require('./api/browserWindows')(socket, app);
@@ -186,7 +185,7 @@ function startSocketApiBridge(port) {
186185
hostHook.onHostReady();
187186
}
188187
} catch (error) {
189-
console.log(chalk.bold.red(error.message));
188+
console.error(error.message);
190189
}
191190
});
192191
}
@@ -252,7 +251,7 @@ function startAspCoreBackendWithWatch(electronPort) {
252251
apiProcess = cProcess('dotnet', parameters, options);
253252

254253
apiProcess.stdout.on('data', (data) => {
255-
console.log(chalk.bold.blue(`${data.toString()}`));
254+
console.log(`stdout: ${data.toString()}`);
256255
});
257256
}
258257
}

ElectronNET.Host/package-lock.json

Lines changed: 0 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"start": "tsc -p ."
1313
},
1414
"dependencies": {
15-
"chalk": "^4.0.0",
1615
"dasherize": "^2.0.0",
1716
"electron-updater": "^4.2.5",
1817
"image-size": "^0.7.4",

0 commit comments

Comments
 (0)