Fixed merge conflicts

This commit is contained in:
Leo Lamprecht 2018-04-16 07:17:17 -07:00
parent 4d7ce43755
commit 4ce99863c4
133 changed files with 74506 additions and 53064 deletions

View file

@ -1,31 +0,0 @@
const colorList = [
'black',
'red',
'green',
'yellow',
'blue',
'magenta',
'cyan',
'white',
'lightBlack',
'lightRed',
'lightGreen',
'lightYellow',
'lightBlue',
'lightMagenta',
'lightCyan',
'lightWhite',
'colorCubes',
'grayscale'
];
export default function getColorList(colors) {
// For backwards compatibility, return early if it's already an array
if (Array.isArray(colors)) {
return colors;
}
return colorList.map(colorName => {
return colors[colorName];
});
}

View file

@ -15,9 +15,5 @@ export default function isExecutable(fileStat) {
return true;
}
return Boolean(
(fileStat.mode & 0o0001) ||
(fileStat.mode & 0o0010) ||
(fileStat.mode & 0o0100)
);
return Boolean(fileStat.mode & 0o0001 || fileStat.mode & 0o0010 || fileStat.mode & 0o0100);
}

View file

@ -1,79 +0,0 @@
/**
* Keyboard event keyCodes have proven to be really unreliable.
* This util function will cover most of the edge cases where
* String.fromCharCode() doesn't work.
*/
const _toAscii = {
188: '44',
109: '45',
190: '46',
191: '47',
192: '96',
220: '92',
222: '39',
221: '93',
219: '91',
173: '45',
187: '61', // IE Key codes
186: '59', // IE Key codes
189: '45' // IE Key codes
};
const _shiftUps = {
96: '~',
49: '!',
50: '@',
51: '#',
52: '$',
53: '%',
54: '^',
55: '&',
56: '*',
57: '(',
48: ')',
45: '_',
61: '+',
91: '{',
93: '}',
92: '|',
59: ':',
39: '\'',
44: '<',
46: '>',
47: '?'
};
const _arrowKeys = {
38: '',
40: '',
39: '',
37: ''
};
/**
* This fn takes a keyboard event and returns
* the character that was pressed. This fn
* purposely doesn't take into account if the alt/meta
* key was pressed.
*/
export default function fromCharCode(e) {
let code = String(e.which);
if ({}.hasOwnProperty.call(_arrowKeys, code)) {
return _arrowKeys[code];
}
if ({}.hasOwnProperty.call(_toAscii, code)) {
code = _toAscii[code];
}
const char = String.fromCharCode(code);
if (e.shiftKey) {
if ({}.hasOwnProperty.call(_shiftUps, code)) {
return _shiftUps[code];
}
return char.toUpperCase();
}
return char.toLowerCase();
}

View file

@ -1,34 +0,0 @@
import {remote} from 'electron';
const getCommand = remote.require('./utils/keymaps/get-command');
export default function returnKey(e) {
let keys = [];
if (e.metaKey && process.platform === 'darwin') {
keys.push('cmd');
} else if (e.metaKey) {
keys.push(e.key);
}
if (e.ctrlKey) {
keys.push('ctrl');
}
if (e.shiftKey) {
keys.push('shift');
}
if (e.altKey) {
keys.push('alt');
}
if (e.key === ' ') {
keys.push('space');
} else if (e.key !== 'Meta' && e.key !== 'Control' && e.key !== 'Shift' && e.key !== 'Alt') {
keys.push(e.key.replace('Arrow', ''));
}
keys = keys.join('+');
return getCommand(keys);
}

View file

@ -1,6 +1,7 @@
/* global Notification */
/* eslint no-new:0 */
export default function notify(title, body) {
//eslint-disable-next-line no-console
console.log(`[Notification] ${title}: ${body}`);
new Notification(title, {body});
}

21
lib/utils/paste.js Normal file
View file

@ -0,0 +1,21 @@
import {clipboard} from 'electron';
const getPath = platform => {
switch (platform) {
case 'darwin': {
const filepath = clipboard.read('public.file-url');
return filepath.replace('file://', '');
}
case 'win32': {
const filepath = clipboard.read('FileNameW');
return filepath.replace(new RegExp(String.fromCharCode(0), 'g'), '');
}
// Linux already pastes full path
default:
return null;
}
};
export default function processClipboard() {
return getPath(process.platform);
}

View file

