Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: develar/onshape-desktop-shell
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.5.17
Choose a base ref
...
head repository: develar/onshape-desktop-shell
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 16 commits
  • 28 files changed
  • 2 contributors

Commits on Dec 31, 2017

  1. chore: update deps

    develar committed Dec 31, 2017
    Copy the full SHA
    675ec6d View commit details

Commits on Jan 16, 2018

  1. chore: update deps

    develar committed Jan 16, 2018
    Copy the full SHA
    51c8894 View commit details

Commits on Jan 23, 2018

  1. chore: update deps

    develar committed Jan 23, 2018
    Copy the full SHA
    27517f3 View commit details

Commits on Jan 31, 2018

  1. chore: idea project files

    develar committed Jan 31, 2018
    Copy the full SHA
    ca676c4 View commit details
  2. Copy the full SHA
    20792a2 View commit details
  3. chore: update deps

    develar committed Jan 31, 2018
    Copy the full SHA
    e310fc4 View commit details

Commits on Feb 13, 2018

  1. chore: update deps

    develar committed Feb 13, 2018
    Copy the full SHA
    b85416a View commit details
  2. Copy the full SHA
    a67fcc9 View commit details

Commits on Feb 18, 2018

  1. chore: update deps

    develar committed Feb 18, 2018
    Copy the full SHA
    3152b59 View commit details

Commits on Mar 6, 2018

  1. chore: update deps

    develar committed Mar 6, 2018
    Copy the full SHA
    cee1255 View commit details

Commits on Apr 21, 2018

  1. chore: update deps

    develar committed Apr 21, 2018
    Copy the full SHA
    960dfdc View commit details

Commits on Jul 15, 2018

  1. Copy the full SHA
    dbced5b View commit details

Commits on Nov 2, 2018

  1. Copy the full SHA
    2a767a7 View commit details

Commits on Jun 29, 2019

  1. chore: update deps

    develar committed Jun 29, 2019
    Copy the full SHA
    4b49ea2 View commit details
  2. chore: get rid of git lfs

    develar committed Jun 29, 2019
    Copy the full SHA
    deacdbd View commit details

Commits on Jul 10, 2019

  1. fix: use electron-store

    develar committed Jul 10, 2019
    Copy the full SHA
    8d71775 View commit details
4 changes: 0 additions & 4 deletions .gitattributes

This file was deleted.

6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -2,4 +2,8 @@ dist/
node_modules/
npm-debug.log
app/out
_gsdata_/
_gsdata_/

/.idea/workspace.xml
/.idea/shelf/
/out/
7 changes: 2 additions & 5 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 2 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
matrix:
include:
- os: osx
osx_image: xcode9.0
osx_image: xcode10.2
language: node_js
node_js: "8"
node_js: "10"
env:
- ELECTRON_CACHE=$HOME/.cache/electron
- ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder
@@ -18,16 +18,6 @@ cache:
- $HOME/.cache/electron
- $HOME/.cache/electron-builder

before_install:
- |
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
mkdir -p /tmp/git-lfs && curl -L https://github.com/github/git-lfs/releases/download/v2.3.1/git-lfs-$([ "$TRAVIS_OS_NAME" == "linux" ] && echo "linux" || echo "darwin")-amd64-2.3.1.tar.gz | tar -xz -C /tmp/git-lfs --strip-components 1
export PATH="/tmp/git-lfs:$PATH"
fi
before_script:
- git lfs pull

