hyper/typings/hyper.d.ts

409 lines
11 KiB
TypeScript
Raw Normal View History

2023-07-25 09:30:19 -08:00
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable import/order */
import type {Immutable, ImmutableDate} from 'seamless-immutable';
2023-07-25 01:39:51 -08:00
import type Client from '../lib/utils/rpc';
2019-10-12 07:29:25 -08:00
declare global {
interface Window {
__rpcId: string;
2020-06-19 04:51:34 -08:00
rpc: Client;
focusActiveTerm: (uid?: string) => void;
2023-06-30 11:07:04 -08:00
profileName: string;
2019-10-12 07:29:25 -08:00
}
2022-04-14 08:50:54 -08:00
const snapshotResult: {
customRequire: {
(module: string): NodeModule;
cache: Record<string, {exports: NodeModule}>;
definitions: Record<string, {exports: any}>;
};
setGlobals(global: any, process: any, window: any, document: any, console: any, require: any): void;
};
const __non_webpack_require__: NodeRequire;
2019-10-12 07:29:25 -08:00
}
2021-03-05 07:03:35 -09:00
export type ITermGroup = Immutable<{
2019-10-20 00:08:48 -08:00
uid: string;
2019-10-12 07:29:25 -08:00
sessionUid: string | null;
parentUid: string | null;
2020-03-07 05:38:46 -09:00
direction: 'HORIZONTAL' | 'VERTICAL' | null;
2019-10-12 07:29:25 -08:00
sizes: number[] | null;
children: string[];
2021-03-05 07:03:35 -09:00
}>;
2019-10-12 07:29:25 -08:00
2021-03-05 07:03:35 -09:00
export type ITermGroups = Immutable<Record<string, ITermGroup>>;
2019-10-12 07:29:25 -08:00
2021-03-05 07:03:35 -09:00
export type ITermState = Immutable<{
termGroups: Mutable<ITermGroups>;
2019-10-12 07:29:25 -08:00
activeSessions: Record<string, string>;
activeRootGroup: string | null;
2021-03-05 07:03:35 -09:00
}>;
2020-03-07 05:38:46 -09:00
export type cursorShapes = 'BEAM' | 'UNDERLINE' | 'BLOCK';
import type {FontWeight, IWindowsPty, Terminal} from '@xterm/xterm';
2023-06-28 22:21:51 -08:00
import type {ColorMap, configOptions} from './config';
2020-03-07 05:38:46 -09:00
2021-03-05 07:03:35 -09:00
export type uiState = Immutable<{
2019-12-28 01:39:17 -09:00
_lastUpdate: number | null;
activeUid: string | null;
activityMarkers: Record<string, boolean>;
backgroundColor: string;
2023-07-12 21:54:31 -08:00
bell: 'SOUND' | false;
bellSoundURL: string | null;
bellSound: string | null;
borderColor: string;
2021-03-05 07:03:35 -09:00
colors: ColorMap;
cols: number | null;
copyOnSelect: boolean;
css: string;
cursorAccentColor: string;
cursorBlink: boolean;
cursorColor: string;
2020-03-07 05:38:46 -09:00
cursorShape: cursorShapes;
cwd?: string;
disableLigatures: boolean;
fontFamily: string;
fontSize: number;
fontSizeOverride: null | number;
fontSmoothingOverride: string;
2020-03-07 05:38:46 -09:00
fontWeight: FontWeight;
fontWeightBold: FontWeight;
foregroundColor: string;
fullScreen: boolean;
imageSupport: boolean;
letterSpacing: number;
lineHeight: number;
macOptionSelectionMode: string;
maximized: boolean;
messageDismissable: null | boolean;
2019-12-28 01:39:17 -09:00
messageText: string | null;
messageURL: string | null;
modifierKeys: {
altIsMeta: boolean;
cmdIsMeta: boolean;
};
notifications: {
font: boolean;
message: boolean;
resize: boolean;
updates: boolean;
};
openAt: Record<string, number>;
padding: string;
quickEdit: boolean;
resizeAt: number;
rows: number | null;
2020-11-24 04:18:50 -09:00
screenReaderMode: boolean;
scrollback: number;
selectionColor: string;
2020-04-27 05:32:08 -08:00
showHamburgerMenu: boolean | '';
2022-12-25 20:01:04 -09:00
showWindowControls: boolean | 'left' | '';
termCSS: string;
uiFontFamily: string;
updateCanInstall: null | boolean;
updateNotes: string | null;
updateReleaseUrl: string | null;
updateVersion: string | null;
webGLRenderer: boolean;
2023-06-15 09:10:34 -08:00
webLinksActivationKey: 'ctrl' | 'alt' | 'meta' | 'shift' | '';
2023-06-15 21:34:31 -08:00
windowsPty?: IWindowsPty;
2023-06-28 22:21:51 -08:00
defaultProfile: string;
profiles: configOptions['profiles'];
2021-03-05 07:03:35 -09:00
}>;
export type session = {
cleared: boolean;
2019-10-20 00:08:48 -08:00
cols: number | null;
pid: number | null;
resizeAt?: number;
rows: number | null;
search: ImmutableDate | null;
2019-12-28 01:39:17 -09:00
shell: string | null;
title: string;
uid: string;
2020-03-07 05:38:46 -09:00
splitDirection?: 'HORIZONTAL' | 'VERTICAL';
2019-10-20 00:08:48 -08:00
activeUid?: string;
2023-06-28 21:04:33 -08:00
profile: string;
};
2023-06-26 05:59:29 -08:00
2021-03-05 07:03:35 -09:00
export type sessionState = Immutable<{
2019-10-20 00:08:48 -08:00
sessions: Record<string, session>;
activeUid: string | null;
write?: any;
2021-03-05 07:03:35 -09:00
}>;
2021-03-05 07:03:35 -09:00
export type ITermGroupReducer = Reducer<ITermState, HyperActions>;
2019-12-28 01:39:17 -09:00
2021-03-05 07:03:35 -09:00
export type IUiReducer = Reducer<uiState, HyperActions>;
2019-12-28 01:39:17 -09:00
2021-03-05 07:03:35 -09:00
export type ISessionReducer = Reducer<sessionState, HyperActions>;
2023-06-26 01:29:50 -08:00
import type {Middleware, Reducer} from 'redux';
export type hyperPlugin = {
getTabProps: any;
getTabsProps: any;
getTermGroupProps: any;
getTermProps: any;
mapHeaderDispatch: any;
mapHyperDispatch: any;
mapHyperTermDispatch: any;
mapNotificationsDispatch: any;
mapTermsDispatch: any;
mapHeaderState: any;
mapHyperState: any;
mapHyperTermState: any;
mapNotificationsState: any;
mapTermsState: any;
2020-03-07 05:38:46 -09:00
middleware: Middleware;
2020-06-19 04:51:34 -08:00
onRendererUnload: any;
onRendererWindow: any;
2019-10-20 00:08:48 -08:00
reduceSessions: ISessionReducer;
reduceTermGroups: ITermGroupReducer;
reduceUI: IUiReducer;
};
export type HyperState = {
2021-03-05 07:03:35 -09:00
ui: uiState;
sessions: sessionState;
termGroups: ITermState;
};
2023-07-25 02:39:11 -08:00
import type {UIActions} from './constants/ui';
import type {ConfigActions} from './constants/config';
import type {SessionActions} from './constants/sessions';
import type {NotificationActions} from './constants/notifications';
import type {UpdateActions} from './constants/updater';
import type {TermGroupActions} from './constants/term-groups';
import type {InitActions} from './constants';
import type {TabActions} from './constants/tabs';
2019-12-27 06:33:21 -09:00
export type HyperActions = (
| UIActions
| ConfigActions
| SessionActions
| NotificationActions
| UpdateActions
| TermGroupActions
| InitActions
| TabActions
) & {effect?: () => void};
2023-07-25 01:39:51 -08:00
import type configureStore from '../lib/store/configure-store';
2020-01-02 08:49:57 -09:00
export type HyperDispatch = ReturnType<typeof configureStore>['dispatch'];
2023-08-01 00:38:35 -08:00
import type {ReactChild, ReactNode} from 'react';
type extensionProps = Partial<{
2020-06-19 04:51:34 -08:00
customChildren: ReactChild | ReactChild[];
customChildrenBefore: ReactChild | ReactChild[];
customCSS: string;
2020-06-19 04:51:34 -08:00
customInnerChildren: ReactChild | ReactChild[];
}>;
2023-07-25 01:39:51 -08:00
import type {HeaderConnectedProps} from '../lib/containers/header';
export type HeaderProps = HeaderConnectedProps & extensionProps;
2023-07-25 01:39:51 -08:00
import type {HyperConnectedProps} from '../lib/containers/hyper';
export type HyperProps = HyperConnectedProps & extensionProps;
2023-07-25 01:39:51 -08:00
import type {NotificationsConnectedProps} from '../lib/containers/notifications';
export type NotificationsProps = NotificationsConnectedProps & extensionProps;
2023-07-25 01:39:51 -08:00
import type Terms from '../lib/components/terms';
import type {TermsConnectedProps} from '../lib/containers/terms';
2020-06-19 04:51:34 -08:00
export type TermsProps = TermsConnectedProps & extensionProps & {ref_: (terms: Terms | null) => void};
2020-03-10 03:16:00 -08:00
export type StyleSheetProps = {
backgroundColor: string;
borderColor: string;
fontFamily: string;
foregroundColor: string;
} & extensionProps;
export type TabProps = {
borderColor: string;
hasActivity: boolean;
isActive: boolean;
isFirst: boolean;
isLast: boolean;
2020-03-18 07:26:46 -08:00
onClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
2020-03-10 03:16:00 -08:00
onClose: () => void;
onSelect: () => void;
text: string;
2025-04-21 21:50:39 -08:00
lastFocused: Date | undefined;
2020-03-10 03:16:00 -08:00
} & extensionProps;
export type ITab = {
uid: string;
title: string;
isActive: boolean;
hasActivity: boolean;
};
export type TabsProps = {
tabs: ITab[];
borderColor: string;
2023-06-29 20:42:32 -08:00
backgroundColor: string;
2020-03-18 07:26:46 -08:00
onChange: (uid: string) => void;
onClose: (uid: string) => void;
2020-03-10 03:16:00 -08:00
fullScreen: boolean;
2023-06-29 20:42:32 -08:00
defaultProfile: string;
profiles: configOptions['profiles'];
openNewTab: (profile: string) => void;
2020-03-10 03:16:00 -08:00
} & extensionProps;
export type NotificationProps = {
backgroundColor: string;
color?: string;
dismissAfter?: number;
onDismiss: Function;
text?: string | null;
userDismissable?: boolean | null;
userDismissColor?: string;
} & extensionProps;
export type SplitPaneProps = {
borderColor: string;
direction: 'horizontal' | 'vertical';
2023-08-01 00:38:35 -08:00
onResize: (sizes: number[]) => void;
sizes?: Immutable<number[]> | null;
2023-08-01 00:38:35 -08:00
children: ReactNode[];
};
2020-03-16 06:32:04 -08:00
2023-07-25 01:39:51 -08:00
import type Term from '../lib/components/term';
2020-03-16 06:32:04 -08:00
export type TermGroupOwnProps = {
cursorAccentColor?: string;
fontSmoothing?: string;
parentProps: TermsProps;
2020-06-19 04:51:34 -08:00
ref_: (uid: string, term: Term | null) => void;
2021-03-05 07:03:35 -09:00
termGroup: ITermGroup;
2020-03-16 06:32:04 -08:00
terms: Record<string, Term | null>;
} & Pick<
TermsProps,
| 'activeSession'
| 'backgroundColor'
| 'bell'
| 'bellSound'
| 'bellSoundURL'
| 'borderColor'
| 'colors'
| 'copyOnSelect'
| 'cursorBlink'
| 'cursorColor'
| 'cursorShape'
| 'disableLigatures'
| 'fontFamily'
| 'fontSize'
| 'fontWeight'
| 'fontWeightBold'
| 'foregroundColor'
| 'letterSpacing'
| 'lineHeight'
| 'macOptionSelectionMode'
| 'modifierKeys'
| 'onActive'
| 'onContextMenu'
| 'onCloseSearch'
2020-03-16 06:32:04 -08:00
| 'onData'
| 'onOpenSearch'
2020-03-16 06:32:04 -08:00
| 'onResize'
| 'onTitle'
| 'padding'
| 'quickEdit'
2020-11-24 04:18:50 -09:00
| 'screenReaderMode'
2020-03-16 06:32:04 -08:00
| 'scrollback'
| 'selectionColor'
| 'sessions'
| 'uiFontFamily'
| 'webGLRenderer'
2020-05-06 11:04:14 -08:00
| 'webLinksActivationKey'
2023-06-15 21:34:31 -08:00
| 'windowsPty'
| 'imageSupport'
2020-03-16 06:32:04 -08:00
>;
2023-07-25 01:39:51 -08:00
import type {TermGroupConnectedProps} from '../lib/components/term-group';
2020-03-16 06:32:04 -08:00
export type TermGroupProps = TermGroupConnectedProps & TermGroupOwnProps;
2020-03-18 07:26:46 -08:00
export type SearchBoxProps = {
dateFocused: ImmutableDate | null;
2022-12-30 23:17:19 -09:00
caseSensitive: boolean;
wholeWord: boolean;
regex: boolean;
results: {resultIndex: number; resultCount: number} | undefined;
toggleCaseSensitive: () => void;
toggleWholeWord: () => void;
toggleRegex: () => void;
2020-03-18 07:26:46 -08:00
next: (searchTerm: string) => void;
prev: (searchTerm: string) => void;
close: () => void;
2022-12-30 23:17:19 -09:00
backgroundColor: string;
foregroundColor: string;
borderColor: string;
selectionColor: string;
font: string;
2020-03-18 07:26:46 -08:00
};
import type {FitAddon} from '@xterm/addon-fit';
import type {SearchAddon} from '@xterm/addon-search';
2020-03-18 07:26:46 -08:00
export type TermProps = {
backgroundColor: string;
2023-07-12 21:54:31 -08:00
bell: 'SOUND' | false;
2020-03-18 07:26:46 -08:00
bellSound: string | null;
bellSoundURL: string | null;
borderColor: string;
cleared: boolean;
2021-03-05 07:03:35 -09:00
colors: ColorMap;
2020-03-18 07:26:46 -08:00
cols: number | null;
copyOnSelect: boolean;
cursorAccentColor?: string;
cursorBlink: boolean;
cursorColor: string;
cursorShape: cursorShapes;
disableLigatures: boolean;
fitAddon: FitAddon | null;
fontFamily: string;
fontSize: number;
fontSmoothing?: string;
fontWeight: FontWeight;
fontWeightBold: FontWeight;
foregroundColor: string;
imageSupport: boolean;
2020-03-18 07:26:46 -08:00
isTermActive: boolean;
letterSpacing: number;
lineHeight: number;
macOptionSelectionMode: string;
modifierKeys: Immutable<{altIsMeta: boolean; cmdIsMeta: boolean}>;
onActive: () => void;
onCloseSearch: () => void;
2020-03-18 07:26:46 -08:00
onContextMenu: (selection: any) => void;
onCursorMove?: (cursorFrame: {x: number; y: number; width: number; height: number; col: number; row: number}) => void;
2020-06-19 04:51:34 -08:00
onData: (data: string) => void;
onOpenSearch: () => void;
2020-03-18 07:26:46 -08:00
onResize: (cols: number, rows: number) => void;
onTitle: (title: string) => void;
padding: string;
quickEdit: boolean;
rows: number | null;
2020-11-24 04:18:50 -09:00
screenReaderMode: boolean;
2020-03-18 07:26:46 -08:00
scrollback: number;
search: ImmutableDate | null;
2020-03-18 07:26:46 -08:00
searchAddon: SearchAddon | null;
selectionColor: string;
term: Terminal | null;
uid: string;
uiFontFamily: string;
webGLRenderer: boolean;
2023-06-15 09:10:34 -08:00
webLinksActivationKey: 'ctrl' | 'alt' | 'meta' | 'shift' | '';
2023-06-15 21:34:31 -08:00
windowsPty?: IWindowsPty;
2020-06-19 04:51:34 -08:00
ref_: (uid: string, term: Term | null) => void;
} & extensionProps;
2020-03-18 07:26:46 -08:00
2021-03-05 07:03:35 -09:00
// Utility types
export type Mutable<T> = T extends Immutable<infer U> ? (Exclude<U, T> extends never ? U : Exclude<U, T>) : T;
export type immutableRecord<T> = {[k in keyof T]: Immutable<T[k]>};
2020-03-18 07:26:46 -08:00
export type Assignable<T, U> = {[k in keyof U]: k extends keyof T ? T[k] : U[k]} & Partial<T>;