Browse Source

ifdef triple slash to double slash

master
Eduard Kuzmenko 2 years ago
parent
commit
6d18ef9d15
  1. 2
      src/components/appMediaPlaybackController.ts
  2. 2
      src/components/popups/payment.ts
  3. 12
      src/config/modes.ts
  4. 8
      src/lib/calls/utils.ts
  5. 14
      src/lib/mtproto/apiManager.ts
  6. 16
      src/lib/mtproto/authorizer.ts
  7. 38
      src/lib/mtproto/dcConfigurator.ts
  8. 28
      src/lib/mtproto/mtprotoworker.ts
  9. 122
      src/lib/mtproto/networker.ts
  10. 8
      src/lib/mtproto/transports/http.ts
  11. 4
      src/lib/mtproto/transports/socketProxied.ts
  12. 12
      src/lib/mtproto/transports/tcpObfuscated.ts
  13. 12
      src/lib/serviceWorker/index.service.ts
  14. 94
      webpack.common.js

2
src/components/appMediaPlaybackController.ts

@ -415,7 +415,7 @@ export class AppMediaPlaybackController extends EventListenerBase<{
* Only for audio * Only for audio
*/ */
public isSafariBuffering(media: HTMLMediaElement) { public isSafariBuffering(media: HTMLMediaElement) {
/// @ts-ignore // @ts-ignore
return !!media.safariBuffering; return !!media.safariBuffering;
} }

2
src/components/popups/payment.ts

@ -399,7 +399,7 @@ export default class PopupPayment extends PopupElement {
pricesElements.push(tipsLabel.label); pricesElements.push(tipsLabel.label);
/// //
const tipsEl = document.createElement('div'); const tipsEl = document.createElement('div');
tipsEl.classList.add(tipsClassName); tipsEl.classList.add(tipsClassName);

12
src/config/modes.ts

@ -21,20 +21,20 @@ const Modes = {
transport: 'websocket' as TransportType transport: 'websocket' as TransportType
}; };
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
Modes.http = location.search.indexOf('http=1') > 0; Modes.http = location.search.indexOf('http=1') > 0;
/// #endif // #endif
/// #if MTPROTO_HTTP || !MTPROTO_HAS_WS // #if MTPROTO_HTTP || !MTPROTO_HAS_WS
Modes.http = true; Modes.http = true;
/// #endif // #endif
if(Modes.http) { if(Modes.http) {
Modes.transport = 'https'; Modes.transport = 'https';
} }
/// #if MTPROTO_SW // #if MTPROTO_SW
Modes.asServiceWorker = true; Modes.asServiceWorker = true;
/// #endif // #endif
export default Modes; export default Modes;

8
src/lib/calls/utils.ts

@ -9,14 +9,14 @@
* https://github.com/evgeny-nadymov/telegram-react/blob/master/LICENSE * https://github.com/evgeny-nadymov/telegram-react/blob/master/LICENSE
*/ */
/// NOTE: telegram returns sign source, while webrtc uses unsign source internally // NOTE: telegram returns sign source, while webrtc uses unsign source internally
/// unsign => sign // unsign => sign
export function toTelegramSource(source: number) { export function toTelegramSource(source: number) {
return source << 0; return source << 0;
} }
/// NOTE: telegram returns sign source, while webrtc uses unsign source internally // NOTE: telegram returns sign source, while webrtc uses unsign source internally
/// sign => unsign // sign => unsign
export function fromTelegramSource(source: number) { export function fromTelegramSource(source: number) {
return source >>> 0; return source >>> 0;
} }

14
src/lib/mtproto/apiManager.ts

@ -9,10 +9,10 @@
* https://github.com/zhukov/webogram/blob/master/LICENSE * https://github.com/zhukov/webogram/blob/master/LICENSE
*/ */
/// #if MTPROTO_AUTO // #if MTPROTO_AUTO
import transportController from './transports/controller'; import transportController from './transports/controller';
import MTTransport from './transports/transport'; import MTTransport from './transports/transport';
/// #endif // #endif
import type { UserAuth } from './mtproto_config'; import type { UserAuth } from './mtproto_config';
import sessionStorage from '../sessionStorage'; import sessionStorage from '../sessionStorage';
@ -93,11 +93,11 @@ export class ApiManager extends ApiManagerMethods {
this.transportType = Modes.transport; this.transportType = Modes.transport;
/// #if MTPROTO_AUTO // #if MTPROTO_AUTO
transportController.addEventListener('transport', (transportType) => { transportController.addEventListener('transport', (transportType) => {
this.changeTransportType(transportType); this.changeTransportType(transportType);
}); });
/// #endif // #endif
} }
protected after() { protected after() {
@ -148,14 +148,14 @@ export class ApiManager extends ApiManagerMethods {
} */ } */
private getTransportType(connectionType: ConnectionType) { private getTransportType(connectionType: ConnectionType) {
/// #if MTPROTO_HTTP_UPLOAD // #if MTPROTO_HTTP_UPLOAD
// @ts-ignore // @ts-ignore
const transportType: TransportType = connectionType === 'upload' && getEnvironment().IS_SAFARI ? 'https' : 'websocket'; const transportType: TransportType = connectionType === 'upload' && getEnvironment().IS_SAFARI ? 'https' : 'websocket';
//const transportType: TransportType = connectionType !== 'client' ? 'https' : 'websocket'; //const transportType: TransportType = connectionType !== 'client' ? 'https' : 'websocket';
/// #else // #else
// @ts-ignore // @ts-ignore
const transportType: TransportType = this.transportType; const transportType: TransportType = this.transportType;
/// #endif // #endif
return transportType; return transportType;
} }

16
src/lib/mtproto/authorizer.ts

@ -9,9 +9,9 @@
* https://github.com/zhukov/webogram/blob/master/LICENSE * https://github.com/zhukov/webogram/blob/master/LICENSE
*/ */
/// #if MTPROTO_AUTO // #if MTPROTO_AUTO
import transportController from "./transports/controller"; import transportController from "./transports/controller";
/// #endif // #endif
import { TLSerialization, TLDeserialization } from "./tl_utils"; import { TLSerialization, TLDeserialization } from "./tl_utils";
import { TransportType } from "./dcConfigurator"; import { TransportType } from "./dcConfigurator";
@ -114,9 +114,9 @@ export class Authorizer extends AppManager {
private transportType: TransportType; private transportType: TransportType;
/// #if MTPROTO_AUTO // #if MTPROTO_AUTO
private getTransportTypePromise: Promise<void>; private getTransportTypePromise: Promise<void>;
/// #endif // #endif
protected after() { protected after() {
this.cached = {}; this.cached = {};
@ -584,7 +584,7 @@ export class Authorizer extends AppManager {
} }
} }
/// #if MTPROTO_AUTO // #if MTPROTO_AUTO
private getTransportType() { private getTransportType() {
if(this.getTransportTypePromise) return this.getTransportTypePromise; if(this.getTransportTypePromise) return this.getTransportTypePromise;
return this.getTransportTypePromise = transportController.pingTransports().then(({websocket}) => { return this.getTransportTypePromise = transportController.pingTransports().then(({websocket}) => {
@ -592,7 +592,7 @@ export class Authorizer extends AppManager {
this.log('will use transport:', this.transportType); this.log('will use transport:', this.transportType);
}); });
} }
/// #endif // #endif
public auth(dcId: DcId) { public auth(dcId: DcId) {
let promise = this.cached[dcId]; let promise = this.cached[dcId];
@ -601,9 +601,9 @@ export class Authorizer extends AppManager {
} }
promise = new Promise(async(resolve, reject) => { promise = new Promise(async(resolve, reject) => {
/// #if MTPROTO_AUTO // #if MTPROTO_AUTO
await this.getTransportType(); await this.getTransportType();
/// #endif // #endif
let error: ApiError; let error: ApiError;
let _try = 1; let _try = 1;

38
src/lib/mtproto/dcConfigurator.ts

@ -14,22 +14,22 @@ import Modes from '../../config/modes';
import App from '../../config/app'; import App from '../../config/app';
import indexOfAndSplice from '../../helpers/array/indexOfAndSplice'; import indexOfAndSplice from '../../helpers/array/indexOfAndSplice';
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
import HTTP from './transports/http'; import HTTP from './transports/http';
/// #endif // #endif
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
import Socket from './transports/websocket'; import Socket from './transports/websocket';
import TcpObfuscated from './transports/tcpObfuscated'; import TcpObfuscated from './transports/tcpObfuscated';
import { IS_WEB_WORKER } from '../../helpers/context'; import { IS_WEB_WORKER } from '../../helpers/context';
import { DcId } from '../../types'; import { DcId } from '../../types';
import { getEnvironment } from '../../environment/utils'; import { getEnvironment } from '../../environment/utils';
/// #if !MTPROTO_SW && SAFARI_PROXY_WEBSOCKET // #if !MTPROTO_SW && SAFARI_PROXY_WEBSOCKET
import SocketProxied from './transports/socketProxied'; import SocketProxied from './transports/socketProxied';
/// #endif // #endif
/// #endif // #endif
export type TransportType = 'websocket' | 'https' | 'http'; export type TransportType = 'websocket' | 'https' | 'http';
export type ConnectionType = 'client' | 'download' | 'upload'; export type ConnectionType = 'client' | 'download' | 'upload';
@ -48,7 +48,7 @@ export function getTelegramConnectionSuffix(connectionType: ConnectionType) {
return connectionType === 'client' ? '' : '-1'; return connectionType === 'client' ? '' : '-1';
} }
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
export function constructTelegramWebSocketUrl(dcId: DcId, connectionType: ConnectionType, premium?: boolean) { export function constructTelegramWebSocketUrl(dcId: DcId, connectionType: ConnectionType, premium?: boolean) {
const suffix = getTelegramConnectionSuffix(connectionType); const suffix = getTelegramConnectionSuffix(connectionType);
const path = connectionType !== 'client' ? 'apiws' + (premium ? PREMIUM_SUFFIX : TEST_SUFFIX) : ('apiws' + TEST_SUFFIX); const path = connectionType !== 'client' ? 'apiws' + (premium ? PREMIUM_SUFFIX : TEST_SUFFIX) : ('apiws' + TEST_SUFFIX);
@ -56,7 +56,7 @@ export function constructTelegramWebSocketUrl(dcId: DcId, connectionType: Connec
return chosenServer; return chosenServer;
} }
/// #endif // #endif
export class DcConfigurator { export class DcConfigurator {
private sslSubdomains = ['pluto', 'venus', 'aurora', 'vesta', 'flora']; private sslSubdomains = ['pluto', 'venus', 'aurora', 'vesta', 'flora'];
@ -77,7 +77,7 @@ export class DcConfigurator {
public chosenServers: Servers = {} as any; public chosenServers: Servers = {} as any;
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
private transportSocket = (dcId: DcId, connectionType: ConnectionType, premium?: boolean) => { private transportSocket = (dcId: DcId, connectionType: ConnectionType, premium?: boolean) => {
const chosenServer = constructTelegramWebSocketUrl(dcId, connectionType, premium); const chosenServer = constructTelegramWebSocketUrl(dcId, connectionType, premium);
const logSuffix = connectionType === 'upload' ? '-U' : connectionType === 'download' ? '-D' : ''; const logSuffix = connectionType === 'upload' ? '-U' : connectionType === 'download' ? '-D' : '';
@ -85,17 +85,17 @@ export class DcConfigurator {
const retryTimeout = connectionType === 'client' ? 10000 : 10000; const retryTimeout = connectionType === 'client' ? 10000 : 10000;
let oooohLetMeLive: MTConnectionConstructable; let oooohLetMeLive: MTConnectionConstructable;
/// #if MTPROTO_SW || !SAFARI_PROXY_WEBSOCKET // #if MTPROTO_SW || !SAFARI_PROXY_WEBSOCKET
oooohLetMeLive = Socket; oooohLetMeLive = Socket;
/// #else // #else
oooohLetMeLive = (getEnvironment().IS_SAFARI && IS_WEB_WORKER && typeof(SocketProxied) !== 'undefined') /* || true */ ? SocketProxied : Socket; oooohLetMeLive = (getEnvironment().IS_SAFARI && IS_WEB_WORKER && typeof(SocketProxied) !== 'undefined') /* || true */ ? SocketProxied : Socket;
/// #endif // #endif
return new TcpObfuscated(oooohLetMeLive, dcId, chosenServer, logSuffix, retryTimeout); return new TcpObfuscated(oooohLetMeLive, dcId, chosenServer, logSuffix, retryTimeout);
}; };
/// #endif // #endif
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
private transportHTTP = (dcId: DcId, connectionType: ConnectionType, premium?: boolean) => { private transportHTTP = (dcId: DcId, connectionType: ConnectionType, premium?: boolean) => {
let chosenServer: string; let chosenServer: string;
if(Modes.ssl || !Modes.http) { if(Modes.ssl || !Modes.http) {
@ -115,7 +115,7 @@ export class DcConfigurator {
const logSuffix = connectionType === 'upload' ? '-U' : connectionType === 'download' ? '-D' : ''; const logSuffix = connectionType === 'upload' ? '-U' : connectionType === 'download' ? '-D' : '';
return new HTTP(dcId, chosenServer, logSuffix); return new HTTP(dcId, chosenServer, logSuffix);
}; };
/// #endif // #endif
public chooseServer( public chooseServer(
dcId: DcId, dcId: DcId,
@ -147,13 +147,13 @@ export class DcConfigurator {
if(!transports.length || !reuse/* || (upload && transports.length < 1) */) { if(!transports.length || !reuse/* || (upload && transports.length < 1) */) {
let transport: MTTransport; let transport: MTTransport;
/// #if MTPROTO_HAS_WS && MTPROTO_HAS_HTTP // #if MTPROTO_HAS_WS && MTPROTO_HAS_HTTP
transport = (transportType === 'websocket' ? this.transportSocket : this.transportHTTP)(dcId, connectionType, premium); transport = (transportType === 'websocket' ? this.transportSocket : this.transportHTTP)(dcId, connectionType, premium);
/// #elif !MTPROTO_HTTP // #elif !MTPROTO_HTTP
transport = this.transportSocket(dcId, connectionType, premium); transport = this.transportSocket(dcId, connectionType, premium);
/// #else // #else
transport = this.transportHTTP(dcId, connectionType, premium); transport = this.transportHTTP(dcId, connectionType, premium);
/// #endif // #endif
if(!transport) { if(!transport) {
console.error('No chosenServer!', dcId); console.error('No chosenServer!', dcId);

28
src/lib/mtproto/mtprotoworker.ts

@ -74,9 +74,9 @@ class ApiManagerProxy extends MTProtoMessagePort {
this.log('constructor'); this.log('constructor');
/// #if !MTPROTO_SW // #if !MTPROTO_SW
this.registerWorker(); this.registerWorker();
/// #endif // #endif
this.registerServiceWorker(); this.registerServiceWorker();
this.registerCryptoWorker(); this.registerCryptoWorker();
@ -222,9 +222,9 @@ class ApiManagerProxy extends MTProtoMessagePort {
const controller = navigator.serviceWorker.controller || registration.installing || registration.waiting || registration.active; const controller = navigator.serviceWorker.controller || registration.installing || registration.waiting || registration.active;
this.attachServiceWorker(controller); this.attachServiceWorker(controller);
/// #if MTPROTO_SW // #if MTPROTO_SW
this.onWorkerFirstMessage(controller); this.onWorkerFirstMessage(controller);
/// #endif // #endif
}, (err) => { }, (err) => {
this.log.error('SW registration failed!', err); this.log.error('SW registration failed!', err);
@ -260,16 +260,16 @@ class ApiManagerProxy extends MTProtoMessagePort {
}); });
}); });
/// #if MTPROTO_SW // #if MTPROTO_SW
this.attachListenPort(worker); this.attachListenPort(worker);
/// #else // #else
this.serviceMessagePort.attachListenPort(worker); this.serviceMessagePort.attachListenPort(worker);
this.serviceMessagePort.addMultipleEventsListeners({ this.serviceMessagePort.addMultipleEventsListeners({
port: (payload, source, event) => { port: (payload, source, event) => {
this.invokeVoid('serviceWorkerPort', undefined, undefined, [event.ports[0]]); this.invokeVoid('serviceWorkerPort', undefined, undefined, [event.ports[0]]);
} }
}); });
/// #endif // #endif
worker.addEventListener('messageerror', (e) => { worker.addEventListener('messageerror', (e) => {
this.log.error('SW messageerror:', e); this.log.error('SW messageerror:', e);
@ -299,7 +299,7 @@ class ApiManagerProxy extends MTProtoMessagePort {
this.attachWorkerToPort(worker, cryptoMessagePort, 'crypto'); this.attachWorkerToPort(worker, cryptoMessagePort, 'crypto');
} }
/// #if !MTPROTO_SW // #if !MTPROTO_SW
private registerWorker() { private registerWorker() {
// return; // return;
@ -320,7 +320,7 @@ class ApiManagerProxy extends MTProtoMessagePort {
this.onWorkerFirstMessage(worker); this.onWorkerFirstMessage(worker);
} }
/// #endif // #endif
private attachWorkerToPort(worker: SharedWorker | Worker, messagePort: SuperMessagePort<any, any, any>, type: string) { private attachWorkerToPort(worker: SharedWorker | Worker, messagePort: SuperMessagePort<any, any, any>, type: string) {
const port: MessagePort = (worker as SharedWorker).port || worker as any; const port: MessagePort = (worker as SharedWorker).port || worker as any;
@ -335,11 +335,11 @@ class ApiManagerProxy extends MTProtoMessagePort {
this.log('set webWorker'); this.log('set webWorker');
// this.worker = worker; // this.worker = worker;
/// #if MTPROTO_SW // #if MTPROTO_SW
this.attachSendPort(worker); this.attachSendPort(worker);
/// #else // #else
this.attachWorkerToPort(worker, this, 'mtproto'); this.attachWorkerToPort(worker, this, 'mtproto');
/// #endif // #endif
} }
private loadState() { private loadState() {
@ -362,11 +362,11 @@ class ApiManagerProxy extends MTProtoMessagePort {
}); });
} }
/// #if MTPROTO_WORKER // #if MTPROTO_WORKER
public invokeCrypto<Method extends keyof CryptoMethods>(method: Method, ...args: Parameters<CryptoMethods[typeof method]>): Promise<Awaited<ReturnType<CryptoMethods[typeof method]>>> { public invokeCrypto<Method extends keyof CryptoMethods>(method: Method, ...args: Parameters<CryptoMethods[typeof method]>): Promise<Awaited<ReturnType<CryptoMethods[typeof method]>>> {
return cryptoMessagePort.invokeCrypto(method, ...args); return cryptoMessagePort.invokeCrypto(method, ...args);
} }
/// #endif // #endif
public async toggleStorages(enabled: boolean, clearWrite: boolean) { public async toggleStorages(enabled: boolean, clearWrite: boolean) {
await toggleStorages(enabled, clearWrite); await toggleStorages(enabled, clearWrite);

122
src/lib/mtproto/networker.ts

@ -24,9 +24,9 @@ import DEBUG from '../../config/debug';
import Modes from '../../config/modes'; import Modes from '../../config/modes';
import noop from '../../helpers/noop'; import noop from '../../helpers/noop';
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
import HTTP from './transports/http'; import HTTP from './transports/http';
/// #endif // #endif
import type TcpObfuscated from './transports/tcpObfuscated'; import type TcpObfuscated from './transports/tcpObfuscated';
import bigInt from 'big-integer'; import bigInt from 'big-integer';
@ -135,7 +135,7 @@ export default class MTPNetworker {
private nextReqTimeout: number; private nextReqTimeout: number;
private nextReq: number = 0; private nextReq: number = 0;
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
private longPollInterval: number; private longPollInterval: number;
private longPollPending: number; private longPollPending: number;
private checkConnectionRetryAt: number; private checkConnectionRetryAt: number;
@ -144,7 +144,7 @@ export default class MTPNetworker {
private sleepAfter: number; private sleepAfter: number;
private offline = false; private offline = false;
private sendingLongPoll: boolean; private sendingLongPoll: boolean;
/// #endif // #endif
private seqNo: number; private seqNo: number;
private prevSessionId: Uint8Array; private prevSessionId: Uint8Array;
@ -173,13 +173,13 @@ export default class MTPNetworker {
public transport: MTTransport; public transport: MTTransport;
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
private pingDelayDisconnectDeferred: CancellablePromise<string>; private pingDelayDisconnectDeferred: CancellablePromise<string>;
private pingPromise: Promise<void>; private pingPromise: Promise<void>;
// private pingInterval: number; // private pingInterval: number;
private lastPingTime: number; private lastPingTime: number;
private lastPingDelayDisconnectId: string; private lastPingDelayDisconnectId: string;
/// #endif // #endif
//public onConnectionStatusChange: (online: boolean) => void; //public onConnectionStatusChange: (online: boolean) => void;
//private debugRequests: Array<{before: Uint8Array, after: Uint8Array}> = []; //private debugRequests: Array<{before: Uint8Array, after: Uint8Array}> = [];
@ -413,19 +413,19 @@ export default class MTPNetworker {
this.connectionInited = false; this.connectionInited = false;
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
if(this.longPollInterval !== undefined) { if(this.longPollInterval !== undefined) {
clearInterval(this.longPollInterval); clearInterval(this.longPollInterval);
this.longPollInterval = undefined; this.longPollInterval = undefined;
} }
this.clearCheckConnectionTimeout(); this.clearCheckConnectionTimeout();
/// #endif // #endif
} }
this.log('change transport', transport, oldTransport); this.log('change transport', transport, oldTransport);
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
this.clearPingDelayDisconnect(); this.clearPingDelayDisconnect();
// if(this.pingInterval !== undefined) { // if(this.pingInterval !== undefined) {
@ -434,7 +434,7 @@ export default class MTPNetworker {
// } // }
// this.clearPing(); // this.clearPing();
/// #endif // #endif
this.transport = transport; this.transport = transport;
if(!transport) { if(!transport) {
@ -443,19 +443,19 @@ export default class MTPNetworker {
transport.networker = this; transport.networker = this;
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
if(transport instanceof HTTP) { if(transport instanceof HTTP) {
/// #endif // #endif
this.longPollInterval = ctx.setInterval(this.checkLongPoll, 10000); this.longPollInterval = ctx.setInterval(this.checkLongPoll, 10000);
this.checkLongPoll(); this.checkLongPoll();
this.checkConnection('changed transport'); this.checkConnection('changed transport');
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
} }
/// #endif // #endif
/// #endif // #endif
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
// * handle outcoming dead socket, server will close the connection // * handle outcoming dead socket, server will close the connection
if((transport as TcpObfuscated).connection) { if((transport as TcpObfuscated).connection) {
// this.sendPingDelayDisconnect(); // this.sendPingDelayDisconnect();
@ -467,7 +467,7 @@ export default class MTPNetworker {
// this.pingInterval = ctx.setInterval(this.sendPing, PING_INTERVAL); // this.pingInterval = ctx.setInterval(this.sendPing, PING_INTERVAL);
// this.sendPing(); // this.sendPing();
} }
/// #endif // #endif
this.resend(); this.resend();
} }
@ -612,7 +612,7 @@ export default class MTPNetworker {
.finally(onFinally); .finally(onFinally);
}; };
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
private checkLongPoll = () => { private checkLongPoll = () => {
const isClean = this.cleanupSent(); const isClean = this.cleanupSent();
//this.log.error('Check lp', this.longPollPending, this.dcId, isClean, this); //this.log.error('Check lp', this.longPollPending, this.dcId, isClean, this);
@ -725,20 +725,20 @@ export default class MTPNetworker {
this.checkConnectionTimeout = ctx.setTimeout(() => this.checkConnection('from toggleOfline'), delay); this.checkConnectionTimeout = ctx.setTimeout(() => this.checkConnection('from toggleOfline'), delay);
this.checkConnectionPeriod = Math.min(30, (1 + this.checkConnectionPeriod) * 1.5); this.checkConnectionPeriod = Math.min(30, (1 + this.checkConnectionPeriod) * 1.5);
/// #if !MTPROTO_WORKER // #if !MTPROTO_WORKER
document.body.addEventListener('online', this.checkConnection, false); document.body.addEventListener('online', this.checkConnection, false);
document.body.addEventListener('focus', this.checkConnection, false); document.body.addEventListener('focus', this.checkConnection, false);
/// #endif // #endif
} else { } else {
this.setConnectionStatus(ConnectionStatus.Connected); this.setConnectionStatus(ConnectionStatus.Connected);
this.checkLongPoll(); this.checkLongPoll();
this.scheduleRequest(); this.scheduleRequest();
/// #if !MTPROTO_WORKER // #if !MTPROTO_WORKER
document.body.removeEventListener('online', this.checkConnection); document.body.removeEventListener('online', this.checkConnection);
document.body.removeEventListener('focus', this.checkConnection); document.body.removeEventListener('focus', this.checkConnection);
/// #endif // #endif
} }
} }
@ -784,7 +784,7 @@ export default class MTPNetworker {
}); });
}); });
} }
/// #endif // #endif
// тут можно сделать таймаут и выводить дисконнект // тут можно сделать таймаут и выводить дисконнект
private pushMessage(message: { private pushMessage(message: {
@ -1029,10 +1029,10 @@ export default class MTPNetworker {
//const currentTime = Date.now(); //const currentTime = Date.now();
let messagesByteLen = 0; let messagesByteLen = 0;
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
let hasApiCall = false; let hasApiCall = false;
let hasHttpWait = false; let hasHttpWait = false;
/// #endif // #endif
let lengthOverflow = false; let lengthOverflow = false;
@ -1062,13 +1062,13 @@ export default class MTPNetworker {
messages.push(message); messages.push(message);
messagesByteLen += messageByteLength; messagesByteLen += messageByteLength;
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
if(message.isAPI) { if(message.isAPI) {
hasApiCall = true; hasApiCall = true;
} else if(message.longPoll) { } else if(message.longPoll) {
hasHttpWait = true; hasHttpWait = true;
} }
/// #endif // #endif
outMessage = message; outMessage = message;
} else { } else {
@ -1079,10 +1079,10 @@ export default class MTPNetworker {
//} //}
} }
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
if(this.transport instanceof HTTP) if(this.transport instanceof HTTP)
/// #endif // #endif
if(hasApiCall && !hasHttpWait) { if(hasApiCall && !hasHttpWait) {
const serializer = new TLSerialization({mtproto: true}); const serializer = new TLSerialization({mtproto: true});
serializer.storeMethod('http_wait', { serializer.storeMethod('http_wait', {
@ -1097,16 +1097,16 @@ export default class MTPNetworker {
body: serializer.getBytes(true) body: serializer.getBytes(true)
}); });
} }
/// #endif // #endif
if(!messages.length) { if(!messages.length) {
// this.log('no scheduled messages') // this.log('no scheduled messages')
return; return;
} }
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
const noResponseMsgs: Array<string> = messages.filter((message) => message.noResponse).map((message) => message.msg_id); const noResponseMsgs: Array<string> = messages.filter((message) => message.noResponse).map((message) => message.msg_id);
/// #endif // #endif
if(messages.length > 1) { if(messages.length > 1) {
const container = this.generateContainerMessage(messagesByteLen, messages); const container = this.generateContainerMessage(messagesByteLen, messages);
@ -1121,19 +1121,19 @@ export default class MTPNetworker {
const promise = this.sendEncryptedRequest(outMessage); const promise = this.sendEncryptedRequest(outMessage);
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
if(this.transport instanceof HTTP) if(this.transport instanceof HTTP)
/// #endif // #endif
this.handleSentEncryptedRequestHTTP(promise, outMessage, noResponseMsgs); this.handleSentEncryptedRequestHTTP(promise, outMessage, noResponseMsgs);
/// #endif // #endif
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
if(!(this.transport instanceof HTTP)) if(!(this.transport instanceof HTTP))
/// #endif // #endif
this.cleanupSent(); // ! WARNING this.cleanupSent(); // ! WARNING
/// #endif // #endif
if(lengthOverflow) { if(lengthOverflow) {
this.scheduleRequest(); this.scheduleRequest();
@ -1302,13 +1302,13 @@ export default class MTPNetworker {
const promise: Promise<Uint8Array> = this.transport ? this.transport.send(requestData) as any : Promise.reject({}); const promise: Promise<Uint8Array> = this.transport ? this.transport.send(requestData) as any : Promise.reject({});
// this.debug && this.log.debug('sendEncryptedRequest: launched message into space:', message, promise); // this.debug && this.log.debug('sendEncryptedRequest: launched message into space:', message, promise);
/// #if !MTPROTO_HAS_HTTP // #if !MTPROTO_HAS_HTTP
return promise; return promise;
/// #else // #else
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
if(!(this.transport instanceof HTTP)) return promise; if(!(this.transport instanceof HTTP)) return promise;
/// #endif // #endif
const baseError: ApiError = { const baseError: ApiError = {
code: 406, code: 406,
@ -1334,7 +1334,7 @@ export default class MTPNetworker {
throw error; throw error;
}); });
/// #endif // #endif
} }
public parseResponse(responseBuffer: Uint8Array) { public parseResponse(responseBuffer: Uint8Array) {
@ -1475,19 +1475,19 @@ export default class MTPNetworker {
return; return;
} */ } */
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
if(this.transport instanceof HTTP) { if(this.transport instanceof HTTP) {
/// #endif // #endif
if(this.offline) { if(this.offline) {
this.checkConnection('forced schedule'); this.checkConnection('forced schedule');
} }
delay ||= 0; // set zero timeout to pack other messages too delay ||= 0; // set zero timeout to pack other messages too
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
} }
/// #endif // #endif
/// #endif // #endif
const nextReq = Date.now() + (delay || 0); const nextReq = Date.now() + (delay || 0);
if(this.nextReq && (delay === undefined || this.nextReq <= nextReq)) { if(this.nextReq && (delay === undefined || this.nextReq <= nextReq)) {
@ -1512,15 +1512,15 @@ export default class MTPNetworker {
this.nextReqTimeout = 0; this.nextReqTimeout = 0;
this.nextReq = 0; this.nextReq = 0;
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
if(this.transport instanceof HTTP) if(this.transport instanceof HTTP)
/// #endif // #endif
if(this.offline) { if(this.offline) {
//this.log('Cancel scheduled'); //this.log('Cancel scheduled');
return; return;
} }
/// #endif // #endif
this.performScheduledRequest(); this.performScheduledRequest();
}; };
@ -1540,12 +1540,12 @@ export default class MTPNetworker {
let delay: number; let delay: number;
/// #if MTPROTO_HAS_HTTP // #if MTPROTO_HAS_HTTP
/// #if MTPROTO_HAS_WS // #if MTPROTO_HAS_WS
if(this.transport instanceof HTTP) if(this.transport instanceof HTTP)
/// #endif // #endif
delay = 30000; delay = 30000;
/// #endif // #endif
this.scheduleRequest(delay); this.scheduleRequest(delay);
} }

8
src/lib/mtproto/transports/http.ts

@ -11,10 +11,10 @@ import type MTPNetworker from '../networker';
import MTTransport from './transport'; import MTTransport from './transport';
import Modes from '../../../config/modes'; import Modes from '../../../config/modes';
/// #if MTPROTO_AUTO // #if MTPROTO_AUTO
import transportController from './controller'; import transportController from './controller';
import networkStats from '../networkStats'; import networkStats from '../networkStats';
/// #endif // #endif
export default class HTTP implements MTTransport { export default class HTTP implements MTTransport {
public networker: MTPNetworker; public networker: MTPNetworker;
@ -82,9 +82,9 @@ export default class HTTP implements MTTransport {
this.connected = connected; this.connected = connected;
/// #if MTPROTO_AUTO // #if MTPROTO_AUTO
transportController.setTransportValue('https', connected); transportController.setTransportValue('https', connected);
/// #endif // #endif
} }
public destroy() { public destroy() {

4
src/lib/mtproto/transports/socketProxied.ts

@ -36,7 +36,7 @@ export interface SocketProxyCloseTask extends WorkerTaskVoidTemplate {
id: number id: number
}; };
/// #if !MTPROTO_SW // #if !MTPROTO_SW
export default class SocketProxied extends EventListenerBase<{ export default class SocketProxied extends EventListenerBase<{
open: () => void, open: () => void,
message: (buffer: ArrayBuffer) => any, message: (buffer: ArrayBuffer) => any,
@ -92,4 +92,4 @@ export default class SocketProxied extends EventListenerBase<{
} }
export const socketsProxied: Map<number, SocketProxied> = new Map(); export const socketsProxied: Map<number, SocketProxied> = new Map();
/// #endif // #endif

12
src/lib/mtproto/transports/tcpObfuscated.ts

@ -14,12 +14,12 @@ import abridgedPacketCodec from './abridged';
// import paddedIntermediatePacketCodec from './padded'; // import paddedIntermediatePacketCodec from './padded';
import { ConnectionStatus } from "../connectionStatus"; import { ConnectionStatus } from "../connectionStatus";
/// #if MTPROTO_AUTO // #if MTPROTO_AUTO
import transportController from "./controller"; import transportController from "./controller";
import bytesToHex from "../../../helpers/bytes/bytesToHex"; import bytesToHex from "../../../helpers/bytes/bytesToHex";
import networkStats from "../networkStats"; import networkStats from "../networkStats";
import ctx from "../../../environment/ctx"; import ctx from "../../../environment/ctx";
/// #endif // #endif
export default class TcpObfuscated implements MTTransport { export default class TcpObfuscated implements MTTransport {
private codec = abridgedPacketCodec; private codec = abridgedPacketCodec;
@ -64,9 +64,9 @@ export default class TcpObfuscated implements MTTransport {
private onOpen = async() => { private onOpen = async() => {
this.connected = true; this.connected = true;
/// #if MTPROTO_AUTO // #if MTPROTO_AUTO
transportController.setTransportOpened('websocket'); transportController.setTransportOpened('websocket');
/// #endif // #endif
const initPayload = await this.obfuscation.init(this.codec); const initPayload = await this.obfuscation.init(this.codec);
if(!this.connected) { if(!this.connected) {
@ -156,11 +156,11 @@ export default class TcpObfuscated implements MTTransport {
}; };
public clear() { public clear() {
/// #if MTPROTO_AUTO // #if MTPROTO_AUTO
if(this.connected) { if(this.connected) {
transportController.setTransportClosed('websocket'); transportController.setTransportClosed('websocket');
} }
/// #endif // #endif
this.connected = false; this.connected = false;

12
src/lib/serviceWorker/index.service.ts

@ -4,9 +4,9 @@
* https://github.com/morethanwords/tweb/blob/master/LICENSE * https://github.com/morethanwords/tweb/blob/master/LICENSE
*/ */
/// #if MTPROTO_SW // #if MTPROTO_SW
import '../mtproto/mtproto.worker'; import '../mtproto/mtproto.worker';
/// #endif // #endif
import { logger, LogTypes } from '../logger'; import { logger, LogTypes } from '../logger';
import { CACHE_ASSETS_NAME, requestCache } from './cache'; import { CACHE_ASSETS_NAME, requestCache } from './cache';
@ -24,7 +24,7 @@ import makeError from '../../helpers/makeError';
export const log = logger('SW', LogTypes.Error | LogTypes.Debug | LogTypes.Log | LogTypes.Warn); export const log = logger('SW', LogTypes.Error | LogTypes.Debug | LogTypes.Log | LogTypes.Warn);
const ctx = self as any as ServiceWorkerGlobalScope; const ctx = self as any as ServiceWorkerGlobalScope;
/// #if !MTPROTO_SW // #if !MTPROTO_SW
let _mtprotoMessagePort: MessagePort; let _mtprotoMessagePort: MessagePort;
export const getMtprotoMessagePort = () => _mtprotoMessagePort; export const getMtprotoMessagePort = () => _mtprotoMessagePort;
@ -191,10 +191,10 @@ listenMessagePort(serviceMessagePort, undefined, (source) => {
} }
} }
}); });
/// #endif // #endif
const onFetch = (event: FetchEvent): void => { const onFetch = (event: FetchEvent): void => {
/// #if !DEBUG // #if !DEBUG
if( if(
!IS_SAFARI && !IS_SAFARI &&
event.request.url.indexOf(location.origin + '/') === 0 && event.request.url.indexOf(location.origin + '/') === 0 &&
@ -202,7 +202,7 @@ const onFetch = (event: FetchEvent): void => {
) { ) {
return event.respondWith(requestCache(event)); return event.respondWith(requestCache(event));
} }
/// #endif // #endif
try { try {
const [, url, scope, params] = /http[:s]+\/\/.*?(\/(.*?)(?:$|\/(.*)$))/.exec(event.request.url) || []; const [, url, scope, params] = /http[:s]+\/\/.*?(\/(.*?)(?:$|\/(.*)$))/.exec(event.request.url) || [];

94
webpack.common.js

@ -4,7 +4,7 @@ const MediaQueryPlugin = require('media-query-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const postcssPresetEnv = require('postcss-preset-env'); const postcssPresetEnv = require('postcss-preset-env');
// const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin'); // const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin');
const { RetryChunkLoadPlugin } = require('webpack-retry-chunk-load-plugin'); const {RetryChunkLoadPlugin} = require('webpack-retry-chunk-load-plugin');
const fs = require('fs'); const fs = require('fs');
const Dotenv = require('dotenv-webpack'); const Dotenv = require('dotenv-webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
@ -24,20 +24,20 @@ const MTPROTO_HTTP = false;
const MTPROTO_AUTO = true; const MTPROTO_AUTO = true;
const opts = { const opts = {
MTPROTO_WORKER: true, 'MTPROTO_WORKER': true,
MTPROTO_SW: false, 'MTPROTO_SW': false,
MTPROTO_HTTP: MTPROTO_HTTP, 'MTPROTO_HTTP': MTPROTO_HTTP,
MTPROTO_HTTP_UPLOAD: false, 'MTPROTO_HTTP_UPLOAD': false,
MTPROTO_AUTO: MTPROTO_AUTO, // use HTTPS when WS is unavailable 'MTPROTO_AUTO': MTPROTO_AUTO, // use HTTPS when WS is unavailable
MTPROTO_HAS_HTTP: MTPROTO_AUTO || MTPROTO_HTTP, 'MTPROTO_HAS_HTTP': MTPROTO_AUTO || MTPROTO_HTTP,
MTPROTO_HAS_WS: MTPROTO_AUTO || !MTPROTO_HTTP, 'MTPROTO_HAS_WS': MTPROTO_AUTO || !MTPROTO_HTTP,
SAFARI_PROXY_WEBSOCKET: false, 'SAFARI_PROXY_WEBSOCKET': false,
DEBUG: devMode, 'DEBUG': devMode,
version: 3, 'version': 3,
'ifdef-verbose': devMode, // add this for verbose output 'ifdef-verbose': devMode, // add this for verbose output
'ifdef-triple-slash': true, // add this to use double slash comment instead of default triple slash 'ifdef-triple-slash': false, // add this to use double slash comment instead of default triple slash
'ifdef-fill-with-blanks': true // add this to remove code with blank spaces instead of "//" comments 'ifdef-fill-with-blanks': true, // add this to remove code with blank spaces instead of "//" comments
}; };
const domain = 'yourdomain.com'; const domain = 'yourdomain.com';
@ -45,17 +45,17 @@ const localIp = '192.168.92.78';
const middleware = (req, res, next) => { const middleware = (req, res, next) => {
let IP = ''; let IP = '';
if(req.headers['cf-connecting-ip']) { if (req.headers['cf-connecting-ip']) {
IP = req.headers['cf-connecting-ip']; IP = req.headers['cf-connecting-ip'];
} else { } else {
IP = req.connection.remoteAddress.split(':').pop(); IP = req.connection.remoteAddress.split(':').pop();
} }
if(!allowedIPs.includes(IP) && !/^192\.168\.\d{1,3}\.\d{1,3}$/.test(IP)) { if (!allowedIPs.includes(IP) && !/^192\.168\.\d{1,3}\.\d{1,3}$/.test(IP)) {
console.log('Bad IP connecting: ' + IP, req.url); console.log('Bad IP connecting: ' + IP, req.url);
res.status(404).send('Nothing interesting here.'); res.status(404).send('Nothing interesting here.');
} else { } else {
if(req.url.indexOf('/assets/') !== 0) { if (req.url.indexOf('/assets/') !== 0) {
console.log(req.url, IP); console.log(req.url, IP);
} }
@ -69,7 +69,7 @@ module.exports = {
{ {
test: /\.scss$/, test: /\.scss$/,
use: [ use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,/* { devMode ? 'style-loader' : MiniCssExtractPlugin.loader, /* {
loader: MiniCssExtractPlugin.loader, loader: MiniCssExtractPlugin.loader,
options: { options: {
hmr: devMode, hmr: devMode,
@ -83,8 +83,8 @@ module.exports = {
{ {
loader: 'css-loader', loader: 'css-loader',
options: { options: {
url: false url: false,
} },
}, },
devMode ? undefined : MediaQueryPlugin.loader, devMode ? undefined : MediaQueryPlugin.loader,
@ -101,17 +101,17 @@ module.exports = {
postcssOptions: { postcssOptions: {
plugins: [ plugins: [
postcssPresetEnv(), postcssPresetEnv(),
] ],
} },
} },
}, },
{ {
loader: 'sass-loader', loader: 'sass-loader',
options: { options: {
sourceMap: devMode sourceMap: devMode,
} },
} },
].filter(Boolean) ].filter(Boolean),
}, },
// { // {
// test: /\.worker\.ts$/i, // test: /\.worker\.ts$/i,
@ -123,9 +123,9 @@ module.exports = {
{ {
test: /\.ts?$/, test: /\.ts?$/,
use: [ use: [
//{ loader: 'babel-loader', options: require('./babel.config') }, // { loader: 'babel-loader', options: require('./babel.config') },
'ts-loader', 'ts-loader',
{loader: 'ifdef-loader', options: opts} {loader: 'ifdef-loader', options: opts},
], ],
exclude: /node_modules/, exclude: /node_modules/,
}, },
@ -133,13 +133,13 @@ module.exports = {
test: /\.hbs$/, test: /\.hbs$/,
loader: 'handlebars-loader', loader: 'handlebars-loader',
options: { options: {
helperDirs: __dirname + '/handlebarsHelpers' helperDirs: __dirname + '/handlebarsHelpers',
} },
// loader: 'handlebars-loader?helperDirs[]=' + __dirname + '/handlebarsHelpers', // loader: 'handlebars-loader?helperDirs[]=' + __dirname + '/handlebarsHelpers',
// use: [ // use: [
// 'handlebars-loader' // 'handlebars-loader'
// ] // ]
} },
], ],
}, },
@ -156,7 +156,7 @@ module.exports = {
index: './src/index.ts', index: './src/index.ts',
pluralPolyfill: './src/lib/pluralPolyfill.ts' pluralPolyfill: './src/lib/pluralPolyfill.ts'
}, */ }, */
//devtool: 'inline-source-map', // devtool: 'inline-source-map',
output: { output: {
globalObject: 'this', globalObject: 'this',
@ -167,7 +167,7 @@ module.exports = {
// Webpack 5 // Webpack 5
clean: { clean: {
keep: keepAsset, keep: keepAsset,
} },
}, },
devServer: { devServer: {
@ -182,19 +182,19 @@ module.exports = {
// overlay: true, // overlay: true,
// static: { // static: {
// directory: path.join(__dirname, 'public') // directory: path.join(__dirname, 'public')
// }, // },
compress: true, compress: true,
http2: useLocalNotLocal ? true : (useLocal ? undefined : true), http2: useLocalNotLocal ? true : (useLocal ? undefined : true),
https: useLocal ? undefined : { https: useLocal ? undefined : {
key: fs.readFileSync(__dirname + '/certs/server-key.pem', 'utf8'), key: fs.readFileSync(__dirname + '/certs/server-key.pem', 'utf8'),
cert: fs.readFileSync(__dirname + '/certs/server-cert.pem', 'utf8') cert: fs.readFileSync(__dirname + '/certs/server-cert.pem', 'utf8'),
}, },
allowedHosts: useLocal ? undefined : [ allowedHosts: useLocal ? undefined : [
domain domain,
], ],
host: useLocalNotLocal ? localIp : (useLocal ? undefined : '0.0.0.0'), host: useLocalNotLocal ? localIp : (useLocal ? undefined : '0.0.0.0'),
//host: domain, // '0.0.0.0' // host: domain, // '0.0.0.0'
port: useLocal ? undefined : 443, port: useLocal ? undefined : 443,
@ -207,7 +207,7 @@ module.exports = {
}, },
client: { client: {
overlay: true, overlay: true,
progress: false progress: false,
}, },
}, },
@ -216,7 +216,7 @@ module.exports = {
analyzerMode: 'static', analyzerMode: 'static',
openAnalyzer: false, openAnalyzer: false,
generateStatsFile: false, generateStatsFile: false,
defaultSizes: 'gzip' defaultSizes: 'gzip',
}), }),
new Dotenv(), new Dotenv(),
@ -246,7 +246,7 @@ module.exports = {
description: 'Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed.', description: 'Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed.',
url: 'https://web.telegram.org/k/', url: 'https://web.telegram.org/k/',
filename: 'index.html', filename: 'index.html',
//template: 'public/index_template.html', // template: 'public/index_template.html',
template: 'src/index.hbs', template: 'src/index.hbs',
inject: 'body', // true, 'head' inject: 'body', // true, 'head'
scriptLoading: 'blocking', scriptLoading: 'blocking',
@ -260,7 +260,7 @@ module.exports = {
keepClosingSlash: true, keepClosingSlash: true,
minifyJS: true, minifyJS: true,
minifyCSS: true, minifyCSS: true,
minifyURLs: true minifyURLs: true,
}, },
chunks: 'all', chunks: 'all',
excludeChunks: [], excludeChunks: [],
@ -272,7 +272,7 @@ module.exports = {
match: /(mtproto).*\.js$/, match: /(mtproto).*\.js$/,
attributes: {rel: 'modulepreload'}, attributes: {rel: 'modulepreload'},
}, },
] ],
}), }),
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
@ -284,12 +284,12 @@ module.exports = {
new MediaQueryPlugin({ new MediaQueryPlugin({
include: [ include: [
'style' 'style',
], ],
queries: { queries: {
'only screen and (max-width: 720px)': 'mobile', 'only screen and (max-width: 720px)': 'mobile',
'only screen and (min-width: 721px)': 'desktop', 'only screen and (min-width: 721px)': 'desktop',
} },
}), }),
new RetryChunkLoadPlugin({ new RetryChunkLoadPlugin({
@ -304,10 +304,10 @@ module.exports = {
maxRetries: 999999, maxRetries: 999999,
// optional list of chunks to which retry script should be injected // optional list of chunks to which retry script should be injected
// if not set will add retry script to all chunks that have webpack script loading // if not set will add retry script to all chunks that have webpack script loading
//chunks: ['chunkName'], // chunks: ['chunkName'],
// optional code to be executed in the browser context if after all retries chunk is not loaded. // optional code to be executed in the browser context if after all retries chunk is not loaded.
// if not set - nothing will happen and error will be returned to the chunk loader. // if not set - nothing will happen and error will be returned to the chunk loader.
//lastResortScript: "window.location.href='/500.html';", // lastResortScript: "window.location.href='/500.html';",
}), }),
].filter(Boolean), ].filter(Boolean),
}; };

Loading…
Cancel
Save