build: upgrade deps

This commit is contained in:
Haishan 2020-12-06 20:12:16 +08:00
parent d2b01d80fb
commit b0b0edab16
18 changed files with 551 additions and 731 deletions

View file

@ -23,6 +23,7 @@ globals:
__DEV__: true __DEV__: true
rules: rules:
'@typescript-eslint/no-empty-interface': 'off'
'@typescript-eslint/interface-name-prefix': 'off' '@typescript-eslint/interface-name-prefix': 'off'
'@typescript-eslint/explicit-function-return-type': 'off' '@typescript-eslint/explicit-function-return-type': 'off'
'@typescript-eslint/no-explicit-any': 'off' '@typescript-eslint/no-explicit-any': 'off'

View file

@ -5,7 +5,7 @@ const presets = [
modules: false, modules: false,
// see also zloirock/core-js https://bit.ly/2JLnrgw // see also zloirock/core-js https://bit.ly/2JLnrgw
useBuiltIns: 'usage', useBuiltIns: 'usage',
corejs: '3.7', corejs: '3.8.1',
// new in babel 7.9.0 https://babeljs.io/blog/2020/03/16/7.9.0 // new in babel 7.9.0 https://babeljs.io/blog/2020/03/16/7.9.0
bugfixes: true, bugfixes: true,
}, },

View file

