Skip to content

Commit

Permalink
chore: use official electron typings
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed May 31, 2017
1 parent d86c05f commit 482fbbe
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 51 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Onshape",
"version": "0.5.9",
"version": "0.5.10",
"license": "MIT",
"description": "Onshape desktop app (web application shell)",
"author": "Vladimir Krivosheev <develar@gmail.com>",
Expand Down Expand Up @@ -53,10 +53,9 @@
},
"devDependencies": {
"@types/debug": "0.0.29",
"@types/electron": "^1.4.38",
"electron": "1.7.1",
"electron-builder": "next",
"rimraf": "^2.6.1",
"typescript": "^2.3.2"
"typescript": "^2.3.4"
}
}
16 changes: 8 additions & 8 deletions src/AppMenuManager.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {app, Menu, shell, BrowserWindow, ipcMain} from "electron";
import {WINDOW_NAVIGATED} from "./WindowManager";
import {AppSignal} from "./electronEventSignals";
import MenuItemOptions = Electron.MenuItemOptions
import { app, BrowserWindow, ipcMain, Menu, shell } from "electron"
import { AppSignal } from "./electronEventSignals"
import { WINDOW_NAVIGATED } from "./WindowManager"
import MenuItemConstructorOptions = Electron.MenuItemConstructorOptions
import WebContents = Electron.WebContents

