Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Commit

Permalink
Update electron to 1.7.9 and fix typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bilou84 committed Oct 28, 2017
1 parent 68ba439 commit b6703d1
Show file tree
Hide file tree
Showing 12 changed files with 6,461 additions and 2,171 deletions.
8,582 changes: 6,434 additions & 2,148 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"devDependencies": {
"@types/async": "^2.0.32",
"@types/electron": "^1.4.25",
"@types/electron": "^1.6.10",
"@types/electron-packager": "^5.1.29",
"@types/escape-html": "0.0.19",
"@types/lodash": "^4.14.37",
Expand All @@ -39,7 +39,6 @@
"gulp-tslint": "^4.3.1",
"gulp-typescript": "^3.1.2",
"tslint": "^3.12.1",
"typescript": "^2.0.6",
"yargs": "^4.1.0"
"typescript": "^2.0.6"
}
}
2 changes: 1 addition & 1 deletion public/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0-dev",
"main": "main.js",
"superpowers": {
"electron": "1.3.8",
"electron": "1.7.9",
"appApiVersion": 4
}
}
2 changes: 1 addition & 1 deletion scripts/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ packager({
}
}, (err, oldPaths) => {
if (err) throw err;

const buildPaths = [];
for (const oldPath of oldPaths) {
const newPath = oldPath
Expand Down
16 changes: 8 additions & 8 deletions src/SupApp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ interface OpenWindowOptions {
resizable?: boolean;
}

function onFolderChosen(event: Electron.IpcRendererEvent, ipcId: string, folderPath: string) {
function onFolderChosen(event: Electron.Event, ipcId: string, folderPath: string) {
const callback = ipcCallbacks[ipcId] as ChooseFolderCallback;
if (callback == null) return;
delete ipcCallbacks[ipcId];

callback(folderPath);
}

function onFileChosen(event: Electron.IpcRendererEvent, ipcId: string, filename: string) {
function onFileChosen(event: Electron.Event, ipcId: string, filename: string) {
const callback = ipcCallbacks[ipcId] as ChooseFileCallback;
if (callback == null) return;
delete ipcCallbacks[ipcId];

callback(filename);
}

function onFolderAuthorized(event: Electron.IpcRendererEvent, ipcId: string) {
function onFolderAuthorized(event: Electron.Event, ipcId: string) {
const callback = ipcCallbacks[ipcId] as AuthorizeFolderCallback;
if (callback == null) return;
delete ipcCallbacks[ipcId];
Expand All @@ -69,7 +69,7 @@ function checkPathAuthorization(pathToCheck: string, callback: CheckPathAuthoriz
electron.ipcRenderer.send("check-path-authorization", secretKey, ipcId, window.location.origin, pathToCheck);
}

function onPathAuthorizationChecked(event: Electron.IpcRendererEvent, ipcId: string, checkedPath: string, authorization: "readWrite"|"execute") {
function onPathAuthorizationChecked(event: Electron.Event, ipcId: string, checkedPath: string, authorization: "readWrite"|"execute") {
const callback = ipcCallbacks[ipcId] as CheckPathAuthorizationCallback;
if (callback == null) return;
delete ipcCallbacks[ipcId];
Expand All @@ -79,7 +79,7 @@ function onPathAuthorizationChecked(event: Electron.IpcRendererEvent, ipcId: str

namespace SupApp {
export function onMessage(messageType: string, callback: Function) {
electron.ipcRenderer.addListener(`sup-app-message-${messageType}`, (event, ...args) => { callback(...args); });
electron.ipcRenderer.addListener(`sup-app-message-${messageType}`, (event: Electron.Event, args: any[]) => { callback(...args); });
}
export function sendMessage(windowId: number, message: string) {
electron.ipcRenderer.send("send-message", windowId, message);
Expand All @@ -98,7 +98,7 @@ namespace SupApp {

if (options.resizable == null) options.resizable = true;

const electronWindowOptions: Electron.BrowserWindowOptions = {
const electronWindowOptions: Electron.BrowserWindowConstructorOptions = {
icon: `${__dirname}/../superpowers.ico`,
useContentSize: true, autoHideMenuBar: true,
resizable: options.resizable,
Expand Down Expand Up @@ -126,7 +126,7 @@ namespace SupApp {
export function showItemInFolder(path: string) { electron.shell.showItemInFolder(path); }

export function createMenu() { return new electron.remote.Menu(); }
export function createMenuItem(options: Electron.MenuItemOptions) {
export function createMenuItem(options: Electron.MenuItemConstructorOptions) {
return new electron.remote.MenuItem(options);
}

Expand Down Expand Up @@ -172,7 +172,7 @@ namespace SupApp {

export function mktmpdir(callback: (err: any, path: string) => void) {
let tempFolderPath: string;
async.retry(10, (cb: ErrorCallback<NodeJS.ErrnoException>) => {
async.retry(10, (cb) => {
let folderName = "superpowers-temp-";
for (let i = 0; i < 16; i++) folderName += getRandomTmpCharacter();
tempFolderPath = `${tmpRoot}/${folderName}`;
Expand Down
12 changes: 6 additions & 6 deletions src/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ electron.ipcMain.on("send-message", onSendMessage);

const secretKeys = new Map<Electron.WebContents, string>();

function onSetupKey(event: Electron.IpcMainEvent, secretKey: string) {
function onSetupKey(event: Electron.Event, secretKey: string) {
if (secretKeys.has(event.sender)) return;
secretKeys.set(event.sender, secretKey);
}

function onChooseFolder(event: Electron.IpcMainEvent, secretKey: string, ipcId: string, origin: string) {
function onChooseFolder(event: Electron.Event, secretKey: string, ipcId: string, origin: string) {
if (secretKeys.get(event.sender) !== secretKey) return;

electron.dialog.showOpenDialog({ properties: [ "openDirectory" ] }, (directory: string[]) => {
Expand All @@ -52,7 +52,7 @@ function onChooseFolder(event: Electron.IpcMainEvent, secretKey: string, ipcId:
});
}

function onChooseFile(event: Electron.IpcMainEvent, secretKey: string, ipcId: string, origin: string, access: "readWrite"|"execute") {
function onChooseFile(event: Electron.Event, secretKey: string, ipcId: string, origin: string, access: "readWrite"|"execute") {
if (secretKeys.get(event.sender) !== secretKey) return;

electron.dialog.showOpenDialog({ properties: [ "openFile" ] }, (file: string[]) => {
Expand All @@ -68,14 +68,14 @@ function onChooseFile(event: Electron.IpcMainEvent, secretKey: string, ipcId: st
});
}

function onAuthorizeFolder(event: Electron.IpcMainEvent, secretKey: string, ipcId: string, origin: string, folderPath: string) {
function onAuthorizeFolder(event: Electron.Event, secretKey: string, ipcId: string, origin: string, folderPath: string) {
const normalizedPath = path.normalize(folderPath);
getAuthorizationsForOrigin(origin).folders.push(normalizedPath);

event.sender.send("authorize-folder-callback", ipcId);
}

function onCheckPathAuthorization(event: Electron.IpcMainEvent, secretKey: string, ipcId: string, origin: string, pathToCheck: string) {
function onCheckPathAuthorization(event: Electron.Event, secretKey: string, ipcId: string, origin: string, pathToCheck: string) {
if (secretKeys.get(event.sender) !== secretKey) return;

const normalizedPath = path.normalize(pathToCheck);
Expand All @@ -98,7 +98,7 @@ function onCheckPathAuthorization(event: Electron.IpcMainEvent, secretKey: strin
event.sender.send("check-path-authorization-callback", ipcId, normalizedPath, authorization);
}

function onSendMessage(event: Electron.IpcMainEvent, windowId: number, message: string, args: any[] = []) {
function onSendMessage(event: Electron.Event, windowId: number, message: string, args: any[] = []) {
const window = electron.BrowserWindow.fromId(windowId);
if (window == null) return;

Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function startCleanExit() {
isQuitting = true;
}

electron.ipcMain.on("ready-to-quit", (event) => {
electron.ipcMain.on("ready-to-quit", (event: Electron.Event) => {
if (event.sender !== mainWindow.webContents) return;

SupAppIPC.saveAuthorizations(userDataPath);
Expand Down
2 changes: 1 addition & 1 deletion src/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function setup(app: Electron.App) {
}

const name = app.getName();
const template: Electron.MenuItemOptions[] = [
const template: Electron.MenuItemConstructorOptions[] = [
{
label: name,
submenu: [
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ html
label= t("welcome:askGameInstall.waiting")

script.
// Workaround some error with module generation. See https://github.com/Microsoft/TypeScript/issues/14351
const exports = {};

window.addEventListener("keyup", (event) => {
if (event.keyCode === 123 /* F12 */) electron.remote.getCurrentWindow().webContents.openDevTools();
});
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ function installFirstSystem(callback: Function) {

const label = i18n.t("welcome:sidebarInformation.info");
const options = {
header: i18n.t("welcome:sidebarInformation.title")
header: i18n.t("welcome:sidebarInformation.title"),
closeLabel: dialogs.BaseDialog.defaultLabels.close
};

new dialogs.InfoDialog(label, options, cb);
Expand Down
1 change: 1 addition & 0 deletions src/renderer/serverSettings/systems.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as electron from "electron";
import { ChildProcess } from "child_process";
import * as async from "async";
import forkServerProcess from "../forkServerProcess";
import * as TreeView from "dnd-tree-view";
import * as dialogs from "simple-dialogs";
Expand Down
2 changes: 1 addition & 1 deletion src/shared/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function fetch(url: string, type: string, callback: (err: Error, data?: any) => any) {
export default function fetch(url: string, type: XMLHttpRequestResponseType, callback: (err: Error, data?: any) => any) {
const xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.responseType = type;
Expand Down

0 comments on commit b6703d1

Please sign in to comment.