script:
- |
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
Binary file modified build/background.tiff
Binary file not shown.
Binary file modified build/icon.icns
Binary file not shown.
Binary file modified build/icon.ico
Binary file not shown.
Binary file modified build/icons/1024x1024.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified build/icons/128x128.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified build/icons/16x16.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified build/icons/24x24.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified build/icons/256x256.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified build/icons/32x32.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified build/icons/48x48.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified build/icons/512x512.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified build/icons/64x64.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified build/icons/96x96.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 17 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "Onshape",
"version": "0.5.17",
"version": "0.5.20",
"license": "MIT",
"description": "Onshape desktop app (web application shell)",
"author": "Vladimir Krivosheev <develar@gmail.com>",
"main": "./out/index.js",
"scripts": {
"postinstall": "electron-builder install-app-deps",
"start": "yarn install && yarn compile && electron ./app",
"start": "yarn install && yarn compile && electron .",
"compile": "rimraf app/out && tsc",
"pack": "yarn compile && electron-builder --dir",
"dist": "yarn compile && electron-builder",
@@ -21,6 +21,9 @@
"mac": {
"category": "public.app-category.graphics-design"
},
"nsis": {
"createDesktopShortcut": "always"
},
"dmg": {
"contents": [
{
@@ -36,26 +39,22 @@
]
},
"linux": {
"category": "Graphics",
"target": [
"AppImage",
"deb"
]
"category": "Graphics"
}
},
"dependencies": {
"configstore": "^3.1.1",
"electron-debug": "^1.4.0",
"electron-is-dev": "^0.3.0",
"electron-log": "^2.2.11",
"electron-updater": "^2.17.3",
"keytar-prebuild": "^4.0.4"
"electron-store": "^4.0.0",
"electron-debug": "^3.0.0",
"electron-is-dev": "^1.1.0",
"electron-log": "^3.0.6",
"electron-updater": "^4.0.14",
"keytar": "^4.11.0"
},
"devDependencies": {
"@types/debug": "^0.0.30",
"electron": "1.7.9",
"electron-builder": "^19.48.3",
"rimraf": "^2.6.2",
"typescript": "^2.6.2"
"@types/debug": "^4.1.4",
"electron": "5.0.6",
"electron-builder": "^21.0.14",
"rimraf": "^2.6.3",
"typescript": "^3.5.2"
}
}
2 changes: 1 addition & 1 deletion src/AppUpdater.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import { autoUpdater } from "electron-updater"
export default class AppUpdater {
constructor() {
const log = require("electron-log")
log.transports.file.level = "info"
log.transports.file.level = "debug"
autoUpdater.logger = log
autoUpdater.checkForUpdatesAndNotify()
}
49 changes: 14 additions & 35 deletions src/StateManager.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
"use strict"

import * as os from "os"
import * as path from "path"
import ConfigStore = require("configstore")
import { isDev } from "./util"
import * as ConfigStore from "electron-store"

export const DEFAULT_URL = "https://cad.onshape.com/"

@@ -14,47 +9,31 @@ function defaultWindows() {
}

export class StateManager {
private store = new ConfigStore("onshape-unofficial", {windows: defaultWindows()})

private data: Config
private store = new ConfigStore()

constructor() {
if (os.platform() == "darwin") {
this.store.path = path.join(os.homedir(), "Library", "Preferences", "org.develar.onshape" + (isDev() ? "-dev" : "") + ".json")
}
}
private windows: Array<WindowItem> = defaultWindows()

restoreWindows(): void {
let data = this.getOrLoadData()
data.windows = defaultWindows()
this.store.all = data
}

private getOrLoadData(): Config {
let data = this.data
if (data == null) {
data = this.store.all
this.data = data
}
return data
this.store.delete("windows")
this.windows = defaultWindows()
}

getWindows(): Array<WindowItem> {
return this.getOrLoadData().windows
const result = this.store.get("windows")
if (result == null || !Array.isArray(result)) {
this.windows = defaultWindows()
}
else {
this.windows = result
}
return this.windows
}

save(): void {
const data = this.data
if (data != null) {
this.store.all = data
}
this.store.set("windows", this.windows)
}
}

interface Config {
windows: Array<WindowItem>
}

export interface WindowItem {
url: string
width?: number
12 changes: 5 additions & 7 deletions src/WindowManager.ts
Original file line number Diff line number Diff line change
@@ -3,14 +3,12 @@ import * as path from "path"
import AppUpdater from "./AppUpdater"
import { WebContentsSignal, WindowEvent } from "./electronEventSignals"
import { DEFAULT_URL, StateManager, WindowItem } from "./StateManager"
import BrowserWindow = Electron.BrowserWindow
import BrowserWindowConstructorOptions = Electron.BrowserWindowConstructorOptions

export const WINDOW_NAVIGATED = "windowNavigated"

export default class WindowManager {
private stateManager = new StateManager()
private windows: Array<BrowserWindow> = []
private windows: Array<Electron.BrowserWindow> = []

constructor() {
app.on("window-all-closed", () => {
@@ -28,7 +26,7 @@ export default class WindowManager {
})
}

private static saveWindowState(window: BrowserWindow, descriptor: WindowItem): void {
private static saveWindowState(window: Electron.BrowserWindow, descriptor: WindowItem): void {
if (window.isMaximized()) {
delete descriptor.width
delete descriptor.height
@@ -44,7 +42,7 @@ export default class WindowManager {
}
}

private registerWindowEventHandlers(window: BrowserWindow, descriptor: WindowItem): void {
private registerWindowEventHandlers(window: Electron.BrowserWindow, descriptor: WindowItem): void {
window.on("close", () => {
WindowManager.saveWindowState(window, descriptor)
const url = window.webContents.getURL()
@@ -99,7 +97,7 @@ export default class WindowManager {
descriptor.url = DEFAULT_URL
}

const options: BrowserWindowConstructorOptions = {
const options: Electron.BrowserWindowConstructorOptions = {
// to avoid visible maximizing
show: false,
webPreferences: {
@@ -109,7 +107,7 @@ export default class WindowManager {
}
}

let isMaximized = true
let isMaximized = false
if (descriptor.width != null && descriptor.height != null) {
options.width = descriptor.width
options.height = descriptor.height
24 changes: 14 additions & 10 deletions src/autoSignIn.ts
Original file line number Diff line number Diff line change
@@ -4,14 +4,15 @@
const SERVICE_NAME = "org.develar.onshape"
const LOGIN_NAME = "data"

const keytar = require("keytar-prebuild")
const keytar = require("keytar")

let passwordToSave: Credentials = null
let foundFormElementTimerId: number = -1
let oldUrl: string = null

const ipcRenderer = require("electron").ipcRenderer
ipcRenderer.on("maybeUrlChanged", (event: any, newUrl: string) => {
console.log(event, newUrl, oldUrl)
if (oldUrl != newUrl) {
try {
urlChanged(oldUrl, window.location)
@@ -31,11 +32,12 @@
}
}

function loadCredentials(): Credentials {
const data = keytar.getPassword(SERVICE_NAME, LOGIN_NAME)
async function loadCredentials(): Promise<Credentials> {
const data = await keytar.getPassword(SERVICE_NAME, LOGIN_NAME)
console.log("data: " + data)
if (isNotEmpty(data)) {
try {
var parsed = JSON.parse(data)
const parsed = JSON.parse(data)
if (Array.isArray(parsed)) {
if (parsed.length == 2) {
return new Credentials(parsed[0], parsed[1])
@@ -47,7 +49,7 @@
}
}
catch (e) {
console.error(e)
console.error("cannot parse data: " + data, e)
ipcRenderer.send("log.error", e)
}
}
@@ -69,8 +71,8 @@
input.dispatchEvent(new Event("change", {"bubbles": true}))
}

function fillAndSubmit(formElement: HTMLFormElement) {
const credentials = loadCredentials()
async function fillAndSubmit(formElement: HTMLFormElement) {
const credentials = await loadCredentials()
if (credentials != null && isNotEmpty(credentials.login)) {
setValue(getInputElement("email"), credentials.login)

@@ -81,7 +83,7 @@
}
}

var superOnSubmit: any = formElement.onsubmit
const superOnSubmit: any = formElement.onsubmit
formElement.onsubmit = event => {
passwordToSave = null
if (superOnSubmit != null) {
@@ -101,6 +103,7 @@
if (formElement != null) {
console.log("form element found")
fillAndSubmit(formElement)
.catch(e => console.error(e))
}
else {
console.log("form element not found, schedule")
@@ -123,8 +126,9 @@
}

if (passwordToSave != null) {
if (newLocation.host == "cad.onshape.com" && oldUrl.endsWith("/signin") && newLocation.pathname != "/signup/forgotpassword") {
keytar.replacePassword(SERVICE_NAME, LOGIN_NAME, JSON.stringify([passwordToSave.login, passwordToSave.password]))
if (newLocation.host == "cad.onshape.com" && (oldUrl == null || oldUrl.endsWith("/signin")) && newLocation.pathname != "/signup/forgotpassword") {
keytar.setPassword(SERVICE_NAME, LOGIN_NAME, JSON.stringify([passwordToSave.login, passwordToSave.password]))
.catch((e: any) => console.error(e))
}
passwordToSave = null
}
15 changes: 6 additions & 9 deletions src/electronEventSignals.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import BrowserWindow = Electron.BrowserWindow
import WebContents = Electron.WebContents
import EventEmitter = NodeJS.EventEmitter
import { app } from "electron"

export interface WindowEvent {
sender: BrowserWindow
sender: Electron.BrowserWindow
}

export interface WebContentsEvent {
sender: WebContents
sender: Electron.WebContents
}

function isEnvTrue(v: string): boolean {
@@ -17,7 +14,7 @@ function isEnvTrue(v: string): boolean {

const isLogEvent = isEnvTrue(process.env.LOG_EVENTS)

function addHandler(emitter: EventEmitter, event: string, handler: (...args: any[]) => void) {
function addHandler(emitter: Electron.EventEmitter, event: string, handler: (...args: any[]) => void) {
if (isLogEvent) {
emitter.on(event, function (...args: any[]) {
console.log("%s %s", event, args)
@@ -30,7 +27,7 @@ function addHandler(emitter: EventEmitter, event: string, handler: (...args: any
}

export class WebContentsSignal {
constructor(private emitter: WebContents) {
constructor(private emitter: Electron.WebContents) {
}

navigated(handler: (event: WebContentsEvent, url: string) => void): WebContentsSignal {
@@ -52,12 +49,12 @@ export class WebContentsSignal {
export class AppSignal {
private emitter = app

windowBlurred(handler: (event: any, window: BrowserWindow) => void): AppSignal {
windowBlurred(handler: (event: any, window: Electron.BrowserWindow) => void): AppSignal {
addHandler(this.emitter, "browser-window-blur", handler)
return this
}

windowFocused(handler: (event: any, window: BrowserWindow) => void): AppSignal {
windowFocused(handler: (event: any, window: Electron.BrowserWindow) => void): AppSignal {
addHandler(this.emitter, "browser-window-focus", handler)
return this
}
Loading