From 6aebc99d5eb75dc8c7e922726b591cd1b171d033 Mon Sep 17 00:00:00 2001 From: Steven Lemon Date: Sun, 21 Jan 2018 09:09:59 +1300 Subject: [PATCH 1/2] open devtools link within atom --- lib/index.js | 7 +- lib/keymap.js | 253 ++++++++++++++++++++++++++++++++++++++++++++++ lib/ui/browser.js | 60 +++++++++++ lib/ui/console.js | 14 ++- styles/appc.less | 15 ++- 5 files changed, 346 insertions(+), 3 deletions(-) create mode 100644 lib/ui/browser.js diff --git a/lib/index.js b/lib/index.js index 5f7d8ec4..83131757 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,6 +5,7 @@ import os from 'os'; import path from 'path'; import Toolbar from './ui/toolbar'; import Console from './ui/console'; +import Browser from './ui/browser'; import GenerateDialog from './ui/generateDialog'; import Appc from './appc'; import Tiapp from './tiapp'; @@ -167,6 +168,7 @@ export default { deactivate() { this.toolbar.destroy(); this.console.destroy(); + this.browser.destroy(); this.subscriptions.dispose(); }, @@ -241,8 +243,11 @@ export default { if (!this.toolbar) { this.toolbar = new Toolbar(); } + if (!this.browser) { + this.browser = new Browser(); + } if (!this.console) { - this.console = new Console(this.serializedState.console); + this.console = new Console(this.serializedState.console, this.browser); } this.toolbar.hud.display({ diff --git a/lib/keymap.js b/lib/keymap.js index a2a6be41..9d330496 100644 --- a/lib/keymap.js +++ b/lib/keymap.js @@ -1,5 +1,258 @@ module.exports = { 'atom-workspace': { 'ctrl-alt-enter': 'appc:build' + }, + '.appc-browser': { + '/': 'native!', + 'a': 'native!', + 'backspace': 'native!', + 'd': 'native!', + 'delete': 'native!', + 'down': 'native!', + 'end': 'native!', + 'enter': 'native!', + 'esc': 'native!', + 'escape': 'native!', + 'f11': 'native!', + 'f2': 'native!', + 'f3': 'native!', + 'h': 'native!', + 'home': 'native!', + 'i': 'native!', + 'j': 'native!', + 'k': 'native!', + 'l': 'native!', + 'left': 'native!', + 'm': 'native!', + 'o': 'native!', + 'pagedown': 'native!', + 'pageup': 'native!', + 'right': 'native!', + 'tab': 'native!', + 'up': 'native!', + + 'alt-1': 'native!', + 'alt-2': 'native!', + 'alt-3': 'native!', + 'alt-4': 'native!', + 'alt-5': 'native!', + 'alt-6': 'native!', + 'alt-7': 'native!', + 'alt-8': 'native!', + 'alt-9': 'native!', + 'alt-\\': 'native!', + 'alt-backspace': 'native!', + 'alt-cmd-.': 'native!', + 'alt-cmd-/': 'native!', + 'alt-cmd-c': 'native!', + 'alt-cmd-down': 'native!', + 'alt-cmd-e': 'native!', + 'alt-cmd-f': 'native!', + 'alt-cmd-q': 'native!', + 'alt-cmd-s': 'native!', + 'alt-cmd-t': 'native!', + 'alt-cmd-up': 'native!', + 'alt-cmd-w': 'native!', + 'alt-delete': 'native!', + 'alt-down': 'native!', + 'alt-enter': 'native!', + 'alt-f3': 'native!', + 'alt-g': 'native!', + 'alt-left': 'native!', + 'alt-m': 'native!', + 'alt-right': 'native!', + 'alt-shift-down': 'native!', + 'alt-shift-f2': 'native!', + 'alt-shift-left': 'native!', + 'alt-shift-right': 'native!', + 'alt-shift-up': 'native!', + 'alt-up': 'native!', + 'cmd-+': 'native!', + 'cmd-,': 'native!', + 'cmd--': 'native!', + 'cmd-.': 'native!', + 'cmd-0': 'native!', + 'cmd-1': 'native!', + 'cmd-2': 'native!', + 'cmd-3': 'native!', + 'cmd-4': 'native!', + 'cmd-5': 'native!', + 'cmd-6': 'native!', + 'cmd-7': 'native!', + 'cmd-8': 'native!', + 'cmd-9': 'native!', + 'cmd-:': 'native!', + 'cmd-=': 'native!', + 'cmd-\\': 'native!', + 'cmd-_': 'native!', + 'cmd-a': 'native!', + 'cmd-b': 'native!', + 'cmd-backspace': 'native!', + 'cmd-c': 'native!', + 'cmd-d': 'native!', + 'cmd-down': 'native!', + 'cmd-e': 'native!', + 'cmd-enter': 'native!', + 'cmd-f': 'native!', + 'cmd-f2': 'native!', + 'cmd-f3': 'native!', + 'cmd-g': 'native!', + 'cmd-k': 'native!', + 'cmd-left': 'native!', + 'cmd-p': 'native!', + 'cmd-r': 'native!', + 'cmd-right': 'native!', + 'cmd-t': 'native!', + 'cmd-u': 'native!', + 'cmd-up': 'native!', + 'cmd-v': 'native!', + 'cmd-w': 'native!', + 'cmd-x': 'native!', + 'cmd-|': 'native!', + 'ctrl-+': 'native!', + 'ctrl-,': 'native!', + 'ctrl--': 'native!', + 'ctrl-.': 'native!', + 'ctrl-/': 'native!', + 'ctrl-0': 'native!', + 'ctrl-1': 'native!', + 'ctrl-2': 'native!', + 'ctrl-3': 'native!', + 'ctrl-4': 'native!', + 'ctrl-5': 'native!', + 'ctrl-6': 'native!', + 'ctrl-7': 'native!', + 'ctrl-8': 'native!', + 'ctrl-9': 'native!', + 'ctrl-:': 'native!', + 'ctrl-<': 'native!', + 'ctrl-=': 'native!', + 'ctrl-[': 'native!', + 'ctrl-\\': 'native!', + 'ctrl-]': 'native!', + 'ctrl-_': 'native!', + 'ctrl-a': 'native!', + 'ctrl-alt-,': 'native!', + 'ctrl-alt--': 'native!', + 'ctrl-alt-.': 'native!', + 'ctrl-alt-/': 'native!', + 'ctrl-alt-=': 'native!', + 'ctrl-alt-[': 'native!', + 'ctrl-alt-]': 'native!', + 'ctrl-alt-backspace': 'native!', + 'ctrl-alt-down': 'native!', + 'ctrl-alt-enter': 'native!', + 'ctrl-alt-f2': 'native!', + 'ctrl-alt-shift-R': 'native!', + 'ctrl-alt-shift-[': 'native!', + 'ctrl-alt-up': 'native!', + 'ctrl-alt-{': 'native!', + 'ctrl-alt-}': 'native!', + 'ctrl-b': 'native!', + 'ctrl-backspace': 'native!', + 'ctrl-c': 'native!', + 'ctrl-cmd-g': 'native!', + 'ctrl-cmd-m': 'native!', + 'ctrl-d': 'native!', + 'ctrl-delete': 'native!', + 'ctrl-down': 'native!', + 'ctrl-e': 'native!', + 'ctrl-end': 'native!', + 'ctrl-enter': 'native!', + 'ctrl-f': 'native!', + 'ctrl-f2': 'native!', + 'ctrl-f3': 'native!', + 'ctrl-f4': 'native!', + 'ctrl-g': 'native!', + 'ctrl-h': 'native!', + 'ctrl-home': 'native!', + 'ctrl-insert': 'native!', + 'ctrl-j': 'native!', + 'ctrl-k': 'native!', + 'ctrl-l': 'native!', + 'ctrl-left': 'native!', + 'ctrl-m': 'native!', + 'ctrl-n': 'native!', + 'ctrl-o': 'native!', + 'ctrl-p': 'native!', + 'ctrl-pagedown': 'native!', + 'ctrl-pageup': 'native!', + 'ctrl-r': 'native!', + 'ctrl-right': 'native!', + 'ctrl-s': 'native!', + 'ctrl-shift-8': 'native!', + 'ctrl-shift-9': 'native!', + 'ctrl-shift-A': 'native!', + 'ctrl-shift-B': 'native!', + 'ctrl-shift-C': 'native!', + 'ctrl-shift-D': 'native!', + 'ctrl-shift-F': 'native!', + 'ctrl-shift-G': 'native!', + 'ctrl-shift-I': 'native!', + 'ctrl-shift-K': 'native!', + 'ctrl-shift-L': 'native!', + 'ctrl-shift-M': 'native!', + 'ctrl-shift-N': 'native!', + 'ctrl-shift-O': 'native!', + 'ctrl-shift-P': 'native!', + 'ctrl-shift-Q': 'native!', + 'ctrl-shift-R': 'native!', + 'ctrl-shift-S': 'native!', + 'ctrl-shift-T': 'native!', + 'ctrl-shift-U': 'native!', + 'ctrl-shift-V': 'native!', + 'ctrl-shift-W': 'native!', + 'ctrl-shift-Y': 'native!', + 'ctrl-shift-Z': 'native!', + 'ctrl-shift-cmd-G': 'native!', + 'ctrl-shift-cmd-R': 'native!', + 'ctrl-shift-down': 'native!', + 'ctrl-shift-end': 'native!', + 'ctrl-shift-enter': 'native!', + 'ctrl-shift-f2': 'native!', + 'ctrl-shift-f3': 'native!', + 'ctrl-shift-home': 'native!', + 'ctrl-shift-left': 'native!', + 'ctrl-shift-right': 'native!', + 'ctrl-shift-tab': 'native!', + 'ctrl-shift-up': 'native!', + 'ctrl-space': 'native!', + 'ctrl-t': 'native!', + 'ctrl-tab': 'native!', + 'ctrl-u': 'native!', + 'ctrl-up': 'native!', + 'ctrl-v': 'native!', + 'ctrl-w': 'native!', + 'ctrl-x': 'native!', + 'ctrl-y': 'native!', + 'ctrl-z': 'native!', + 'ctrl-|': 'native!', + 'shift-A': 'native!', + 'shift-backspace': 'native!', + 'shift-cmd-B': 'native!', + 'shift-cmd-F': 'native!', + 'shift-cmd-G': 'native!', + 'shift-cmd-P': 'native!', + 'shift-cmd-R': 'native!', + 'shift-cmd-down': 'native!', + 'shift-cmd-f2': 'native!', + 'shift-cmd-f3': 'native!', + 'shift-cmd-left': 'native!', + 'shift-cmd-right': 'native!', + 'shift-cmd-up': 'native!', + 'shift-delete': 'native!', + 'shift-down': 'native!', + 'shift-end': 'native!', + 'shift-enter': 'native!', + 'shift-f2': 'native!', + 'shift-f3': 'native!', + 'shift-home': 'native!', + 'shift-insert': 'native!', + 'shift-left': 'native!', + 'shift-pagedown': 'native!', + 'shift-pageup': 'native!', + 'shift-right': 'native!', + 'shift-tab': 'native!', + 'shift-up': 'native!', } }; diff --git a/lib/ui/browser.js b/lib/ui/browser.js new file mode 100644 index 00000000..e561ae86 --- /dev/null +++ b/lib/ui/browser.js @@ -0,0 +1,60 @@ +'use babel'; +/** @jsx etch.dom */ + +import etch from 'etch'; + +import { CompositeDisposable } from 'atom'; + +export default class Browser { + + constructor() { + this.state = { + url: '' + }; + + etch.initialize(this); + } + + async destroy() { + await etch.destroy(this); + } + + render() { + return
+
+ +
+
; + } + + onContextMenu(e) { + e.preventDefault(); + e.cancelBubble = true; + return false; + } + + onReady(e) { + e.target.focus(); + } + + update() { + return etch.update(this); + } + + getTitle() { + return 'debugger'; + } + + show() { + atom.workspace.open(this, { + activatePane: true, + activateItem: true, + searchAllPanes: true + }); + } + + setUrl(url) { + this.state.url = url; + this.update(); + } +} diff --git a/lib/ui/console.js b/lib/ui/console.js index 896818dd..df70a99e 100644 --- a/lib/ui/console.js +++ b/lib/ui/console.js @@ -98,7 +98,7 @@ export default class Console { * @param {Boolean} autoScroll auto-scroll console window * @param {Boolean} showOnBuild display console when running build command */ - constructor(opts) { + constructor(opts, browser) { this.state = { isHidden: true, logLevel: 'trace', @@ -107,6 +107,8 @@ export default class Console { }; opts && Object.assign(this.state, opts); + this.browser = browser; + etch.initialize(this); if (!this.state.isHidden) { @@ -270,6 +272,7 @@ export default class Console { } else { this.info(line); } + this.openDevtools(line); } } @@ -318,6 +321,15 @@ export default class Console { this.refs.log.write(text, 'error'); } + openDevtools(line) { + let matchResult = line.match(/(chrome-devtools.*)$/); + if (matchResult) { + let url = matchResult[0]; + this.browser.setUrl(url); + this.browser.show(); + } + } + /** * Show / hide console */ diff --git a/styles/appc.less b/styles/appc.less index e7a22c90..fac641ea 100644 --- a/styles/appc.less +++ b/styles/appc.less @@ -317,4 +317,17 @@ width:25px; border:none; } -} \ No newline at end of file +} + +.appc-browser { + .webview-container { + width:100%; + height:100%; + + webview { + width:100%; + height:100%; + } + } +} + From cadaafb29bd343d9aaf0a3e41dd760829fdc1610 Mon Sep 17 00:00:00 2001 From: Steven Lemon Date: Sun, 21 Jan 2018 11:15:58 +1300 Subject: [PATCH 2/2] replace keymaps with native-key-bindings class --- lib/keymap.js | 253 ---------------------------------------------- lib/ui/browser.js | 2 +- 2 files changed, 1 insertion(+), 254 deletions(-) diff --git a/lib/keymap.js b/lib/keymap.js index 9d330496..a2a6be41 100644 --- a/lib/keymap.js +++ b/lib/keymap.js @@ -1,258 +1,5 @@ module.exports = { 'atom-workspace': { 'ctrl-alt-enter': 'appc:build' - }, - '.appc-browser': { - '/': 'native!', - 'a': 'native!', - 'backspace': 'native!', - 'd': 'native!', - 'delete': 'native!', - 'down': 'native!', - 'end': 'native!', - 'enter': 'native!', - 'esc': 'native!', - 'escape': 'native!', - 'f11': 'native!', - 'f2': 'native!', - 'f3': 'native!', - 'h': 'native!', - 'home': 'native!', - 'i': 'native!', - 'j': 'native!', - 'k': 'native!', - 'l': 'native!', - 'left': 'native!', - 'm': 'native!', - 'o': 'native!', - 'pagedown': 'native!', - 'pageup': 'native!', - 'right': 'native!', - 'tab': 'native!', - 'up': 'native!', - - 'alt-1': 'native!', - 'alt-2': 'native!', - 'alt-3': 'native!', - 'alt-4': 'native!', - 'alt-5': 'native!', - 'alt-6': 'native!', - 'alt-7': 'native!', - 'alt-8': 'native!', - 'alt-9': 'native!', - 'alt-\\': 'native!', - 'alt-backspace': 'native!', - 'alt-cmd-.': 'native!', - 'alt-cmd-/': 'native!', - 'alt-cmd-c': 'native!', - 'alt-cmd-down': 'native!', - 'alt-cmd-e': 'native!', - 'alt-cmd-f': 'native!', - 'alt-cmd-q': 'native!', - 'alt-cmd-s': 'native!', - 'alt-cmd-t': 'native!', - 'alt-cmd-up': 'native!', - 'alt-cmd-w': 'native!', - 'alt-delete': 'native!', - 'alt-down': 'native!', - 'alt-enter': 'native!', - 'alt-f3': 'native!', - 'alt-g': 'native!', - 'alt-left': 'native!', - 'alt-m': 'native!', - 'alt-right': 'native!', - 'alt-shift-down': 'native!', - 'alt-shift-f2': 'native!', - 'alt-shift-left': 'native!', - 'alt-shift-right': 'native!', - 'alt-shift-up': 'native!', - 'alt-up': 'native!', - 'cmd-+': 'native!', - 'cmd-,': 'native!', - 'cmd--': 'native!', - 'cmd-.': 'native!', - 'cmd-0': 'native!', - 'cmd-1': 'native!', - 'cmd-2': 'native!', - 'cmd-3': 'native!', - 'cmd-4': 'native!', - 'cmd-5': 'native!', - 'cmd-6': 'native!', - 'cmd-7': 'native!', - 'cmd-8': 'native!', - 'cmd-9': 'native!', - 'cmd-:': 'native!', - 'cmd-=': 'native!', - 'cmd-\\': 'native!', - 'cmd-_': 'native!', - 'cmd-a': 'native!', - 'cmd-b': 'native!', - 'cmd-backspace': 'native!', - 'cmd-c': 'native!', - 'cmd-d': 'native!', - 'cmd-down': 'native!', - 'cmd-e': 'native!', - 'cmd-enter': 'native!', - 'cmd-f': 'native!', - 'cmd-f2': 'native!', - 'cmd-f3': 'native!', - 'cmd-g': 'native!', - 'cmd-k': 'native!', - 'cmd-left': 'native!', - 'cmd-p': 'native!', - 'cmd-r': 'native!', - 'cmd-right': 'native!', - 'cmd-t': 'native!', - 'cmd-u': 'native!', - 'cmd-up': 'native!', - 'cmd-v': 'native!', - 'cmd-w': 'native!', - 'cmd-x': 'native!', - 'cmd-|': 'native!', - 'ctrl-+': 'native!', - 'ctrl-,': 'native!', - 'ctrl--': 'native!', - 'ctrl-.': 'native!', - 'ctrl-/': 'native!', - 'ctrl-0': 'native!', - 'ctrl-1': 'native!', - 'ctrl-2': 'native!', - 'ctrl-3': 'native!', - 'ctrl-4': 'native!', - 'ctrl-5': 'native!', - 'ctrl-6': 'native!', - 'ctrl-7': 'native!', - 'ctrl-8': 'native!', - 'ctrl-9': 'native!', - 'ctrl-:': 'native!', - 'ctrl-<': 'native!', - 'ctrl-=': 'native!', - 'ctrl-[': 'native!', - 'ctrl-\\': 'native!', - 'ctrl-]': 'native!', - 'ctrl-_': 'native!', - 'ctrl-a': 'native!', - 'ctrl-alt-,': 'native!', - 'ctrl-alt--': 'native!', - 'ctrl-alt-.': 'native!', - 'ctrl-alt-/': 'native!', - 'ctrl-alt-=': 'native!', - 'ctrl-alt-[': 'native!', - 'ctrl-alt-]': 'native!', - 'ctrl-alt-backspace': 'native!', - 'ctrl-alt-down': 'native!', - 'ctrl-alt-enter': 'native!', - 'ctrl-alt-f2': 'native!', - 'ctrl-alt-shift-R': 'native!', - 'ctrl-alt-shift-[': 'native!', - 'ctrl-alt-up': 'native!', - 'ctrl-alt-{': 'native!', - 'ctrl-alt-}': 'native!', - 'ctrl-b': 'native!', - 'ctrl-backspace': 'native!', - 'ctrl-c': 'native!', - 'ctrl-cmd-g': 'native!', - 'ctrl-cmd-m': 'native!', - 'ctrl-d': 'native!', - 'ctrl-delete': 'native!', - 'ctrl-down': 'native!', - 'ctrl-e': 'native!', - 'ctrl-end': 'native!', - 'ctrl-enter': 'native!', - 'ctrl-f': 'native!', - 'ctrl-f2': 'native!', - 'ctrl-f3': 'native!', - 'ctrl-f4': 'native!', - 'ctrl-g': 'native!', - 'ctrl-h': 'native!', - 'ctrl-home': 'native!', - 'ctrl-insert': 'native!', - 'ctrl-j': 'native!', - 'ctrl-k': 'native!', - 'ctrl-l': 'native!', - 'ctrl-left': 'native!', - 'ctrl-m': 'native!', - 'ctrl-n': 'native!', - 'ctrl-o': 'native!', - 'ctrl-p': 'native!', - 'ctrl-pagedown': 'native!', - 'ctrl-pageup': 'native!', - 'ctrl-r': 'native!', - 'ctrl-right': 'native!', - 'ctrl-s': 'native!', - 'ctrl-shift-8': 'native!', - 'ctrl-shift-9': 'native!', - 'ctrl-shift-A': 'native!', - 'ctrl-shift-B': 'native!', - 'ctrl-shift-C': 'native!', - 'ctrl-shift-D': 'native!', - 'ctrl-shift-F': 'native!', - 'ctrl-shift-G': 'native!', - 'ctrl-shift-I': 'native!', - 'ctrl-shift-K': 'native!', - 'ctrl-shift-L': 'native!', - 'ctrl-shift-M': 'native!', - 'ctrl-shift-N': 'native!', - 'ctrl-shift-O': 'native!', - 'ctrl-shift-P': 'native!', - 'ctrl-shift-Q': 'native!', - 'ctrl-shift-R': 'native!', - 'ctrl-shift-S': 'native!', - 'ctrl-shift-T': 'native!', - 'ctrl-shift-U': 'native!', - 'ctrl-shift-V': 'native!', - 'ctrl-shift-W': 'native!', - 'ctrl-shift-Y': 'native!', - 'ctrl-shift-Z': 'native!', - 'ctrl-shift-cmd-G': 'native!', - 'ctrl-shift-cmd-R': 'native!', - 'ctrl-shift-down': 'native!', - 'ctrl-shift-end': 'native!', - 'ctrl-shift-enter': 'native!', - 'ctrl-shift-f2': 'native!', - 'ctrl-shift-f3': 'native!', - 'ctrl-shift-home': 'native!', - 'ctrl-shift-left': 'native!', - 'ctrl-shift-right': 'native!', - 'ctrl-shift-tab': 'native!', - 'ctrl-shift-up': 'native!', - 'ctrl-space': 'native!', - 'ctrl-t': 'native!', - 'ctrl-tab': 'native!', - 'ctrl-u': 'native!', - 'ctrl-up': 'native!', - 'ctrl-v': 'native!', - 'ctrl-w': 'native!', - 'ctrl-x': 'native!', - 'ctrl-y': 'native!', - 'ctrl-z': 'native!', - 'ctrl-|': 'native!', - 'shift-A': 'native!', - 'shift-backspace': 'native!', - 'shift-cmd-B': 'native!', - 'shift-cmd-F': 'native!', - 'shift-cmd-G': 'native!', - 'shift-cmd-P': 'native!', - 'shift-cmd-R': 'native!', - 'shift-cmd-down': 'native!', - 'shift-cmd-f2': 'native!', - 'shift-cmd-f3': 'native!', - 'shift-cmd-left': 'native!', - 'shift-cmd-right': 'native!', - 'shift-cmd-up': 'native!', - 'shift-delete': 'native!', - 'shift-down': 'native!', - 'shift-end': 'native!', - 'shift-enter': 'native!', - 'shift-f2': 'native!', - 'shift-f3': 'native!', - 'shift-home': 'native!', - 'shift-insert': 'native!', - 'shift-left': 'native!', - 'shift-pagedown': 'native!', - 'shift-pageup': 'native!', - 'shift-right': 'native!', - 'shift-tab': 'native!', - 'shift-up': 'native!', } }; diff --git a/lib/ui/browser.js b/lib/ui/browser.js index e561ae86..dd6a1ef7 100644 --- a/lib/ui/browser.js +++ b/lib/ui/browser.js @@ -20,7 +20,7 @@ export default class Browser { } render() { - return
+ return