@ -23,11 +23,11 @@
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@hsjs/react-cache": "0.0.0-alpha.aa94237", "@hsjs/react-cache": "0.0.0-alpha.aa94237",
"@reach/tooltip": "^0.11.2", "@reach/tooltip": "^0.12.1",
"@sentry/browser": "^5.28.0", "@sentry/browser": "^5.28.0",
"chart.js": "^2.9.2", "chart.js": "^2.9.2",
"clsx": "^1.1.0", "clsx": "^1.1.0",
"core-js": "^3.8.0", "core-js": "^3.8.1",
"date-fns": "^2.16.0", "date-fns": "^2.16.0",
"fontsource-open-sans": "^3.0.9", "fontsource-open-sans": "^3.0.9",
"fontsource-roboto-mono": "^3.0.3", "fontsource-roboto-mono": "^3.0.3",
@ -47,7 +47,7 @@
"react-feather": "^2.0.9", "react-feather": "^2.0.9",
"react-helmet": "^6.1.0", "react-helmet": "^6.1.0",
"react-i18next": "^11.7.4", "react-i18next": "^11.7.4",
"react-icons": "^3.10.0", "react-icons": "^4.1.0",
"react-modal": "^3.12.1", "react-modal": "^3.12.1",
"react-query": "^2.26.3", "react-query": "^2.26.3",
"react-router": "6.0.0-beta.0", "react-router": "6.0.0-beta.0",
@ -55,16 +55,16 @@
"react-switch": "^5.0.1", "react-switch": "^5.0.1",
"react-table": "^7.6.2", "react-table": "^7.6.2",
"react-tabs": "^3.1.0", "react-tabs": "^3.1.0",
"react-tiny-fab": "^3.5.0", "react-tiny-fab": "^4.0.2",
"react-window": "^1.8.5", "react-window": "^1.8.5",
"recoil": "^0.1.2", "recoil": "^0.1.2",
"regenerator-runtime": "^0.13.7", "regenerator-runtime": "^0.13.7",
"reselect": "^4.0.0", "reselect": "^4.0.0",
"workbox-core": "^5.1.4", "workbox-core": "^6.0.2",
"workbox-expiration": "^5.1.4", "workbox-expiration": "^6.0.2",
"workbox-precaching": "^5.1.4", "workbox-precaching": "^6.0.2",
"workbox-routing": "^5.1.4", "workbox-routing": "^6.0.2",
"workbox-strategies": "^5.1.4" "workbox-strategies": "^6.0.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.12.9", "@babel/core": "^7.12.9",
@ -84,7 +84,6 @@
"@types/react-dom": "^17.0.0", "@types/react-dom": "^17.0.0",
"@types/react-helmet": "^6.1.0", "@types/react-helmet": "^6.1.0",
"@types/react-modal": "^3.10.6", "@types/react-modal": "^3.10.6",
"@types/react-table": "^7.0.25",
"@types/react-tabs": "^2.3.2", "@types/react-tabs": "^2.3.2",
"@typescript-eslint/eslint-plugin": "^4.9.0", "@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0", "@typescript-eslint/parser": "^4.9.0",
@ -96,9 +95,9 @@
"css-loader": "^5.0.1", "css-loader": "^5.0.1",
"css-minimizer-webpack-plugin": "^1.1.5", "css-minimizer-webpack-plugin": "^1.1.5",
"cssnano": "^4.1.7", "cssnano": "^4.1.7",
"eslint": "^7.14.0", "eslint": "^7.15.0",
"eslint-config-airbnb-base": "^14.2.1", "eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^6.11.0", "eslint-config-prettier": "^7.0.0",
"eslint-config-react-app": "^6.0.0", "eslint-config-react-app": "^6.0.0",
"eslint-import-resolver-webpack": "^0.13.0", "eslint-import-resolver-webpack": "^0.13.0",
"eslint-plugin-flowtype": "^5.2.0", "eslint-plugin-flowtype": "^5.2.0",
@ -110,15 +109,15 @@
"eslint-plugin-simple-import-sort": "^6.0.1", "eslint-plugin-simple-import-sort": "^6.0.1",
"file-loader": "^6.1.1", "file-loader": "^6.1.1",
"fork-ts-checker-notifier-webpack-plugin": "^3.0.0", "fork-ts-checker-notifier-webpack-plugin": "^3.0.0",
"fork-ts-checker-webpack-plugin": "^6.0.4", "fork-ts-checker-webpack-plugin": "^6.0.5",
"html-webpack-plugin": "^4.5.0", "html-webpack-plugin": "^4.5.0",
"mini-css-extract-plugin": "^1.3.1", "mini-css-extract-plugin": "^1.3.2",
"postcss": "^8.1.10", "postcss": "^8.1.14",
"postcss-custom-media": "^7.0.8", "postcss-custom-media": "^7.0.8",
"postcss-extend-rule": "^3.0.0", "postcss-extend-rule": "^3.0.0",
"postcss-import": "^13.0.0", "postcss-import": "^13.0.0",
"postcss-loader": "^4.1.0", "postcss-loader": "^4.1.0",
"postcss-nested": "^5.0.0", "postcss-nested": "^5.0.2",
"postcss-simple-vars": "^6.0.0", "postcss-simple-vars": "^6.0.0",
"prettier": "^2.2.1", "prettier": "^2.2.1",
"react-refresh": "^0.9.0", "react-refresh": "^0.9.0",
@ -127,11 +126,11 @@
"terser-webpack-plugin": "^5.0.0", "terser-webpack-plugin": "^5.0.0",
"ts-loader": "^8.0.11", "ts-loader": "^8.0.11",
"typescript": "^4.1.2", "typescript": "^4.1.2",
"webpack": "^5.9.0", "webpack": "^5.10.0",
"webpack-bundle-analyzer": "^4.2.0", "webpack-bundle-analyzer": "^4.2.0",
"webpack-cli": "^4.2.0", "webpack-cli": "^4.2.0",
"webpack-dev-middleware": "^4.0.2", "webpack-dev-middleware": "^4.0.2",
"webpack-hot-middleware": "^2.22.2", "webpack-hot-middleware": "^2.22.2",
"workbox-webpack-plugin": "^5.1.4" "workbox-webpack-plugin": "^6.0.2"
} }
} }

View file

@ -24,7 +24,7 @@ const columns = [
{ Header: 'Type', accessor: 'type' }, { Header: 'Type', accessor: 'type' },
]; ];
function renderCell(cell) { function renderCell(cell: { column: { id: string }; value: number }) {
switch (cell.column.id) { switch (cell.column.id) {
case 'start': case 'start':
return formatDistance(cell.value, 0); return formatDistance(cell.value, 0);

View file

@ -243,7 +243,7 @@ function Conn({ apiConfig }) {
} }
: {} : {}
} }
position={fabPosition} style={fabPosition}
text={isRefreshPaused ? 'Resume Refresh' : 'Pause Refresh'} text={isRefreshPaused ? 'Resume Refresh' : 'Pause Refresh'}
onClick={toggleIsRefreshPaused} onClick={toggleIsRefreshPaused}
> >

View file

@ -89,6 +89,7 @@
Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol,
'PingFang SC', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif; 'PingFang SC', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
--color-focus-blue: #1a73e8; --color-focus-blue: #1a73e8;
--btn-bg: #387cec;
} }
body { body {

View file

@ -9,6 +9,8 @@ import { fetchRules } from 'src/api/rules';
import { RuleProviderItem } from 'src/components/rules/RuleProviderItem'; import { RuleProviderItem } from 'src/components/rules/RuleProviderItem';
import { TextFilter } from 'src/components/rules/TextFilter'; import { TextFilter } from 'src/components/rules/TextFilter';
import { ruleFilterText } from 'src/store/rules'; import { ruleFilterText } from 'src/store/rules';
import { State } from 'src/store/types';
import type { ClashAPIConfig } from 'src/types';
import useRemainingViewPortHeight from '../hooks/useRemainingViewPortHeight'; import useRemainingViewPortHeight from '../hooks/useRemainingViewPortHeight';
import { getClashAPIConfig } from '../store/app'; import { getClashAPIConfig } from '../store/app';
@ -22,7 +24,7 @@ const { memo, useMemo, useCallback } = React;
const paddingBottom = 30; const paddingBottom = 30;
function itemKey(index, { rules, provider }) { function itemKey(index: number, { rules, provider }) {
const providerQty = provider.names.length; const providerQty = provider.names.length;
if (index < providerQty) { if (index < providerQty) {
@ -33,7 +35,7 @@ function itemKey(index, { rules, provider }) {
} }
function getItemSizeFactory({ provider }) { function getItemSizeFactory({ provider }) {
return function getItemSize(idx) { return function getItemSize(idx: number) {
const providerQty = provider.names.length; const providerQty = provider.names.length;
if (idx < providerQty) { if (idx < providerQty) {
// provider // provider
@ -67,16 +69,20 @@ const Row = memo(({ index, style, data }) => {
); );
}, areEqual); }, areEqual);
const mapState = (s) => ({ const mapState = (s: State) => ({
apiConfig: getClashAPIConfig(s), apiConfig: getClashAPIConfig(s),
}); });
export default connect(mapState)(Rules); export default connect(mapState)(Rules);
function useRuleAndProvider(apiConfig) { function useRuleAndProvider(apiConfig: ClashAPIConfig) {
const { data: rules } = useQuery(['/rules', apiConfig], fetchRules, { const { data: rules, isFetching } = useQuery(
['/rules', apiConfig],
fetchRules,
{
suspense: true, suspense: true,
}); }
);
const { data: provider } = useQuery( const { data: provider } = useQuery(
['/providers/rules', apiConfig], ['/providers/rules', apiConfig],
fetchRuleProviders, fetchRuleProviders,
@ -85,11 +91,12 @@ function useRuleAndProvider(apiConfig) {
const [filterText] = useRecoilState(ruleFilterText); const [filterText] = useRecoilState(ruleFilterText);
if (filterText === '') { if (filterText === '') {
return { rules, provider }; return { rules, provider, isFetching };
} else { } else {
const f = filterText.toLowerCase(); const f = filterText.toLowerCase();
return { return {
rules: rules.filter((r) => r.payload.toLowerCase().indexOf(f) >= 0), rules: rules.filter((r) => r.payload.toLowerCase().indexOf(f) >= 0),
isFetching,
provider: { provider: {
byName: provider.byName, byName: provider.byName,
names: provider.names.filter((t) => t.toLowerCase().indexOf(f) >= 0), names: provider.names.filter((t) => t.toLowerCase().indexOf(f) >= 0),
@ -141,7 +148,7 @@ function Rules({ apiConfig }) {
<Fab <Fab
icon={refreshIcon} icon={refreshIcon}
text="Refresh" text="Refresh"
position={fabPosition} style={fabPosition}
onClick={invalidateQueries} onClick={invalidateQueries}
/> />
</div> </div>

View file

@ -34,30 +34,3 @@
padding: 10px 40px; padding: 10px 40px;
} }
} }
.spining {
position: relative;
border-radius: 50%;
background: linear-gradient(60deg, #e66465, #9198e5);
}
.spining:before {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border: 2px solid transparent;
border-top-color: currentColor;
border-radius: 50%;
animation: spining_keyframes 1s linear infinite;
}
@keyframes spining_keyframes {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}

View file

@ -15,7 +15,7 @@ import {
import Button from '../Button'; import Button from '../Button';
import ContentHeader from '../ContentHeader'; import ContentHeader from '../ContentHeader';
import BaseModal from '../shared/BaseModal'; import BaseModal from '../shared/BaseModal';
import { Fab, position as fabPosition } from '../shared/Fab'; import { Fab, IsFetching, position as fabPosition } from '../shared/Fab';
import { connect, useStoreActions } from '../StateProvider'; import { connect, useStoreActions } from '../StateProvider';
import Equalizer from '../svg/Equalizer'; import Equalizer from '../svg/Equalizer';
import { ClosePrevConns } from './ClosePrevConns'; import { ClosePrevConns } from './ClosePrevConns';
@ -121,10 +121,18 @@ function Proxies({
<ProxyProviderList items={proxyProviders} /> <ProxyProviderList items={proxyProviders} />
<div style={{ height: 60 }} /> <div style={{ height: 60 }} />
<Fab <Fab
icon={isTestingLatency ? <ColorZap /> : <Zap width={16} height={16} />} icon={
isTestingLatency ? (
<IsFetching>
<Zap width={16} height={16} />
</IsFetching>
) : (
<Zap width={16} height={16} />
)
}
onClick={requestDelayAllFn} onClick={requestDelayAllFn}
text={t('Test Latency')} text={t('Test Latency')}
position={fabPosition} style={fabPosition}
/> />
<BaseModal <BaseModal
isOpen={showModalClosePrevConns} isOpen={showModalClosePrevConns}
@ -139,23 +147,6 @@ function Proxies({
); );
} }
function ColorZap() {
return (
<div
className={s0.spining}
style={{
width: 48,
height: 48,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Zap width={16} height={16} />
</div>
);
}
const mapState = (s) => ({ const mapState = (s) => ({
apiConfig: getClashAPIConfig(s), apiConfig: getClashAPIConfig(s),
groupNames: getProxyGroupNames(s), groupNames: getProxyGroupNames(s),

View file

@ -31,6 +31,7 @@
} }
.isRotating { .isRotating {
animation: rotating 3s infinite linear; animation: rotating 3s infinite linear;
animation-fill-mode: forwards;
} }
@keyframes rotating { @keyframes rotating {

View file

@ -0,0 +1,33 @@
.spining {
position: relative;
border-radius: 50%;
background: linear-gradient(60deg, #e66465, #9198e5);
width: 48px;
height: 48px;
display: flex;
justify-content: center;
align-items: center;
}
.spining:before {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border: 2px solid transparent;
border-top-color: currentColor;
border-radius: 50%;
animation: spining_keyframes 1s linear infinite;
}
@keyframes spining_keyframes {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}

View file

@ -1,10 +0,0 @@
import './rtf.css';
import { Action, Fab } from 'react-tiny-fab';
export const position = {
right: 10,
bottom: 10,
};
export { Fab, Action };

View file

@ -0,0 +1,17 @@
import './rtf.css';
import * as React from 'react';
import { Action, Fab } from 'react-tiny-fab/dist';
import s from './Fab.module.css';
export function IsFetching({ children }: { children: React.ReactNode }) {
return <span className={s.spining}>{children}</span>;
}
export const position = {
right: 10,
bottom: 10,
};
export { Fab, Action };

View file

@ -11,13 +11,7 @@
padding-left: 0; padding-left: 0;
list-style: none; list-style: none;
} }
.rtf.open .rtf--mb > * {
/* transform-origin: center center; */
/* transform: rotate(360deg); */
transition: ease-in-out transform 0.2s;
}
.rtf.open .rtf--mb { .rtf.open .rtf--mb {
background: rgba(56, 124, 236, 0.92);
box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.2), box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.2),
0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12); 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12);
} }
@ -114,10 +108,10 @@
} }
.rtf--mb { .rtf--mb {
height: 48px;
width: 48px; width: 48px;
height: 48px;
background: var(--btn-bg);
z-index: 9999; z-index: 9999;
background: #387cec;
display: inline-flex; display: inline-flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;

44
src/custom.d.ts vendored
View file

@ -20,3 +20,47 @@ declare const process = {
PUBLIC_URL: string, PUBLIC_URL: string,
}, },
}; };
declare module 'react-table' {
interface TableOptions {}
interface Empty {}
interface SortByToggleProps {}
interface Header {
getHeaderProps(p: SortByToggleProps): { role?: string };
getSortByToggleProps(): SortByToggleProps;
render(x: string): string;
isSorted: boolean;
isSortedDesc: boolean;
}
interface HeaderGroup {
getHeaderGroupProps(): { role?: string };
headers: Header[];
}
interface Cell {
getCellProps(): { role?: string };
column: { id: string };
value: number;
}
interface Row {
cells: Cell[];
}
export function useTable(
options: TableOptions,
useSortBy: useSortBy
): {
headerGroups: HeaderGroup[];
getTableProps(): { role?: string };
rows: Row[];
prepareRow(r: Row): void;
};
export function useSortBy(): Empty;
}

View file

@ -1,15 +1,15 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8" />
<link rel="shortcut icon" href="yacd.ico"> <link rel="shortcut icon" href="yacd.ico" />
<link rel="icon" type="image/png" sizes="64x64" href="yacd-64.png"> <link rel="icon" type="image/png" sizes="64x64" href="yacd-64.png" />
<link rel="icon" type="image/png" sizes="128x128" href="yacd-128.png"> <link rel="icon" type="image/png" sizes="128x128" href="yacd-128.png" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name=viewport content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="application-name" content="yacd"> <meta name="application-name" content="yacd" />
<meta name="description" content="Yet Another Clash Dashboard"> <meta name="description" content="Yet Another Clash Dashboard" />
<meta name="theme-color" content="#202020"> <meta name="theme-color" content="#202020" />
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
</head> </head>
<body> <body>

View file

@ -32,6 +32,7 @@ i18next
switch (url) { switch (url) {
case '/__zh/translation.json': case '/__zh/translation.json':
case '/__zh-CN/translation.json':
p = allLocales.zh; p = allLocales.zh;
break; break;
case '/__en/translation.json': case '/__en/translation.json':
@ -47,7 +48,7 @@ i18next
} }
}, },
}, },
supportedLngs: ['en', 'zh'], supportedLngs: ['en', 'zh-CN'],
fallbackLng: 'en', fallbackLng: 'en',
interpolation: { interpolation: {
escapeValue: false, escapeValue: false,

1006
yarn.lock

File diff suppressed because it is too large Load diff