From d185e59d4cc73ef87b79e77d2d24375b353678a2 Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Tue, 25 Jul 2023 16:09:11 +0530 Subject: [PATCH] move constants to typings as well --- lib/actions/config.ts | 2 +- lib/actions/header.ts | 4 ++-- lib/actions/index.ts | 2 +- lib/actions/notifications.ts | 2 +- lib/actions/sessions.ts | 2 +- lib/actions/term-groups.ts | 4 ++-- lib/actions/ui.ts | 2 +- lib/actions/updater.ts | 2 +- lib/reducers/sessions.ts | 2 +- lib/reducers/term-groups.ts | 6 +++--- lib/reducers/ui.ts | 10 +++++----- tsconfig.json | 2 +- .../config.ts => typings/constants/config.d.ts | 2 +- .../index.ts => typings/constants/index.d.ts | 0 .../constants/notifications.d.ts | 0 .../constants/sessions.d.ts | 0 .../tabs.ts => typings/constants/tabs.d.ts | 0 .../constants/term-groups.d.ts | 8 ++++---- lib/constants/ui.ts => typings/constants/ui.d.ts | 0 .../updater.ts => typings/constants/updater.d.ts | 0 typings/hyper.d.ts | 16 ++++++++-------- webpack.config.ts | 2 +- 22 files changed, 34 insertions(+), 34 deletions(-) rename lib/constants/config.ts => typings/constants/config.d.ts (86%) rename lib/constants/index.ts => typings/constants/index.d.ts (100%) rename lib/constants/notifications.ts => typings/constants/notifications.d.ts (100%) rename lib/constants/sessions.ts => typings/constants/sessions.d.ts (100%) rename lib/constants/tabs.ts => typings/constants/tabs.d.ts (100%) rename lib/constants/term-groups.ts => typings/constants/term-groups.d.ts (89%) rename lib/constants/ui.ts => typings/constants/ui.d.ts (100%) rename lib/constants/updater.ts => typings/constants/updater.d.ts (100%) diff --git a/lib/actions/config.ts b/lib/actions/config.ts index d792d84675d3..d43235f2e142 100644 --- a/lib/actions/config.ts +++ b/lib/actions/config.ts @@ -1,4 +1,4 @@ -import {CONFIG_LOAD, CONFIG_RELOAD} from '../constants/config'; +import {CONFIG_LOAD, CONFIG_RELOAD} from '../../typings/constants/config'; import type {HyperActions} from '../../typings/hyper'; import type {configOptions} from '../../typings/config'; diff --git a/lib/actions/header.ts b/lib/actions/header.ts index 1057f00f7e61..fa638bdf987d 100644 --- a/lib/actions/header.ts +++ b/lib/actions/header.ts @@ -1,11 +1,11 @@ -import {CLOSE_TAB, CHANGE_TAB} from '../constants/tabs'; +import {CLOSE_TAB, CHANGE_TAB} from '../../typings/constants/tabs'; import { UI_WINDOW_MAXIMIZE, UI_WINDOW_UNMAXIMIZE, UI_OPEN_HAMBURGER_MENU, UI_WINDOW_MINIMIZE, UI_WINDOW_CLOSE -} from '../constants/ui'; +} from '../../typings/constants/ui'; import rpc from '../rpc'; import {userExitTermGroup, setActiveGroup} from './term-groups'; import type {HyperDispatch} from '../../typings/hyper'; diff --git a/lib/actions/index.ts b/lib/actions/index.ts index e001bc662986..3749833cf096 100644 --- a/lib/actions/index.ts +++ b/lib/actions/index.ts @@ -1,5 +1,5 @@ import rpc from '../rpc'; -import {INIT} from '../constants'; +import {INIT} from '../../typings/constants'; import type {HyperDispatch} from '../../typings/hyper'; export default function init() { diff --git a/lib/actions/notifications.ts b/lib/actions/notifications.ts index 7ad64611cff8..8433671f7734 100644 --- a/lib/actions/notifications.ts +++ b/lib/actions/notifications.ts @@ -1,4 +1,4 @@ -import {NOTIFICATION_MESSAGE, NOTIFICATION_DISMISS} from '../constants/notifications'; +import {NOTIFICATION_MESSAGE, NOTIFICATION_DISMISS} from '../../typings/constants/notifications'; import type {HyperActions} from '../../typings/hyper'; export function dismissNotification(id: string): HyperActions { diff --git a/lib/actions/sessions.ts b/lib/actions/sessions.ts index f90130164c35..135ac0745f9b 100644 --- a/lib/actions/sessions.ts +++ b/lib/actions/sessions.ts @@ -14,7 +14,7 @@ import { SESSION_USER_DATA, SESSION_SET_XTERM_TITLE, SESSION_SEARCH -} from '../constants/sessions'; +} from '../../typings/constants/sessions'; import type {HyperState, HyperDispatch, HyperActions} from '../../typings/hyper'; import type {Session} from '../../typings/common'; diff --git a/lib/actions/term-groups.ts b/lib/actions/term-groups.ts index 75c8a6252401..44df015c05df 100644 --- a/lib/actions/term-groups.ts +++ b/lib/actions/term-groups.ts @@ -5,8 +5,8 @@ import { TERM_GROUP_REQUEST, TERM_GROUP_EXIT, TERM_GROUP_EXIT_ACTIVE -} from '../constants/term-groups'; -import {SESSION_REQUEST} from '../constants/sessions'; +} 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'; diff --git a/lib/actions/ui.ts b/lib/actions/ui.ts index fd737ed31ec7..25427ae1a014 100644 --- a/lib/actions/ui.ts +++ b/lib/actions/ui.ts @@ -24,7 +24,7 @@ import { UI_OPEN_SSH_URL, UI_CONTEXTMENU_OPEN, UI_COMMAND_EXEC -} from '../constants/ui'; +} from '../../typings/constants/ui'; import {setActiveGroup} from './term-groups'; import type parseUrl from 'parse-url'; diff --git a/lib/actions/updater.ts b/lib/actions/updater.ts index e4cf53e4ece4..9425462d910e 100644 --- a/lib/actions/updater.ts +++ b/lib/actions/updater.ts @@ -1,4 +1,4 @@ -import {UPDATE_INSTALL, UPDATE_AVAILABLE} from '../constants/updater'; +import {UPDATE_INSTALL, UPDATE_AVAILABLE} from '../../typings/constants/updater'; import rpc from '../rpc'; import type {HyperActions} from '../../typings/hyper'; diff --git a/lib/reducers/sessions.ts b/lib/reducers/sessions.ts index 85fab286f77e..c463f15ea8cb 100644 --- a/lib/reducers/sessions.ts +++ b/lib/reducers/sessions.ts @@ -11,7 +11,7 @@ import { SESSION_SET_XTERM_TITLE, SESSION_SET_CWD, SESSION_SEARCH -} from '../constants/sessions'; +} from '../../typings/constants/sessions'; import type {sessionState, session, Mutable, ISessionReducer} from '../../typings/hyper'; const initialState: sessionState = Immutable>({ diff --git a/lib/reducers/term-groups.ts b/lib/reducers/term-groups.ts index 8ca33ef90820..c15b48512a6d 100644 --- a/lib/reducers/term-groups.ts +++ b/lib/reducers/term-groups.ts @@ -1,9 +1,9 @@ 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 '../constants/term-groups'; -import type {SessionAddAction} from '../constants/sessions'; -import {SESSION_ADD, SESSION_SET_ACTIVE} from '../constants/sessions'; +import {TERM_GROUP_EXIT, TERM_GROUP_RESIZE} from '../../typings/constants/term-groups'; +import type {SessionAddAction} from '../../typings/constants/sessions'; +import {SESSION_ADD, SESSION_SET_ACTIVE} from '../../typings/constants/sessions'; import findBySession from '../utils/term-groups'; import {decorateTermGroupsReducer} from '../utils/plugins'; import type {ITermGroup, ITermState, ITermGroups, ITermGroupReducer, Mutable} from '../../typings/hyper'; diff --git a/lib/reducers/ui.ts b/lib/reducers/ui.ts index dd1dbf01ba85..4acf01b18e97 100644 --- a/lib/reducers/ui.ts +++ b/lib/reducers/ui.ts @@ -1,7 +1,7 @@ import type {Immutable as ImmutableType} from 'seamless-immutable'; import Immutable from 'seamless-immutable'; import {decorateUIReducer} from '../utils/plugins'; -import {CONFIG_LOAD, CONFIG_RELOAD} from '../constants/config'; +import {CONFIG_LOAD, CONFIG_RELOAD} from '../../typings/constants/config'; import { UI_FONT_SIZE_SET, UI_FONT_SIZE_RESET, @@ -11,8 +11,8 @@ import { UI_WINDOW_GEOMETRY_CHANGED, UI_ENTER_FULLSCREEN, UI_LEAVE_FULLSCREEN -} from '../constants/ui'; -import {NOTIFICATION_MESSAGE, NOTIFICATION_DISMISS} from '../constants/notifications'; +} from '../../typings/constants/ui'; +import {NOTIFICATION_MESSAGE, NOTIFICATION_DISMISS} from '../../typings/constants/notifications'; import { SESSION_ADD, SESSION_RESIZE, @@ -20,8 +20,8 @@ import { SESSION_PTY_EXIT, SESSION_SET_ACTIVE, SESSION_SET_CWD -} from '../constants/sessions'; -import {UPDATE_AVAILABLE} from '../constants/updater'; +} from '../../typings/constants/sessions'; +import {UPDATE_AVAILABLE} from '../../typings/constants/updater'; import type {uiState, Mutable, IUiReducer} from '../../typings/hyper'; import {release} from 'os'; diff --git a/tsconfig.json b/tsconfig.json index e8a421e6667b..fd6b18133d5a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,7 @@ "./lib/", "./test/", "./cli/", - "./typings" + "./typings/" ], "references": [ { diff --git a/lib/constants/config.ts b/typings/constants/config.d.ts similarity index 86% rename from lib/constants/config.ts rename to typings/constants/config.d.ts index 3345fe550fa8..31aff6daac68 100644 --- a/lib/constants/config.ts +++ b/typings/constants/config.d.ts @@ -1,4 +1,4 @@ -import type {configOptions} from '../../typings/config'; +import type {configOptions} from '../config'; export const CONFIG_LOAD = 'CONFIG_LOAD'; export const CONFIG_RELOAD = 'CONFIG_RELOAD'; diff --git a/lib/constants/index.ts b/typings/constants/index.d.ts similarity index 100% rename from lib/constants/index.ts rename to typings/constants/index.d.ts diff --git a/lib/constants/notifications.ts b/typings/constants/notifications.d.ts similarity index 100% rename from lib/constants/notifications.ts rename to typings/constants/notifications.d.ts diff --git a/lib/constants/sessions.ts b/typings/constants/sessions.d.ts similarity index 100% rename from lib/constants/sessions.ts rename to typings/constants/sessions.d.ts diff --git a/lib/constants/tabs.ts b/typings/constants/tabs.d.ts similarity index 100% rename from lib/constants/tabs.ts rename to typings/constants/tabs.d.ts diff --git a/lib/constants/term-groups.ts b/typings/constants/term-groups.d.ts similarity index 89% rename from lib/constants/term-groups.ts rename to typings/constants/term-groups.d.ts index 798b9e8460d3..6f4edec7effa 100644 --- a/lib/constants/term-groups.ts +++ b/typings/constants/term-groups.d.ts @@ -2,10 +2,10 @@ export const TERM_GROUP_REQUEST = 'TERM_GROUP_REQUEST'; export const TERM_GROUP_EXIT = 'TERM_GROUP_EXIT'; export const TERM_GROUP_RESIZE = 'TERM_GROUP_RESIZE'; export const TERM_GROUP_EXIT_ACTIVE = 'TERM_GROUP_EXIT_ACTIVE'; -export const DIRECTION = { - HORIZONTAL: 'HORIZONTAL', - VERTICAL: 'VERTICAL' -} as const; +export enum DIRECTION { + HORIZONTAL = 'HORIZONTAL', + VERTICAL = 'VERTICAL' +} export interface TermGroupRequestAction { type: typeof TERM_GROUP_REQUEST; diff --git a/lib/constants/ui.ts b/typings/constants/ui.d.ts similarity index 100% rename from lib/constants/ui.ts rename to typings/constants/ui.d.ts diff --git a/lib/constants/updater.ts b/typings/constants/updater.d.ts similarity index 100% rename from lib/constants/updater.ts rename to typings/constants/updater.d.ts diff --git a/typings/hyper.d.ts b/typings/hyper.d.ts index 85c407559d3e..53b221dda3e8 100644 --- a/typings/hyper.d.ts +++ b/typings/hyper.d.ts @@ -167,14 +167,14 @@ export type HyperState = { termGroups: ITermState; }; -import type {UIActions} from '../lib/constants/ui'; -import type {ConfigActions} from '../lib/constants/config'; -import type {SessionActions} from '../lib/constants/sessions'; -import type {NotificationActions} from '../lib/constants/notifications'; -import type {UpdateActions} from '../lib/constants/updater'; -import type {TermGroupActions} from '../lib/constants/term-groups'; -import type {InitActions} from '../lib/constants'; -import type {TabActions} from '../lib/constants/tabs'; +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'; export type HyperActions = ( | UIActions diff --git a/webpack.config.ts b/webpack.config.ts index bfa4ddd7f1a5..53576ba734a1 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -72,7 +72,7 @@ const config: webpack.Configuration[] = [ mode: 'none', name: 'hyper', resolve: { - extensions: ['.js', '.jsx', '.ts', '.tsx'] + extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'] }, devtool: isProd ? 'hidden-source-map' : 'cheap-module-source-map', entry: './lib/index.tsx',