[Refactoring] Update dependencies (#1365)

This commit is contained in:
Alexander Zinchuk 2021-08-16 14:21:20 +03:00
parent 62bcbbd5cc
commit 94526b2362
12 changed files with 7934 additions and 8408 deletions

View File

@ -11,8 +11,8 @@
]
],
"plugins": [
[
"@babel/plugin-proposal-class-properties"
]
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-syntax-nullish-coalescing-operator"
]
}

View File

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

16066
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,12 +10,12 @@
"build:production": "npm i && rm -rf dist/ && APP_VERSION=$(npm run inc_version --silent) APP_ENV=production npm run build && ./deploy/copy_to_dist.sh",
"deploy:production": "npm run build:production && git add -A && git commit -a -m '[Build]' --no-verify && git push",
"inc_version": "echo $((`cat .patch-version` + 1)) > .patch-version && echo \"$(node -p -e \"require('./package.json').version.match(/^\\d+\\.\\d+/)[0]\").$(cat .patch-version)\"",
"perf:serve": "APP_ENV=perf parcel src/index-perf.html",
"perf:serve": "cross-env APP_ENV=perf parcel src/index-perf.html",
"lint": "eslint . --ext .ts,.tsx --ignore-pattern src/lib/gramjs",
"lint:fix": "npm run lint -- --fix",
"gramjs:tl": "node ./src/lib/gramjs/tl/generateModules.js",
"gramjs:lint:fix": "eslint ./src/lib/gramjs --ignore-path=src/lib/gramjs/.eslintignore --fix",
"test": "APP_ENV=test jest --verbose --forceExit"
"test": "cross-env APP_ENV=test jest --verbose --forceExit"
},
"engines": {
"node": "^12.13",
@ -32,83 +32,86 @@
"author": "Alexander Zinchuk (alexander@zinchuk.com)",
"license": "GPL-3.0-or-later",
"devDependencies": {
"@babel/core": "^7.10.2",
"@babel/plugin-proposal-class-properties": "^7.7.0",
"@babel/preset-env": "^7.10.2",
"@babel/preset-react": "^7.10.1",
"@babel/preset-typescript": "^7.10.1",
"@peculiar/webcrypto": "^1.1.4",
"@testing-library/jest-dom": "^5.11.6",
"@types/croppie": "^2.5.4",
"@types/css-font-loading-module": "0.0.2",
"@types/dom-mediacapture-record": "^1.0.3",
"@types/jest": "^26.0.15",
"@types/react": "^16.9.35",
"@types/react-dom": "^16.9.8",
"@types/resize-observer-browser": "^0.1.3",
"@typescript-eslint/eslint-plugin": "^2.6.1",
"@typescript-eslint/parser": "^2.6.1",
"@babel/core": "^7.15.0",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3",
"@babel/preset-env": "^7.15.0",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.15.0",
"@peculiar/webcrypto": "^1.1.7",
"@testing-library/jest-dom": "^5.14.1",
"@types/croppie": "^2.6.1",
"@types/css-font-loading-module": "0.0.6",
"@types/dom-mediacapture-record": "^1.0.10",
"@types/jest": "^27.0.0",
"@types/react": "^17.0.17",
"@types/react-dom": "^17.0.9",
"@types/resize-observer-browser": "^0.1.6",
"@typescript-eslint/eslint-plugin": "^4.29.1",
"@typescript-eslint/parser": "^4.29.1",
"@webpack-cli/serve": "^1.5.1",
"autoprefixer": "^9.8.0",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.1.0",
"autoprefixer": "^10.3.1",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.2",
"browserlist": "^1.0.1",
"buffer": "^6.0.3",
"cross-env": "^7.0.2",
"css-loader": "^3.5.3",
"dotenv": "^8.2.0",
"eslint": "^7.2.0",
"eslint-config-airbnb-typescript": "^6.0.0",
"eslint-config-react-app": "^5.0.2",
"eslint-import-resolver-webpack": "^0.12.1",
"eslint-plugin-flowtype": "^3.13.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"cross-env": "^7.0.3",
"css-loader": "^6.2.0",
"css-minimizer-webpack-plugin": "^3.0.2",
"dotenv": "^10.0.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-config-react-app": "^6.0.0",
"eslint-import-resolver-webpack": "^0.13.1",
"eslint-plugin-flowtype": "^5.9.0",
"eslint-plugin-import": "^2.24.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-no-async-without-await": "^1.2.0",
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^1.7.0",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-teactn": "github:korenskoy/eslint-plugin-teactn#8fbd2b9",
"file-loader": "^6.0.0",
"html-webpack-plugin": "^4.3.0",
"husky": "^3.0.9",
"jest": "^26.6.3",
"lint-staged": "^9.4.2",
"mini-css-extract-plugin": "^0.9.0",
"node-sass": "^4.14.1",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"postcss-loader": "^3.0.0",
"postcss-modules": "^1.5.0",
"raw-loader": "^4.0.1",
"react": "^16.12.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.3.2",
"husky": "^7.0.1",
"jest": "^27.0.6",
"lint-staged": "^11.1.2",
"mini-css-extract-plugin": "^2.2.0",
"node-sass": "^6.0.1",
"optimize-css-assets-webpack-plugin": "^6.0.1",
"postcss-loader": "^6.1.1",
"postcss-modules": "^4.2.2",
"raw-loader": "^4.0.2",
"react": "^17.0.2",
"replace-in-file": "^6.2.0",
"sass": "^1.23.3",
"sass-loader": "^8.0.2",
"service-worker-loader": "^4.0.2",
"style-loader": "^1.2.1",
"terser": "^4.7.0",
"terser-webpack-plugin": "^3.0.3",
"ts-node": "^8.9.1",
"typescript": "^3.9.5",
"url-loader": "^4.1.0",
"webpack": "^4.43.0",
"webpack-bundle-analyzer": "^3.8.0",
"sass": "^1.37.5",
"sass-loader": "^12.1.0",
"style-loader": "^3.2.1",
"terser": "^5.7.1",
"terser-webpack-plugin": "^5.1.4",
"ts-node": "^10.2.0",
"typescript": "^4.3.5",
"url-loader": "^4.1.1",
"webpack": "^5.50.0",
"webpack-bundle-analyzer": "^4.4.2",
"webpack-cli": "^4.7.2",
"webpack-dev-server": "^3.11.2",
"webpack-merge": "^4.2.2",
"worker-loader": "^2.0.0"
"webpack-merge": "^5.8.0"
},
"dependencies": {
"@cryptography/aes": "^0.1.1",
"async-mutex": "^0.1.4",
"big-integer": "painor/BigInteger.js",
"croppie": "^2.6.4",
"async-mutex": "^0.3.1",
"big-integer": "github:painor/BigInteger.js",
"croppie": "^2.6.5",
"emoji-data-ios": "github:korenskoy/emoji-data-ios#1a4532f",
"events": "^3.0.0",
"idb-keyval": "^5.0.5",
"events": "^3.3.0",
"idb-keyval": "^5.1.3",
"opus-recorder": "github:Ajaxy/opus-recorder",
"pako": "^1.0.10",
"os-browserify": "^0.3.0",
"pako": "^2.0.4",
"path-browserify": "^1.0.1",
"qr-creator": "^1.0.0",
"websocket": "^1.0.30"
"websocket": "^1.0.34"
}
}

