mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
cleanup and type fixes
This commit is contained in:
parent
8991dfab61
commit
e31d72cc31
12 changed files with 45 additions and 40 deletions
|
|
@ -76,21 +76,16 @@ export default (win: BrowserWindow) => {
|
||||||
|
|
||||||
const {rpc} = win;
|
const {rpc} = win;
|
||||||
|
|
||||||
const onupdate = (
|
const onupdate = (ev: Event, releaseNotes: string, releaseName: string, date: Date, updateUrl: string) => {
|
||||||
ev: Event,
|
|
||||||
releaseNotes: string,
|
|
||||||
releaseName: string,
|
|
||||||
date: Date,
|
|
||||||
updateUrl: string,
|
|
||||||
onQuitAndInstall: any
|
|
||||||
) => {
|
|
||||||
const releaseUrl = updateUrl || `https://github.com/vercel/hyper/releases/tag/${releaseName}`;
|
const releaseUrl = updateUrl || `https://github.com/vercel/hyper/releases/tag/${releaseName}`;
|
||||||
rpc.emit('update available', {releaseNotes, releaseName, releaseUrl, canInstall: !!onQuitAndInstall});
|
rpc.emit('update available', {releaseNotes, releaseName, releaseUrl, canInstall: !isLinux});
|
||||||
};
|
};
|
||||||
|
|
||||||
const eventName: any = isLinux ? 'update-available' : 'update-downloaded';
|
if (isLinux) {
|
||||||
|
autoUpdater.on('update-available', onupdate);
|
||||||
autoUpdater.on(eventName, onupdate);
|
} else {
|
||||||
|
autoUpdater.on('update-downloaded', onupdate);
|
||||||
|
}
|
||||||
|
|
||||||
rpc.once('quit and install', () => {
|
rpc.once('quit and install', () => {
|
||||||
autoUpdater.quitAndInstall();
|
autoUpdater.quitAndInstall();
|
||||||
|
|
@ -111,6 +106,10 @@ export default (win: BrowserWindow) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
win.on('close', () => {
|
win.on('close', () => {
|
||||||
autoUpdater.removeListener(eventName, onupdate);
|
if (isLinux) {
|
||||||
|
autoUpdater.removeListener('update-available', onupdate);
|
||||||
|
} else {
|
||||||
|
autoUpdater.removeListener('update-downloaded', onupdate);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ const fileName =
|
||||||
function memoize<T extends (...args: any[]) => any>(fn: T): T {
|
function memoize<T extends (...args: any[]) => any>(fn: T): T {
|
||||||
let hasResult = false;
|
let hasResult = false;
|
||||||
let result: any;
|
let result: any;
|
||||||
return ((...args: any[]) => {
|
return ((...args: Parameters<T>) => {
|
||||||
if (!hasResult) {
|
if (!hasResult) {
|
||||||
result = fn(...args);
|
result = fn(...args);
|
||||||
hasResult = true;
|
hasResult = true;
|
||||||
|
|
|
||||||
|
|
@ -191,8 +191,10 @@ const main = (argv: string[]) => {
|
||||||
version: false,
|
version: false,
|
||||||
mri: {
|
mri: {
|
||||||
boolean: ['v', 'verbose']
|
boolean: ['v', 'verbose']
|
||||||
}
|
},
|
||||||
} as any);
|
mainColor: 'yellow',
|
||||||
|
subColor: 'dim'
|
||||||
|
});
|
||||||
|
|
||||||
if (commandPromise) {
|
if (commandPromise) {
|
||||||
return commandPromise;
|
return commandPromise;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ import parseUrl from 'parse-url';
|
||||||
import {HyperState, HyperDispatch, HyperActions, ITermGroups} from '../hyper';
|
import {HyperState, HyperDispatch, HyperActions, ITermGroups} from '../hyper';
|
||||||
import {stat, Stats} from 'fs';
|
import {stat, Stats} from 'fs';
|
||||||
|
|
||||||
export function openContextMenu(uid: string, selection: any) {
|
export function openContextMenu(uid: string, selection: string) {
|
||||||
return (dispatch: HyperDispatch, getState: () => HyperState) => {
|
return (dispatch: HyperDispatch, getState: () => HyperState) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: UI_CONTEXTMENU_OPEN,
|
type: UI_CONTEXTMENU_OPEN,
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,14 @@ export default class SplitPane extends React.PureComponent<SplitPaneProps, {drag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setupPanes(ev: any) {
|
setupPanes(ev: React.MouseEvent<HTMLDivElement>) {
|
||||||
this.panes = Array.from(ev.target.parentNode.childNodes);
|
const target = ev.target as HTMLDivElement;
|
||||||
this.paneIndex = this.panes.indexOf(ev.target);
|
this.panes = Array.from(target.parentElement?.children || []);
|
||||||
|
this.paneIndex = this.panes.indexOf(target);
|
||||||
this.paneIndex -= Math.ceil(this.paneIndex / 2);
|
this.paneIndex -= Math.ceil(this.paneIndex / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleAutoResize = (ev: React.MouseEvent) => {
|
handleAutoResize = (ev: React.MouseEvent<HTMLDivElement>) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
||||||
this.setupPanes(ev);
|
this.setupPanes(ev);
|
||||||
|
|
@ -46,8 +47,7 @@ export default class SplitPane extends React.PureComponent<SplitPaneProps, {drag
|
||||||
this.props.onResize(sizes_);
|
this.props.onResize(sizes_);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleDragStart = (ev: any) => {
|
handleDragStart = (ev: React.MouseEvent<HTMLDivElement>) => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
this.setState({dragging: true});
|
this.setState({dragging: true});
|
||||||
window.addEventListener('mousemove', this.onDrag);
|
window.addEventListener('mousemove', this.onDrag);
|
||||||
|
|
@ -64,10 +64,10 @@ export default class SplitPane extends React.PureComponent<SplitPaneProps, {drag
|
||||||
this.d3 = 'clientX';
|
this.d3 = 'clientX';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dragTarget = ev.target;
|
const target = ev.target as HTMLDivElement;
|
||||||
|
this.dragTarget = target;
|
||||||
this.dragPanePosition = this.dragTarget.getBoundingClientRect()[this.d2];
|
this.dragPanePosition = this.dragTarget.getBoundingClientRect()[this.d2];
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
this.panesSize = target.parentElement!.getBoundingClientRect()[this.d1];
|
||||||
this.panesSize = ev.target.parentNode.getBoundingClientRect()[this.d1];
|
|
||||||
this.setupPanes(ev);
|
this.setupPanes(ev);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ export interface SessionAddDataAction {
|
||||||
}
|
}
|
||||||
export interface SessionPtyDataAction {
|
export interface SessionPtyDataAction {
|
||||||
type: typeof SESSION_PTY_DATA;
|
type: typeof SESSION_PTY_DATA;
|
||||||
|
data: string;
|
||||||
uid: string;
|
uid: string;
|
||||||
now: number;
|
now: number;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ const mapDispatchToProps = (dispatch: HyperDispatch) => {
|
||||||
dispatch(closeSearch(uid));
|
dispatch(closeSearch(uid));
|
||||||
},
|
},
|
||||||
|
|
||||||
onContextMenu(uid: string, selection: any) {
|
onContextMenu(uid: string, selection: string) {
|
||||||
dispatch(setActiveSession(uid));
|
dispatch(setActiveSession(uid));
|
||||||
dispatch(openContextMenu(uid, selection));
|
dispatch(openContextMenu(uid, selection));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].includes(navigator.plat
|
||||||
const allowedCursorShapes = new Set(['BEAM', 'BLOCK', 'UNDERLINE']);
|
const allowedCursorShapes = new Set(['BEAM', 'BLOCK', 'UNDERLINE']);
|
||||||
const allowedCursorBlinkValues = new Set([true, false]);
|
const allowedCursorBlinkValues = new Set([true, false]);
|
||||||
const allowedBells = new Set(['SOUND', 'false', false]);
|
const allowedBells = new Set(['SOUND', 'false', false]);
|
||||||
const allowedHamburgerMenuValues = new Set([true, false]);
|
const allowedHamburgerMenuValues = new Set([true, false, '']);
|
||||||
const allowedWindowControlsValues = new Set([true, false, 'left']);
|
const allowedWindowControlsValues = new Set([true, false, 'left']);
|
||||||
|
|
||||||
// Populate `config-default.js` from this :)
|
// Populate `config-default.js` from this :)
|
||||||
|
|
@ -239,7 +239,7 @@ const reducer: IUiReducer = (state = initial, action) => {
|
||||||
ret.modifierKeys = config.modifierKeys;
|
ret.modifierKeys = config.modifierKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowedHamburgerMenuValues.has(config.showHamburgerMenu as any)) {
|
if (allowedHamburgerMenuValues.has(config.showHamburgerMenu)) {
|
||||||
ret.showHamburgerMenu = config.showHamburgerMenu;
|
ret.showHamburgerMenu = config.showHamburgerMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
|
import {HyperActions, HyperState} from '../hyper';
|
||||||
import terms from '../terms';
|
import terms from '../terms';
|
||||||
import {Middleware} from 'redux';
|
import {Dispatch, Middleware} from 'redux';
|
||||||
|
|
||||||
// the only side effect we perform from middleware
|
// the only side effect we perform from middleware
|
||||||
// is to write to the react term instance directly
|
// is to write to the react term instance directly
|
||||||
// to avoid a performance hit
|
// to avoid a performance hit
|
||||||
const writeMiddleware: Middleware = () => (next) => (action) => {
|
const writeMiddleware: Middleware<{}, HyperState, Dispatch<HyperActions>> = () => (next) => (action: HyperActions) => {
|
||||||
if (action.type === 'SESSION_PTY_DATA') {
|
if (action.type === 'SESSION_PTY_DATA') {
|
||||||
const term = terms[action.uid];
|
const term = terms[action.uid];
|
||||||
if (term) {
|
if (term) {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {Dispatch, Middleware} from 'redux';
|
||||||
|
import {HyperActions, HyperState} from '../hyper';
|
||||||
/**
|
/**
|
||||||
* Simple redux middleware that executes
|
* Simple redux middleware that executes
|
||||||
* the `effect` field if provided in an action
|
* the `effect` field if provided in an action
|
||||||
|
|
@ -6,8 +8,7 @@
|
||||||
* defer or add to existing side effects at will
|
* defer or add to existing side effects at will
|
||||||
* as the result of an action being triggered.
|
* as the result of an action being triggered.
|
||||||
*/
|
*/
|
||||||
import {Middleware} from 'redux';
|
const effectsMiddleware: Middleware<{}, HyperState, Dispatch<HyperActions>> = () => (next) => (action) => {
|
||||||
const effectsMiddleware: Middleware = () => (next) => (action) => {
|
|
||||||
const ret = next(action);
|
const ret = next(action);
|
||||||
if (action.effect) {
|
if (action.effect) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import {basename} from 'path';
|
||||||
// patching Module._load
|
// patching Module._load
|
||||||
// so plugins can `require` them without needing their own version
|
// so plugins can `require` them without needing their own version
|
||||||
// https://github.com/vercel/hyper/issues/619
|
// https://github.com/vercel/hyper/issues/619
|
||||||
import React, {PureComponent} from 'react';
|
import React, {ComponentType, PureComponent} from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import Notification from '../components/notification';
|
import Notification from '../components/notification';
|
||||||
import notify from './notify';
|
import notify from './notify';
|
||||||
|
|
@ -24,9 +24,10 @@ import {
|
||||||
TabsProps,
|
TabsProps,
|
||||||
TermGroupOwnProps,
|
TermGroupOwnProps,
|
||||||
TermProps,
|
TermProps,
|
||||||
Assignable
|
Assignable,
|
||||||
|
HyperActions
|
||||||
} from '../hyper';
|
} from '../hyper';
|
||||||
import {Middleware} from 'redux';
|
import {Dispatch, Middleware} from 'redux';
|
||||||
import {ObjectTypedKeys} from './object';
|
import {ObjectTypedKeys} from './object';
|
||||||
import IPCChildProcess from './ipc-child-process';
|
import IPCChildProcess from './ipc-child-process';
|
||||||
import ChildProcess from 'child_process';
|
import ChildProcess from 'child_process';
|
||||||
|
|
@ -456,10 +457,10 @@ export function getTabProps<T extends Assignable<TabProps, T>>(tab: any, parentP
|
||||||
export function connect<stateProps extends {}, dispatchProps>(
|
export function connect<stateProps extends {}, dispatchProps>(
|
||||||
stateFn: (state: HyperState) => stateProps,
|
stateFn: (state: HyperState) => stateProps,
|
||||||
dispatchFn: (dispatch: HyperDispatch) => dispatchProps,
|
dispatchFn: (dispatch: HyperDispatch) => dispatchProps,
|
||||||
c: any,
|
c: null | undefined,
|
||||||
d: Options = {}
|
d: Options = {}
|
||||||
) {
|
) {
|
||||||
return (Class: any, name: keyof typeof connectors) => {
|
return (Class: ComponentType<any>, name: keyof typeof connectors) => {
|
||||||
return reduxConnect<stateProps, dispatchProps, any, HyperState>(
|
return reduxConnect<stateProps, dispatchProps, any, HyperState>(
|
||||||
(state) => {
|
(state) => {
|
||||||
let ret = stateFn(state);
|
let ret = stateFn(state);
|
||||||
|
|
@ -570,7 +571,7 @@ export function decorateSessionsReducer(fn: ISessionReducer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// redux middleware generator
|
// redux middleware generator
|
||||||
export const middleware: Middleware = (store) => (next) => (action) => {
|
export const middleware: Middleware<{}, HyperState, Dispatch<HyperActions>> = (store) => (next) => (action) => {
|
||||||
const nextMiddleware = (remaining: Middleware[]) => (action_: any) =>
|
const nextMiddleware = (remaining: Middleware[]) => (action_: any) =>
|
||||||
remaining.length ? remaining[0](store)(nextMiddleware(remaining.slice(1)))(action_) : next(action_);
|
remaining.length ? remaining[0](store)(nextMiddleware(remaining.slice(1)))(action_) : next(action_);
|
||||||
nextMiddleware(middlewares)(action);
|
nextMiddleware(middlewares)(action);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ if (typeof snapshotResult !== 'undefined') {
|
||||||
const Module = __non_webpack_require__('module');
|
const Module = __non_webpack_require__('module');
|
||||||
const originalLoad: (module: string, ...args: any[]) => any = Module._load;
|
const originalLoad: (module: string, ...args: any[]) => any = Module._load;
|
||||||
|
|
||||||
Module._load = function _load(module: string, ...args: any[]): NodeModule {
|
Module._load = function _load(module: string, ...args: unknown[]): NodeModule {
|
||||||
let cachedModule = snapshotResult.customRequire.cache[module];
|
let cachedModule = snapshotResult.customRequire.cache[module];
|
||||||
|
|
||||||
if (cachedModule) return cachedModule.exports;
|
if (cachedModule) return cachedModule.exports;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue