From 35c1e8aa058b54808cf16be08cc2b13779b5ffac Mon Sep 17 00:00:00 2001 From: LawnCable Date: Tue, 5 Nov 2019 03:39:34 +0100 Subject: upgrade to electron 4 --- package-lock.json | 238 +++++++++++++++++++++--------------------------------- package.json | 2 +- src/main.ts | 86 +++++++++----------- 3 files changed, 132 insertions(+), 194 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7f4bc8c..c9d2800 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mana-launcher", - "version": "1.0.2", + "version": "1.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -393,12 +393,6 @@ "sax": "^1.2.4" } }, - "builtin-modules": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true - }, "camelcase": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", @@ -701,17 +695,32 @@ "resolved": "https://registry.npmjs.org/discord-rich-presence/-/discord-rich-presence-0.0.8.tgz", "integrity": "sha512-IpVMPjv15C9UvppxvrrGdv6bzQHOW1P1vLoMH15HvdJwGJ3dBd2bnrJ63Uy36YRUfrAMxGLiwUDHncvC8AuPaQ==", "requires": { - "discord-rpc": "github:discordjs/rpc#60ddddc38d2bd3ffe6df91e518ac7974239562b5" + "discord-rpc": "github:discordjs/rpc" }, "dependencies": { "discord-rpc": { "version": "github:discordjs/rpc#60ddddc38d2bd3ffe6df91e518ac7974239562b5", "from": "github:discordjs/rpc", "requires": { - "node-fetch": "^2.3.0", - "ws": "^6.1.1" + "node-fetch": "2.6.0", + "ws": "7.1.2" + }, + "dependencies": { + "ws": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.1.2.tgz", + "integrity": "sha512-gftXq3XI81cJCgkUiAVixA0raD9IVmXqsylCrjRygw4+UOOGzPoxnQ6r/CnVL9i+mDncJo94tSkyrtuuQVBmrg==", + "requires": { + "async-limiter": "^1.0.0" + } + } } }, + "node-fetch": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" + }, "ws": { "version": "6.1.4", "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.4.tgz", @@ -790,14 +799,22 @@ "dev": true }, "electron": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/electron/-/electron-2.0.1.tgz", - "integrity": "sha512-piSwY2P7L6NWx672MNdSvtGPdQP/mhwAg8ICN6ofTTItPkd7D6kNHBPkq+DXwZcXVH1EifYR9yD/l3Xw1haVpQ==", + "version": "4.2.12", + "resolved": "https://registry.npmjs.org/electron/-/electron-4.2.12.tgz", + "integrity": "sha512-EES8eMztoW8gEP5E4GQLP8slrfS2jqTYtHbu36mlu3k1xYAaNPyQQr6mCILkYxqj4l3la4CT2Vcs89CUG62vcQ==", "dev": true, "requires": { - "@types/node": "^8.0.24", - "electron-download": "^3.0.1", + "@types/node": "^10.12.18", + "electron-download": "^4.1.0", "extract-zip": "^1.0.3" + }, + "dependencies": { + "@types/node": { + "version": "10.17.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.0.tgz", + "integrity": "sha512-wuJwN2KV4tIRz1bu9vq5kSPasJ8IsEjZaP1ZR7KlmdUZvGF/rXy8DmXOVwUD0kAtvtJ7aqMKPqUXC0NUTDbrDg==", + "dev": true + } } }, "electron-builder": { @@ -822,52 +839,47 @@ } }, "electron-download": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/electron-download/-/electron-download-3.3.0.tgz", - "integrity": "sha1-LP1U1pZsAZxNSa1l++Zcyc3vaMg=", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/electron-download/-/electron-download-4.1.1.tgz", + "integrity": "sha512-FjEWG9Jb/ppK/2zToP+U5dds114fM1ZOJqMAR4aXXL5CvyPE9fiqBK/9YcwC9poIFQTEJk/EM/zyRwziziRZrg==", "dev": true, "requires": { - "debug": "^2.2.0", - "fs-extra": "^0.30.0", - "home-path": "^1.0.1", + "debug": "^3.0.0", + "env-paths": "^1.0.0", + "fs-extra": "^4.0.1", "minimist": "^1.2.0", - "nugget": "^2.0.0", - "path-exists": "^2.1.0", - "rc": "^1.1.2", - "semver": "^5.3.0", - "sumchecker": "^1.2.0" + "nugget": "^2.0.1", + "path-exists": "^3.0.0", + "rc": "^1.2.1", + "semver": "^5.4.1", + "sumchecker": "^2.0.2" }, "dependencies": { "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } }, "fs-extra": { - "version": "0.30.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz", - "integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", + "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", "dev": true, "requires": { "graceful-fs": "^4.1.2", - "jsonfile": "^2.1.0", - "klaw": "^1.0.0", - "path-is-absolute": "^1.0.0", - "rimraf": "^2.2.8" + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" } }, - "jsonfile": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", - "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6" - } + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true } } }, @@ -935,21 +947,21 @@ "once": "^1.4.0" } }, + "env-paths": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-1.0.0.tgz", + "integrity": "sha1-QWgTO0K7BcOKNbGuQ5fIKYqzaeA=", + "dev": true + }, "error-ex": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", - "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", "dev": true, "requires": { "is-arrayish": "^0.2.1" } }, - "es6-promise": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", - "dev": true - }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -1039,6 +1051,17 @@ "requires": { "path-exists": "^2.0.0", "pinkie-promise": "^2.0.0" + }, + "dependencies": { + "path-exists": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "dev": true, + "requires": { + "pinkie-promise": "^2.0.0" + } + } } }, "forever-agent": { @@ -1089,12 +1112,6 @@ } } }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -1121,20 +1138,6 @@ "assert-plus": "^1.0.0" } }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, "global-dirs": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", @@ -1188,16 +1191,10 @@ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, - "home-path": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/home-path/-/home-path-1.0.6.tgz", - "integrity": "sha512-wo+yjrdAtoXt43Vy92a+0IPCYViiyLAHyp0QVS4xL/tfvVz5sXIW1ubLZk3nhVkD92fQpUMKX+fzMjr5F489vw==", - "dev": true - }, "hosted-git-info": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.0.tgz", - "integrity": "sha512-lIbgIIQA3lz5XaB6vxakj6sDHADJiZadYEJB+FgA+C4nubM1NwcuvUr9EJPmnH1skZqpqUzWborWo8EIUi0Sdw==", + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz", + "integrity": "sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==", "dev": true }, "http-signature": { @@ -1240,16 +1237,6 @@ "repeating": "^2.0.0" } }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", @@ -1273,15 +1260,6 @@ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true }, - "is-builtin-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", - "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", - "dev": true, - "requires": { - "builtin-modules": "^1.0.0" - } - }, "is-ci": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-2.0.0.tgz", @@ -1451,15 +1429,6 @@ "verror": "1.10.0" } }, - "klaw": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", - "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.9" - } - }, "latest-version": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-3.1.0.tgz", @@ -1662,12 +1631,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, - "ncp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", - "integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=", - "dev": true - }, "nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", @@ -1685,13 +1648,13 @@ "integrity": "sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==" }, "normalize-package-data": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", "dev": true, "requires": { "hosted-git-info": "^2.1.4", - "is-builtin-module": "^1.0.0", + "resolve": "^1.10.0", "semver": "2 || 3 || 4 || 5", "validate-npm-package-license": "^3.0.1" } @@ -1894,18 +1857,9 @@ } }, "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "requires": { - "pinkie-promise": "^2.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", "dev": true }, "path-is-inside": { @@ -2233,15 +2187,6 @@ "path-parse": "^1.0.6" } }, - "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", - "dev": true, - "requires": { - "glob": "^7.0.5" - } - }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -2455,13 +2400,12 @@ "dev": true }, "sumchecker": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-1.3.1.tgz", - "integrity": "sha1-ebs7RFbdBPGOvbwNcDodHa7FEF0=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-2.0.2.tgz", + "integrity": "sha1-D0LBDl0F2l1C7qPlbDOZo31sWz4=", "dev": true, "requires": { - "debug": "^2.2.0", - "es6-promise": "^4.0.5" + "debug": "^2.2.0" }, "dependencies": { "debug": { diff --git a/package.json b/package.json index d54aa1b..56369c8 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "author": "LawnCable", "license": "GNU GPLv3", "devDependencies": { - "electron": "^2.0.1", + "electron": "^4.2.9", "electron-builder": "^20.39.0", "typescript": "^2.8.3" }, diff --git a/src/main.ts b/src/main.ts index 9009b6f..202e24b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,16 +4,10 @@ import { app, BrowserWindow, ipcMain, remote, Tray, Menu, dialog } from 'electro // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. export let mainWindow: BrowserWindow; -const isSecondInstance = app.makeSingleInstance(() => { - // Someone tried to run a second instance, we should focus our window. - if (mainWindow) { - if (mainWindow.isMinimized()) mainWindow.restore() - mainWindow.focus() - } - }) - -if (isSecondInstance) { - app.quit(); + +if (!app.requestSingleInstanceLock()) { + // Someone tried to run a second instance + app.quit(); } const createWindow = () => { // Create the browser window. @@ -23,7 +17,7 @@ const createWindow = () => { minHeight: 475, minWidth: 650, frame: false, - icon: path.join(__dirname,"../assets/media/icon.ico") + icon: path.join(__dirname, "../assets/media/icon.ico") }); // and load the index.html of the app. @@ -60,50 +54,50 @@ app.on('activate', () => { } }); -ipcMain.on('quit', (event:any, arg:any)=> { - mainWindow.close(); +ipcMain.on('quit', (event: any, arg: any) => { + mainWindow.close(); }); -ipcMain.on('minimize', (event:any, arg:any)=> { +ipcMain.on('minimize', (event: any, arg: any) => { mainWindow.minimize(); }); -ipcMain.on('debug', (event:any, arg:any)=> { - if(mainWindow.webContents.isDevToolsOpened()) +ipcMain.on('debug', (event: any, arg: any) => { + if (mainWindow.webContents.isDevToolsOpened()) mainWindow.webContents.closeDevTools(); - else + else mainWindow.webContents.openDevTools(); Status.setActivity("Debug menue Toggled") }); -import {Status, EventEmitter} from './main/status'; +import { Status, EventEmitter } from './main/status'; -import {quit as drpcQuit} from './main/richpresence'; +import { quit as drpcQuit } from './main/richpresence'; app.on('quit', () => { drpcQuit(); if (appIcon) appIcon.destroy() }); -let appIcon:Tray = null; +let appIcon: Tray = null; -EventEmitter.on('openTray',()=>{ - if(!appIcon){ - const iconName = "../assets/media/plushmouboo.png"; - const iconPath = path.join(__dirname, iconName) - appIcon = new Tray(iconPath) +EventEmitter.on('openTray', () => { + if (!appIcon) { + const iconName = "../assets/media/plushmouboo.png"; + const iconPath = path.join(__dirname, iconName) + appIcon = new Tray(iconPath) - updateTrayIconMenue(); -} + updateTrayIconMenue(); + } }); -function updateTrayIconMenue(){ - if(appIcon && appIcon!==null){ - let menue:Electron.MenuItemConstructorOptions[] = []; - if(Status.getStatus().gameRunning){ +function updateTrayIconMenue() { + if (appIcon && appIcon !== null) { + let menue: Electron.MenuItemConstructorOptions[] = []; + if (Status.getStatus().gameRunning) { menue.push({ label: 'Open screenshot folder', click: () => { @@ -121,13 +115,13 @@ function updateTrayIconMenue(){ buttons: ['Yes', 'No'] } dialog.showMessageBox(options, (index) => { - if(index===0){ + if (index === 0) { EventEmitter.emit('Mana:killMana'); } }) } }); - }else{ + } else { menue.push({ label: 'Close Tray Icon', click: () => { @@ -144,7 +138,7 @@ function updateTrayIconMenue(){ EventEmitter.on('status', updateTrayIconMenue); -EventEmitter.on('closeTray',()=>{ +EventEmitter.on('closeTray', () => { if (appIcon) { appIcon.destroy(); appIcon = null; @@ -156,30 +150,30 @@ import { ManaPlus } from './main/manaplus/manaplus'; ManaPlus.init(); -ipcMain.on('play', async (event:any, arg:any) => { - if(Status.getStatus().playing)return; - //console.log("play", arg); - Status.setGameStatus({server: arg.address}) - Status.setPlaying(true); - await ManaPlus.start(arg); - //Status.showError("Failed To Launch Mana Plus","Not implemented yet!","Launch Manaplus faild: Not Implemented"); - return false; +ipcMain.on('play', async (event: any, arg: any) => { + if (Status.getStatus().playing) return; + //console.log("play", arg); + Status.setGameStatus({ server: arg.address }) + Status.setPlaying(true); + await ManaPlus.start(arg); + //Status.showError("Failed To Launch Mana Plus","Not implemented yet!","Launch Manaplus faild: Not Implemented"); + return false; }); -ipcMain.on('dragFileOut', (event:any, filepath:any) => { +ipcMain.on('dragFileOut', (event: any, filepath: any) => { event.sender.startDrag({ file: filepath, - icon:path.join(__dirname, "../assets/media/screenshot.png") + icon: path.join(__dirname, "../assets/media/screenshot.png") }) }) -EventEmitter.on('reopenWindow',()=>{ +EventEmitter.on('reopenWindow', () => { if (mainWindow === null) { createWindow(); } }); -EventEmitter.on('closeWindow',()=>{ +EventEmitter.on('closeWindow', () => { if (mainWindow !== null) { mainWindow.close(); } -- cgit v1.2.3-70-g09d2