View File

@ -56,25 +56,6 @@ declare module 'pako/dist/pako_inflate' {
type WindowWithPerf = typeof window & { perf: AnyLiteral };
declare module 'worker-loader!*' {
class WebpackWorker extends Worker {
constructor();
}
export default WebpackWorker;
}
declare module 'service-worker-loader!*' {
const register: import('service-worker-loader/types').ServiceWorkerRegister;
const ServiceWorkerNoSupportError: import('service-worker-loader/types').ServiceWorkerNoSupportError;
const scriptUrl: import('service-worker-loader/types').ScriptUrl;
export default register;
export {
ServiceWorkerNoSupportError,
scriptUrl,
};
}
interface IWebpWorker extends Worker {
wasmReady?: boolean;
requests: Map<string, (value?: PromiseLike<TEncodedImage>) => void>;

View File

@ -1,5 +1,3 @@
import Worker from 'worker-loader!./worker';
import { ApiInitialArgs, ApiOnProgress, OnApiUpdate } from '../../types';
import { Methods, MethodArgs, MethodResponse } from '../methods/types';
import { WorkerMessageEvent, ThenArg, OriginRequest } from './types';
@ -27,7 +25,7 @@ export function initApi(onUpdate: OnApiUpdate, initialArgs: ApiInitialArgs) {
console.log('>>> START LOAD WORKER');
}
worker = new Worker();
worker = new Worker(new URL('./worker.ts', import.meta.url));
subscribeToWorker(onUpdate);
}

View File

@ -51,7 +51,7 @@
opacity: 0;
pointer-events: none;
&-inner {
.shown-inner {
transform: scaleX(var(--toolbar-hidden-scale, 1));
}

View File

@ -1,5 +1,3 @@
import Worker from 'worker-loader!./rlottie.worker';
import {
DPR,
IS_SINGLE_COLUMN_LAYOUT,
@ -29,7 +27,7 @@ const LOW_PRIORITY_MAX_FPS = 30;
const HIGH_PRIORITY_CACHE_MODULO = IS_SAFARI ? 2 : 4;
const LOW_PRIORITY_CACHE_MODULO = 0;
const workers = new Array(MAX_WORKERS).fill(undefined).map(() => new WorkerConnector(new Worker()));
const workers = new Array(MAX_WORKERS).fill(undefined).map(() => new WorkerConnector(new Worker(new URL('./rlottie.worker.ts', import.meta.url))));
let lastWorkerIndex = -1;
class RLottie {

View File

@ -1,6 +1,3 @@
import DecoderWorker from 'worker-loader!opus-recorder/dist/decoderWorker.min';
import WavWorker from 'worker-loader!opus-recorder/dist/waveWorker.min';
const SAMPLE_RATE = 48000;
const BIT_DEPTH = 16;
@ -10,8 +7,8 @@ export async function oggToWav(opusData: Blob): Promise<Blob> {
return new Promise((resolve) => {
const typedArray = new Uint8Array(arrayBuffer);
let decoderWorker: DecoderWorker | undefined = new DecoderWorker();
let wavWorker: WavWorker | undefined = new WavWorker();
let decoderWorker: Worker | undefined = new Worker(new URL('opus-recorder/dist/decoderWorker.min.js', import.meta.url));
let wavWorker: Worker | undefined = new Worker(new URL('opus-recorder/dist/waveWorker.min.js', import.meta.url));
decoderWorker.onmessage = (e) => {
// eslint-disable-next-line no-null/no-null

View File

@ -1,5 +1,3 @@
import { scriptUrl } from 'service-worker-loader!../serviceWorker';
import { DEBUG } from '../config';
import { getDispatch } from '../lib/teact/teactn';
import { IS_ANDROID, IS_IOS, IS_SERVICE_WORKER_SUPPORTED } from './environment';
@ -36,7 +34,7 @@ function subscribeToWorker() {
if (IS_SERVICE_WORKER_SUPPORTED) {
window.addEventListener('load', async () => {
try {
await navigator.serviceWorker.register(scriptUrl);
await navigator.serviceWorker.register(new URL('../serviceWorker.ts', import.meta.url));
if (DEBUG) {
// eslint-disable-next-line no-console

View File

@ -1,4 +1,3 @@
import WebpWorker from 'worker-loader!../lib/webp/webp_wasm.worker';
import { isWebpSupported } from './environment';
import { dataUriToBlob, blobToDataUri } from './files';
import { pause } from './schedulers';
@ -50,7 +49,7 @@ export async function webpToPngBase64(key: string, url: string): Promise<string>
function initWebpWorker() {
if (!worker) {
worker = new WebpWorker() as IWebpWorker;
worker = new Worker(new URL('../lib/webp/webp_wasm.worker.js', import.meta.url)) as IWebpWorker;
worker.wasmReady = false;
worker.onmessage = handleLibWebpMessage;
}

View File

@ -1,12 +1,12 @@
const path = require('path');
const dotenv = require('dotenv');
const { EnvironmentPlugin } = require('webpack');
const { EnvironmentPlugin, ProvidePlugin } = require('webpack');
const HtmlPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const TerserJSPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
dotenv.config();
@ -14,6 +14,7 @@ module.exports = (env = {}, argv = {}) => {
return {
mode: argv.mode,
entry: './src/index.tsx',
target: 'web',
devServer: {
contentBase: [
path.resolve(__dirname, 'public'),
@ -30,6 +31,7 @@ module.exports = (env = {}, argv = {}) => {
output: {
filename: '[name].[contenthash].js',
chunkFilename: '[id].[chunkhash].js',
assetModuleFilename: '[name].[contenthash].[ext]',
path: path.resolve(__dirname, argv['output-path'] || 'dist'),
},
module: {
@ -63,10 +65,7 @@ module.exports = (env = {}, argv = {}) => {
},
{
test: /\.(woff(2)?|ttf|eot|svg|png|jpg|tgs)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader',
options: {
name: '[name].[contenthash].[ext]',
},
type: 'asset/resource',
},
{
test: /-extra\.json$/,
@ -92,6 +91,12 @@ module.exports = (env = {}, argv = {}) => {
},
resolve: {
extensions: ['.js', '.ts', '.tsx'],
fallback: {
path: require.resolve("path-browserify"),
os: require.resolve("os-browserify/browser"),
buffer: require.resolve("buffer/"),
fs: false,
}
},
plugins: [
new HtmlPlugin({
@ -110,6 +115,9 @@ module.exports = (env = {}, argv = {}) => {
TELEGRAM_T_API_HASH: '',
TEST_SESSION: '',
}),
new ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
...(argv.mode === 'production' ? [
new BundleAnalyzerPlugin({
analyzerMode: 'static',
@ -117,9 +125,6 @@ module.exports = (env = {}, argv = {}) => {
}),
] : []),
],
node: {
fs: 'empty',
},
...(!env.noSourceMap && {
devtool: 'source-map',
@ -130,7 +135,7 @@ module.exports = (env = {}, argv = {}) => {
minimize: !env.noMinify,
minimizer: [
new TerserJSPlugin({ sourceMap: true }),
new OptimizeCSSAssetsPlugin({}),
new CssMinimizerPlugin(),
],
},
}),