From d9fd78fb42772b85c6df30e2e233786fd4c7bef3 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Tue, 20 Jun 2017 22:11:08 +0200 Subject: [PATCH] wip --- app/index.pug | 1 + app/package.json | 2 +- app/src/entry.preload.ts | 30 +++++++++++ package-lock.json | 50 +++++++++++++++++++ package.json | 4 ++ terminus-core/src/configDefaults.yaml | 1 + terminus-core/src/services/config.service.ts | 7 +-- .../src/services/electron.service.ts | 8 +-- terminus-core/src/services/hotkeys.service.ts | 2 +- terminus-core/src/services/themes.service.ts | 3 +- .../src/components/settingsTab.component.pug | 7 +++ .../src/components/settingsTab.component.scss | 15 ++++-- .../src/components/terminalTab.component.ts | 2 +- terminus-terminal/src/persistenceProviders.ts | 2 +- 14 files changed, 117 insertions(+), 17 deletions(-) diff --git a/app/index.pug b/app/index.pug index 445e857e..1132e12c 100644 --- a/app/index.pug +++ b/app/index.pug @@ -8,6 +8,7 @@ html window.nodeRequire = require script(src='./preload.js') script(src='./bundle.js', defer) + style#custom-css body(style='background: ; min-height: 100vh; overflow: hidden') app-root .preload-logo diff --git a/app/package.json b/app/package.json index 3ad79bb2..483113fa 100644 --- a/app/package.json +++ b/app/package.json @@ -6,7 +6,7 @@ "email": "e@ajenti.org" }, "main": "main.js", - "version": "0.0.2", + "version": "1.0.0-alpha.1", "scripts": { "build": "../node_modules/.bin/webpack --progress --color --display-modules", "watch": "../node_modules/.bin/webpack --progress --color --watch" diff --git a/app/src/entry.preload.ts b/app/src/entry.preload.ts index 358467d9..8478ea2f 100644 --- a/app/src/entry.preload.ts +++ b/app/src/entry.preload.ts @@ -1,3 +1,33 @@ import 'source-sans-pro' import 'font-awesome/css/font-awesome.css' import './preload.scss' + +import * as Raven from 'raven-js' + +const SENTRY_DSN = 'https://4717a0a7ee0b4429bd3a0f06c3d7eec3@sentry.io/181876' + +Raven.config( + SENTRY_DSN, + { + release: require('electron').remote.app.getVersion(), + dataCallback: (data: any) => { + const normalize = (filename) => { + let splitArray = filename.split('/') + return splitArray[splitArray.length - 1] + } + + data.exception.values[0].stacktrace.frames.forEach(frame => { + frame.filename = normalize(frame.filename) + }) + + data.culprit = data.exception.values[0].stacktrace.frames[0].filename + + return data + } + } +) + +process.on('uncaughtException', (err) => { + Raven.captureException(err) + console.error(err) +}) diff --git a/package-lock.json b/package-lock.json index 7149f271..ca9691cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,6 +27,18 @@ "integrity": "sha1-JeTdgEtjDJFq5nEjPm1x9s4YEko=", "dev": true }, + "@types/raven": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@types/raven/-/raven-1.2.2.tgz", + "integrity": "sha1-r+Ur2YGHo6PSi4IS42MUO9FvI78=", + "dev": true + }, + "@types/raven-js": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/@types/raven-js/-/raven-js-3.10.0.tgz", + "integrity": "sha1-0IMhYuvqdnHq//CKMktWrd5b+cM=", + "dev": true + }, "@types/webpack-env": { "version": "https://registry.npmjs.org/@types/webpack-env/-/webpack-env-1.13.0.tgz", "integrity": "sha1-MEQ4FkfhHulzxa8uklMjkw9pHYA=", @@ -641,6 +653,12 @@ "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", "dev": true }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=", + "dev": true + }, "core-js": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.4.1.tgz", @@ -1985,6 +2003,12 @@ "integrity": "sha1-HRdnnAac2l0ECZGgnbwsDbN35V4=", "dev": true }, + "lsmod": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lsmod/-/lsmod-1.0.0.tgz", + "integrity": "sha1-mgD3bco26yP6BTUK/htYXUKZ5ks=", + "dev": true + }, "macaddress": { "version": "https://registry.npmjs.org/macaddress/-/macaddress-0.2.8.tgz", "integrity": "sha1-WQTcU3w57G2+/q6QIycTX6hRHxI=", @@ -2756,6 +2780,26 @@ "integrity": "sha1-Z0yZdgkBw8QRJ3GjHlIdw0nMCew=", "dev": true }, + "raven": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/raven/-/raven-2.0.2.tgz", + "integrity": "sha1-pD07hwKubbLpGYdii+jyiVAIEK4=", + "dev": true, + "dependencies": { + "uuid": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.0.tgz", + "integrity": "sha1-Zyj8BFnEUNeWqZwxg3VpvfZy1yg=", + "dev": true + } + } + }, + "raven-js": { + "version": "3.16.0", + "resolved": "https://registry.npmjs.org/raven-js/-/raven-js-3.16.0.tgz", + "integrity": "sha1-p5naT90ExjlD9n3rk9qg7P4QHqs=", + "dev": true + }, "raw-loader": { "version": "https://registry.npmjs.org/raw-loader/-/raw-loader-0.5.1.tgz", "integrity": "sha1-DD0L6u2KAclm2Xh793goElKpeao=", @@ -3131,6 +3175,12 @@ } } }, + "stack-trace": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.9.tgz", + "integrity": "sha1-qPbq7KkGdMMz58Q5U/J1tFFRBpU=", + "dev": true + }, "stat-mode": { "version": "https://registry.npmjs.org/stat-mode/-/stat-mode-0.2.2.tgz", "integrity": "sha1-5sgLYjEj19gM8TLOU480YokHJQI=", diff --git a/package.json b/package.json index f3e11ba9..34146dc7 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,8 @@ "@types/electron": "1.4.34", "@types/fs-promise": "^1.0.1", "@types/node": "^7.0.5", + "@types/raven": "^1.2.2", + "@types/raven-js": "^3.10.0", "@types/webpack-env": "^1.13.0", "apply-loader": "^0.1.0", "awesome-typescript-loader": "3.1.2", @@ -28,6 +30,8 @@ "pug-html-loader": "^1.0.9", "pug-loader": "^2.3.0", "pug-static-loader": "0.0.1", + "raven": "^2.0.2", + "raven-js": "^3.16.0", "raw-loader": "^0.5.1", "sass-loader": "^6.0.3", "shelljs": "^0.7.7", diff --git a/terminus-core/src/configDefaults.yaml b/terminus-core/src/configDefaults.yaml index 408946a5..93b593ce 100644 --- a/terminus-core/src/configDefaults.yaml +++ b/terminus-core/src/configDefaults.yaml @@ -5,3 +5,4 @@ appearance: tabsLocation: top theme: Standard frame: thin + css: '/* * { color: blue !important; } */' diff --git a/terminus-core/src/services/config.service.ts b/terminus-core/src/services/config.service.ts index de61ae55..0fe1474e 100644 --- a/terminus-core/src/services/config.service.ts +++ b/terminus-core/src/services/config.service.ts @@ -1,7 +1,8 @@ +import { Subject } from 'rxjs' import * as yaml from 'js-yaml' import * as path from 'path' import * as fs from 'fs' -import { EventEmitter, Injectable, Inject } from '@angular/core' +import { Injectable, Inject } from '@angular/core' import { ConfigProvider } from '../api/configProvider' import { ElectronService } from './electron.service' import { HostAppService } from './hostApp.service' @@ -51,7 +52,7 @@ export class ConfigProxy { @Injectable() export class ConfigService { store: any - change = new EventEmitter() + changed$ = new Subject() restartRequested: boolean private _store: any private path: string @@ -91,7 +92,7 @@ export class ConfigService { } emitChange (): void { - this.change.emit() + this.changed$.next() } requestRestart (): void { diff --git a/terminus-core/src/services/electron.service.ts b/terminus-core/src/services/electron.service.ts index 635c7653..9f6dfc9a 100644 --- a/terminus-core/src/services/electron.service.ts +++ b/terminus-core/src/services/electron.service.ts @@ -15,13 +15,13 @@ export class ElectronService { constructor () { this.electron = require('electron') this.remoteElectron = this.remoteRequire('electron') - this.app = this.remoteElectron.app - this.screen = this.remoteElectron.screen - this.dialog = this.remoteElectron.dialog + this.app = this.electron.remote.app + this.screen = this.electron.remote.screen + this.dialog = this.electron.remote.dialog this.shell = this.electron.shell this.clipboard = this.electron.clipboard this.ipcRenderer = this.electron.ipcRenderer - this.globalShortcut = this.remoteElectron.globalShortcut + this.globalShortcut = this.electron.remote.globalShortcut } remoteRequire (name: string): any { diff --git a/terminus-core/src/services/hotkeys.service.ts b/terminus-core/src/services/hotkeys.service.ts index bb5f95c5..efc598c6 100644 --- a/terminus-core/src/services/hotkeys.service.ts +++ b/terminus-core/src/services/hotkeys.service.ts @@ -43,7 +43,7 @@ export class HotkeysService { }) }) this.hotkeyDescriptions = hotkeyProviders.map(x => x.hotkeys).reduce((a, b) => a.concat(b)) - this.config.change.subscribe(() => { + this.config.changed$.subscribe(() => { this.registerGlobalHotkey() }) this.registerGlobalHotkey() diff --git a/terminus-core/src/services/themes.service.ts b/terminus-core/src/services/themes.service.ts index ef7bc1f2..6e052664 100644 --- a/terminus-core/src/services/themes.service.ts +++ b/terminus-core/src/services/themes.service.ts @@ -11,8 +11,9 @@ export class ThemesService { @Inject(Theme) private themes: Theme[], ) { this.applyCurrentTheme() - config.change.subscribe(() => { + config.changed$.subscribe(() => { this.applyCurrentTheme() + document.querySelector('style#custom-css').innerHTML = config.store.appearance.css }) } diff --git a/terminus-settings/src/components/settingsTab.component.pug b/terminus-settings/src/components/settingsTab.component.pug index 95f55bcb..48879d67 100644 --- a/terminus-settings/src/components/settingsTab.component.pug +++ b/terminus-settings/src/components/settingsTab.component.pug @@ -145,6 +145,13 @@ ngb-tabset.vertical(type='tabs') i.fa.fa-bug span Open DevTools + .form-group + label Custom CSS + textarea.form-control( + [(ngModel)]='config.store.appearance.css', + '(ngModelChange)'='config.save()', + ) + ngb-tab template(ngbTabTitle) | Hotkeys diff --git a/terminus-settings/src/components/settingsTab.component.scss b/terminus-settings/src/components/settingsTab.component.scss index 9c75b481..da822d86 100644 --- a/terminus-settings/src/components/settingsTab.component.scss +++ b/terminus-settings/src/components/settingsTab.component.scss @@ -8,12 +8,17 @@ width: auto; flex: none; } +} - .hotkeys-table { - margin-top: 30px; +.hotkeys-table { + margin-top: 30px; - td, th { - padding: 5px 10px; - } + td, th { + padding: 5px 10px; } } + +textarea { + font-family: 'Source Sans Mono', monospace; + height: 120px; +} diff --git a/terminus-terminal/src/components/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index 6e7518a9..24256486 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -44,7 +44,7 @@ export class TerminalTabComponent extends BaseTabComponent { super() this.decorators = this.decorators || [] this.title$.next('Terminal') - this.configSubscription = config.change.subscribe(() => { + this.configSubscription = config.changed$.subscribe(() => { this.configure() }) this.resize$.first().subscribe(async (resizeEvent) => { diff --git a/terminus-terminal/src/persistenceProviders.ts b/terminus-terminal/src/persistenceProviders.ts index 1f08feed..4f8ac9e0 100644 --- a/terminus-terminal/src/persistenceProviders.ts +++ b/terminus-terminal/src/persistenceProviders.ts @@ -7,7 +7,7 @@ import { Injectable } from '@angular/core' import { Logger, LogService } from 'terminus-core' import { SessionOptions, SessionPersistenceProvider } from './api' -declare function delay(ms: number): Promise +declare function delay (ms: number): Promise interface IChildProcess { pid: number