export default function setMenu(homeUrl: string) {
const windowsMenu: MenuItemOptions = {
const windowsMenu: MenuItemConstructorOptions = {
label: 'Window',
role: 'window',
submenu: [
Expand All @@ -23,7 +23,7 @@ export default function setMenu(homeUrl: string) {
}

const name = app.getName()
const template: Array<MenuItemOptions> = [
const template: Array<MenuItemConstructorOptions> = [
{
label: 'Edit',
submenu: [
Expand Down Expand Up @@ -185,7 +185,7 @@ export default function setMenu(homeUrl: string) {
]
});

(<Array<MenuItemOptions>>(windowsMenu.submenu)).push(
(<Array<MenuItemConstructorOptions>>(windowsMenu.submenu)).push(
{
type: 'separator'
},
Expand All @@ -207,7 +207,7 @@ export default function setMenu(homeUrl: string) {
Menu.setApplicationMenu(appMenu)
}

function updateHistoryMenuItems(items: MenuItemOptions[], homeUrl: string) {
function updateHistoryMenuItems(items: Array<MenuItemConstructorOptions>, homeUrl: string) {
function updateEnabled(webContents: WebContents) {
items[0].enabled = webContents.canGoBack()
items[1].enabled = webContents.canGoForward()
Expand Down
7 changes: 3 additions & 4 deletions src/WindowManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import AppUpdater from "./AppUpdater"
import { WebContentsSignal, WindowEvent } from "./electronEventSignals"
import { DEFAULT_URL, StateManager, WindowItem } from "./StateManager"
import BrowserWindow = Electron.BrowserWindow
import BrowserWindowOptions = Electron.BrowserWindowOptions
import BrowserWindowConstructorOptions = Electron.BrowserWindowConstructorOptions

export const WINDOW_NAVIGATED = "windowNavigated"

Expand Down Expand Up @@ -45,8 +45,7 @@ export default class WindowManager {
}

private registerWindowEventHandlers(window: BrowserWindow, descriptor: WindowItem): void {
window.on("close", (event: WindowEvent) => {
const window = event.sender
window.on("close", () => {
WindowManager.saveWindowState(window, descriptor)
const url = window.webContents.getURL()
if (!isUrlInvalid(url)) {
Expand Down Expand Up @@ -100,7 +99,7 @@ export default class WindowManager {
descriptor.url = DEFAULT_URL
}

const options: BrowserWindowOptions = {
const options: BrowserWindowConstructorOptions = {
// to avoid visible maximizing
show: false,
webPreferences: {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
},
"include": [
"node_modules/@types/*/*.d.ts",
"node_modules/electron/electron.d.ts",
"node_modules/electron-updater/out/*.d.ts",
"node_modules/electron-builder-http/out/*.d.ts",
"src/*.ts",
"typings/**/*.d.ts"
],
"exclude": [
]
}
}
76 changes: 41 additions & 35 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,13 @@
version "0.0.29"
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-0.0.29.tgz#a1e514adfbd92f03a224ba54d693111dbf1f3754"

"@types/electron@^1.4.38":
version "1.4.38"
resolved "https://registry.yarnpkg.com/@types/electron/-/electron-1.4.38.tgz#f3e5e58fdcd5462ee4b5817d33dfdb6700ba2415"
dependencies:
"@types/node" "*"

"@types/node@*", "@types/node@^7.0.18":
version "7.0.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.21.tgz#22a890f19b26cff9b6699b493dea1bcee4410da1"
"@types/node@^7.0.18":
version "7.0.22"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.22.tgz#4593f4d828bdd612929478ea40c67b4f403ca255"

ajv-keywords@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.0.0.tgz#a37d02f845b6f52569804164270b24cb6c6cee61"
version "2.1.0"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.0.tgz#a296e17f7bfae7c1ce4f7e0de53d29cb32162df0"

ajv@^4.9.1:
version "4.11.8"
Expand All @@ -48,8 +42,8 @@ ajv@^4.9.1:
json-stable-stringify "^1.0.1"

ajv@^5.1.3:
version "5.1.3"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.1.3.tgz#423d1c302c61e617081b30ca05f595ec51408e33"
version "5.1.5"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.1.5.tgz#8734931b601f00d4feef7c65738d77d1b65d1f68"
dependencies:
co "^4.6.0"
json-stable-stringify "^1.0.1"
Expand Down Expand Up @@ -351,22 +345,29 @@ electron-builder-core@17.2.0:
version "17.2.0"
resolved "https://registry.yarnpkg.com/electron-builder-core/-/electron-builder-core-17.2.0.tgz#e235d11aae64bffbad36b601ac58173f9377f619"

electron-builder-http@17.9.0, electron-builder-http@~17.9.0:
electron-builder-http@18.0.1, electron-builder-http@~18.0.1:
version "18.0.1"
resolved "https://registry.yarnpkg.com/electron-builder-http/-/electron-builder-http-18.0.1.tgz#9d10ead501656087222b4de28b2b90df9f978313"
dependencies:
debug "2.6.8"
fs-extra-p "^4.3.0"

electron-builder-http@~17.9.0:
version "17.9.0"
resolved "https://registry.yarnpkg.com/electron-builder-http/-/electron-builder-http-17.9.0.tgz#e760947b86c5dea1fb9a0ceff845cc21e7f881cc"
dependencies:
debug "2.6.8"
fs-extra-p "^4.3.0"

electron-builder-util@17.9.0, electron-builder-util@~17.9.0:
version "17.9.0"
resolved "https://registry.yarnpkg.com/electron-builder-util/-/electron-builder-util-17.9.0.tgz#fee1e406bba100afdd0611661e39f1abde2b53f7"
electron-builder-util@18.0.1, electron-builder-util@~18.0.1:
version "18.0.1"
resolved "https://registry.yarnpkg.com/electron-builder-util/-/electron-builder-util-18.0.1.tgz#891ddd09ae0fcb7bf9f4abde6e3fa7045fbdb231"
dependencies:
"7zip-bin" "^2.0.4"
bluebird-lst "^1.0.2"
chalk "^1.1.3"
debug "2.6.8"
electron-builder-http "~17.9.0"
electron-builder-http "~18.0.1"
fs-extra-p "^4.3.0"
ini "^1.3.4"
is-ci "^1.0.10"
Expand All @@ -376,8 +377,8 @@ electron-builder-util@17.9.0, electron-builder-util@~17.9.0:
tunnel-agent "^0.6.0"

electron-builder@next:
version "17.10.0"
resolved "https://registry.yarnpkg.com/electron-builder/-/electron-builder-17.10.0.tgz#5b733577f75850bd303b4835b062f915338b4ad2"
version "18.0.1"
resolved "https://registry.yarnpkg.com/electron-builder/-/electron-builder-18.0.1.tgz#13517273e287e458c95d853622003874ddb90f89"
dependencies:
"7zip-bin" "^2.0.4"
ajv "^5.1.3"
Expand All @@ -388,16 +389,17 @@ electron-builder@next:
cuint "^0.2.2"
debug "2.6.8"
electron-builder-core "17.2.0"
electron-builder-http "17.9.0"
electron-builder-util "17.9.0"
electron-builder-http "18.0.1"
electron-builder-util "18.0.1"
electron-download-tf "4.3.1"
electron-osx-sign "0.4.4"
electron-publish "17.9.0"
electron-osx-sign "0.4.5"
electron-publish "18.0.1"
fs-extra-p "^4.3.0"
hosted-git-info "^2.4.2"
is-ci "^1.0.10"
isbinaryfile "^3.0.2"
js-yaml "^3.8.4"
json5 "^0.5.1"
minimatch "^3.0.4"
node-forge "^0.7.1"
normalize-package-data "^2.3.8"
Expand Down Expand Up @@ -456,9 +458,9 @@ electron-log@^2.2.6:
version "2.2.6"
resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-2.2.6.tgz#ccfa3e09b39f321468c90a642701380a34079f1a"

electron-osx-sign@0.4.4:
version "0.4.4"
resolved "https://registry.yarnpkg.com/electron-osx-sign/-/electron-osx-sign-0.4.4.tgz#afdf38450ccaebe6dabeca71fb0fad6294a8c57c"
electron-osx-sign@0.4.5:
version "0.4.5"
resolved "https://registry.yarnpkg.com/electron-osx-sign/-/electron-osx-sign-0.4.5.tgz#59037cae6ac05ba9e802f76d9bb772b31a8c75c7"
dependencies:
bluebird "^3.4.7"
compare-version "^0.1.2"
Expand All @@ -468,14 +470,14 @@ electron-osx-sign@0.4.4:
plist "^2.0.1"
tempfile "^1.1.1"

electron-publish@17.9.0:
version "17.9.0"
resolved "https://registry.yarnpkg.com/electron-publish/-/electron-publish-17.9.0.tgz#5826ce22a06ff95e9d1cd6f4ee367703810a24bb"
electron-publish@18.0.1:
version "18.0.1"
resolved "https://registry.yarnpkg.com/electron-publish/-/electron-publish-18.0.1.tgz#04e8bd1db2c431f9de47c277c845234e3d7e0df8"
dependencies:
bluebird-lst "^1.0.2"
chalk "^1.1.3"
electron-builder-http "~17.9.0"
electron-builder-util "~17.9.0"
electron-builder-http "~18.0.1"
electron-builder-util "~18.0.1"
fs-extra-p "^4.3.0"
mime "^1.3.6"

Expand Down Expand Up @@ -865,6 +867,10 @@ json-stringify-safe@~5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"

json5@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"

jsonfile@^2.1.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
Expand Down Expand Up @@ -1623,9 +1629,9 @@ typedarray@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"

typescript@^2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.3.2.tgz#f0f045e196f69a72f06b25fd3bd39d01c3ce9984"
typescript@^2.3.4:
version "2.3.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.3.4.tgz#3d38321828231e434f287514959c37a82b629f42"

unique-string@^1.0.0:
version "1.0.0"
Expand Down

0 comments on commit 482fbbe

Please sign in to comment.