diff --git a/src/components/appSelectPeers.ts b/src/components/appSelectPeers.ts index 306e44f7..20e41e0e 100644 --- a/src/components/appSelectPeers.ts +++ b/src/components/appSelectPeers.ts @@ -4,7 +4,7 @@ import { $rootScope, cancelEvent, findUpTag, findUpClassName } from "../lib/util import appDialogsManager from "../lib/appManagers/appDialogsManager"; import appChatsManager from "../lib/appManagers/appChatsManager"; import appUsersManager from "../lib/appManagers/appUsersManager"; -import { appPeersManager } from "../lib/services"; +import appPeersManager from "../lib/appManagers/appPeersManager"; import appPhotosManager from "../lib/appManagers/appPhotosManager"; export class AppSelectPeers { diff --git a/src/components/chatInput.ts b/src/components/chatInput.ts index 6e2e89c7..65fbeee1 100644 --- a/src/components/chatInput.ts +++ b/src/components/chatInput.ts @@ -147,7 +147,7 @@ export class ChatInput { this.btnSend.classList.remove('tgico-send'); this.btnSend.classList.add('tgico-microphone2'); - appImManager.setTyping('sendMessageCancelAction'); + appMessagesManager.setTyping('sendMessageCancelAction'); } else if(!this.btnSend.classList.contains('tgico-send')) { this.btnSend.classList.add('tgico-send'); this.btnSend.classList.remove('tgico-microphone2'); @@ -155,7 +155,7 @@ export class ChatInput { let time = Date.now(); if(time - this.lastTimeType >= 6000) { this.lastTimeType = time; - appImManager.setTyping('sendMessageTypingAction'); + appMessagesManager.setTyping('sendMessageTypingAction'); } } }); diff --git a/src/components/emoticonsDropdown.ts b/src/components/emoticonsDropdown.ts index f292c32f..2deae6b3 100644 --- a/src/components/emoticonsDropdown.ts +++ b/src/components/emoticonsDropdown.ts @@ -11,10 +11,11 @@ import appStickersManager, { MTStickerSet } from "../lib/appManagers/appStickers import apiManager from '../lib/mtproto/mtprotoworker'; //import CryptoWorker from '../lib/crypto/cryptoworker'; import LazyLoadQueue from "./lazyLoadQueue"; -import { MTDocument, wrapSticker } from "./wrappers"; +import { wrapSticker } from "./wrappers"; import appDocsManager from "../lib/appManagers/appDocsManager"; import ProgressivePreloader from "./preloader"; import Config from "../lib/config"; +import { MTDocument } from "../types"; export const EMOTICONSSTICKERGROUP = 'emoticons-dropdown'; diff --git a/src/components/wrappers.ts b/src/components/wrappers.ts index a8e15181..a38f7369 100644 --- a/src/components/wrappers.ts +++ b/src/components/wrappers.ts @@ -17,52 +17,7 @@ import { Layouter, RectPart } from './groupedLayout'; import PollElement from './poll'; import appWebpManager from '../lib/appManagers/appWebpManager'; import { mediaSizes } from '../lib/config'; - -export type MTDocument = { - _: 'document' | 'documentEmpty', - pFlags: any, - flags: number, - id: string, - access_hash: string, - file_reference: Uint8Array | number[], - date: number, - mime_type: string, - size: number, - thumbs: MTPhotoSize[], - dc_id: number, - attributes: any[], - - thumb?: MTPhotoSize, - type?: string, - h?: number, - w?: number, - file_name?: string, - file?: File, - duration?: number, - downloaded?: boolean, - url?: string, - - audioTitle?: string, - audioPerformer?: string, - - sticker?: number, - stickerEmoji?: string, - stickerEmojiRaw?: string, - stickerSetInput?: any, - stickerThumbConverted?: true, - - animated?: boolean -}; - -export type MTPhotoSize = { - _: string, - w?: number, - h?: number, - size?: number, - type?: string, // i, m, x, y, w by asc - location?: any, - bytes?: Uint8Array // if type == 'i' -}; +import { MTDocument, MTPhotoSize } from '../types'; export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTail, isOut, middleware, lazyLoadQueue}: { doc: MTDocument, diff --git a/src/lib/appManagers/AppInlineBotsManager.ts b/src/lib/appManagers/AppInlineBotsManager.ts index 576e309d..13d5a3b9 100644 --- a/src/lib/appManagers/AppInlineBotsManager.ts +++ b/src/lib/appManagers/AppInlineBotsManager.ts @@ -1,6 +1,6 @@ import appMessagesManager from "./appMessagesManager"; import apiManagerProxy from "../mtproto/mtprotoworker"; -import { appPeersManager } from "../services"; +import appPeersManager from "../appManagers/appPeersManager"; import appMessagesIDsManager from "./appMessagesIDsManager"; import { toast } from "../../components/misc"; import { RichTextProcessor } from "../richtextprocessor"; diff --git a/src/lib/appManagers/appDialogsManager.ts b/src/lib/appManagers/appDialogsManager.ts index b353073d..ac957f28 100644 --- a/src/lib/appManagers/appDialogsManager.ts +++ b/src/lib/appManagers/appDialogsManager.ts @@ -442,7 +442,7 @@ export class AppDialogsManager { } }); - /* false && */appMessagesManager.loaded.then(() => { + /* false && */appMessagesManager.loadSavedState().then(() => { this.loadDialogs().then(result => { this.setPinnedDelimiter(); //appSidebarLeft.onChatsScroll(); diff --git a/src/lib/appManagers/appDocsManager.ts b/src/lib/appManagers/appDocsManager.ts index 1932addb..9b48e5bf 100644 --- a/src/lib/appManagers/appDocsManager.ts +++ b/src/lib/appManagers/appDocsManager.ts @@ -2,9 +2,9 @@ import apiFileManager from '../mtproto/apiFileManager'; import FileManager from '../filemanager'; import {RichTextProcessor} from '../richtextprocessor'; import { CancellablePromise, deferredPromise } from '../polyfill'; -import { MTDocument } from '../../components/wrappers'; import { isObject } from '../utils'; import opusDecodeController from '../opusDecodeController'; +import { MTDocument } from '../../types'; class AppDocsManager { private docs: {[docID: string]: MTDocument} = {}; diff --git a/src/lib/appManagers/appImManager.ts b/src/lib/appManagers/appImManager.ts index cd687992..6615d3c4 100644 --- a/src/lib/appManagers/appImManager.ts +++ b/src/lib/appManagers/appImManager.ts @@ -455,10 +455,9 @@ export class AppImManager { const pinnedMessage = appMessagesManager.getPinnedMessage(this.peerID); mids.forEach(mid => { if(pinnedMessage.mid == mid) { - /////this.log('setting pinned message', message); - this.pinnedMessageContainer.dataset.mid = '' + mid; - this.topbar.classList.add('is-pinned-shown'); - this.pinnedMessageContent.innerHTML = pinnedMessage.rReply; + (this.messagesQueuePromise || Promise.resolve()).then(() => { + this.setPinnedMessage(pinnedMessage); + }); } this.needUpdate.forEachReverse((obj, idx) => { @@ -763,6 +762,13 @@ export class AppImManager { } }); } + + public setPinnedMessage(message: any) { + /////this.log('setting pinned message', message); + this.pinnedMessageContainer.dataset.mid = '' + message.mid; + this.topbar.classList.add('is-pinned-shown'); + this.pinnedMessageContent.innerHTML = message.rReply; + } public updateStatus() { if(!this.myID) return Promise.resolve(); @@ -1072,6 +1078,11 @@ export class AppImManager { this.scrollable.container.innerHTML = ''; //oldChatInner.remove(); !samePeer && this.finishPeerChange(); + + const pinned = appMessagesManager.getPinnedMessage(peerID); + if(pinned && !pinned.deleted) { + this.setPinnedMessage(pinned); + } } else { this.preloader.detach(); } @@ -1191,20 +1202,6 @@ export class AppImManager { $rootScope.$broadcast('peer_changed', this.peerID); } - public setTyping(action: any): Promise { - if(!this.peerID) return Promise.resolve(false); - - if(typeof(action) == 'string') { - action = {_: action}; - } - - let input = appPeersManager.getInputPeerByID(this.peerID); - return apiManager.invokeApi('messages.setTyping', { - peer: input, - action: action - }) as Promise; - } - public updateUnreadByDialog(dialog: Dialog) { let maxID = this.peerID == this.myID ? dialog.read_inbox_max_id : dialog.read_outbox_max_id; diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index a3701fa4..c40f94f2 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -13,8 +13,6 @@ import appPeersManager from "./appPeersManager"; import ServerTimeManager from "../mtproto/serverTimeManager"; import apiFileManager from "../mtproto/apiFileManager"; import appDocsManager from "./appDocsManager"; -import appImManager from "./appImManager"; -import { MTDocument, MTPhotoSize } from "../../components/wrappers"; import ProgressivePreloader from "../../components/preloader"; import serverTimeManager from "../mtproto/serverTimeManager"; //import apiManager from '../mtproto/apiManager'; @@ -23,6 +21,9 @@ import appWebPagesManager from "./appWebPagesManager"; import { CancellablePromise, deferredPromise } from "../polyfill"; import appPollsManager from "./appPollsManager"; import searchIndexManager from '../searchIndexManager'; +import { MTDocument, MTPhotoSize } from "../../types"; + +console.trace('include'); const APITIMEOUT = 0; @@ -178,7 +179,10 @@ export class AppMessagesManager { }); } }); + } + public loadSavedState() { + if(this.loaded) return this.loaded; this.loaded = new Promise((resolve, reject) => { AppStorage.get<{ dialogs: Dialog[], @@ -781,7 +785,7 @@ export class AppMessagesManager { preloader.preloader.onclick = () => { console.log('cancelling upload', media); - appImManager.setTyping('sendMessageCancelAction'); + this.setTyping('sendMessageCancelAction'); media.progress.cancel(); }; @@ -820,7 +824,7 @@ export class AppMessagesManager { uploadPromise: ReturnType = null; let invoke = (flags: number, inputMedia: any) => { - appImManager.setTyping('sendMessageCancelAction'); + this.setTyping('sendMessageCancelAction'); return apiManager.invokeApi('messages.sendMedia', { flags: flags, @@ -915,7 +919,7 @@ export class AppMessagesManager { console.log('upload progress', progress); media.progress.done = progress.done; media.progress.percent = Math.max(1, Math.floor(100 * progress.done / progress.total)); - appImManager.setTyping({_: actionName, progress: media.progress.percent | 0}); + this.setTyping({_: actionName, progress: media.progress.percent | 0}); preloader.setProgress(media.progress.percent); // lol, nice $rootScope.$broadcast('history_update', {peerID: peerID}); }; @@ -1078,7 +1082,7 @@ export class AppMessagesManager { preloader.preloader.onclick = () => { console.log('cancelling upload', media); - appImManager.setTyping('sendMessageCancelAction'); + this.setTyping('sendMessageCancelAction'); media.progress.cancel(); }; @@ -1127,7 +1131,7 @@ export class AppMessagesManager { let inputPeer = appPeersManager.getInputPeerByID(peerID); let invoke = (multiMedia: any[]) => { - appImManager.setTyping('sendMessageCancelAction'); + this.setTyping('sendMessageCancelAction'); return apiManager.invokeApi('messages.sendMultiMedia', { flags: flags, @@ -1161,7 +1165,7 @@ export class AppMessagesManager { uploadPromise.notify = (progress: {done: number, total: number}) => { console.log('upload progress', progress); media.progress.percent = Math.max(1, Math.floor(100 * progress.done / progress.total)); - appImManager.setTyping({_: actionName, progress: media.progress.percent | 0}); + this.setTyping({_: actionName, progress: media.progress.percent | 0}); preloader.setProgress(media.progress.percent); // lol, nice $rootScope.$broadcast('history_update', {peerID: peerID}); }; @@ -3843,6 +3847,20 @@ export class AppMessagesManager { } } } + + public setTyping(action: any): Promise { + if(!$rootScope.myID) return Promise.resolve(false); + + if(typeof(action) == 'string') { + action = {_: action}; + } + + let input = appPeersManager.getInputPeerByID($rootScope.myID); + return apiManager.invokeApi('messages.setTyping', { + peer: input, + action: action + }) as Promise; + } } export default new AppMessagesManager(); diff --git a/src/lib/appManagers/appPhotosManager.ts b/src/lib/appManagers/appPhotosManager.ts index 9a6e901b..811cc262 100644 --- a/src/lib/appManagers/appPhotosManager.ts +++ b/src/lib/appManagers/appPhotosManager.ts @@ -2,10 +2,10 @@ import appUsersManager from "./appUsersManager"; import { calcImageInBox, isObject } from "../utils"; import fileManager from '../filemanager'; import { bytesFromHex } from "../bin_utils"; -import { MTPhotoSize } from "../../components/wrappers"; import apiFileManager from "../mtproto/apiFileManager"; //import apiManager from '../mtproto/apiManager'; import apiManager from '../mtproto/mtprotoworker'; +import { MTPhotoSize } from "../../types"; export type MTPhoto = { _: 'photo' | 'photoEmpty' | string, diff --git a/src/lib/appManagers/appSidebarLeft.ts b/src/lib/appManagers/appSidebarLeft.ts index 70e8936f..efae390c 100644 --- a/src/lib/appManagers/appSidebarLeft.ts +++ b/src/lib/appManagers/appSidebarLeft.ts @@ -9,7 +9,7 @@ import { horizontalMenu, putPreloader, parseMenuButtonsTo } from "../../componen import appUsersManager from "./appUsersManager"; import Scrollable from "../../components/scrollable_new"; import appPhotosManager from "./appPhotosManager"; -import { appPeersManager } from "../services"; +import appPeersManager from "../appManagers/appPeersManager"; import popupAvatar from "../../components/popupAvatar"; import appChatsManager from "./appChatsManager"; import { AppSelectPeers } from "../../components/appSelectPeers"; diff --git a/src/lib/appManagers/appSidebarRight.ts b/src/lib/appManagers/appSidebarRight.ts index 8779b474..096b8191 100644 --- a/src/lib/appManagers/appSidebarRight.ts +++ b/src/lib/appManagers/appSidebarRight.ts @@ -756,11 +756,6 @@ class AppSidebarRight { } //this.log('userFull', userFull); - - if(userFull.pinned_msg_id) { // request pinned message - appImManager.pinnedMsgID = userFull.pinned_msg_id; - appMessagesManager.wrapSingleMessage(userFull.pinned_msg_id); - } }); } else { membersLi.style.display = appPeersManager.isBroadcast(peerID) ? 'none' : ''; diff --git a/src/lib/appManagers/appStickersManager.ts b/src/lib/appManagers/appStickersManager.ts index 315dbd64..0a485c76 100644 --- a/src/lib/appManagers/appStickersManager.ts +++ b/src/lib/appManagers/appStickersManager.ts @@ -1,9 +1,9 @@ import AppStorage from '../storage'; -import { MTDocument } from '../../components/wrappers'; //import apiManager from '../mtproto/apiManager'; import apiManager from '../mtproto/mtprotoworker'; import apiFileManager from '../mtproto/apiFileManager'; import appDocsManager from './appDocsManager'; +import { MTDocument } from '../../types'; export type MTStickerSet = { _: 'stickerSet', diff --git a/src/lib/services.ts b/src/lib/services.ts index 73872f99..25138464 100644 --- a/src/lib/services.ts +++ b/src/lib/services.ts @@ -17,28 +17,29 @@ import AppSidebarLeft from './appManagers/appSidebarLeft'; import AppMediaViewer from './appManagers/appMediaViewer'; //import AppSharedMediaManager from './appManagers/appSharedMediaManager'; -export const appUsersManager = AppUsersManager; -export const appChatsManager = AppChatsManager; -export const appMessagesIDsManager = AppMessagesIDsManager; -export const apiUpdatesManager = ApiUpdatesManager; -export const appPhotosManager = AppPhotosManager; -export const appMessagesManager = AppMessagesManager; -export const appProfileManager = AppProfileManager; -export const appImManager = AppImManager; -export const appPeersManager = AppPeersManager; -export const appStickersManager = AppStickersManager; -export const appDocsManager = AppDocsManager; +const appUsersManager = AppUsersManager; +const appChatsManager = AppChatsManager; +const appMessagesIDsManager = AppMessagesIDsManager; +const apiUpdatesManager = ApiUpdatesManager; +const appPhotosManager = AppPhotosManager; +const appMessagesManager = AppMessagesManager; +const appProfileManager = AppProfileManager; +const appImManager = AppImManager; +const appPeersManager = AppPeersManager; +const appStickersManager = AppStickersManager; +const appDocsManager = AppDocsManager; //export const appSharedMediaManager = AppSharedMediaManager; -export const appSidebarRight = AppSidebarRight; -export const appSidebarLeft = AppSidebarLeft; -export const appMediaViewer = AppMediaViewer; -export const appDialogsManager = AppDialogsManager; +const appSidebarRight = AppSidebarRight; +const appSidebarLeft = AppSidebarLeft; +const appMediaViewer = AppMediaViewer; +const appDialogsManager = AppDialogsManager; (window as any).Services = { appUsersManager, appChatsManager, apiUpdatesManager, appMessagesManager, + appMessagesIDsManager, appPeersManager, appProfileManager, appPhotosManager, diff --git a/src/pages/pageSignUp.ts b/src/pages/pageSignUp.ts index 394e4e46..d99a34ff 100644 --- a/src/pages/pageSignUp.ts +++ b/src/pages/pageSignUp.ts @@ -4,16 +4,16 @@ import pageIm from './pageIm'; import apiManager from '../lib/mtproto/mtprotoworker'; import Page from './page'; import popupAvatar from '../components/popupAvatar'; -import appProfileManager from '../lib/appManagers/appProfileManager'; let authCode: { 'phone_number': string, 'phone_code_hash': string } = null; -let onFirstMount = () => { +let onFirstMount = () => import('../lib/appManagers/appProfileManager').then(imported => { const pageElement = page.pageEl; const avatarPreview = pageElement.querySelector('#canvas-avatar') as HTMLCanvasElement; + const appProfileManager = imported.default; let uploadAvatar: () => Promise; pageElement.querySelector('.auth-image').addEventListener('click', () => { @@ -114,7 +114,7 @@ let onFirstMount = () => { } }); }); -}; +}); const page = new Page('page-signUp', true, onFirstMount, (_authCode: typeof authCode) => { authCode = _authCode; diff --git a/src/scss/partials/_chat.scss b/src/scss/partials/_chat.scss index ec56b349..731f8f7a 100644 --- a/src/scss/partials/_chat.scss +++ b/src/scss/partials/_chat.scss @@ -20,7 +20,9 @@ $time-background: rgba(0, 0, 0, .35); } @include respond-to(handhelds) { - margin-bottom: 60px; + & + #bubbles { + margin-top: 60px; + } } } diff --git a/src/types.d.ts b/src/types.d.ts index 3a77ee0c..39fd45e5 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -1,249 +1,45 @@ -// Type definitions for jsbn v1.2.29 -// Project: http://www-cs-students.stanford.edu/%7Etjw/jsbn/ -// Definitions by: Eugene Chernyshov , Al Tabayoyon -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export class SecureRandom { - nextBytes(bytes: number[]): void; -} - -export class BigInteger { - constructor(a: number, c: SecureRandom); - constructor(a: number, b: number, c: SecureRandom); - constructor(a: string, b?: number); - constructor(a: number[], b?: number); - constructor(a: BigInteger); - - s: number; - t: number; - data: number[]; // forge specific - - DB: number; - DM: number; - DV: number; - - FV: number; - F1: number; - F2: number; - - // am: Compute w_j += (x*this_i), propagate carries, - am(i: number, x: number, w: BigInteger, j: number, c: number, n: number): number; - - // (protected) copy this to r - copyTo(r: BigInteger): void; - - // (protected) set from integer value x, -DV <= x < DV - fromInt(x: number): void; - - // (protected) set from string and radix - fromString(x: string, b: number): void; - - // (protected) clamp off excess high words - clamp(): void; - - // (public) return string representation in given radix - toString(b?: number): string; - - // (public) -this - negate(): BigInteger; - - // (public) |this| - abs(): BigInteger; - - // (public) return + if this > a, - if this < a, 0 if equal - compareTo(a: BigInteger): number; - - // (public) return the number of bits in "this" - bitLength(): number; - - // (protected) r = this << n*DB - dlShiftTo(n: number, r: BigInteger): void; - - // (protected) r = this >> n*DB - drShiftTo(n: number, r: BigInteger): void; - - // (protected) r = this << n - lShiftTo(n: number, r: BigInteger): void; - - // (protected) r = this >> n - rShiftTo(n: number, r: BigInteger): void; - - // (protected) r = this - a - subTo(a: BigInteger, r: BigInteger): void; - - // (protected) r = this * a, r != this,a (HAC 14.12) - multiplyTo(a: BigInteger, r: BigInteger): void; - - // (protected) r = this^2, r != this (HAC 14.16) - squareTo(r: BigInteger): void; - - // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20) - // r != q, this != m. q or r may be null. - divRemTo(m: BigInteger, q: BigInteger, r: BigInteger): void; - - // (public) this mod a - mod(a: BigInteger): BigInteger; - - // (protected) return "-1/this % 2^DB"; useful for Mont. reduction - invDigit(): number; - - // (protected) true iff this is even - isEven(): boolean; - - // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79) - exp(e: number, z: Reduction): BigInteger; - - // (public) this^e % m, 0 <= e < 2^32 - modPowInt(e: number, m: BigInteger): BigInteger; - - // (public) - clone(): BigInteger; - - // (public) return value as integer - intValue(): number; - - // (public) return value as byte - byteValue(): number; - - // (public) return value as short (assumes DB>=16) - shortValue(): number; - - // (protected) return x s.t. r^x < DV - chunkSize(r: number): number; - - // (public) 0 if this == 0, 1 if this > 0 - signum(): number; - - // (protected) convert to radix string - toRadix(b: number): string; - - // (protected) convert from radix string - fromRadix(s: string, b: number): void; - - // (protected) alternate constructor - fromNumber(a: number, b?: number, c?: number): void; - - // (public) convert to bigendian byte array - toByteArray(): number[]; - - equals(a: BigInteger): boolean; - - min(a: BigInteger): BigInteger; - - max(a: BigInteger): BigInteger; - - // (protected) r = this op a (bitwise) - bitwiseTo(a: BigInteger, op: (x: number, y: number) => number, r: BigInteger): void; - - // (public) this & a - and(a: BigInteger): BigInteger; - - // (public) this | a - or(a: BigInteger): BigInteger; - - // (public) this ^ a - xor(a: BigInteger): BigInteger; - - // (public) this & ~a - andNot(a: BigInteger): BigInteger; - - // (public) ~this - not(): BigInteger; - - // (public) this << n - shiftLeft(n: number): BigInteger; - - // (public) this >> n - shiftRight(n: number): BigInteger; - - // (public) returns index of lowest 1-bit (or -1 if none) - getLowestSetBit(): number; - - // (public) return number of set bits - bitCount(): number; - - // (public) true iff nth bit is set - testBit(n: number): boolean; - - // (protected) this op (1< number): BigInteger; - - // (protected) this op (1<= 0, 1 < n < DV - dMultiply(n: number): void; - - // (protected) this += n << w words, this >= 0 - dAddOffset(n: number, w: number): void; - - // (public) this^e - pow(e: number): BigInteger; - - // (protected) r = lower n words of "this * a", a.t <= n - multiplyLowerTo(a: BigInteger, n: number, r: BigInteger): void; - - // (protected) r = "this * a" without lower n words, n > 0 - multiplyUpperTo(a: BigInteger, n: number, r: BigInteger): void; - - // (public) this^e % m (HAC 14.85) - modPow(e: BigInteger, m: BigInteger): BigInteger; - - // (public) gcd(this,a) (HAC 14.54) - gcd(a: BigInteger): BigInteger; - - // (protected) this % n, n < 2^26 - modInt(n: number): number; - - // (public) 1/this % m (HAC 14.61) - modInverse(m: BigInteger): BigInteger; - - // (public) test primality with certainty >= 1-.5^t - isProbablePrime(t: number): boolean; - - // (protected) true if probably prime (HAC 4.24, Miller-Rabin) - millerRabin(t: number): boolean; - - static ZERO: BigInteger; - static ONE: BigInteger; -} - -export interface Reduction { - convert(x: BigInteger): BigInteger; - revert(x: BigInteger): BigInteger; - reduce(x: BigInteger): void; - mulTo(x: BigInteger, y: BigInteger, r: BigInteger): void; - sqrTo(x: BigInteger, r: BigInteger): void; -} - -export as namespace jsbn; +export type MTDocument = { + _: 'document' | 'documentEmpty', + pFlags: any, + flags: number, + id: string, + access_hash: string, + file_reference: Uint8Array | number[], + date: number, + mime_type: string, + size: number, + thumbs: MTPhotoSize[], + dc_id: number, + attributes: any[], + + thumb?: MTPhotoSize, + type?: string, + h?: number, + w?: number, + file_name?: string, + file?: File, + duration?: number, + downloaded?: boolean, + url?: string, + + audioTitle?: string, + audioPerformer?: string, + + sticker?: number, + stickerEmoji?: string, + stickerEmojiRaw?: string, + stickerSetInput?: any, + stickerThumbConverted?: true, + + animated?: boolean +}; + +export type MTPhotoSize = { + _: string, + w?: number, + h?: number, + size?: number, + type?: string, // i, m, x, y, w by asc + location?: any, + bytes?: Uint8Array // if type == 'i' +}; \ No newline at end of file diff --git a/webpack.common.js b/webpack.common.js index a154d300..9fb57615 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -6,8 +6,8 @@ const postcssPresetEnv = require('postcss-preset-env'); const fs = require('fs'); const allowedIPs = ['195.66.140.39', '192.168.31.144', '127.0.0.1', '192.168.31.1', '192.168.31.192']; - const devMode = process.env.NODE_ENV !== 'production'; +const useLocal = false; console.log('DEVMODE:', devMode); @@ -130,15 +130,15 @@ module.exports = { watchContentBase: true, compress: true, http2: true, - https: { + https: useLocal ? undefined : { key: fs.readFileSync(__dirname + '/certs/server-key.pem', 'utf8'), cert: fs.readFileSync(__dirname + '/certs/server-cert.pem', 'utf8') }, - allowedHosts: [ + allowedHosts: useLocal ? undefined : [ 'tweb.enko.club' ], host: '0.0.0.0', - public: 'tweb.enko.club', + public: useLocal ? undefined : 'tweb.enko.club', //host: '192.168.0.105', // '0.0.0.0' //host: 'tweb.enko.club', // '0.0.0.0' port: 443, @@ -161,7 +161,7 @@ module.exports = { } }); }, - sockHost: 'tweb.enko.club', + sockHost: useLocal ? undefined : 'tweb.enko.club', }, plugins: [ new HtmlWebpackPlugin({