diff --git a/.idea/misc.xml b/.idea/misc.xml index 76183cf..0eea40c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -51,5 +51,5 @@ - + \ No newline at end of file diff --git a/.idea/runConfigurations/Packed_App.xml b/.idea/runConfigurations/Packed_App.xml new file mode 100644 index 0000000..efb7ae5 --- /dev/null +++ b/.idea/runConfigurations/Packed_App.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/.idea/scopes/app_source_files.xml b/.idea/scopes/app_source_files.xml new file mode 100644 index 0000000..2f41f6c --- /dev/null +++ b/.idea/scopes/app_source_files.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/typescript-compiler.xml b/.idea/typescript-compiler.xml index 88b88fe..97af70f 100644 --- a/.idea/typescript-compiler.xml +++ b/.idea/typescript-compiler.xml @@ -3,6 +3,7 @@ diff --git a/README.md b/README.md index e96e414..3e43035 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,13 @@ -[Download](https://github.com/develar/onshape-desktop-shell/releases/latest) latest release. +[Download](https://onshape-download.develar.org/download) Onshape standalone app ([see [releases](https://github.com/develar/onshape-desktop-shell/releases/latest)). “[Onshape](http://example.com/) is the first and only full-cloud 3D CAD system that lets everyone on a design team simultaneously work together using a web browser, phone or tablet. CAD Anywhere, Anytime, On Any Device.” So, there is no official desktop application since you can use Onshape on a desktop computer using web browser. -But using web browser in this case is not always convenient — you lost all standard ways to open app or to switch to it. +But using web browser in this case is not always convenient — you lost all standard ways to open app or to switch to it. What if you want to easily switch to Onshape using cmd+tab? And not to lose Onshape among other web pages? Please note – it is unofficial application. # todo -* Keep opened windows state (restore last opened documents on launch). -* Auto sign-in (don't to type password every launch). +* Keep opened windows state (restore last opened documents on launch). \ No newline at end of file diff --git a/app/package.json b/app/package.json index 1d3e799..0f33c01 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "Onshape", - "version": "0.1.0", + "version": "0.3.0", "private": true, "main": "./out/index.js", "dependencies": { diff --git a/build/build.js b/build/build.js index 62483c7..e30c3eb 100644 --- a/build/build.js +++ b/build/build.js @@ -37,10 +37,11 @@ packager({ }) function pack() { - let outDir = `${__dirname}/../dist/Onshape-darwin-x64` - let appName = "Onshape" + const outDir = `${__dirname}/../dist/Onshape-darwin-x64` + const appName = "Onshape" + const appPath = `${outDir}/${appName}.app` require("electron-builder").init().build({ - "appPath": `${outDir}/${appName}.app`, + "appPath": appPath, "platform": "osx", "out": outDir, "config": `${__dirname}/packager.json`, @@ -51,5 +52,10 @@ function pack() { } fs.renameSync(`${outDir}/${appName}.dmg`, `${outDir}/${appName}-${version}.dmg`) + const spawnSync = require("child_process").spawnSync + spawnSync("zip", ["-ryX", `${outDir}/${appName}-${version}.zip`, appName + ".app"], { + cwd: outDir, + stdio: "inherit", + }) }) } \ No newline at end of file diff --git a/build/install-production-deps.js b/build/install-production-deps.js index fbbb502..f93dd91 100644 --- a/build/install-production-deps.js +++ b/build/install-production-deps.js @@ -1,12 +1,12 @@ "use strict" const fs = require("fs") -const spawnSync = require('child_process').spawnSync +const spawnSync = require("child_process").spawnSync const packageJson = JSON.parse(fs.readFileSync(__dirname + "/../package.json")) const args = require("command-line-args")({name: "arch", type: String}).parse() -const env = require('merge')(process.env, { +const env = Object.assign(process.env, { npm_config_disturl: "https://atom.io/download/atom-shell", npm_config_target: packageJson.devDependencies["electron-prebuilt"].substring(1), npm_config_arch: "x64", diff --git a/onshape-desktop-shell.iml b/onshape-desktop-shell.iml index 7582bd5..3545e4b 100644 --- a/onshape-desktop-shell.iml +++ b/onshape-desktop-shell.iml @@ -1,6 +1,6 @@ - + diff --git a/package.json b/package.json index c2095cc..1b8fcda 100644 --- a/package.json +++ b/package.json @@ -23,11 +23,10 @@ }, "devDependencies": { "command-line-args": "^2.1.3", - "electron-builder": "^2.4.0", + "electron-builder": "^2.5.0", "electron-packager": "^5.2.0", - "electron-prebuilt": "^0.36.1", - "merge": "^1.2.0", - "rimraf": "^2.4.4", - "typescript": "^1.8.0-dev.20151223" + "electron-prebuilt": "^0.36.2", + "rimraf": "^2.5.0", + "typescript": "^1.8.0-dev.20151225" } } diff --git a/src/ApplicationUpdater.ts b/src/ApplicationUpdater.ts index c562e5a..905802c 100644 --- a/src/ApplicationUpdater.ts +++ b/src/ApplicationUpdater.ts @@ -16,9 +16,9 @@ export default class ApplicationUpdater { return } - let version = app.getVersion() - autoUpdater.addListener("update-available", (event: any, releaseNotes: string, releaseName: string, releaseDate: string, updateURL: string) => { - log("A new update is available", `Version ${releaseName} is available and will be automatically downloaded`) + const version = app.getVersion() + autoUpdater.addListener("update-available", (event: any) => { + log("A new update is available") }) autoUpdater.addListener("update-downloaded", (event: any, releaseNotes: string, releaseName: string, releaseDate: string, updateURL: string) => { notify("A new update is ready to install", `Version ${releaseName} is downloaded and will be automatically installed on Quit`) @@ -26,13 +26,13 @@ export default class ApplicationUpdater { autoUpdater.addListener("error", (error: any) => { log(error) }) - autoUpdater.addListener("checking-for-update", () => { + autoUpdater.addListener("checking-for-update", (event: any) => { log("checking-for-update") }) autoUpdater.addListener("update-not-available", () => { log("update-not-available") }) - autoUpdater.setFeedURL(`http://${UPDATE_SERVER_HOST}/update/${os.platform()}_${os.arch()}/${version}`) + autoUpdater.setFeedURL(`https://${UPDATE_SERVER_HOST}/update/${os.platform()}_${os.arch()}/${version}`) window.webContents.once("did-frame-finish-load", (event: any) => { autoUpdater.checkForUpdates() diff --git a/src/StateManager.ts b/src/StateManager.ts index 07b7450..29cb62a 100644 --- a/src/StateManager.ts +++ b/src/StateManager.ts @@ -5,9 +5,11 @@ import * as path from "path" import ConfigStore = require("configstore") import { isDev } from "./util" +export const DEFAULT_URL = "https://cad.onshape.com/" + function defaultWindows() { return [ - {url: "https://cad.onshape.com/"} + {url: DEFAULT_URL} ] } diff --git a/src/index.ts b/src/index.ts index 6b98097..b8cb229 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import { app, ipcMain, BrowserWindow as BrowserWindowElectron } from "electron" import BrowserWindow = GitHubElectron.BrowserWindow import BrowserWindowOptions = GitHubElectron.BrowserWindowOptions -import { StateManager, WindowItem } from "./StateManager" +import { StateManager, WindowItem, DEFAULT_URL } from "./StateManager" import ApplicationUpdater from "./ApplicationUpdater" import setMenu from "./menu" import { log } from "./util" @@ -48,9 +48,12 @@ function saveWindowState(window: BrowserWindow, descriptor: WindowItem) { function registerWindowEventHandlers(window: BrowserWindow, descriptor: WindowItem) { window.on("close", (event: WindowEvent) => { - let window = event.sender + const window = event.sender saveWindowState(window, descriptor) - descriptor.url = window.webContents.getURL() + const url = window.webContents.getURL() + if (url != "about:blank") { + descriptor.url = url + } stateManager.save() }) window.on("closed", (event: WindowEvent) => { @@ -81,7 +84,12 @@ function openWindows() { } for (const descriptor of descriptors) { - let options: BrowserWindowOptions = { + if (descriptor.url == "about:blank") { + // was error on load + descriptor.url = DEFAULT_URL + } + + const options: BrowserWindowOptions = { // to avoid visible maximizing show: false, preload: __dirname + "/autoSignIn.js", diff --git a/src/tsconfig.json b/src/tsconfig.json index ef8a55f..f02b466 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -5,6 +5,10 @@ "noImplicitAny": true, "removeComments": true, "outDir": "../app/out", + "newLine": "LF", + "noResolve": true, + "noEmitOnError": true, + "inlineSources": true, "sourceMap": true } } \ No newline at end of file diff --git a/src/util.ts b/src/util.ts index 53a3a0e..e29e8f1 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,7 +1,7 @@ import { app } from "electron" export function isDev() { - return app.getAppPath().indexOf("/node_modules/electron-prebuilt/") + return app.getAppPath().includes("/node_modules/electron-prebuilt/") } let _log: (...args: any[]) => void