build(deps): bumped prettier to 3.0.3

This commit is contained in:
alina 🌸 2023-10-06 21:15:52 +03:00 committed by Alina Tumanova
parent 75021648eb
commit a6726ccb40
55 changed files with 271 additions and 82 deletions

View file

@ -44,7 +44,7 @@
"mocha": "10.2.0", "mocha": "10.2.0",
"node-forge": "1.3.1", "node-forge": "1.3.1",
"nyc": "15.1.0", "nyc": "15.1.0",
"prettier": "2.8.8", "prettier": "3.0.3",
"rimraf": "5.0.1", "rimraf": "5.0.1",
"semver": "7.5.1", "semver": "7.5.1",
"ts-node": "10.9.1", "ts-node": "10.9.1",

View file

@ -42,7 +42,9 @@ export async function hideMyStoriesViews(
const upd = res.updates.find(hasValueAtKey('_', 'updateStoriesStealthMode')) const upd = res.updates.find(hasValueAtKey('_', 'updateStoriesStealthMode'))
if (!upd) { throw new MtTypeAssertionError('hideMyStoriesViews (@ res.updates[*])', 'updateStoriesStealthMode', 'none') } if (!upd) {
throw new MtTypeAssertionError('hideMyStoriesViews (@ res.updates[*])', 'updateStoriesStealthMode', 'none')
}
return new StoriesStealthMode(upd.stealthMode) return new StoriesStealthMode(upd.stealthMode)
} }

View file

@ -8,7 +8,11 @@ import { PeersIndex, User } from '../peers'
* Game high score * Game high score
*/ */
export class GameHighScore { export class GameHighScore {
constructor(readonly client: TelegramClient, readonly raw: tl.RawHighScore, readonly _peers: PeersIndex) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawHighScore,
readonly _peers: PeersIndex,
) {}
private _user?: User private _user?: User
/** /**

View file

@ -43,7 +43,10 @@ export class Conversation {
private _pendingRead: Map<number, QueuedHandler<void>> = new Map() private _pendingRead: Map<number, QueuedHandler<void>> = new Map()
constructor(readonly client: TelegramClient, readonly chat: InputPeerLike) { constructor(
readonly client: TelegramClient,
readonly chat: InputPeerLike,
) {
this._onNewMessage = this._onNewMessage.bind(this) this._onNewMessage = this._onNewMessage.bind(this)
this._onEditMessage = this._onEditMessage.bind(this) this._onEditMessage = this._onEditMessage.bind(this)
this._onHistoryRead = this._onHistoryRead.bind(this) this._onHistoryRead = this._onHistoryRead.bind(this)

View file

@ -11,7 +11,11 @@ export class MtPeerNotFoundError extends MtcuteError {}
* Could not find a message by the provided information * Could not find a message by the provided information
*/ */
export class MtMessageNotFoundError extends MtcuteError { export class MtMessageNotFoundError extends MtcuteError {
constructor(readonly peerId: number, readonly messageId: number, readonly context?: string) { constructor(
readonly peerId: number,
readonly messageId: number,
readonly context?: string,
) {
super(`Message${context ? ' ' + context : ''} ${messageId} not found in ${peerId}`) super(`Message${context ? ' ' + context : ''} ${messageId} not found in ${peerId}`)
} }
} }

View file

@ -19,7 +19,10 @@ const STUB_LOCATION = () => {
* > To be sure, check `isDownloadable` property. * > To be sure, check `isDownloadable` property.
*/ */
export class WebDocument extends FileLocation { export class WebDocument extends FileLocation {
constructor(client: TelegramClient, readonly raw: tl.TypeWebDocument) { constructor(
client: TelegramClient,
readonly raw: tl.TypeWebDocument,
) {
super( super(
client, client,
raw._ === 'webDocument' ? raw._ === 'webDocument' ?

View file

@ -15,7 +15,11 @@ export class Audio extends RawDocument {
return tdFileId.FileType.Audio return tdFileId.FileType.Audio
} }
constructor(client: TelegramClient, doc: tl.RawDocument, readonly attr: tl.RawDocumentAttributeAudio) { constructor(
client: TelegramClient,
doc: tl.RawDocument,
readonly attr: tl.RawDocumentAttributeAudio,
) {
super(client, doc) super(client, doc)
} }

View file

@ -14,7 +14,10 @@ import { Thumbnail } from './thumbnail'
export abstract class RawDocument extends FileLocation { export abstract class RawDocument extends FileLocation {
abstract type: string abstract type: string
constructor(client: TelegramClient, readonly raw: tl.RawDocument) { constructor(
client: TelegramClient,
readonly raw: tl.RawDocument,
) {
super( super(
client, client,
{ {

View file

@ -8,7 +8,10 @@ import { Video } from './video'
export class Game { export class Game {
readonly type = 'game' as const readonly type = 'game' as const
constructor(readonly client: TelegramClient, readonly game: tl.RawGame) {} constructor(
readonly client: TelegramClient,
readonly game: tl.RawGame,
) {}
/** /**
* Unique identifier of the game. * Unique identifier of the game.

View file

@ -15,7 +15,10 @@ import { Thumbnail } from './thumbnail'
export type InvoiceExtendedMediaState = 'none' | 'preview' | 'full' export type InvoiceExtendedMediaState = 'none' | 'preview' | 'full'
export class InvoiceExtendedMediaPreview { export class InvoiceExtendedMediaPreview {
constructor(public readonly client: TelegramClient, public readonly raw: tl.RawMessageExtendedMediaPreview) {} constructor(
public readonly client: TelegramClient,
public readonly raw: tl.RawMessageExtendedMediaPreview,
) {}
/** /**
* Width of the preview, in pixels (if available, else 0) * Width of the preview, in pixels (if available, else 0)
@ -55,7 +58,10 @@ export class InvoiceExtendedMediaPreview {
export class Invoice { export class Invoice {
readonly type = 'invoice' as const readonly type = 'invoice' as const
constructor(readonly client: TelegramClient, readonly raw: tl.RawMessageMediaInvoice) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawMessageMediaInvoice,
) {}
/** /**
* Whether the shipping address was requested * Whether the shipping address was requested

View file

@ -8,7 +8,10 @@ import { FileLocation } from '../files'
* A point on the map * A point on the map
*/ */
export class RawLocation { export class RawLocation {
constructor(readonly client: TelegramClient, readonly geo: tl.RawGeoPoint) {} constructor(
readonly client: TelegramClient,
readonly geo: tl.RawGeoPoint,
) {}
/** /**
* Geo point latitude * Geo point latitude
@ -107,7 +110,10 @@ export class Location extends RawLocation {
export class LiveLocation extends RawLocation { export class LiveLocation extends RawLocation {
readonly type = 'live_location' as const readonly type = 'live_location' as const
constructor(client: TelegramClient, readonly live: tl.RawMessageMediaGeoLive) { constructor(
client: TelegramClient,
readonly live: tl.RawMessageMediaGeoLive,
) {
super(client, live.geo as tl.RawGeoPoint) super(client, live.geo as tl.RawGeoPoint)
} }

View file

@ -19,7 +19,11 @@ export class Photo extends FileLocation {
private _bestSize?: tl.RawPhotoSize | tl.RawPhotoSizeProgressive private _bestSize?: tl.RawPhotoSize | tl.RawPhotoSizeProgressive
constructor(client: TelegramClient, readonly raw: tl.RawPhoto, readonly media?: tl.RawMessageMediaPhoto) { constructor(
client: TelegramClient,
readonly raw: tl.RawPhoto,
readonly media?: tl.RawMessageMediaPhoto,
) {
const location = { const location = {
_: 'inputPhotoFileLocation', _: 'inputPhotoFileLocation',
id: raw.id, id: raw.id,

View file

@ -30,7 +30,10 @@ export interface VenueSource {
export class Venue { export class Venue {
readonly type = 'venue' as const readonly type = 'venue' as const
constructor(readonly client: TelegramClient, readonly raw: tl.RawMessageMediaVenue) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawMessageMediaVenue,
) {}
private _location?: Location private _location?: Location
/** /**

View file

@ -16,7 +16,11 @@ export class Voice extends RawDocument {
return tdFileId.FileType.VoiceNote return tdFileId.FileType.VoiceNote
} }
constructor(client: TelegramClient, doc: tl.RawDocument, readonly attr: tl.RawDocumentAttributeAudio) { constructor(
client: TelegramClient,
doc: tl.RawDocument,
readonly attr: tl.RawDocumentAttributeAudio,
) {
super(client, doc) super(client, doc)
} }

View file

@ -19,7 +19,10 @@ import { Photo } from './photo'
export class WebPage { export class WebPage {
readonly type = 'web_page' as const readonly type = 'web_page' as const
constructor(readonly client: TelegramClient, readonly raw: tl.RawWebPage) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawWebPage,
) {}
/** /**
* Unique ID of the preview * Unique ID of the preview

View file

@ -8,7 +8,10 @@ import { MessageEntity } from './message-entity'
* A draft message * A draft message
*/ */
export class DraftMessage { export class DraftMessage {
constructor(readonly client: TelegramClient, readonly raw: tl.RawDraftMessage) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawDraftMessage,
) {}
/** /**
* Text of the draft message * Text of the draft message

View file

@ -56,7 +56,10 @@ export type MessageEntityKind = MessageEntityParams['kind']
* One special entity in a text message (like mention, hashtag, URL, etc.) * One special entity in a text message (like mention, hashtag, URL, etc.)
*/ */
export class MessageEntity { export class MessageEntity {
constructor(readonly raw: tl.TypeMessageEntity, readonly _text?: string) {} constructor(
readonly raw: tl.TypeMessageEntity,
readonly _text?: string,
) {}
/** /**
* Offset in UTF-16 code units to the start of the entity. * Offset in UTF-16 code units to the start of the entity.

View file

@ -102,7 +102,10 @@ export class StickerSet {
*/ */
readonly isFull: boolean readonly isFull: boolean
constructor(readonly client: TelegramClient, raw: tl.TypeStickerSet | tl.messages.TypeStickerSet) { constructor(
readonly client: TelegramClient,
raw: tl.TypeStickerSet | tl.messages.TypeStickerSet,
) {
if (raw._ === 'messages.stickerSet') { if (raw._ === 'messages.stickerSet') {
this.full = raw this.full = raw
this.brief = raw.set this.brief = raw.set

View file

@ -12,7 +12,10 @@ export class TakeoutSession {
*/ */
readonly id: tl.Long readonly id: tl.Long
constructor(readonly client: TelegramClient, session: tl.account.RawTakeout) { constructor(
readonly client: TelegramClient,
session: tl.account.RawTakeout,
) {
this.id = session.id this.id = session.id
} }

View file

@ -44,7 +44,10 @@ export class FormattedString<T extends string = never> {
* @param value Value that the string holds * @param value Value that the string holds
* @param mode Name of the parse mode used * @param mode Name of the parse mode used
*/ */
constructor(readonly value: string, readonly mode?: T) {} constructor(
readonly value: string,
readonly mode?: T,
) {}
toString(): string { toString(): string {
return this.value return this.value

View file

@ -6,7 +6,11 @@ import { PeersIndex } from './peers-index'
import { User } from './user' import { User } from './user'
export class ChatInviteLinkMember { export class ChatInviteLinkMember {
constructor(readonly client: TelegramClient, readonly raw: tl.RawChatInviteImporter, readonly _peers: PeersIndex) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawChatInviteImporter,
readonly _peers: PeersIndex,
) {}
private _user?: User private _user?: User
/** /**

View file

@ -12,7 +12,11 @@ import { User } from './user'
export class ChatInviteLink { export class ChatInviteLink {
raw: tl.RawChatInviteExported raw: tl.RawChatInviteExported
constructor(readonly client: TelegramClient, raw: tl.TypeExportedChatInvite, readonly _peers?: PeersIndex) { constructor(
readonly client: TelegramClient,
raw: tl.TypeExportedChatInvite,
readonly _peers?: PeersIndex,
) {
assertTypeIsNot('ChatInviteLink', raw, 'chatInvitePublicJoinRequests') assertTypeIsNot('ChatInviteLink', raw, 'chatInvitePublicJoinRequests')
this.raw = raw this.raw = raw
} }

View file

@ -8,7 +8,10 @@ import { Location } from '../media'
* Geolocation of a supergroup * Geolocation of a supergroup
*/ */
export class ChatLocation { export class ChatLocation {
constructor(readonly client: TelegramClient, readonly raw: tl.RawChannelLocation) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawChannelLocation,
) {}
private _location?: Location private _location?: Location
/** /**

View file

@ -35,7 +35,10 @@ export class User {
*/ */
readonly raw: tl.RawUser readonly raw: tl.RawUser
constructor(readonly client: TelegramClient, user: tl.TypeUser) { constructor(
readonly client: TelegramClient,
user: tl.TypeUser,
) {
assertTypeIs('User#init', user, 'user') assertTypeIs('User#init', user, 'user')
this.raw = user this.raw = user

View file

@ -9,7 +9,10 @@ import { StoriesStealthMode } from './stealth-mode'
* Returned by {@link TelegramClient.getAllStories} * Returned by {@link TelegramClient.getAllStories}
*/ */
export class AllStories { export class AllStories {
constructor(readonly client: TelegramClient, readonly raw: tl.stories.RawAllStories) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.stories.RawAllStories,
) {}
readonly _peers = PeersIndex.from(this.raw) readonly _peers = PeersIndex.from(this.raw)

View file

@ -8,7 +8,11 @@ import { PeersIndex, User } from '../peers'
* Information about a user who is boosting a channel * Information about a user who is boosting a channel
*/ */
export class Booster { export class Booster {
constructor(readonly client: TelegramClient, readonly raw: tl.RawBooster, readonly _peers: PeersIndex) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawBooster,
readonly _peers: PeersIndex,
) {}
/** /**
* Date when this boost will automatically expire. * Date when this boost will automatically expire.

View file

@ -5,7 +5,10 @@ import { TelegramClient } from '../../../client'
export abstract class StoryInteractiveArea { export abstract class StoryInteractiveArea {
abstract type: string abstract type: string
constructor(readonly client: TelegramClient, readonly raw: Exclude<tl.TypeMediaArea, tl.RawInputMediaAreaVenue>) { constructor(
readonly client: TelegramClient,
readonly raw: Exclude<tl.TypeMediaArea, tl.RawInputMediaAreaVenue>,
) {
this.raw = raw this.raw = raw
} }

View file

@ -12,7 +12,10 @@ import { StoryInteractiveArea } from './base'
export class StoryInteractiveLocation extends StoryInteractiveArea { export class StoryInteractiveLocation extends StoryInteractiveArea {
readonly type = 'location' as const readonly type = 'location' as const
constructor(client: TelegramClient, readonly raw: tl.RawMediaAreaGeoPoint) { constructor(
client: TelegramClient,
readonly raw: tl.RawMediaAreaGeoPoint,
) {
super(client, raw) super(client, raw)
} }

View file

@ -15,7 +15,10 @@ import { StoryInteractiveArea } from './base'
export class StoryInteractiveReaction extends StoryInteractiveArea { export class StoryInteractiveReaction extends StoryInteractiveArea {
readonly type = 'reaction' as const readonly type = 'reaction' as const
constructor(client: TelegramClient, readonly raw: tl.RawMediaAreaSuggestedReaction) { constructor(
client: TelegramClient,
readonly raw: tl.RawMediaAreaSuggestedReaction,
) {
super(client, raw) super(client, raw)
} }

View file

@ -12,7 +12,10 @@ import { StoryInteractiveArea } from './base'
export class StoryInteractiveVenue extends StoryInteractiveArea { export class StoryInteractiveVenue extends StoryInteractiveArea {
readonly type = 'venue' as const readonly type = 'venue' as const
constructor(client: TelegramClient, readonly raw: tl.RawMediaAreaVenue) { constructor(
client: TelegramClient,
readonly raw: tl.RawMediaAreaVenue,
) {
super(client, raw) super(client, raw)
} }

View file

@ -6,7 +6,11 @@ import { Chat, PeersIndex, User } from '../peers'
import { Story } from './story' import { Story } from './story'
export class PeerStories { export class PeerStories {
constructor(readonly client: TelegramClient, readonly raw: tl.RawPeerStories, readonly _peers: PeersIndex) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawPeerStories,
readonly _peers: PeersIndex,
) {}
private _peer?: User | Chat private _peer?: User | Chat
/** /**

View file

@ -9,7 +9,11 @@ import { ReactionCount } from '../reactions/reaction-count'
* Brief information about story views/interactions * Brief information about story views/interactions
*/ */
export class StoryInteractions { export class StoryInteractions {
constructor(readonly client: TelegramClient, readonly raw: tl.RawStoryViews, readonly _peers: PeersIndex) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawStoryViews,
readonly _peers: PeersIndex,
) {}
/** /**
* Whether information about viewers is available. * Whether information about viewers is available.

View file

@ -9,7 +9,11 @@ import { ReactionEmoji, toReactionEmoji } from '../reactions'
* Information about a single user who has viewed a story. * Information about a single user who has viewed a story.
*/ */
export class StoryViewer { export class StoryViewer {
constructor(readonly client: TelegramClient, readonly raw: tl.RawStoryView, readonly _peers: PeersIndex) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawStoryView,
readonly _peers: PeersIndex,
) {}
/** Whether this user is in current user's global blacklist */ /** Whether this user is in current user's global blacklist */
get isBlocked(): boolean { get isBlocked(): boolean {
@ -46,7 +50,10 @@ makeInspectable(StoryViewer)
* List of story viewers. * List of story viewers.
*/ */
export class StoryViewersList { export class StoryViewersList {
constructor(readonly client: TelegramClient, readonly raw: tl.stories.RawStoryViewsList) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.stories.RawStoryViewsList,
) {}
readonly _peers = PeersIndex.from(this.raw) readonly _peers = PeersIndex.from(this.raw)

View file

@ -22,7 +22,11 @@ export type StoryVisibility = 'public' | 'contacts' | 'selected_contacts' | 'clo
export type StoryMedia = Photo | Video export type StoryMedia = Photo | Video
export class Story { export class Story {
constructor(readonly client: TelegramClient, readonly raw: tl.RawStoryItem, readonly _peers: PeersIndex) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawStoryItem,
readonly _peers: PeersIndex,
) {}
/** Whether this story is pinned */ /** Whether this story is pinned */
get isPinned(): boolean { get isPinned(): boolean {

View file

@ -11,7 +11,11 @@ import { PeersIndex, User } from '../peers'
* interacts with the bot. * interacts with the bot.
*/ */
export class BotStoppedUpdate { export class BotStoppedUpdate {
constructor(readonly client: TelegramClient, readonly raw: tl.RawUpdateBotStopped, readonly _peers: PeersIndex) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawUpdateBotStopped,
readonly _peers: PeersIndex,
) {}
/** /**
* ID of the user who stopped or restarted the bot * ID of the user who stopped or restarted the bot

View file

@ -5,7 +5,11 @@ import { makeInspectable } from '../../utils'
* A story was deleted * A story was deleted
*/ */
export class DeleteStoryUpdate { export class DeleteStoryUpdate {
constructor(readonly client: TelegramClient, readonly raw: tl.RawUpdateStory, readonly _peers: PeersIndex) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawUpdateStory,
readonly _peers: PeersIndex,
) {}
private _peer?: User | Chat private _peer?: User | Chat
/** /**

View file

@ -12,7 +12,11 @@ import { PeersIndex, Poll } from '../'
* polls which were sent by this bot * polls which were sent by this bot
*/ */
export class PollUpdate { export class PollUpdate {
constructor(readonly client: TelegramClient, readonly raw: tl.RawUpdateMessagePoll, readonly _peers: PeersIndex) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawUpdateMessagePoll,
readonly _peers: PeersIndex,
) {}
/** /**
* Unique poll ID * Unique poll ID

View file

@ -8,7 +8,11 @@ import { assertTypeIs, makeInspectable } from '../../utils'
* > is to store known stories IDs and compare them to the one in the update. * > is to store known stories IDs and compare them to the one in the update.
*/ */
export class StoryUpdate { export class StoryUpdate {
constructor(readonly client: TelegramClient, readonly raw: tl.RawUpdateStory, readonly _peers: PeersIndex) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawUpdateStory,
readonly _peers: PeersIndex,
) {}
private _peer?: User | Chat private _peer?: User | Chat
/** /**

View file

@ -8,7 +8,10 @@ import { User, UserParsedStatus, UserStatus } from '../'
* User status has changed * User status has changed
*/ */
export class UserStatusUpdate { export class UserStatusUpdate {
constructor(readonly client: TelegramClient, readonly raw: tl.RawUpdateUserStatus) {} constructor(
readonly client: TelegramClient,
readonly raw: tl.RawUpdateUserStatus,
) {}
/** /**
* ID of the user whose status has updated * ID of the user whose status has updated

View file

@ -4,7 +4,10 @@ export class RpsMeter {
_hits: Deque<bigint> _hits: Deque<bigint>
time: bigint time: bigint
constructor(readonly size = 500, time = 5000) { constructor(
readonly size = 500,
time = 5000,
) {
if (typeof process === 'undefined' || !process.hrtime.bigint) { if (typeof process === 'undefined' || !process.hrtime.bigint) {
throw new Error('RPS meter is not supported on this platform') throw new Error('RPS meter is not supported on this platform')
} }

View file

@ -15,7 +15,11 @@ export class AuthKey {
clientSalt!: Buffer clientSalt!: Buffer
serverSalt!: Buffer serverSalt!: Buffer
constructor(readonly _crypto: ICryptoProvider, readonly log: Logger, readonly _readerMap: TlReaderMap) {} constructor(
readonly _crypto: ICryptoProvider,
readonly log: Logger,
readonly _readerMap: TlReaderMap,
) {}
match(keyId: Buffer): boolean { match(keyId: Buffer): boolean {
return this.ready && buffersEqual(keyId, this.id) return this.ready && buffersEqual(keyId, this.id)

View file

@ -12,7 +12,12 @@ export class MultiSessionConnection extends EventEmitter {
readonly _sessions: MtprotoSession[] readonly _sessions: MtprotoSession[]
private _enforcePfs = false private _enforcePfs = false
constructor(readonly params: SessionConnectionParams, private _count: number, log: Logger, logPrefix = '') { constructor(
readonly params: SessionConnectionParams,
private _count: number,
log: Logger,
logPrefix = '',
) {
super() super()
this._log = log.create('multi') this._log = log.create('multi')
if (logPrefix) this._log.prefix = `[${logPrefix}] ` if (logPrefix) this._log.prefix = `[${logPrefix}] `

View file

@ -365,7 +365,10 @@ export class NetworkManager {
private _lastUpdateTime = 0 private _lastUpdateTime = 0
private _updateHandler: (upd: tl.TypeUpdates) => void = () => {} private _updateHandler: (upd: tl.TypeUpdates) => void = () => {}
constructor(readonly params: NetworkManagerParams & NetworkManagerExtraParams, readonly config: ConfigManager) { constructor(
readonly params: NetworkManagerParams & NetworkManagerExtraParams,
readonly config: ConfigManager,
) {
let deviceModel = 'mtcute on ' let deviceModel = 'mtcute on '
let appVersion = 'unknown' let appVersion = 'unknown'
if (typeof process !== 'undefined' && typeof require !== 'undefined') { if (typeof process !== 'undefined' && typeof require !== 'undefined') {

View file

@ -50,7 +50,10 @@ export abstract class PersistentConnection extends EventEmitter {
protected abstract onMessage(data: Buffer): void protected abstract onMessage(data: Buffer): void
protected constructor(params: PersistentConnectionParams, readonly log: Logger) { protected constructor(
params: PersistentConnectionParams,
readonly log: Logger,
) {
super() super()
this.params = params this.params = params
this.changeTransport(params.transportFactory) this.changeTransport(params.transportFactory)

View file

@ -73,7 +73,10 @@ export class SessionConnection extends PersistentConnection {
private _readerMap: TlReaderMap private _readerMap: TlReaderMap
private _writerMap: TlWriterMap private _writerMap: TlWriterMap
constructor(params: SessionConnectionParams, readonly _session: MtprotoSession) { constructor(
params: SessionConnectionParams,
readonly _session: MtprotoSession,
) {
super(params, _session.log.create('conn')) super(params, _session.log.create('conn'))
this._flushTimer.onTimeout(this._flush.bind(this)) this._flushTimer.onTimeout(this._flush.bind(this))
@ -433,11 +436,14 @@ export class SessionConnection extends PersistentConnection {
this.onConnectionUsable() this.onConnectionUsable()
// set a timeout to update temp auth key in advance to avoid interruption // set a timeout to update temp auth key in advance to avoid interruption
this._pfsUpdateTimeout = setTimeout(() => { this._pfsUpdateTimeout = setTimeout(
() => {
this._pfsUpdateTimeout = undefined this._pfsUpdateTimeout = undefined
this.log.debug('temp key is expiring soon') this.log.debug('temp key is expiring soon')
this._authorizePfs(true) this._authorizePfs(true)
}, (TEMP_AUTH_KEY_EXPIRY - 60) * 1000) },
(TEMP_AUTH_KEY_EXPIRY - 60) * 1000,
)
}) })
.catch((err: Error) => { .catch((err: Error) => {
this.log.error('PFS Authorization error: %s', err.message) this.log.error('PFS Authorization error: %s', err.message)

View file

@ -9,8 +9,9 @@ const b64urlAvailable = Buffer.isEncoding('base64url')
* @param arr Typed array to convert * @param arr Typed array to convert
*/ */
export function typedArrayToBuffer(arr: NodeJS.TypedArray): Buffer { export function typedArrayToBuffer(arr: NodeJS.TypedArray): Buffer {
return ArrayBuffer.isView(arr) ? // To avoid a copy, use the typed array's underlying ArrayBuffer to back // To avoid a copy, use the typed array's underlying ArrayBuffer to back
// new Buffer, respecting the "view", i.e. byteOffset and byteLength // new Buffer, respecting the "view", i.e. byteOffset and byteLength
return ArrayBuffer.isView(arr) ?
Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength) : // Pass through all other types to `Buffer.from` Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength) : // Pass through all other types to `Buffer.from`
Buffer.from(arr) Buffer.from(arr)
} }

View file

@ -23,7 +23,10 @@ export class Deque<T> {
protected _tail = 0 protected _tail = 0
protected _capacity: number protected _capacity: number
constructor(minCapacity = MIN_INITIAL_CAPACITY, readonly maxLength = Infinity) { constructor(
minCapacity = MIN_INITIAL_CAPACITY,
readonly maxLength = Infinity,
) {
let capacity = minCapacity let capacity = minCapacity
if (capacity >= MIN_INITIAL_CAPACITY) { if (capacity >= MIN_INITIAL_CAPACITY) {

View file

@ -26,7 +26,11 @@ export class Logger {
prefix = '' prefix = ''
constructor(readonly mgr: LogManager, readonly tag: string, readonly parent: Logger = mgr) { constructor(
readonly mgr: LogManager,
readonly tag: string,
readonly parent: Logger = mgr,
) {
let hash = 0 let hash = 0
for (let i = 0; i < tag.length; i++) { for (let i = 0; i < tag.length; i++) {

View file

@ -9,7 +9,10 @@
export class SortedArray<T> { export class SortedArray<T> {
readonly raw: T[] readonly raw: T[]
constructor(array: T[] = [], readonly comparator: (a: T, b: T) => number) { constructor(
array: T[] = [],
readonly comparator: (a: T, b: T) => number,
) {
this.raw = array.sort(comparator) this.raw = array.sort(comparator)
this.comparator = comparator this.comparator = comparator
} }

View file

@ -19,7 +19,10 @@ export class CallbackDataBuilder<T extends string> {
* @param prefix Prefix for the data. Use something unique across your bot. * @param prefix Prefix for the data. Use something unique across your bot.
* @param fields Field names in the order they will be serialized. * @param fields Field names in the order they will be serialized.
*/ */
constructor(public prefix: string, ...fields: T[]) { constructor(
public prefix: string,
...fields: T[]
) {
this._fields = fields this._fields = fields
} }

View file

@ -30,7 +30,9 @@ export const chatMember: {
* @link User.Status * @link User.Status
*/ */
export const userStatus: { export const userStatus: {
<T extends UserStatus>(status: T): UpdateFilter< <T extends UserStatus>(
status: T,
): UpdateFilter<
UserStatusUpdate, UserStatusUpdate,
{ {
type: T type: T

View file

@ -285,7 +285,8 @@ export class SqliteStorage implements ITelegramStorage, IStateStorage {
this._wal = !params?.disableWal this._wal = !params?.disableWal
this._saveUnimportantLater = throttle(() => { this._saveUnimportantLater = throttle(
() => {
// unimportant changes are changes about cached in memory entities, // unimportant changes are changes about cached in memory entities,
// that don't really need to be cached right away. // that don't really need to be cached right away.
// to avoid redundant DB calls, these changes are persisted // to avoid redundant DB calls, these changes are persisted
@ -301,7 +302,9 @@ export class SqliteStorage implements ITelegramStorage, IStateStorage {
this._updateManyPeers(items) this._updateManyPeers(items)
this._pendingUnimportant = {} this._pendingUnimportant = {}
}, params?.unimportantSavesDelay ?? 30000) },
params?.unimportantSavesDelay ?? 30000,
)
this._vacuumInterval = params?.vacuumInterval ?? 300_000 this._vacuumInterval = params?.vacuumInterval ?? 300_000

View file

@ -42,7 +42,11 @@ export class TlBinaryReader {
* @param data Buffer to read from * @param data Buffer to read from
* @param start Position to start reading from * @param start Position to start reading from
*/ */
constructor(readonly objectsMap: TlReaderMap | undefined, data: Buffer, start = 0) { constructor(
readonly objectsMap: TlReaderMap | undefined,
data: Buffer,
start = 0,
) {
this.data = data this.data = data
this.pos = start this.pos = start
} }

View file

@ -147,7 +147,11 @@ export class TlBinaryWriter {
* @param buffer Buffer to write to * @param buffer Buffer to write to
* @param start Position to start writing at * @param start Position to start writing at
*/ */
constructor(readonly objectMap: TlWriterMap | undefined, buffer: Buffer, start = 0) { constructor(
readonly objectMap: TlWriterMap | undefined,
buffer: Buffer,
start = 0,
) {
this.buffer = buffer this.buffer = buffer
this.pos = start this.pos = start
} }

View file

@ -82,8 +82,8 @@ importers:
specifier: 15.1.0 specifier: 15.1.0
version: 15.1.0 version: 15.1.0
prettier: prettier:
specifier: 2.8.8 specifier: 3.0.3
version: 2.8.8 version: 3.0.3
rimraf: rimraf:
specifier: 5.0.1 specifier: 5.0.1
version: 5.0.1 version: 5.0.1
@ -4235,9 +4235,9 @@ packages:
engines: {node: '>= 0.8.0'} engines: {node: '>= 0.8.0'}
dev: true dev: true
/prettier@2.8.8: /prettier@3.0.3:
resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} resolution: {integrity: sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==}
engines: {node: '>=10.13.0'} engines: {node: '>=14'}
hasBin: true hasBin: true
dev: true dev: true