mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-16 05:38:41 -09:00
Fix typescript errors
This commit is contained in:
parent
887e656f1b
commit
a9cb042bd6
8 changed files with 59 additions and 49 deletions
|
|
@ -1,12 +1,12 @@
|
||||||
import {app, Menu} from 'electron';
|
import {app, Menu} from 'electron';
|
||||||
import type {BrowserWindow} from 'electron';
|
import type {BaseWindow} from 'electron';
|
||||||
|
|
||||||
import {openConfig, getConfig} from './config';
|
import {openConfig, getConfig} from './config';
|
||||||
import {updatePlugins} from './plugins';
|
import {updatePlugins} from './plugins';
|
||||||
import {installCLI} from './utils/cli-install';
|
import {installCLI} from './utils/cli-install';
|
||||||
import * as systemContextMenu from './utils/system-context-menu';
|
import * as systemContextMenu from './utils/system-context-menu';
|
||||||
|
|
||||||
const commands: Record<string, (focusedWindow?: BrowserWindow) => void> = {
|
const commands: Record<string, (focusedWindow?: any) => void> = {
|
||||||
'window:new': () => {
|
'window:new': () => {
|
||||||
// If window is created on the same tick, it will consume event too
|
// If window is created on the same tick, it will consume event too
|
||||||
setTimeout(app.createWindow, 0);
|
setTimeout(app.createWindow, 0);
|
||||||
|
|
@ -162,7 +162,7 @@ getConfig().profiles.forEach((profile) => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
export const execCommand = (command: string, focusedWindow?: BrowserWindow) => {
|
export const execCommand = (command: string, focusedWindow?: BaseWindow) => {
|
||||||
const fn = commands[command];
|
const fn = commands[command];
|
||||||
if (fn) {
|
if (fn) {
|
||||||
fn(focusedWindow);
|
fn(focusedWindow);
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ const editMenu = (
|
||||||
label: 'Select All',
|
label: 'Select All',
|
||||||
accelerator: commandKeys['editor:selectAll'],
|
accelerator: commandKeys['editor:selectAll'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('editor:selectAll', focusedWindow);
|
execCommand('editor:selectAll', focusedWindow as BrowserWindow | undefined);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -51,28 +51,28 @@ const editMenu = (
|
||||||
label: 'Previous word',
|
label: 'Previous word',
|
||||||
accelerator: commandKeys['editor:movePreviousWord'],
|
accelerator: commandKeys['editor:movePreviousWord'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('editor:movePreviousWord', focusedWindow);
|
execCommand('editor:movePreviousWord', focusedWindow as BrowserWindow | undefined);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Next word',
|
label: 'Next word',
|
||||||
accelerator: commandKeys['editor:moveNextWord'],
|
accelerator: commandKeys['editor:moveNextWord'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('editor:moveNextWord', focusedWindow);
|
execCommand('editor:moveNextWord', focusedWindow as BrowserWindow | undefined);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Line beginning',
|
label: 'Line beginning',
|
||||||
accelerator: commandKeys['editor:moveBeginningLine'],
|
accelerator: commandKeys['editor:moveBeginningLine'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('editor:moveBeginningLine', focusedWindow);
|
execCommand('editor:moveBeginningLine', focusedWindow as BrowserWindow | undefined);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Line end',
|
label: 'Line end',
|
||||||
accelerator: commandKeys['editor:moveEndLine'],
|
accelerator: commandKeys['editor:moveEndLine'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('editor:moveEndLine', focusedWindow);
|
execCommand('editor:moveEndLine', focusedWindow as BrowserWindow | undefined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -84,28 +84,28 @@ const editMenu = (
|
||||||
label: 'Previous word',
|
label: 'Previous word',
|
||||||
accelerator: commandKeys['editor:deletePreviousWord'],
|
accelerator: commandKeys['editor:deletePreviousWord'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('editor:deletePreviousWord', focusedWindow);
|
execCommand('editor:deletePreviousWord', focusedWindow as BrowserWindow | undefined);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Next word',
|
label: 'Next word',
|
||||||
accelerator: commandKeys['editor:deleteNextWord'],
|
accelerator: commandKeys['editor:deleteNextWord'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('editor:deleteNextWord', focusedWindow);
|
execCommand('editor:deleteNextWord', focusedWindow as BrowserWindow | undefined);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Line beginning',
|
label: 'Line beginning',
|
||||||
accelerator: commandKeys['editor:deleteBeginningLine'],
|
accelerator: commandKeys['editor:deleteBeginningLine'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('editor:deleteBeginningLine', focusedWindow);
|
execCommand('editor:deleteBeginningLine', focusedWindow as BrowserWindow | undefined);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Line end',
|
label: 'Line end',
|
||||||
accelerator: commandKeys['editor:deleteEndLine'],
|
accelerator: commandKeys['editor:deleteEndLine'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('editor:deleteEndLine', focusedWindow);
|
execCommand('editor:deleteEndLine', focusedWindow as BrowserWindow | undefined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -117,14 +117,14 @@ const editMenu = (
|
||||||
label: 'Clear Buffer',
|
label: 'Clear Buffer',
|
||||||
accelerator: commandKeys['editor:clearBuffer'],
|
accelerator: commandKeys['editor:clearBuffer'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('editor:clearBuffer', focusedWindow);
|
execCommand('editor:clearBuffer', focusedWindow as BrowserWindow | undefined);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Search',
|
label: 'Search',
|
||||||
accelerator: commandKeys['editor:search'],
|
accelerator: commandKeys['editor:search'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('editor:search', focusedWindow);
|
execCommand('editor:search', focusedWindow as BrowserWindow | undefined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
import type {BaseWindow, MenuItemConstructorOptions} from 'electron';
|
||||||
|
|
||||||
const shellMenu = (
|
const shellMenu = (
|
||||||
commandKeys: Record<string, string>,
|
commandKeys: Record<string, string>,
|
||||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void,
|
execCommand: (command: string, focusedWindow?: BaseWindow) => void,
|
||||||
profiles: string[]
|
profiles: string[]
|
||||||
): MenuItemConstructorOptions => {
|
): MenuItemConstructorOptions => {
|
||||||
const isMac = process.platform === 'darwin';
|
const isMac = process.platform === 'darwin';
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
import type {BaseWindow, MenuItemConstructorOptions} from 'electron';
|
||||||
|
|
||||||
const viewMenu = (
|
const viewMenu = (
|
||||||
commandKeys: Record<string, string>,
|
commandKeys: Record<string, string>,
|
||||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void
|
execCommand: (command: string, focusedWindow?: BaseWindow) => void
|
||||||
): MenuItemConstructorOptions => {
|
): MenuItemConstructorOptions => {
|
||||||
return {
|
return {
|
||||||
label: 'View',
|
label: 'View',
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
import type {BaseWindow, MenuItemConstructorOptions} from 'electron';
|
||||||
|
|
||||||
const windowMenu = (
|
const windowMenu = (
|
||||||
commandKeys: Record<string, string>,
|
commandKeys: Record<string, string>,
|
||||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void
|
execCommand: (command: string, focusedWindow?: BaseWindow) => void
|
||||||
): MenuItemConstructorOptions => {
|
): MenuItemConstructorOptions => {
|
||||||
// Generating tab:jump array
|
// Generating tab:jump array
|
||||||
const tabJump: MenuItemConstructorOptions[] = [];
|
const tabJump: MenuItemConstructorOptions[] = [];
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import './v8-snapshot-util';
|
import './v8-snapshot-util';
|
||||||
import {webFrame} from 'electron';
|
import {webFrame} from 'electron';
|
||||||
import React from 'react';
|
import React, { useMemo } from 'react';
|
||||||
|
|
||||||
import {createRoot} from 'react-dom/client';
|
import {createRoot} from 'react-dom/client';
|
||||||
import {Provider} from 'react-redux';
|
import {Provider} from 'react-redux';
|
||||||
|
|
|
||||||
8
typings/styled.d.ts
vendored
Normal file
8
typings/styled.d.ts
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
import 'react';
|
||||||
|
|
||||||
|
declare module 'react' {
|
||||||
|
interface StyleHTMLAttributes<T> extends React.HTMLAttributes<T> {
|
||||||
|
jsx?: boolean;
|
||||||
|
global?: boolean;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -69,6 +69,10 @@ const config: webpack.Configuration[] = [
|
||||||
mode: 'none',
|
mode: 'none',
|
||||||
name: 'hyper',
|
name: 'hyper',
|
||||||
resolve: {
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
react: path.resolve(__dirname, 'node_modules/react'),
|
||||||
|
'react-dom': path.resolve(__dirname, 'node_modules/react-dom')
|
||||||
|
},
|
||||||
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts']
|
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts']
|
||||||
},
|
},
|
||||||
devtool: isProd ? 'hidden-source-map' : 'cheap-module-source-map',
|
devtool: isProd ? 'hidden-source-map' : 'cheap-module-source-map',
|
||||||
|
|
@ -96,34 +100,32 @@ const config: webpack.Configuration[] = [
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
externals: {
|
externals: {
|
||||||
'color-convert': 'require("./node_modules/color-convert/index.js")',
|
'color-convert': 'commonjs color-convert',
|
||||||
'color-string': 'require("./node_modules/color-string/index.js")',
|
'color-string': 'commonjs color-string',
|
||||||
columnify: 'require("./node_modules/columnify/columnify.js")',
|
columnify: 'commonjs columnify',
|
||||||
lodash: 'require("./node_modules/lodash/lodash.js")',
|
lodash: 'commonjs lodash',
|
||||||
ms: 'require("./node_modules/ms/index.js")',
|
ms: 'commonjs ms',
|
||||||
'normalize-url': 'require("./node_modules/normalize-url/index.js")',
|
'normalize-url': 'commonjs normalize-url',
|
||||||
'parse-url': 'require("./node_modules/parse-url/dist/index.js")',
|
'parse-url': 'commonjs parse-url',
|
||||||
'php-escape-shell': 'require("./node_modules/php-escape-shell/php-escape-shell.js")',
|
'php-escape-shell': 'commonjs php-escape-shell',
|
||||||
plist: 'require("./node_modules/plist/index.js")',
|
plist: 'commonjs plist',
|
||||||
'react-dom': 'require("./node_modules/react-dom/index.js")',
|
// 'react-dom': 'commonjs react-dom',
|
||||||
'react-redux': 'require("./node_modules/react-redux/lib/index.js")',
|
'redux-thunk': 'commonjs redux-thunk',
|
||||||
react: 'require("./node_modules/react/index.js")',
|
redux: 'commonjs redux',
|
||||||
'redux-thunk': 'require("./node_modules/redux-thunk/lib/index.js")',
|
reselect: 'commonjs reselect',
|
||||||
redux: 'require("./node_modules/redux/lib/redux.js")',
|
'seamless-immutable': 'commonjs seamless-immutable',
|
||||||
reselect: 'require("./node_modules/reselect/lib/index.js")',
|
stylis: 'commonjs stylis',
|
||||||
'seamless-immutable': 'require("./node_modules/seamless-immutable/src/seamless-immutable.js")',
|
'@xterm/addon-unicode11': 'commonjs @xterm/addon-unicode11',
|
||||||
stylis: 'require("./node_modules/stylis/stylis.js")',
|
args: 'commonjs args',
|
||||||
'@xterm/addon-unicode11': 'require("./node_modules/@xterm/addon-unicode11/lib/addon-unicode11.js")',
|
mousetrap: 'commonjs mousetrap',
|
||||||
args: 'require("./node_modules/args/lib/index.js")',
|
open: 'commonjs open',
|
||||||
mousetrap: 'require("./node_modules/mousetrap/mousetrap.js")',
|
'@xterm/addon-fit': 'commonjs @xterm/addon-fit',
|
||||||
open: 'require("./node_modules/open/index.js")',
|
'@xterm/addon-image': 'commonjs @xterm/addon-image',
|
||||||
'@xterm/addon-fit': 'require("./node_modules/@xterm/addon-fit/lib/addon-fit.js")',
|
'@xterm/addon-search': 'commonjs @xterm/addon-search',
|
||||||
'@xterm/addon-image': 'require("./node_modules/@xterm/addon-image/lib/addon-image.js")',
|
'@xterm/addon-web-links': 'commonjs @xterm/addon-web-links',
|
||||||
'@xterm/addon-search': 'require("./node_modules/@xterm/addon-search/lib/addon-search.js")',
|
'@xterm/addon-webgl': 'commonjs @xterm/addon-webgl',
|
||||||
'@xterm/addon-web-links': 'require("./node_modules/@xterm/addon-web-links/lib/addon-web-links.js")',
|
'@xterm/addon-canvas': 'commonjs @xterm/addon-canvas',
|
||||||
'@xterm/addon-webgl': 'require("./node_modules/@xterm/addon-webgl/lib/addon-webgl.js")',
|
xterm: 'commonjs xterm'
|
||||||
'@xterm/addon-canvas': 'require("./node_modules/@xterm/addon-canvas/lib/addon-canvas.js")',
|
|
||||||
xterm: 'require("./node_modules/xterm/lib/xterm.js")'
|
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.IgnorePlugin({resourceRegExp: /.*\.js.map$/i}),
|
new webpack.IgnorePlugin({resourceRegExp: /.*\.js.map$/i}),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue