[dev] Bump dependencies (#2839)

This commit is contained in:
Alexander Zinchuk 2023-03-30 18:25:08 -05:00
parent 2c8b22b964
commit f53e38c4a7
23 changed files with 1828 additions and 1500 deletions

View File

@ -1,19 +0,0 @@
{
"presets": [
[
"@babel/typescript"
],
[
"@babel/preset-env"
],
[
"@babel/preset-react"
]
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-syntax-nullish-coalescing-operator",
"@babel/plugin-proposal-logical-assignment-operators",
]
}

View File

@ -90,6 +90,12 @@
"import/prefer-default-export": "off", "import/prefer-default-export": "off",
"import/named": "off", "import/named": "off",
"import/no-webpack-loader-syntax": "off", "import/no-webpack-loader-syntax": "off",
"import/no-cycle": [
"error",
{
"allowUnsafeDynamicCyclicDependency": true // TODO: Fix this
}
],
"react/prop-types": "off", "react/prop-types": "off",
"react/jsx-one-expression-per-line": "off", "react/jsx-one-expression-per-line": "off",
"react/button-has-type": "off", "react/button-has-type": "off",

22
babel.config.js Normal file
View File

@ -0,0 +1,22 @@
const isTest = process.env.APP_ENV === 'test';
module.exports = {
presets: [
[
'@babel/typescript',
],
[
'@babel/preset-env',
],
[
'@babel/preset-react',
],
],
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-syntax-nullish-coalescing-operator',
'@babel/plugin-proposal-logical-assignment-operators',
...(isTest ? ['babel-plugin-transform-import-meta'] : []),
],
};

View File

@ -1,7 +1,7 @@
module.exports = { module.exports = {
setupFilesAfterEnv: ['./tests/init.js'], setupFilesAfterEnv: ['./tests/init.js'],
moduleNameMapper: { moduleNameMapper: {
'\\.(css|scss|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|tgs)$': '\\.(css|scss|wasm|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|tgs)$':
'<rootDir>/tests/staticFileMock.js', '<rootDir>/tests/staticFileMock.js',
}, },
testPathIgnorePatterns: [ testPathIgnorePatterns: [

3144
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
"dev": "cross-env APP_ENV=development APP_VERSION=$(npm run version:print --silent) webpack serve --mode development", "dev": "cross-env APP_ENV=development APP_VERSION=$(npm run version:print --silent) webpack serve --mode development",
"dev:mocked": "cross-env APP_ENV=test APP_MOCKED_CLIENT=1 webpack serve --mode development --port 1235", "dev:mocked": "cross-env APP_ENV=test APP_MOCKED_CLIENT=1 webpack serve --mode development --port 1235",
"build:mocked": "cross-env APP_ENV=test APP_MOCKED_CLIENT=1 webpack --mode development", "build:mocked": "cross-env APP_ENV=test APP_MOCKED_CLIENT=1 webpack --mode development",
"build:staging": "APP_ENV=staging APP_VERSION=$(npm run version:inc --silent) webpack --mode development && ./deploy/copy_to_dist.sh", "build:staging": "cross-env APP_ENV=staging APP_VERSION=$(npm run version:inc --silent) webpack --mode development && ./deploy/copy_to_dist.sh",
"build:production": "npm i && APP_VERSION=$(npm run version:inc --silent) webpack && ./deploy/copy_to_dist.sh", "build:production": "npm i && APP_VERSION=$(npm run version:inc --silent) webpack && ./deploy/copy_to_dist.sh",
"deploy:production": "npm run build:production && git add -A && git commit -a -m '[Build]' --no-verify && git push", "deploy:production": "npm run build:production && git add -A && git commit -a -m '[Build]' --no-verify && git push",
"postversion": "npm run version:update", "postversion": "npm run version:update",
@ -24,7 +24,6 @@
"test:playwright": "playwright test", "test:playwright": "playwright test",
"test:record": "playwright codegen localhost:1235", "test:record": "playwright codegen localhost:1235",
"prepare": "husky install", "prepare": "husky install",
"statoscope:validate": "statoscope validate --input public/build-stats.json",
"statoscope:validate-diff": "statoscope validate --input input.json --reference reference.json", "statoscope:validate-diff": "statoscope validate --input input.json --reference reference.json",
"postinstall": "(cd dev/eslint-multitab && npm i)" "postinstall": "(cd dev/eslint-multitab && npm i)"
}, },
@ -44,76 +43,77 @@
"author": "Alexander Zinchuk (alexander@zinchuk.com)", "author": "Alexander Zinchuk (alexander@zinchuk.com)",
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
"devDependencies": { "devDependencies": {
"@babel/core": "^7.20.5", "@babel/core": "^7.21.3",
"@babel/plugin-proposal-class-properties": "^7.18.6", "@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-logical-assignment-operators": "^7.18.9", "@babel/plugin-proposal-logical-assignment-operators": "^7.20.7",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3",
"@babel/preset-env": "^7.20.2", "@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6", "@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6", "@babel/preset-typescript": "^7.21.0",
"@glen/jest-raw-loader": "^2.0.0", "@glen/jest-raw-loader": "^2.0.0",
"@playwright/test": "^1.28.1", "@playwright/test": "^1.31.2",
"@statoscope/cli": "^5.24.0", "@statoscope/cli": "^5.26.1",
"@statoscope/webpack-plugin": "^5.20.1", "@statoscope/webpack-plugin": "^5.25.1",
"@testing-library/jest-dom": "^5.16.5", "@testing-library/jest-dom": "^5.16.5",
"@types/croppie": "^2.6.1", "@types/croppie": "^2.6.1",
"@types/hast": "^2.3.4", "@types/hast": "^2.3.4",
"@types/jest": "^29.2.3", "@types/jest": "^29.5.0",
"@types/react": "^18.0.25", "@types/react": "^18.0.28",
"@types/react-dom": "^18.0.9", "@types/react-dom": "^18.0.11",
"@typescript-eslint/eslint-plugin": "^5.45.0", "@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.45.0", "@typescript-eslint/parser": "^5.55.0",
"@webpack-cli/serve": "^2.0.0", "@webpack-cli/serve": "^2.0.1",
"autoprefixer": "^10.4.13", "autoprefixer": "^10.4.14",
"babel-loader": "^9.1.0", "babel-loader": "^9.1.2",
"babel-plugin-transform-import-meta": "^2.2.0",
"browserlist": "^1.0.1", "browserlist": "^1.0.1",
"buffer": "^6.0.3", "buffer": "^6.0.3",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"css-loader": "^6.7.2", "css-loader": "^6.7.3",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
"eslint": "^8.28.0", "eslint": "^8.36.0",
"eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0", "eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-react-app": "^7.0.1", "eslint-config-react-app": "^7.0.1",
"eslint-import-resolver-webpack": "^0.13.2", "eslint-import-resolver-webpack": "^0.13.2",
"eslint-plugin-eslint-multitab-tt": "file:dev/eslint-multitab", "eslint-plugin-eslint-multitab-tt": "file:dev/eslint-multitab",
"eslint-plugin-flowtype": "^8.0.3", "eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.26.0", "eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.6.1", "eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-jsx-expressions": "^1.3.1", "eslint-plugin-jsx-expressions": "^1.3.1",
"eslint-plugin-no-async-without-await": "^1.2.0", "eslint-plugin-no-async-without-await": "^1.2.0",
"eslint-plugin-no-null": "^1.0.2", "eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-react": "^7.31.11", "eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-hooks-static-deps": "^1.0.7", "eslint-plugin-react-hooks-static-deps": "^1.0.7",
"eslint-plugin-teactn": "git+https://github.com/korenskoy/eslint-plugin-teactn#c2c39dd005d58c07c24c4361de804dce1c6261b5", "eslint-plugin-teactn": "git+https://github.com/korenskoy/eslint-plugin-teactn#c2c39dd005d58c07c24c4361de804dce1c6261b5",
"git-revision-webpack-plugin": "^5.0.0", "git-revision-webpack-plugin": "^5.0.0",
"gitlog": "^4.0.4", "gitlog": "^4.0.4",
"html-webpack-plugin": "^5.5.0", "html-webpack-plugin": "^5.5.0",
"husky": "^8.0.2", "husky": "^8.0.3",
"jest": "^29.3.1", "jest": "^29.5.0",
"jest-environment-jsdom": "^29.3.1", "jest-environment-jsdom": "^29.5.0",
"lint-staged": "^13.0.4", "lint-staged": "^13.2.0",
"mini-css-extract-plugin": "^2.7.1", "mini-css-extract-plugin": "^2.7.5",
"postcss-loader": "^7.0.1", "postcss-loader": "^7.1.0",
"postcss-modules": "^6.0.0", "postcss-modules": "^6.0.0",
"react": "^18.2.0", "react": "^18.2.0",
"sass": "^1.56.1", "sass": "^1.59.3",
"sass-loader": "^13.2.0", "sass-loader": "^13.2.1",
"script-loader": "^0.7.2", "script-loader": "^0.7.2",
"serve": "^14.1.2", "serve": "^14.2.0",
"style-loader": "^3.3.1", "style-loader": "^3.3.2",
"stylelint": "^14.15.0", "stylelint": "^14.16.1",
"stylelint-config-recommended-scss": "^8.0.0", "stylelint-config-recommended-scss": "^8.0.0",
"stylelint-declaration-block-no-ignored-properties": "^2.6.0", "stylelint-declaration-block-no-ignored-properties": "^2.7.0",
"stylelint-group-selectors": "^1.0.9", "stylelint-group-selectors": "^1.0.9",
"stylelint-high-performance-animation": "^1.6.0", "stylelint-high-performance-animation": "^1.8.0",
"stylelint-selector-tag-no-without-class": "^2.0.5", "stylelint-selector-tag-no-without-class": "^2.0.5",
"telegraph-node": "^1.0.4", "telegraph-node": "^1.0.4",
"typescript": "^4.9.3", "typescript": "^5.0.2",
"webpack": "^5.75.0", "webpack": "^5.76.2",
"webpack-dev-server": "^4.11.1", "webpack-dev-server": "^4.13.1",
"whatwg-fetch": "^3.6.2" "whatwg-fetch": "^3.6.2"
}, },
"dependencies": { "dependencies": {
@ -123,7 +123,7 @@
"croppie": "^2.6.5", "croppie": "^2.6.5",
"emoji-data-ios": "git+https://github.com/korenskoy/emoji-data-ios#3c401da02c6792cea0b6c758795da406377bf667", "emoji-data-ios": "git+https://github.com/korenskoy/emoji-data-ios#3c401da02c6792cea0b6c758795da406377bf667",
"idb-keyval": "^6.2.0", "idb-keyval": "^6.2.0",
"lowlight": "^2.8.0", "lowlight": "^2.8.1",
"opus-recorder": "github:Ajaxy/opus-recorder", "opus-recorder": "github:Ajaxy/opus-recorder",
"os-browserify": "^0.3.0", "os-browserify": "^0.3.0",
"pako": "^2.1.0", "pako": "^2.1.0",

View File

@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-cycle
export { default as MediaViewer } from '../components/mediaViewer/MediaViewer'; export { default as MediaViewer } from '../components/mediaViewer/MediaViewer';
export { default as ForwardRecipientPicker } from '../components/main/ForwardRecipientPicker'; export { default as ForwardRecipientPicker } from '../components/main/ForwardRecipientPicker';
@ -30,29 +29,23 @@ export { default as ReactorListModal } from '../components/middle/ReactorListMod
export { default as EmojiInteractionAnimation } from '../components/middle/EmojiInteractionAnimation'; export { default as EmojiInteractionAnimation } from '../components/middle/EmojiInteractionAnimation';
export { default as MessageLanguageModal } from '../components/middle/MessageLanguageModal'; export { default as MessageLanguageModal } from '../components/middle/MessageLanguageModal';
// eslint-disable-next-line import/no-cycle
export { default as LeftSearch } from '../components/left/search/LeftSearch'; export { default as LeftSearch } from '../components/left/search/LeftSearch';
// eslint-disable-next-line import/no-cycle
export { default as Settings } from '../components/left/settings/Settings'; export { default as Settings } from '../components/left/settings/Settings';
export { default as ContactList } from '../components/left/main/ContactList'; export { default as ContactList } from '../components/left/main/ContactList';
export { default as NewChat } from '../components/left/newChat/NewChat'; export { default as NewChat } from '../components/left/newChat/NewChat';
export { default as NewChatStep1 } from '../components/left/newChat/NewChatStep1'; export { default as NewChatStep1 } from '../components/left/newChat/NewChatStep1';
export { default as NewChatStep2 } from '../components/left/newChat/NewChatStep2'; export { default as NewChatStep2 } from '../components/left/newChat/NewChatStep2';
// eslint-disable-next-line import/no-cycle
export { default as ArchivedChats } from '../components/left/ArchivedChats'; export { default as ArchivedChats } from '../components/left/ArchivedChats';
export { default as ChatFolderModal } from '../components/left/ChatFolderModal'; export { default as ChatFolderModal } from '../components/left/ChatFolderModal';
// eslint-disable-next-line import/no-cycle
export { default as ContextMenuContainer } from '../components/middle/message/ContextMenuContainer'; export { default as ContextMenuContainer } from '../components/middle/message/ContextMenuContainer';
export { default as SponsoredMessageContextMenuContainer } export { default as SponsoredMessageContextMenuContainer }
from '../components/middle/message/SponsoredMessageContextMenuContainer'; from '../components/middle/message/SponsoredMessageContextMenuContainer';
// eslint-disable-next-line import/no-cycle
export { default as StickerSetModal } from '../components/common/StickerSetModal'; export { default as StickerSetModal } from '../components/common/StickerSetModal';
export { default as CustomEmojiSetsModal } from '../components/common/CustomEmojiSetsModal'; export { default as CustomEmojiSetsModal } from '../components/common/CustomEmojiSetsModal';
export { default as HeaderMenuContainer } from '../components/middle/HeaderMenuContainer'; export { default as HeaderMenuContainer } from '../components/middle/HeaderMenuContainer';
export { default as MobileSearch } from '../components/middle/MobileSearch'; export { default as MobileSearch } from '../components/middle/MobileSearch';
// eslint-disable-next-line import/no-cycle
export { default as AttachmentModal } from '../components/middle/composer/AttachmentModal'; export { default as AttachmentModal } from '../components/middle/composer/AttachmentModal';
export { default as PollModal } from '../components/middle/composer/PollModal'; export { default as PollModal } from '../components/middle/composer/PollModal';
export { default as SymbolMenu } from '../components/middle/composer/SymbolMenu'; export { default as SymbolMenu } from '../components/middle/composer/SymbolMenu';
@ -68,13 +61,9 @@ export { default as EmojiTooltip } from '../components/middle/composer/EmojiTool
export { default as InlineBotTooltip } from '../components/middle/composer/InlineBotTooltip'; export { default as InlineBotTooltip } from '../components/middle/composer/InlineBotTooltip';
export { default as SendAsMenu } from '../components/middle/composer/SendAsMenu'; export { default as SendAsMenu } from '../components/middle/composer/SendAsMenu';
// eslint-disable-next-line import/no-cycle
export { default as RightSearch } from '../components/right/RightSearch'; export { default as RightSearch } from '../components/right/RightSearch';
// eslint-disable-next-line import/no-cycle
export { default as StickerSearch } from '../components/right/StickerSearch'; export { default as StickerSearch } from '../components/right/StickerSearch';
// eslint-disable-next-line import/no-cycle
export { default as GifSearch } from '../components/right/GifSearch'; export { default as GifSearch } from '../components/right/GifSearch';
// eslint-disable-next-line import/no-cycle
export { default as Statistics } from '../components/right/statistics/Statistics'; export { default as Statistics } from '../components/right/statistics/Statistics';
export { default as MessageStatistics } from '../components/right/statistics/MessageStatistics'; export { default as MessageStatistics } from '../components/right/statistics/MessageStatistics';
export { default as PollResults } from '../components/right/PollResults'; export { default as PollResults } from '../components/right/PollResults';

View File

@ -3,7 +3,6 @@ import { getActions, getGlobal } from '../global';
import { IS_MULTITAB_SUPPORTED } from '../util/windowEnvironment'; import { IS_MULTITAB_SUPPORTED } from '../util/windowEnvironment';
import { DEBUG } from '../config'; import { DEBUG } from '../config';
// eslint-disable-next-line import/no-cycle
export { default as Main } from '../components/main/Main'; export { default as Main } from '../components/main/Main';
export { default as LockScreen } from '../components/main/LockScreen'; export { default as LockScreen } from '../components/main/LockScreen';

View File

@ -43,8 +43,7 @@ const StatusButton: FC<StateProps> = ({ emojiStatus }) => {
showEffect(); showEffect();
unmarkShouldShowEffect(); unmarkShouldShowEffect();
} }
// eslint-disable-next-line react-hooks-static-deps/exhaustive-deps }, [emojiStatus, shouldShowEffect, showEffect, unmarkShouldShowEffect]);
}, [emojiStatus, shouldShowEffect, showEffect, unmarkShouldShowEffect] as const);
const handleEmojiStatusSet = useCallback((sticker: ApiSticker) => { const handleEmojiStatusSet = useCallback((sticker: ApiSticker) => {
markShouldShowEffect(); markShouldShowEffect();

View File

@ -8,7 +8,7 @@ export enum ChatAnimationTypes {
export function useChatAnimationType<T extends number | string>(orderDiffById: Record<T, number>) { export function useChatAnimationType<T extends number | string>(orderDiffById: Record<T, number>) {
return useMemo(() => { return useMemo(() => {
const orderDiffs = Object.values(orderDiffById) as T[]; const orderDiffs = Object.values(orderDiffById) as number[];
const numberOfUp = orderDiffs.filter((diff) => diff < 0).length; const numberOfUp = orderDiffs.filter((diff) => diff < 0).length;
const numberOfDown = orderDiffs.filter((diff) => diff > 0).length; const numberOfDown = orderDiffs.filter((diff) => diff > 0).length;

View File

@ -373,7 +373,7 @@ const Main: FC<OwnProps & StateProps> = ({
willAnimateLeftColumnRef.current = false; willAnimateLeftColumnRef.current = false;
forceUpdate(); forceUpdate();
}); });
}, [animationLevel, forceUpdate, isLeftColumnOpen]); }, [isLeftColumnOpen, animationLevel, forceUpdate]);
const rightColumnTransition = useShowTransition( const rightColumnTransition = useShowTransition(
isRightColumnOpen, undefined, true, undefined, shouldSkipHistoryAnimations, undefined, true, isRightColumnOpen, undefined, true, undefined, shouldSkipHistoryAnimations, undefined, true,
@ -402,7 +402,7 @@ const Main: FC<OwnProps & StateProps> = ({
forceUpdate(); forceUpdate();
setIsNarrowMessageList(isRightColumnOpen); setIsNarrowMessageList(isRightColumnOpen);
}); });
}, [animationLevel, forceUpdate, isRightColumnOpen]); }, [isRightColumnOpen, animationLevel, forceUpdate]);
const className = buildClassName( const className = buildClassName(
leftColumnTransition.hasShownClass && 'left-column-shown', leftColumnTransition.hasShownClass && 'left-column-shown',

View File

@ -506,8 +506,7 @@ const MessageList: FC<OwnProps & StateProps> = ({
console.timeEnd('scrollTop'); console.timeEnd('scrollTop');
} }
// This should match deps for `useSyncEffect` above // This should match deps for `useSyncEffect` above
// eslint-disable-next-line react-hooks-static-deps/exhaustive-deps -- `as const` not yet supported by linter }, [messageIds, isViewportNewest, containerHeight, hasTools]);
}, [messageIds, isViewportNewest, containerHeight, hasTools] as const);
useEffectWithPrevDeps(([prevIsSelectModeActive]) => { useEffectWithPrevDeps(([prevIsSelectModeActive]) => {
if (prevIsSelectModeActive !== undefined) { if (prevIsSelectModeActive !== undefined) {

View File

@ -98,10 +98,7 @@ const useDraft = (
} }
}); });
} }
// eslint-disable-next-line react-hooks-static-deps/exhaustive-deps }, [chatId, threadId, draft, setHtml, editedMessage, loadCustomEmojis]);
}, [
chatId, threadId, draft, setHtml, editedMessage, loadCustomEmojis,
] as const);
// Save draft on chat change // Save draft on chat change
useEffect(() => { useEffect(() => {

View File

@ -64,8 +64,7 @@ const useEditing = (
focusEditableElement(messageInput, true); focusEditableElement(messageInput, true);
} }
}); });
// eslint-disable-next-line react-hooks-static-deps/exhaustive-deps -- `as const` not yet supported by linter }, [editedMessage, replyingToId, editingDraft, setHtml]);
}, [editedMessage, replyingToId, setHtml] as const);
useEffect(() => { useEffect(() => {
if (!editedMessage) { if (!editedMessage) {

View File

@ -45,8 +45,7 @@ export default function useInlineBotTooltip(
if (prevUsername) { if (prevUsername) {
resetInlineBot({ username: prevUsername }); resetInlineBot({ username: prevUsername });
} }
// eslint-disable-next-line react-hooks-static-deps/exhaustive-deps }, [username, resetInlineBot]);
}, [username, resetInlineBot] as const);
useEffect(() => { useEffect(() => {
if (!usernameLowered) return; if (!usernameLowered) return;

View File

@ -182,7 +182,7 @@ addActionHandler('reset', (global, actions): ActionReturnType => {
void cacheApi.clear(CUSTOM_BG_CACHE_NAME); void cacheApi.clear(CUSTOM_BG_CACHE_NAME);
const langCachePrefix = LANG_CACHE_NAME.replace(/\d+$/, ''); const langCachePrefix = LANG_CACHE_NAME.replace(/\d+$/, '');
const langCacheVersion = (LANG_CACHE_NAME.match(/\d+$/) || [0])[0]; const langCacheVersion = Number((LANG_CACHE_NAME.match(/\d+$/) || ['0'])[0]);
for (let i = 0; i < langCacheVersion; i++) { for (let i = 0; i < langCacheVersion; i++) {
void cacheApi.clear(`${langCachePrefix}${i === 0 ? '' : i}`); void cacheApi.clear(`${langCachePrefix}${i === 0 ? '' : i}`);
} }

View File

@ -370,7 +370,7 @@ addActionHandler('requestMasterAndRequestCall', (global, actions, payload): Acti
}); });
}); });
addActionHandler('requestCall', async (global, actions, payload): Promise<void> => { addActionHandler('requestCall', (global, actions, payload): ActionReturnType => {
const { userId, isVideo, tabId = getCurrentTabId() } = payload; const { userId, isVideo, tabId = getCurrentTabId() } = payload;
if (global.phoneCall) { if (global.phoneCall) {

View File

@ -1,7 +1,7 @@
import { useEffect } from '../lib/teact/teact'; import { useEffect } from '../lib/teact/teact';
import usePrevious from './usePrevious'; import usePrevious from './usePrevious';
const useEffectWithPrevDeps = <T extends readonly any[]>( const useEffectWithPrevDeps = <const T extends readonly any[]>(
cb: (args: T | readonly []) => void, dependencies: T, debugKey?: string, cb: (args: T | readonly []) => void, dependencies: T, debugKey?: string,
) => { ) => {
const prevDeps = usePrevious<T>(dependencies); const prevDeps = usePrevious<T>(dependencies);

View File

@ -1,7 +1,7 @@
import { useLayoutEffect } from '../lib/teact/teact'; import { useLayoutEffect } from '../lib/teact/teact';
import usePrevious from './usePrevious'; import usePrevious from './usePrevious';
const useLayoutEffectWithPrevDeps = <T extends readonly any[]>( const useLayoutEffectWithPrevDeps = <const T extends readonly any[]>(
cb: (args: T | readonly []) => void, dependencies: T, debugKey?: string, cb: (args: T | readonly []) => void, dependencies: T, debugKey?: string,
) => { ) => {
const prevDeps = usePrevious<T>(dependencies); const prevDeps = usePrevious<T>(dependencies);

View File

@ -1,6 +1,6 @@
import usePrevious from './usePrevious'; import usePrevious from './usePrevious';
const useSyncEffect = <T extends readonly any[]>(cb: (args: T | readonly []) => void, dependencies: T) => { const useSyncEffect = <const T extends readonly any[]>(cb: (args: T | readonly []) => void, dependencies: T) => {
const prevDeps = usePrevious<T>(dependencies); const prevDeps = usePrevious<T>(dependencies);
if (!prevDeps || dependencies.some((d, i) => d !== prevDeps[i])) { if (!prevDeps || dependencies.some((d, i) => d !== prevDeps[i])) {
cb(prevDeps || []); cb(prevDeps || []);

View File

@ -28,7 +28,7 @@ const PLURAL_RULES = {
en: (n: number) => (n !== 1 ? 6 : 2), en: (n: number) => (n !== 1 ? 6 : 2),
ar: (n: number) => (n === 0 ? 1 : n === 1 ? 2 : n === 2 ? 3 : n % 100 >= 3 && n % 100 <= 10 ? 4 : n % 100 >= 11 ? 5 : 6), ar: (n: number) => (n === 0 ? 1 : n === 1 ? 2 : n === 2 ? 3 : n % 100 >= 3 && n % 100 <= 10 ? 4 : n % 100 >= 11 ? 5 : 6),
be: (n: number) => { be: (n: number) => {
const s = String(n).split('.'); const t0 = Number(s[0]) === n; const n10 = t0 && Number(s[0].slice(-1)); const n100 = t0 && Number(s[0].slice(-2)); const s = String(n).split('.'); const t0 = Number(s[0]) === n; const n10 = t0 ? Number(s[0].slice(-1)) : 0; const n100 = t0 ? Number(s[0].slice(-2)) : 0;
return n10 === 1 && n100 !== 11 ? 2 return n10 === 1 && n100 !== 11 ? 2
: (n10 >= 2 && n10 <= 4) && (n100 < 12 || n100 > 14) ? 4 : (n10 >= 2 && n10 <= 4) && (n100 < 12 || n100 > 14) ? 4
: (t0 && n10 === 0) || (n10 >= 5 && n10 <= 9) || (n100 >= 11 && n100 <= 14) ? 5 : (t0 && n10 === 0) || (n10 >= 5 && n10 <= 9) || (n100 >= 11 && n100 <= 14) ? 5

View File

@ -27,5 +27,6 @@
"plugins", "plugins",
"dev", "dev",
"webpack.config.js", "webpack.config.js",
"babel.config.js",
] ]
} }

View File

@ -1,4 +1,5 @@
const path = require('path'); const path = require('path');
const fs = require('fs');
const dotenv = require('dotenv'); const dotenv = require('dotenv');
const { const {
@ -23,6 +24,7 @@ const {
dotenv.config(); dotenv.config();
const STATOSCOPE_REFERENCE_URL = 'https://webz.dev/build-stats.json';
const DEFAULT_APP_TITLE = `Telegram${APP_ENV !== 'production' ? ' Beta' : ''}`; const DEFAULT_APP_TITLE = `Telegram${APP_ENV !== 'production' ? ' Beta' : ''}`;
const { const {
@ -139,6 +141,14 @@ module.exports = (_env, { mode = 'production' }) => {
}, },
plugins: [ plugins: [
{
apply: (compiler) => {
compiler.hooks.compile.tap('Before Compilation', async () => {
const stats = await fetch(STATOSCOPE_REFERENCE_URL).then((res) => res.text());
fs.writeFileSync(path.resolve('./public/reference.json'), stats);
});
},
},
// Clearing of the unused files for code highlight for smaller chunk count // Clearing of the unused files for code highlight for smaller chunk count
new ContextReplacementPlugin( new ContextReplacementPlugin(
/highlight\.js[\\/]lib[\\/]languages/, /highlight\.js[\\/]lib[\\/]languages/,
@ -190,6 +200,7 @@ module.exports = (_env, { mode = 'production' }) => {
}, },
saveReportTo: path.resolve('./public/statoscope-report.html'), saveReportTo: path.resolve('./public/statoscope-report.html'),
saveStatsTo: path.resolve('./public/build-stats.json'), saveStatsTo: path.resolve('./public/build-stats.json'),
additionalStats: ['./public/reference.json'],
normalizeStats: true, normalizeStats: true,
open: 'file', open: 'file',
extensions: [new WebpackContextExtension()], extensions: [new WebpackContextExtension()],