sort imports

This commit is contained in:
Labhansh Agrawal 2023-07-25 23:00:19 +05:30
parent 692f94a87a
commit 36ff6e9b95
75 changed files with 372 additions and 241 deletions

View file

@ -105,7 +105,26 @@
"lodash/collection-return": "error",
"lodash/collection-method-value": "error",
"import/no-extraneous-dependencies": "error",
"import/no-anonymous-default-export": "error"
"import/no-anonymous-default-export": "error",
"import/order": [
"error",
{
"groups": [
"builtin",
"internal",
"external",
"parent",
"sibling",
"index"
],
"newlines-between": "always",
"alphabetize": {
"order": "asc",
"orderImportKind": "desc",
"caseInsensitive": true
}
}
]
}
},
{

View file

@ -1,6 +1,7 @@
import fetch from 'electron-fetch';
import {EventEmitter} from 'events';
import fetch from 'electron-fetch';
class AutoUpdater extends EventEmitter implements Electron.AutoUpdater {
updateURL!: string;
quitAndInstall() {

View file

@ -1,5 +1,6 @@
import type {BrowserWindow} from 'electron';
import {app, Menu} from 'electron';
import type {BrowserWindow} from 'electron';
import {openConfig, getConfig} from './config';
import {updatePlugins} from './plugins';
import {installCLI} from './utils/cli-install';

View file

@ -1,11 +1,14 @@
import {app} from 'electron';
import chokidar from 'chokidar';
import notify from './notify';
import type {parsedConfig, configOptions} from '../typings/config';
import {_import, getDefaultConfig} from './config/import';
import _openConfig from './config/open';
import {cfgPath, cfgDir} from './config/paths';
import notify from './notify';
import {getColorMap} from './utils/colors';
import type {parsedConfig, configOptions} from '../typings/config';
import {app} from 'electron';
const watchers: Function[] = [];
let cfg: parsedConfig = {} as any;

View file

@ -1,9 +1,11 @@
import {readFileSync, mkdirpSync} from 'fs-extra';
import {defaultCfg, cfgPath, plugs, defaultPlatformKeyPath} from './paths';
import {_init} from './init';
import notify from '../notify';
import type {rawConfig} from '../../typings/config';
import notify from '../notify';
import {_init} from './init';
import {migrateHyper3Config} from './migrate';
import {defaultCfg, cfgPath, plugs, defaultPlatformKeyPath} from './paths';
let defaultConfig: rawConfig;

View file

@ -1,8 +1,10 @@
import vm from 'vm';
import merge from 'lodash/merge';
import type {parsedConfig, rawConfig, configOptions} from '../../typings/config';
import notify from '../notify';
import mapKeys from '../utils/map-keys';
import type {parsedConfig, rawConfig, configOptions} from '../../typings/config';
import merge from 'lodash/merge';
const _extract = (script?: vm.Script): Record<string, any> => {
const module: Record<string, any> = {};

View file

@ -1,14 +1,16 @@
import {parse, prettyPrint} from 'recast';
import {builders, namedTypes} from 'ast-types';
import * as babelParser from 'recast/parsers/babel';
import {copy, copySync, existsSync, readFileSync, writeFileSync} from 'fs-extra';
import {dirname, resolve} from 'path';
import {builders, namedTypes} from 'ast-types';
import type {ExpressionKind} from 'ast-types/lib/gen/kinds';
import {copy, copySync, existsSync, readFileSync, writeFileSync} from 'fs-extra';
import merge from 'lodash/merge';
import {parse, prettyPrint} from 'recast';
import * as babelParser from 'recast/parsers/babel';
import notify from '../notify';
import {_extractDefault} from './init';
import {cfgDir, cfgPath, defaultCfg, legacyCfgPath, plugs, schemaFile, schemaPath} from './paths';
import type {ExpressionKind} from 'ast-types/lib/gen/kinds';
// function to remove all json serializable entries from an array expression
function removeElements(node: namedTypes.ArrayExpression): namedTypes.ArrayExpression {

View file

@ -1,8 +1,11 @@
import {shell} from 'electron';
import {cfgPath} from './paths';
import * as Registry from 'native-reg';
import {exec} from 'child_process';
import {shell} from 'electron';
import * as Registry from 'native-reg';
import {cfgPath} from './paths';
const getUserChoiceKey = () => {
try {
// Load FileExts keys for .js files

View file

@ -1,8 +1,10 @@
// This module exports paths, names, and other metadata that is referenced
import {homedir} from 'os';
import {app} from 'electron';
import {statSync} from 'fs';
import {homedir} from 'os';
import {resolve, join} from 'path';
import {app} from 'electron';
import isDev from 'electron-is-dev';
const cfgFile = 'hyper.json';

View file

@ -1,6 +1,7 @@
import Config from 'electron-store';
import type {BrowserWindow} from 'electron';
import Config from 'electron-store';
export const defaults = {
windowPosition: [50, 50] as [number, number],
windowSize: [540, 380] as [number, number]

View file

@ -1,3 +1,4 @@
// eslint-disable-next-line import/order
import {cfgPath} from './config/paths';
// Print diagnostic information for a few arguments instead of running Hyper.
@ -11,28 +12,31 @@ if (['--help', '-v', '--version'].includes(process.argv[1])) {
}
// Enable remote module
// eslint-disable-next-line import/order
import {initialize as remoteInitialize} from '@electron/remote/main';
remoteInitialize();
// set up config
// eslint-disable-next-line import/order
import * as config from './config';
config.setup();
// Native
import {resolve} from 'path';
// Packages
import {app, BrowserWindow, Menu, screen} from 'electron';
import {gitDescribe} from 'git-describe';
import isDev from 'electron-is-dev';
import * as config from './config';
// set up config
config.setup();
import * as plugins from './plugins';
import {installCLI} from './utils/cli-install';
import * as AppMenu from './menus/menu';
import {newWindow} from './ui/window';
import * as windowUtils from './utils/window-utils';
import {gitDescribe} from 'git-describe';
import parseUrl from 'parse-url';
import * as AppMenu from './menus/menu';
import * as plugins from './plugins';
import {newWindow} from './ui/window';
import {installCLI} from './utils/cli-install';
import * as windowUtils from './utils/window-utils';
const windowSet = new Set<BrowserWindow>([]);
// expose to plugins

View file

@ -1,21 +1,22 @@
// Packages
import type {BrowserWindow} from 'electron';
import {app, dialog, Menu} from 'electron';
import type {BrowserWindow} from 'electron';
// Utilities
import {execCommand} from '../commands';
import {getConfig} from '../config';
import {icon} from '../config/paths';
import viewMenu from './menus/view';
import shellMenu from './menus/shell';
import editMenu from './menus/edit';
import toolsMenu from './menus/tools';
import windowMenu from './menus/window';
import helpMenu from './menus/help';
import darwinMenu from './menus/darwin';
import {getDecoratedKeymaps} from '../plugins';
import {execCommand} from '../commands';
import {getRendererTypes} from '../utils/renderer-utils';
import darwinMenu from './menus/darwin';
import editMenu from './menus/edit';
import helpMenu from './menus/help';
import shellMenu from './menus/shell';
import toolsMenu from './menus/tools';
import viewMenu from './menus/view';
import windowMenu from './menus/window';
const appName = app.name;
const appVersion = app.getVersion();

View file

@ -1,7 +1,7 @@
// This menu label is overrided by OSX to be the appName
// The label is set to appName here so it matches actual behavior
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
import {app} from 'electron';
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
const darwinMenu = (
commandKeys: Record<string, string>,

View file

@ -1,10 +1,13 @@
import {release} from 'os';
import type {MenuItemConstructorOptions} from 'electron';
import {app, shell, dialog, clipboard} from 'electron';
import type {MenuItemConstructorOptions} from 'electron';
import {getConfig, getPlugins} from '../../config';
const {arch, env, platform, versions} = process;
import {version} from '../../package.json';
const {arch, env, platform, versions} = process;
const helpMenu = (commands: Record<string, string>, showAbout: () => void): MenuItemConstructorOptions => {
const submenu: MenuItemConstructorOptions[] = [
{

View file

@ -1,8 +1,10 @@
import ms from 'ms';
import fetch from 'electron-fetch';
import {version} from './package.json';
import type {BrowserWindow} from 'electron';
import fetch from 'electron-fetch';
import ms from 'ms';
import {version} from './package.json';
const NEWS_URL = 'https://hyper-news.now.sh';
export default function fetchNotifications(win: BrowserWindow) {

View file

@ -1,4 +1,5 @@
import {app, Notification} from 'electron';
import {icon} from './config/paths';
export default function notify(title: string, body = '', details: {error?: any} = {}) {

View file

@ -1,24 +1,28 @@
/* eslint-disable eslint-comments/disable-enable-pair */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-call */
import type {BrowserWindow, App, MenuItemConstructorOptions} from 'electron';
import {app, dialog, ipcMain as _ipcMain} from 'electron';
import {resolve, basename} from 'path';
import {exec, execFile} from 'child_process';
import {writeFileSync} from 'fs';
import {resolve, basename} from 'path';
import {promisify} from 'util';
import {app, dialog, ipcMain as _ipcMain} from 'electron';
import type {BrowserWindow, App, MenuItemConstructorOptions} from 'electron';
import React from 'react';
import Config from 'electron-store';
import ms from 'ms';
import React from 'react';
import ReactDom from 'react-dom';
import type {IpcMainWithCommands} from '../typings/common';
import type {configOptions} from '../typings/config';
import * as config from './config';
import {plugs} from './config/paths';
import notify from './notify';
import {availableExtensions} from './plugins/extensions';
import {install} from './plugins/install';
import {plugs} from './config/paths';
import mapKeys from './utils/map-keys';
import type {configOptions} from '../typings/config';
import {promisify} from 'util';
import {exec, execFile} from 'child_process';
import type {IpcMainWithCommands} from '../typings/common';
// local storage
const cache = new Config();

View file

@ -1,6 +1,8 @@
import cp from 'child_process';
import queue from 'queue';
import ms from 'ms';
import queue from 'queue';
import {yarn, plugs} from '../config/paths';
export const install = (fn: (err: string | null) => void) => {

View file

@ -1,7 +1,10 @@
import {EventEmitter} from 'events';
import type {BrowserWindow, IpcMainEvent} from 'electron';
import {ipcMain} from 'electron';
import type {BrowserWindow, IpcMainEvent} from 'electron';
import {v4 as uuidv4} from 'uuid';
import type {TypedEmitter, MainEvents, RendererEvents, FilterNever} from '../typings/common';
export class Server {

View file

@ -1,14 +1,16 @@
import {EventEmitter} from 'events';
import {StringDecoder} from 'string_decoder';
import defaultShell from 'default-shell';
import {getDecoratedEnv} from './plugins';
import {productName, version} from './package.json';
import * as config from './config';
import type {IPty, IWindowsPtyForkOptions, spawn as npSpawn} from 'node-pty';
import {cliScriptPath} from './config/paths';
import {dirname} from 'path';
import shellEnv from 'shell-env';
import {StringDecoder} from 'string_decoder';
import defaultShell from 'default-shell';
import type {IPty, IWindowsPtyForkOptions, spawn as npSpawn} from 'node-pty';
import osLocale from 'os-locale';
import shellEnv from 'shell-env';
import * as config from './config';
import {cliScriptPath} from './config/paths';
import {productName, version} from './package.json';
import {getDecoratedEnv} from './plugins';
const createNodePtyError = () =>
new Error(

View file

@ -1,9 +1,11 @@
import type {MenuItemConstructorOptions, BrowserWindow} from 'electron';
import {execCommand} from '../commands';
import {getProfiles} from '../config';
import editMenu from '../menus/menus/edit';
import shellMenu from '../menus/menus/shell';
import {execCommand} from '../commands';
import {getDecoratedKeymaps} from '../plugins';
import type {MenuItemConstructorOptions, BrowserWindow} from 'electron';
import {getProfiles} from '../config';
const separator: MenuItemConstructorOptions = {type: 'separator'};
const getCommandKeys = (keymaps: Record<string, string[]>): Record<string, string> =>

View file

@ -1,26 +1,30 @@
import type {BrowserWindowConstructorOptions} from 'electron';
import {app, BrowserWindow, shell, Menu} from 'electron';
import {existsSync} from 'fs';
import {isAbsolute, normalize, sep} from 'path';
import {URL, fileURLToPath} from 'url';
import {v4 as uuidv4} from 'uuid';
import isDev from 'electron-is-dev';
import updater from '../updater';
import toElectronBackgroundColor from '../utils/to-electron-background-color';
import {icon, homeDirectory} from '../config/paths';
import createRPC from '../rpc';
import notify from '../notify';
import fetchNotifications from '../notifications';
import Session from '../session';
import contextMenuTemplate from './contextmenu';
import {execCommand} from '../commands';
import {setRendererType, unsetRendererType} from '../utils/renderer-utils';
import {decorateSessionOptions, decorateSessionClass} from '../plugins';
import {app, BrowserWindow, shell, Menu} from 'electron';
import type {BrowserWindowConstructorOptions} from 'electron';
import {enable as remoteEnable} from '@electron/remote/main';
import type {configOptions} from '../../typings/config';
import isDev from 'electron-is-dev';
import {getWorkingDirectoryFromPID} from 'native-process-working-directory';
import {existsSync} from 'fs';
import {v4 as uuidv4} from 'uuid';
import type {sessionExtraOptions} from '../../typings/common';
import type {configOptions} from '../../typings/config';
import {execCommand} from '../commands';
import {getDefaultProfile} from '../config';
import {icon, homeDirectory} from '../config/paths';
import fetchNotifications from '../notifications';
import notify from '../notify';
import {decorateSessionOptions, decorateSessionClass} from '../plugins';
import createRPC from '../rpc';
import Session from '../session';
import updater from '../updater';
import {setRendererType, unsetRendererType} from '../utils/renderer-utils';
import toElectronBackgroundColor from '../utils/to-electron-background-color';
import contextMenuTemplate from './contextmenu';
export function newWindow(
options_: BrowserWindowConstructorOptions,

View file

@ -1,14 +1,15 @@
// Packages
import type {BrowserWindow, AutoUpdater} from 'electron';
import electron, {app} from 'electron';
import ms from 'ms';
import type {BrowserWindow, AutoUpdater} from 'electron';
import retry from 'async-retry';
import ms from 'ms';
// Utilities
import {version} from './package.json';
import {getDecoratedConfig} from './plugins';
import autoUpdaterLinux from './auto-updater-linux';
import {getDefaultProfile} from './config';
import {version} from './package.json';
import {getDecoratedConfig} from './plugins';
const {platform} = process;
const isLinux = platform === 'linux';

View file

@ -1,13 +1,16 @@
import {existsSync, readlink, symlink} from 'fs';
import path from 'path';
import notify from '../notify';
import {cliScriptPath, cliLinkPath} from '../config/paths';
import {promisify} from 'util';
import {clipboard, dialog} from 'electron';
import {mkdirpSync} from 'fs-extra';
import * as Registry from 'native-reg';
import type {ValueType} from 'native-reg';
import sudoPrompt from 'sudo-prompt';
import {clipboard, dialog} from 'electron';
import {mkdirpSync} from 'fs-extra';
import {promisify} from 'util';
import {cliScriptPath, cliLinkPath} from '../config/paths';
import notify from '../notify';
const readLink = promisify(readlink);
const symLink = promisify(symlink);

View file

@ -2,10 +2,12 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
import fs from 'fs';
import os from 'os';
import path from 'path';
import got from 'got';
import registryUrlModule from 'registry-url';
const registryUrl = registryUrlModule();
import path from 'path';
// If the user defines XDG_CONFIG_HOME they definitely want their config there,
// otherwise use the home directory in linux/mac and userdata in windows

View file

@ -1,17 +1,20 @@
// This is a CLI tool, using console is OK
/* eslint no-console: 0 */
import type {SpawnOptions} from 'child_process';
import {spawn, exec} from 'child_process';
import {isAbsolute, resolve} from 'path';
import type {SpawnOptions} from 'child_process';
import {existsSync} from 'fs';
import {version} from '../app/package.json';
import {isAbsolute, resolve} from 'path';
import {promisify} from 'util';
import args from 'args';
import chalk from 'chalk';
import open from 'open';
import _columnify from 'columnify';
import got from 'got';
import open from 'open';
import ora from 'ora';
import {version} from '../app/package.json';
import * as api from './api';
let commandPromise: Promise<void> | undefined;

View file

@ -1,6 +1,6 @@
import type {configOptions} from '../../typings/config';
import {CONFIG_LOAD, CONFIG_RELOAD} from '../../typings/constants/config';
import type {HyperActions} from '../../typings/hyper';
import type {configOptions} from '../../typings/config';
export function loadConfig(config: configOptions): HyperActions {
return {

View file

@ -6,9 +6,10 @@ import {
UI_WINDOW_MINIMIZE,
UI_WINDOW_CLOSE
} from '../../typings/constants/ui';
import rpc from '../rpc';
import {userExitTermGroup, setActiveGroup} from './term-groups';
import type {HyperDispatch} from '../../typings/hyper';
import rpc from '../rpc';
import {userExitTermGroup, setActiveGroup} from './term-groups';
export function closeTab(uid: string) {
return (dispatch: HyperDispatch) => {

View file

@ -1,6 +1,6 @@
import rpc from '../rpc';
import {INIT} from '../../typings/constants';
import type {HyperDispatch} from '../../typings/hyper';
import rpc from '../rpc';
export default function init() {
return (dispatch: HyperDispatch) => {

View file

@ -1,6 +1,4 @@
import rpc from '../rpc';
import {keys} from '../utils/object';
import findBySession from '../utils/term-groups';
import type {Session} from '../../typings/common';
import {
SESSION_ADD,
SESSION_RESIZE,
@ -16,7 +14,9 @@ import {
SESSION_SEARCH
} from '../../typings/constants/sessions';
import type {HyperState, HyperDispatch, HyperActions} from '../../typings/hyper';
import type {Session} from '../../typings/common';
import rpc from '../rpc';
import {keys} from '../utils/object';
import findBySession from '../utils/term-groups';
export function addSession({uid, shell, pid, cols = null, rows = null, splitDirection, activeUid, profile}: Session) {
return (dispatch: HyperDispatch, getState: () => HyperState) => {

View file

@ -1,4 +1,4 @@
import rpc from '../rpc';
import {SESSION_REQUEST} from '../../typings/constants/sessions';
import {
DIRECTION,
TERM_GROUP_RESIZE,
@ -6,11 +6,12 @@ import {
TERM_GROUP_EXIT,
TERM_GROUP_EXIT_ACTIVE
} from '../../typings/constants/term-groups';
import {SESSION_REQUEST} from '../../typings/constants/sessions';
import findBySession from '../utils/term-groups';
import {getRootGroups} from '../selectors';
import {setActiveSession, ptyExitSession, userExitSession} from './sessions';
import type {ITermState, ITermGroup, HyperState, HyperDispatch, HyperActions} from '../../typings/hyper';
import rpc from '../rpc';
import {getRootGroups} from '../selectors';
import findBySession from '../utils/term-groups';
import {setActiveSession, ptyExitSession, userExitSession} from './sessions';
function requestSplit(direction: 'VERTICAL' | 'HORIZONTAL') {
return (_activeUid: string | undefined, _profile: string | undefined) =>

View file

@ -1,10 +1,9 @@
import {stat} from 'fs';
import type {Stats} from 'fs';
import type parseUrl from 'parse-url';
import {php_escapeshellcmd as escapeShellCmd} from 'php-escape-shell';
import {isExecutable} from '../utils/file';
import {getRootGroups} from '../selectors';
import findBySession from '../utils/term-groups';
import notify from '../utils/notify';
import rpc from '../rpc';
import {requestSession, sendSessionData, setActiveSession} from './sessions';
import {
UI_FONT_SIZE_SET,
UI_FONT_SIZE_INCR,
@ -25,12 +24,15 @@ import {
UI_CONTEXTMENU_OPEN,
UI_COMMAND_EXEC
} from '../../typings/constants/ui';
import {setActiveGroup} from './term-groups';
import type parseUrl from 'parse-url';
import type {HyperState, HyperDispatch, HyperActions, ITermGroups} from '../../typings/hyper';
import type {Stats} from 'fs';
import {stat} from 'fs';
import rpc from '../rpc';
import {getRootGroups} from '../selectors';
import {isExecutable} from '../utils/file';
import notify from '../utils/notify';
import findBySession from '../utils/term-groups';
import {requestSession, sendSessionData, setActiveSession} from './sessions';
import {setActiveGroup} from './term-groups';
export function openContextMenu(uid: string, selection: string) {
return (dispatch: HyperDispatch, getState: () => HyperState) => {

View file

@ -1,6 +1,6 @@
import {UPDATE_INSTALL, UPDATE_AVAILABLE} from '../../typings/constants/updater';
import rpc from '../rpc';
import type {HyperActions} from '../../typings/hyper';
import rpc from '../rpc';
export function installUpdate(): HyperActions {
return {

View file

@ -1,6 +1,7 @@
import {ipcRenderer} from './utils/ipc';
import type {HyperDispatch} from '../typings/hyper';
import {closeSearch} from './actions/sessions';
import {ipcRenderer} from './utils/ipc';
let commands: Record<string, (event: any, dispatch: HyperDispatch) => void> = {
'editor:search-close': (e, dispatch) => {

View file

@ -1,9 +1,9 @@
import React from 'react';
import type {HeaderProps} from '../../typings/hyper';
import {decorate, getTabsProps} from '../utils/plugins';
import Tabs_ from './tabs';
import type {HeaderProps} from '../../typings/hyper';
const Tabs = decorate(Tabs_, 'Tabs');

View file

@ -1,8 +1,10 @@
import React, {useRef, useState} from 'react';
import {VscChevronDown} from '@react-icons/all-files/vsc/VscChevronDown';
import type {configOptions} from '../../typings/config';
import useClickAway from 'react-use/lib/useClickAway';
import type {configOptions} from '../../typings/config';
interface Props {
defaultProfile: string;
profiles: configOptions['profiles'];

View file

@ -1,4 +1,5 @@
import React, {forwardRef, useEffect, useRef, useState} from 'react';
import type {NotificationProps} from '../../typings/hyper';
const Notification = forwardRef<HTMLDivElement, React.PropsWithChildren<NotificationProps>>((props, ref) => {

View file

@ -1,9 +1,9 @@
import React, {forwardRef} from 'react';
import type {NotificationsProps} from '../../typings/hyper';
import {decorate} from '../utils/plugins';
import Notification_ from './notification';
import type {NotificationsProps} from '../../typings/hyper';
const Notification = decorate(Notification_, 'Notification');

View file

@ -1,13 +1,15 @@
import React, {useCallback, useRef, useEffect, forwardRef} from 'react';
import type {SearchBoxProps} from '../../typings/hyper';
import {VscArrowUp} from '@react-icons/all-files/vsc/VscArrowUp';
import {VscArrowDown} from '@react-icons/all-files/vsc/VscArrowDown';
import {VscClose} from '@react-icons/all-files/vsc/VscClose';
import {VscArrowUp} from '@react-icons/all-files/vsc/VscArrowUp';
import {VscCaseSensitive} from '@react-icons/all-files/vsc/VscCaseSensitive';
import {VscClose} from '@react-icons/all-files/vsc/VscClose';
import {VscRegex} from '@react-icons/all-files/vsc/VscRegex';
import {VscWholeWord} from '@react-icons/all-files/vsc/VscWholeWord';
import clsx from 'clsx';
import type {SearchBoxProps} from '../../typings/hyper';
type SearchButtonColors = {
foregroundColor: string;
selectionColor: string;

View file

@ -1,5 +1,7 @@
import React from 'react';
import sum from 'lodash/sum';
import type {SplitPaneProps} from '../../typings/hyper';
export default class SplitPane extends React.PureComponent<

View file

@ -1,4 +1,5 @@
import React, {forwardRef} from 'react';
import type {StyleSheetProps} from '../../typings/hyper';
const StyleSheet = forwardRef<HTMLStyleElement, StyleSheetProps>((props, ref) => {

View file

@ -1,4 +1,5 @@
import React, {forwardRef} from 'react';
import type {TabProps} from '../../typings/hyper';
const Tab = forwardRef<HTMLLIElement, TabProps>((props, ref) => {

View file

@ -1,10 +1,10 @@
import React, {forwardRef} from 'react';
import type {TabsProps} from '../../typings/hyper';
import {decorate, getTabProps} from '../utils/plugins';
import Tab_ from './tab';
import type {TabsProps} from '../../typings/hyper';
import DropdownButton from './new-tab';
import Tab_ from './tab';
const Tab = decorate(Tab_, 'Tab');
const isMac = /Mac/.test(navigator.userAgent);

View file

@ -1,10 +1,13 @@
import React from 'react';
import {connect} from 'react-redux';
import {decorate, getTermProps, getTermGroupProps} from '../utils/plugins';
import {resizeTermGroup} from '../actions/term-groups';
import Term_ from './term';
import SplitPane_ from './split-pane';
import type {HyperState, HyperDispatch, TermGroupProps, TermGroupOwnProps} from '../../typings/hyper';
import {resizeTermGroup} from '../actions/term-groups';
import {decorate, getTermProps, getTermGroupProps} from '../utils/plugins';
import SplitPane_ from './split-pane';
import Term_ from './term';
const Term = decorate(Term_, 'Term');
const SplitPane = decorate(SplitPane_, 'SplitPane');

View file

@ -1,25 +1,29 @@
import React from 'react';
import type {ITerminalOptions, IDisposable} from 'xterm';
import {Terminal} from 'xterm';
import {FitAddon} from 'xterm-addon-fit';
import {WebLinksAddon} from 'xterm-addon-web-links';
import type {ISearchDecorationOptions} from 'xterm-addon-search';
import {SearchAddon} from 'xterm-addon-search';
import {WebglAddon} from 'xterm-addon-webgl';
import {CanvasAddon} from 'xterm-addon-canvas';
import {LigaturesAddon} from 'xterm-addon-ligatures';
import {Unicode11Addon} from 'xterm-addon-unicode11';
import {clipboard, shell} from 'electron';
import React from 'react';
import Color from 'color';
import isEqual from 'lodash/isEqual';
import pickBy from 'lodash/pickBy';
import {Terminal} from 'xterm';
import type {ITerminalOptions, IDisposable} from 'xterm';
import {CanvasAddon} from 'xterm-addon-canvas';
import {FitAddon} from 'xterm-addon-fit';
import {ImageAddon} from 'xterm-addon-image';
import {LigaturesAddon} from 'xterm-addon-ligatures';
import {SearchAddon} from 'xterm-addon-search';
import type {ISearchDecorationOptions} from 'xterm-addon-search';
import {Unicode11Addon} from 'xterm-addon-unicode11';
import {WebLinksAddon} from 'xterm-addon-web-links';
import {WebglAddon} from 'xterm-addon-webgl';
import type {TermProps} from '../../typings/hyper';
import terms from '../terms';
import processClipboard from '../utils/paste';
import _SearchBox from './searchBox';
import type {TermProps} from '../../typings/hyper';
import pickBy from 'lodash/pickBy';
import isEqual from 'lodash/isEqual';
import {decorate} from '../utils/plugins';
import _SearchBox from './searchBox';
import 'xterm/css/xterm.css';
import {ImageAddon} from 'xterm-addon-image';
const SearchBox = decorate(_SearchBox, 'SearchBox');

View file

@ -1,11 +1,13 @@
import React from 'react';
import {decorate, getTermGroupProps} from '../utils/plugins';
import {registerCommandHandlers} from '../command-registry';
import TermGroup_ from './term-group';
import StyleSheet_ from './style-sheet';
import type {TermsProps, HyperDispatch} from '../../typings/hyper';
import type Term from './term';
import {registerCommandHandlers} from '../command-registry';
import {ObjectTypedKeys} from '../utils/object';
import {decorate, getTermGroupProps} from '../utils/plugins';
import StyleSheet_ from './style-sheet';
import type Term from './term';
import TermGroup_ from './term-group';
const TermGroup = decorate(TermGroup_, 'TermGroup');
const StyleSheet = decorate(StyleSheet_, 'StyleSheet');

View file

@ -1,11 +1,11 @@
import {createSelector} from 'reselect';
import Header from '../components/header';
import {closeTab, changeTab, maximize, openHamburgerMenu, unmaximize, minimize, close} from '../actions/header';
import {connect} from '../utils/plugins';
import {getRootGroups} from '../selectors';
import type {HyperState, HyperDispatch, ITab} from '../../typings/hyper';
import {closeTab, changeTab, maximize, openHamburgerMenu, unmaximize, minimize, close} from '../actions/header';
import {requestTermGroup} from '../actions/term-groups';
import Header from '../components/header';
import {getRootGroups} from '../selectors';
import {connect} from '../utils/plugins';
const isMac = /Mac/.test(navigator.userAgent);

View file

@ -1,17 +1,18 @@
import React, {forwardRef, useEffect, useRef} from 'react';
import type {MousetrapInstance} from 'mousetrap';
import Mousetrap from 'mousetrap';
import {connect} from '../utils/plugins';
import * as uiActions from '../actions/ui';
import {getRegisteredKeys, getCommandHandler, shouldPreventDefault} from '../command-registry';
import Mousetrap from 'mousetrap';
import type {MousetrapInstance} from 'mousetrap';
import stylis from 'stylis';
import {HeaderContainer} from './header';
import TermsContainer from './terms';
import NotificationsContainer from './notifications';
import type {HyperState, HyperProps, HyperDispatch} from '../../typings/hyper';
import * as uiActions from '../actions/ui';
import {getRegisteredKeys, getCommandHandler, shouldPreventDefault} from '../command-registry';
import type Terms from '../components/terms';
import {connect} from '../utils/plugins';
import {HeaderContainer} from './header';
import NotificationsContainer from './notifications';
import TermsContainer from './terms';
const isMac = /Mac/.test(navigator.userAgent);

View file

@ -1,8 +1,8 @@
import Notifications from '../components/notifications';
import {installUpdate} from '../actions/updater';
import {connect} from '../utils/plugins';
import {dismissNotification} from '../actions/notifications';
import type {HyperState, HyperDispatch} from '../../typings/hyper';
import {dismissNotification} from '../actions/notifications';
import {installUpdate} from '../actions/updater';
import Notifications from '../components/notifications';
import {connect} from '../utils/plugins';
const mapStateToProps = (state: HyperState) => {
const {ui} = state;

View file

@ -1,5 +1,4 @@
import Terms from '../components/terms';
import {connect} from '../utils/plugins';
import type {HyperState, HyperDispatch} from '../../typings/hyper';
import {
resizeSession,
sendSessionData,
@ -8,10 +7,10 @@ import {
openSearch,
closeSearch
} from '../actions/sessions';
import {openContextMenu} from '../actions/ui';
import Terms from '../components/terms';
import {getRootGroups} from '../selectors';
import type {HyperState, HyperDispatch} from '../../typings/hyper';
import {connect} from '../utils/plugins';
const mapStateToProps = (state: HyperState) => {
const {sessions} = state.sessions;

View file

@ -1,23 +1,25 @@
import './v8-snapshot-util';
import {webFrame} from 'electron';
import {Provider} from 'react-redux';
import React from 'react';
import {createRoot} from 'react-dom/client';
import rpc from './rpc';
import {createRoot} from 'react-dom/client';
import {Provider} from 'react-redux';
import type {configOptions} from '../typings/config';
import {loadConfig, reloadConfig} from './actions/config';
import init from './actions/index';
import * as config from './utils/config';
import * as plugins from './utils/plugins';
import {getBase64FileData} from './utils/file';
import * as uiActions from './actions/ui';
import * as updaterActions from './actions/updater';
import {addNotificationMessage} from './actions/notifications';
import * as sessionActions from './actions/sessions';
import * as termGroupActions from './actions/term-groups';
import {addNotificationMessage} from './actions/notifications';
import {loadConfig, reloadConfig} from './actions/config';
import * as uiActions from './actions/ui';
import * as updaterActions from './actions/updater';
import HyperContainer from './containers/hyper';
import rpc from './rpc';
import configureStore from './store/configure-store';
import type {configOptions} from '../typings/config';
import * as config from './utils/config';
import {getBase64FileData} from './utils/file';
import * as plugins from './utils/plugins';
// On Linux, the default zoom was somehow changed with Electron 3 (or maybe 2).
// Setting zoom factor to 1.2 brings back the normal default size

View file

@ -1,9 +1,11 @@
import type {Reducer} from 'redux';
import {combineReducers} from 'redux';
import ui from './ui';
import type {Reducer} from 'redux';
import type {HyperActions, HyperState} from '../../typings/hyper';
import sessions from './sessions';
import termGroups from './term-groups';
import type {HyperActions, HyperState} from '../../typings/hyper';
import ui from './ui';
export default combineReducers({
ui,

View file

@ -1,5 +1,5 @@
import Immutable from 'seamless-immutable';
import {decorateSessionsReducer} from '../utils/plugins';
import {
SESSION_ADD,
SESSION_PTY_EXIT,
@ -13,6 +13,7 @@ import {
SESSION_SEARCH
} from '../../typings/constants/sessions';
import type {sessionState, session, Mutable, ISessionReducer} from '../../typings/hyper';
import {decorateSessionsReducer} from '../utils/plugins';
const initialState: sessionState = Immutable<Mutable<sessionState>>({
sessions: {},

View file

@ -1,12 +1,13 @@
import {v4 as uuidv4} from 'uuid';
import type {Immutable as ImmutableType} from 'seamless-immutable';
import Immutable from 'seamless-immutable';
import {TERM_GROUP_EXIT, TERM_GROUP_RESIZE} from '../../typings/constants/term-groups';
import type {SessionAddAction} from '../../typings/constants/sessions';
import type {Immutable as ImmutableType} from 'seamless-immutable';
import {v4 as uuidv4} from 'uuid';
import {SESSION_ADD, SESSION_SET_ACTIVE} from '../../typings/constants/sessions';
import findBySession from '../utils/term-groups';
import {decorateTermGroupsReducer} from '../utils/plugins';
import type {SessionAddAction} from '../../typings/constants/sessions';
import {TERM_GROUP_EXIT, TERM_GROUP_RESIZE} from '../../typings/constants/term-groups';
import type {ITermGroup, ITermState, ITermGroups, ITermGroupReducer, Mutable} from '../../typings/hyper';
import {decorateTermGroupsReducer} from '../utils/plugins';
import findBySession from '../utils/term-groups';
const MIN_SIZE = 0.05;
const initialState: ITermState = Immutable<Mutable<ITermState>>({

View file

@ -1,7 +1,18 @@
import type {Immutable as ImmutableType} from 'seamless-immutable';
import {release} from 'os';
import Immutable from 'seamless-immutable';
import {decorateUIReducer} from '../utils/plugins';
import type {Immutable as ImmutableType} from 'seamless-immutable';
import {CONFIG_LOAD, CONFIG_RELOAD} from '../../typings/constants/config';
import {NOTIFICATION_MESSAGE, NOTIFICATION_DISMISS} from '../../typings/constants/notifications';
import {
SESSION_ADD,
SESSION_RESIZE,
SESSION_PTY_DATA,
SESSION_PTY_EXIT,
SESSION_SET_ACTIVE,
SESSION_SET_CWD
} from '../../typings/constants/sessions';
import {
UI_FONT_SIZE_SET,
UI_FONT_SIZE_RESET,
@ -12,18 +23,9 @@ import {
UI_ENTER_FULLSCREEN,
UI_LEAVE_FULLSCREEN
} from '../../typings/constants/ui';
import {NOTIFICATION_MESSAGE, NOTIFICATION_DISMISS} from '../../typings/constants/notifications';
import {
SESSION_ADD,
SESSION_RESIZE,
SESSION_PTY_DATA,
SESSION_PTY_EXIT,
SESSION_SET_ACTIVE,
SESSION_SET_CWD
} from '../../typings/constants/sessions';
import {UPDATE_AVAILABLE} from '../../typings/constants/updater';
import type {uiState, Mutable, IUiReducer} from '../../typings/hyper';
import {release} from 'os';
import {decorateUIReducer} from '../utils/plugins';
const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].includes(navigator.platform) || process.platform === 'win32';

View file

@ -1,4 +1,5 @@
import {createSelector} from 'reselect';
import type {HyperState} from '../typings/hyper';
const getTermGroups = ({termGroups}: Pick<HyperState, 'termGroups'>) => termGroups.termGroups;

View file

@ -1,12 +1,15 @@
import {composeWithDevTools} from '@redux-devtools/extension';
import {createStore, applyMiddleware} from 'redux';
import type {ThunkMiddleware} from 'redux-thunk';
import _thunk from 'redux-thunk';
import type {ThunkMiddleware} from 'redux-thunk';
import type {HyperState, HyperActions} from '../../typings/hyper';
import rootReducer from '../reducers/index';
import effects from '../utils/effects';
import * as plugins from '../utils/plugins';
import writeMiddleware from './write-middleware';
import {composeWithDevTools} from '@redux-devtools/extension';
import type {HyperState, HyperActions} from '../../typings/hyper';
const thunk: ThunkMiddleware<HyperState, HyperActions> = _thunk;
const configureStoreForDevelopment = () => {

View file

@ -1,11 +1,14 @@
import {createStore, applyMiddleware} from 'redux';
import type {ThunkMiddleware} from 'redux-thunk';
import _thunk from 'redux-thunk';
import type {ThunkMiddleware} from 'redux-thunk';
import type {HyperState, HyperActions} from '../../typings/hyper';
import rootReducer from '../reducers/index';
import effects from '../utils/effects';
import * as plugins from '../utils/plugins';
import writeMiddleware from './write-middleware';
import type {HyperState, HyperActions} from '../../typings/hyper';
const thunk: ThunkMiddleware<HyperState, HyperActions> = _thunk;
const configureStoreForProd = () =>

View file

@ -1,5 +1,5 @@
import configureStoreForProduction from './configure-store.prod';
import configureStoreForDevelopment from './configure-store.dev';
import configureStoreForProduction from './configure-store.prod';
const configureStore = () => {
if (process.env.NODE_ENV === 'production') {

View file

@ -1,6 +1,7 @@
import type {Dispatch, Middleware} from 'redux';
import type {HyperActions, HyperState} from '../../typings/hyper';
import terms from '../terms';
import type {Dispatch, Middleware} from 'redux';
// the only side effect we perform from middleware
// is to write to the react term instance directly

View file

@ -1,7 +1,8 @@
import {ipcRenderer} from './ipc';
import {require as remoteRequire, getCurrentWindow} from '@electron/remote';
// TODO: Should be updates to new async API https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31
import {ipcRenderer} from './ipc';
const plugins = remoteRequire('./plugins') as typeof import('../../app/plugins');
Object.defineProperty(window, 'profileName', {

View file

@ -1,4 +1,5 @@
import type {Dispatch, Middleware} from 'redux';
import type {HyperActions, HyperState} from '../../typings/hyper';
/**
* Simple redux middleware that executes

View file

@ -10,8 +10,8 @@
* PR: https://github.com/kevva/executable/pull/10
*/
import type {Stats} from 'fs';
import fs from 'fs';
import type {Stats} from 'fs';
export function isExecutable(fileStat: Stats): boolean {
if (process.platform === 'win32') {

View file

@ -1,4 +1,5 @@
import type {ExecFileOptions, ExecOptions} from 'child_process';
import {ipcRenderer} from './ipc';
export function exec(command: string, options: ExecOptions, callback: (..._args: any) => void) {

View file

@ -1,4 +1,5 @@
import {ipcRenderer as _ipc} from 'electron';
import type {IpcRendererWithCommands} from '../../typings/common';
export const ipcRenderer = _ipc as IpcRendererWithCommands;

View file

@ -1,4 +1,5 @@
import {clipboard} from 'electron';
import plist from 'plist';
const getPath = (platform: string) => {

View file

@ -1,20 +1,18 @@
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable @typescript-eslint/no-unsafe-return */
import {require as remoteRequire} from '@electron/remote';
// TODO: Should be updates to new async API https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31
import type {ConnectOptions} from 'react-redux/es/components/connect';
import {connect as reduxConnect} from 'react-redux';
import ChildProcess from 'child_process';
import pathModule from 'path';
// patching Module._load
// so plugins can `require` them without needing their own version
// https://github.com/vercel/hyper/issues/619
import type {ComponentType} from 'react';
import React, {PureComponent} from 'react';
import type {ComponentType} from 'react';
import {require as remoteRequire} from '@electron/remote';
// TODO: Should be updates to new async API https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31
import ReactDOM from 'react-dom';
import Notification from '../components/notification';
import notify from './notify';
import {connect as reduxConnect} from 'react-redux';
import type {ConnectOptions} from 'react-redux/es/components/connect';
import type {Dispatch, Middleware} from 'redux';
import type {
hyperPlugin,
IUiReducer,
@ -29,10 +27,11 @@ import type {
Assignable,
HyperActions
} from '../../typings/hyper';
import type {Dispatch, Middleware} from 'redux';
import {ObjectTypedKeys} from './object';
import Notification from '../components/notification';
import IPCChildProcess from './ipc-child-process';
import ChildProcess from 'child_process';
import notify from './notify';
import {ObjectTypedKeys} from './object';
// remote interface to `../plugins`
const plugins = remoteRequire('./plugins') as typeof import('../../app/plugins');
@ -166,6 +165,9 @@ export function decorate<P extends Record<string, any>>(
};
}
// patching Module._load
// so plugins can `require` them without needing their own version
// https://github.com/vercel/hyper/issues/619
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Module = require('module') as typeof import('module') & {_load: Function};
const originalLoad = Module._load;

View file

@ -1,5 +1,7 @@
import {EventEmitter} from 'events';
import type {IpcRendererEvent} from 'electron';
import type {
FilterNever,
IpcRendererWithCommands,
@ -7,6 +9,7 @@ import type {
RendererEvents,
TypedEmitter
} from '../../typings/common';
import {ipcRenderer} from './ipc';
export default class Client {

View file

@ -1,11 +1,11 @@
// Native
import path from 'path';
import fs from 'fs-extra';
// Packages
import test from 'ava';
import type {ElectronApplication} from 'playwright';
import fs from 'fs-extra';
import {_electron} from 'playwright';
import type {ElectronApplication} from 'playwright';
let app: ElectronApplication;

View file

@ -2,6 +2,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-call */
import test from 'ava';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const proxyquire = require('proxyquire').noCallThru();

View file

@ -1,4 +1,5 @@
import test from 'ava';
import toElectronBackgroundColor from '../../app/utils/to-electron-background-color';
import {isHexColor} from '../testUtils/is-hex-color';

View file

@ -1,6 +1,7 @@
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable @typescript-eslint/no-unsafe-call */
import test from 'ava';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const proxyquire = require('proxyquire').noCallThru();

7
typings/common.d.ts vendored
View file

@ -1,6 +1,9 @@
import type parseUrl from 'parse-url';
import type {IpcMain, IpcRenderer} from 'electron';
import type {ExecFileOptions, ExecOptions} from 'child_process';
import type {IpcMain, IpcRenderer} from 'electron';
import type parseUrl from 'parse-url';
import type {configOptions} from './config';
export type Session = {

2
typings/hyper.d.ts vendored
View file

@ -1,3 +1,5 @@
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable import/order */
import type {Immutable} from 'seamless-immutable';
import type Client from '../lib/utils/rpc';

View file

@ -1,5 +1,6 @@
import Copy from 'copy-webpack-plugin';
import path from 'path';
import Copy from 'copy-webpack-plugin';
import TerserPlugin from 'terser-webpack-plugin';
import webpack from 'webpack';