@ -1,25 +1,26 @@
import {remote} from 'electron';
import {connect as reduxConnect} from 'react-redux';
import {basename} from 'path';
// patching Module._load
// so plugins can `require` them wihtout needing their own version
// so plugins can `require` them without needing their own version
// https://github.com/zeit/hyper/issues/619
import React from 'react';
import React, {PureComponent} from 'react';
import ReactDOM from 'react-dom';
import Component from '../component';
import Notification from '../components/notification';
import notify from './notify';
const Module = require('module'); // eslint-disable-line import/newline-after-import
//eslint-disable-next-line import/newline-after-import
const Module = require('module');
const originalLoad = Module._load;
Module._load = function (path) {
Module._load = function _load(path) {
switch (path) {
case 'react':
return React;
case 'react-dom':
return ReactDOM;
case 'hyper/component':
return Component;
return PureComponent;
case 'hyper/notify':
return notify;
case 'hyper/Notification':
@ -53,10 +54,10 @@ let termGroupPropsDecorators;
let propsDecorators;
let reducersDecorators;
// the fs locations where user plugins are stored
const {path, localPath} = plugins.getBasePaths();
const clearModulesCache = () => {
// the fs locations where user plugins are stored
const {path, localPath} = plugins.getBasePaths();
// trigger unload hooks
modules.forEach(mod => {
if (mod.onRendererUnload) {
@ -82,12 +83,14 @@ const getPluginVersion = path => {
try {
version = window.require(pathModule.resolve(path, 'package.json')).version;
} catch (err) {
//eslint-disable-next-line no-console
console.warn(`No package.json found in ${path}`);
}
return version;
};
const loadModules = () => {
//eslint-disable-next-line no-console
console.log('(re)loading renderer plugins');
const paths = plugins.getPaths();
@ -120,7 +123,10 @@ const loadModules = () => {
reduceTermGroups: termGroupsReducers
};
modules = paths.plugins.concat(paths.localPlugins)
const loadedPlugins = plugins.getLoadedPluginVersions().map(plugin => plugin.name);
modules = paths.plugins
.concat(paths.localPlugins)
.filter(plugin => loadedPlugins.indexOf(basename(plugin)) !== -1)
.map(path => {
let mod;
const pluginName = getPluginName(path);
@ -131,8 +137,12 @@ const loadModules = () => {
try {
mod = window.require(path);
} catch (err) {
//eslint-disable-next-line no-console
console.error(err.stack);
notify('Plugin load error', `"${pluginName}" failed to load in the renderer process. Check Developer Tools for details.`);
notify(
'Plugin load error',
`"${pluginName}" failed to load in the renderer process. Check Developer Tools for details.`
);
return undefined;
}
@ -146,12 +156,14 @@ const loadModules = () => {
// mapHyperTermState mapping for backwards compatibility with hyperterm
if (mod.mapHyperTermState) {
mod.mapHyperState = mod.mapHyperTermState;
//eslint-disable-next-line no-console
console.error('mapHyperTermState is deprecated. Use mapHyperState instead.');
}
// mapHyperTermDispatch mapping for backwards compatibility with hyperterm
if (mod.mapHyperTermDispatch) {
mod.mapHyperDispatch = mod.mapHyperTermDispatch;
//eslint-disable-next-line no-console
console.error('mapHyperTermDispatch is deprecated. Use mapHyperDispatch instead.');
}
@ -222,12 +234,21 @@ const loadModules = () => {
if (mod.onRendererWindow) {
mod.onRendererWindow(window);
}
//eslint-disable-next-line no-console
console.log(`Plugin ${pluginName} (${pluginVersion}) loaded.`);
return mod;
})
.filter(mod => Boolean(mod));
const deprecatedPlugins = plugins.getDeprecatedConfig();
Object.keys(deprecatedPlugins).forEach(name => {
const {css} = deprecatedPlugins[name];
if (css) {
//eslint-disable-next-line no-console
console.warn(`Warning: "${name}" plugin uses some deprecated CSS classes (${css.join(', ')}).`);
}
});
};
// load modules for initial decoration
@ -255,6 +276,7 @@ function getProps(name, props, ...fnArgs) {
try {
ret_ = fn(...fnArgs, props_);
} catch (err) {
//eslint-disable-next-line no-console
console.error(err.stack);
notify('Plugin error', `${fn._pluginName}: Error occurred in \`${name}\`. Check Developer Tools for details.`);
return;
@ -301,8 +323,12 @@ export function connect(stateFn, dispatchFn, c, d = {}) {
try {
ret_ = fn(state, ret);
} catch (err) {
//eslint-disable-next-line no-console
console.error(err.stack);
notify('Plugin error', `${fn._pluginName}: Error occurred in \`map${name}State\`. Check Developer Tools for details.`);
notify(
'Plugin error',
`${fn._pluginName}: Error occurred in \`map${name}State\`. Check Developer Tools for details.`
);
return;
}
@ -323,13 +349,20 @@ export function connect(stateFn, dispatchFn, c, d = {}) {
try {
ret_ = fn(dispatch, ret);
} catch (err) {
//eslint-disable-next-line no-console
console.error(err.stack);
notify('Plugin error', `${fn._pluginName}: Error occurred in \`map${name}Dispatch\`. Check Developer Tools for details.`);
notify(
'Plugin error',
`${fn._pluginName}: Error occurred in \`map${name}Dispatch\`. Check Developer Tools for details.`
);
return;
}
if (!ret_ || typeof ret_ !== 'object') {
notify('Plugin error', `${fn._pluginName}: Invalid return value of \`map${name}Dispatch\` (object expected).`);
notify(
'Plugin error',
`${fn._pluginName}: Invalid return value of \`map${name}Dispatch\` (object expected).`
);
return;
}
@ -354,6 +387,7 @@ function decorateReducer(name, fn) {
try {
state__ = pluginReducer(state_, action);
} catch (err) {
//eslint-disable-next-line no-console
console.error(err.stack);
notify('Plugin error', `${fn._pluginName}: Error occurred in \`${name}\`. Check Developer Tools for details.`);
return;
@ -385,26 +419,29 @@ export function decorateSessionsReducer(fn) {
// redux middleware generator
export const middleware = store => next => action => {
const nextMiddleware = remaining => action => remaining.length ?
remaining[0](store)(nextMiddleware(remaining.slice(1)))(action) :
next(action);
const nextMiddleware = remaining => action_ =>
remaining.length ? remaining[0](store)(nextMiddleware(remaining.slice(1)))(action_) : next(action_);
nextMiddleware(middlewares)(action);
};
// expose decorated component instance to the higher-order components
function exposeDecorated(Component) {
return class extends React.Component {
function exposeDecorated(Component_) {
return class DecoratedComponent extends React.Component {
constructor(props, context) {
super(props, context);
this.onRef = this.onRef.bind(this);
}
onRef(decorated) {
onRef(decorated_) {
if (this.props.onDecorated) {
this.props.onDecorated(decorated);
try {
this.props.onDecorated(decorated_);
} catch (e) {
notify('Plugin error', `Error occurred. Check Developer Tools for details`);
}
}
}
render() {
return React.createElement(Component, Object.assign({}, this.props, {ref: this.onRef}));
return React.createElement(Component_, Object.assign({}, this.props, {ref: this.onRef}));
}
};
}
@ -422,16 +459,25 @@ function getDecorated(parent, name) {
let class__;
try {
class__ = fn(class_, {React, Component, Notification, notify});
class__ = fn(class_, {React, PureComponent, Notification, notify});
class__.displayName = `${fn._pluginName}(${name})`;
} catch (err) {
//eslint-disable-next-line no-console
console.error(err.stack);
notify('Plugin error', `${fn._pluginName}: Error occurred in \`${method}\`. Check Developer Tools for details`);
notify(
'Plugin error',
`${fn._pluginName}: Error occurred in \`${method}\`. Check Developer Tools for details`
);
return;
}
if (!class__ || typeof class__.prototype.render !== 'function') {
notify('Plugin error', `${fn._pluginName}: Invalid return value of \`${method}\`. No \`render\` method found. Please return a \`React.Component\`.`);
notify(
'Plugin error',
`${
fn._pluginName
}: Invalid return value of \`${method}\`. No \`render\` method found. Please return a \`React.Component\`.`
);
return;
}
@ -448,10 +494,22 @@ function getDecorated(parent, name) {
// for each component, we return a higher-order component
// that wraps with the higher-order components
// exposed by plugins
export function decorate(Component, name) {
return class extends React.Component {
export function decorate(Component_, name) {
return class DecoratedComponent extends React.Component {
constructor(props) {
super(props);
this.state = {hasError: false};
}
componentDidCatch() {
this.setState({hasError: true});
// No need to detail this error because React print those informations.
notify(
'Plugin error',
`Plugins decorating ${name} has been disabled because of a plugin crash. Check Developer Tools for details.`
);
}
render() {
const Sub = getDecorated(Component, name);
const Sub = this.state.hasError ? Component_ : getDecorated(Component_, name);
return React.createElement(Sub, this.props);
}
};

View file

@ -1,5 +1,4 @@
export default class Client {
constructor() {
const electron = window.require('electron');
const EventEmitter = window.require('events');
@ -56,5 +55,4 @@ export default class Client {
this.removeAllListeners();
this.ipc.removeAllListeners();
}
}

View file

@ -1,11 +1,11 @@
// Clear selection range of current selected term view
// Fix event when terminal text is selected and keyboard action is invoked
exports.clear = function (terminal) {
exports.clear = terminal => {
terminal.document_.getSelection().removeAllRanges();
};
// Use selection extend upon dblclick
exports.extend = function (terminal) {
exports.extend = terminal => {
const sel = terminal.document_.getSelection();
// Test if focusNode exist and nodeName is #text
@ -19,7 +19,7 @@ exports.extend = function (terminal) {
// Fix a bug in ScrollPort selectAll behavior
// Select all rows in the viewport
exports.all = function (terminal) {
exports.all = terminal => {
const scrollPort = terminal.scrollPort_;
let firstRow;
let lastRow;

View file

@ -2,7 +2,7 @@ import path from 'path';
import * as regex from './url-regex';
export default function isUrlCommand(shell, data) {
const matcher = regex[path.parse(shell).name]; // eslint-disable-line import/namespace
const matcher = regex[path.parse(shell).name];
if (undefined === matcher || !data) {
return null;
}