build: migrated to pnpm, updated and cleaned up deps

This commit is contained in:
teidesu 2022-04-28 16:58:09 +03:00
parent 87f668bc30
commit 2289cc690d
32 changed files with 3709 additions and 6777 deletions

View file

@ -25,29 +25,16 @@ Work-in-progress library for MTProto in TypeScript.
> If you encounter errors related to storage, either
> reset your storage by removing the file, or fix it manually.
What currently works:
- [x] TCP Connection in NodeJS
- [x] Sending & receiving text messages
- [x] Uploading & downloading files
- [x] HTML & Markdown parse modes
- [x] Type-safe filter system
What is not done yet:
- pretty much everything else
## Setting up for development:
```bash
git clone https://github.com/mtcute/mtcute
cd mtcute
yarn install
npx lerna link
pnpm install
# generate code from tl schema
cd packages/tl
yarn generate-code
pnpm run gen-code
```
## Acknowledgements

View file

@ -1,11 +0,0 @@
{
"command": {
"create": {
"license": "MIT",
"author": "Alisa Sireneva <me@tei.su>"
}
},
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true
}

View file

@ -13,40 +13,27 @@
"publish-all": "node scripts/publish.js all"
},
"dependencies": {
"node-gyp": "^8.0.0"
"node-gyp": "^9.0.0"
},
"devDependencies": {
"@types/chai": "^4.2.14",
"@types/debug": "^4.1.5",
"@types/mocha": "^8.2.0",
"@types/chai": "^4.3.1",
"@types/mocha": "^9.1.1",
"@types/node": "^14.14.22",
"@types/node-forge": "^0.9.7",
"@types/node-fetch": "^2.5.10",
"@types/pako": "^1.0.1",
"@types/node-forge": "^1.0.2",
"@types/ws": "^7.4.0",
"@typescript-eslint/eslint-plugin": "^4.15.0",
"@typescript-eslint/parser": "^4.15.0",
"benchmark": "^2.1.4",
"chai": "^4.2.0",
"cheerio": "^1.0.0-rc.5",
"eager-async-pool": "^1.0.0",
"eslint": "^7.19.0",
"eslint-config-prettier": "7.2.0",
"lerna": "^4.0.0",
"mocha": "^8.2.1",
"node-fetch": "^2.6.1",
"node-forge": "^0.10.0",
"node-html-parser": "^3.0.4",
"prettier": "2.2.1",
"ts-node": "^9.1.1",
"typedoc": "^0.20.28",
"typescript": "^4.1.3",
"chai": "^4.3.6",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
"mocha": "^9.2.2",
"node-forge": "^1.3.1",
"prettier": "^2.6.2",
"ts-node": "^10.7.0",
"typedoc": "^0.22.15",
"typescript": "^4.6.3",
"nyc": "^15.1.0",
"glob": "^7.1.7",
"rimraf": "^3.0.2",
"dotenv-flow": "^3.2.0"
},
"workspaces": [
"packages/*"
]
}
}

View file

@ -14,9 +14,9 @@
"dependencies": {
"@types/long": "^4.0.1",
"@types/node": "^15.12.1",
"@mtcute/tl": "~139.0",
"@mtcute/core": "^1.0.0",
"@mtcute/file-id": "^1.0.0",
"@mtcute/tl": "workspace:139.0",
"@mtcute/core": "workspace:^1.0.0",
"@mtcute/file-id": "workspace:^1.0.0",
"eager-async-pool": "^1.0.0",
"file-type": "^16.2.0",
"long": "^4.0.0"

View file

@ -100,7 +100,7 @@ export async function* downloadAsIterable(
},
{ connection }
)
} catch (e) {
} catch (e: any) {
if (e.constructor === tl.errors.FileMigrateXError) {
connection = this._downloadConnections[e.new_dc]
if (!connection) {

View file

@ -361,7 +361,7 @@ export async function _saveStorage(
}
await this.storage.save?.()
} catch (err) {
} catch (err: any) {
this._emitError(err)
}
}

View file

@ -489,7 +489,7 @@ export class Conversation {
it.promise.resolve(msg)
this._queuedNewMessage.popFront()
}
} catch (e) {
} catch (e: any) {
this.client['_emitError'](e)
}

View file

@ -71,7 +71,7 @@ export function makeInspectable(
val = val.toJSON(true)
}
ret[it] = val
} catch (e) {
} catch (e: any) {
ret[it] = "Error: " + e.message
}
})

View file

@ -20,8 +20,8 @@
"dependencies": {
"@types/node": "^15.12.1",
"@types/events": "^3.0.0",
"@mtcute/tl": "~139.0",
"@mtcute/tl-runtime": "^1.0.0",
"@mtcute/tl": "workspace:139.0",
"@mtcute/tl-runtime": "workspace:^1.0.0",
"big-integer": "1.6.48",
"long": "^4.0.0",
"events": "3.2.0"

View file

@ -659,7 +659,7 @@ export class BaseTelegramClient extends EventEmitter {
await this._cachePeersFrom(res)
return res
} catch (e) {
} catch (e: any) {
lastError = e
if (e instanceof tl.errors.InternalError) {

View file

@ -1166,7 +1166,7 @@ export class SessionConnection extends PersistentConnection {
try {
this._doFlush()
} catch (e) {
} catch (e: any) {
this.log.error('flush error: %s', e.stack)
// should not happen unless there's a bug in the code
}

View file

@ -17,6 +17,6 @@
"docs": "npx typedoc"
},
"dependencies": {
"@mtcute/core": "^1.0.0"
"@mtcute/core": "workspace:^1.0.0"
}
}

View file

@ -12,9 +12,9 @@
"build": "tsc"
},
"dependencies": {
"@mtcute/tl": "~139.0",
"@mtcute/core": "^1.0.0",
"@mtcute/client": "^1.0.0",
"@mtcute/tl": "workspace:139.0",
"@mtcute/core": "workspace:^1.0.0",
"@mtcute/client": "workspace:^1.0.0",
"events": "^3.2.0"
}
}

View file

@ -447,7 +447,7 @@ export class Dispatcher<State = never, SceneName extends string = string> {
break
}
} catch (e) {
} catch (e: any) {
if (this._errorHandler) {
const handled = await this._errorHandler(
e,

View file

@ -225,7 +225,7 @@ export class UpdateState<State, SceneName extends string = string> {
async throttle(key: string, limit: number, window: number): Promise<[number, number]> {
try {
return await this.rateLimit(key, limit, window)
} catch (e) {
} catch (e: any) {
if (e.constructor === RateLimitError) {
await sleep(e.reset - Date.now())
return this.throttle(key, limit, window)

View file

@ -12,9 +12,9 @@
"build": "tsc"
},
"dependencies": {
"@mtcute/tl": "~139.0",
"@mtcute/tl-runtime": "^1.0.0",
"@mtcute/core": "^1.0.0",
"@mtcute/tl": "workspace:139.0",
"@mtcute/tl-runtime": "workspace:^1.0.0",
"@mtcute/core": "workspace:^1.0.0",
"long": "^4.0.0"
},
"devDependencies": {

View file

@ -13,7 +13,7 @@
"docs": "npx typedoc"
},
"dependencies": {
"@mtcute/tl": "~139.0",
"@mtcute/tl": "workspace:~139.0",
"htmlparser2": "^6.0.1",
"long": "^4.0.0"
},

View file

@ -12,6 +12,6 @@
"build": "tsc"
},
"dependencies": {
"@mtcute/core": "^1.0.0"
"@mtcute/core": "workspace:^1.0.0"
}
}

View file

@ -13,11 +13,11 @@
"docs": "npx typedoc"
},
"dependencies": {
"@mtcute/tl": "~139.0",
"@mtcute/tl": "workspace:139.0",
"long": "^4.0.0"
},
"devDependencies": {
"@mtcute/client": "^1.0.0",
"@mtcute/client": "workspace:^1.0.0",
"@types/long": "^4.0.1"
}
}

View file

@ -12,7 +12,7 @@
"build": "tsc"
},
"dependencies": {
"@mtcute/core": "^1.0.0",
"@mtcute/core": "workspace:^1.0.0",
"big-integer": "1.6.48"
}
}

View file

@ -12,11 +12,11 @@
"build": "tsc"
},
"dependencies": {
"@mtcute/core": "^1.0.0",
"@mtcute/client": "^1.0.0",
"@mtcute/sqlite": "^1.0.0",
"@mtcute/markdown-parser": "^1.0.0",
"@mtcute/html-parser": "^1.0.0",
"@mtcute/dispatcher": "^1.0.0"
"@mtcute/core": "workspace:^1.0.0",
"@mtcute/client": "workspace:^1.0.0",
"@mtcute/sqlite": "workspace:^1.0.0",
"@mtcute/markdown-parser": "workspace:^1.0.0",
"@mtcute/html-parser": "workspace:^1.0.0",
"@mtcute/dispatcher": "workspace:^1.0.0"
}
}

View file

@ -12,7 +12,7 @@
"build": "tsc"
},
"dependencies": {
"@mtcute/core": "^1.0.0",
"@mtcute/core": "workspace:^1.0.0",
"ip6": "^0.2.6"
}
}

View file

@ -7,11 +7,11 @@ import {
LruMap,
TlBinaryWriter,
toggleChannelIdMark,
tl,
throttle,
Logger,
} from '@mtcute/core'
import { tl } from '@mtcute/tl'
import sqlite3 from 'better-sqlite3'
import { throttle } from '@mtcute/core'
import { Logger } from '@mtcute/core/src/utils/logger'
import { TlBinaryReader, TlReaderMap, TlWriterMap } from '../tl-runtime'
// todo: add testMode to "self"
@ -54,46 +54,57 @@ const CURRENT_VERSION = 2
// language=SQLite
const SCHEMA = `
create table kv (
key text primary key,
create table kv
(
key text primary key,
value text not null
);
create table state (
key text primary key,
value text not null,
create table state
(
key text primary key,
value text not null,
expires number
);
create table auth_keys (
dc integer primary key,
create table auth_keys
(
dc integer primary key,
key blob not null
);
create table pts (
create table pts
(
channel_id integer primary key,
pts integer not null
pts integer not null
);
create table entities (
id integer primary key,
hash text not null,
type text not null,
create table entities
(
id integer primary key,
hash text not null,
type text not null,
username text,
phone text,
updated integer not null,
"full" blob
phone text,
updated integer not null,
"full" blob
);
create index idx_entities_username on entities (username);
create index idx_entities_phone on entities (phone);
`
const RESET = `
delete from kv where key <> 'ver';
delete from state;
delete from auth_keys;
delete from pts;
delete from entities
delete
from kv
where key <> 'ver';
delete
from state;
delete
from auth_keys;
delete
from pts;
delete
from entities
`
const USERNAME_TTL = 86400000 // 24 hours

View file

@ -12,8 +12,8 @@
"build": "tsc"
},
"dependencies": {
"@mtcute/core": "^1.0.0",
"@mtcute/tl-runtime": "^1.0.0",
"@mtcute/core": "workspace:^1.0.0",
"@mtcute/tl-runtime": "workspace:^1.0.0",
"better-sqlite3": "^7.4.0",
"long": "^4.0.0"
},

View file

@ -16,10 +16,10 @@
},
"dependencies": {
"long": "4.0.0",
"crc-32": "1.2.0",
"pako": "2.0.2"
},
"devDependencies": {
"@types/long": "4.0.1"
"@types/long": "4.0.1",
"@types/pako": "^1.0.1"
}
}

View file

@ -8,7 +8,7 @@ export function gzipDeflate(buf: Buffer, maxRatio?: number): Buffer | null {
if (maxRatio) {
try {
return deflateSync(buf, { maxOutputLength: Math.floor(buf.length * maxRatio) })
} catch (e) {
} catch (e: any) {
if (e.code === 'ERR_BUFFER_TOO_LARGE') {
return null
}

View file

@ -1,6 +1,11 @@
import { typedArrayToBuffer } from '../buffer-utils'
import { Data, Deflate, inflate } from 'pako'
export function typedArrayToBuffer(arr: NodeJS.TypedArray): Buffer {
return ArrayBuffer.isView(arr)
? Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength)
: Buffer.from(arr)
}
export function gzipInflate(buf: Buffer): Buffer {
return typedArrayToBuffer(inflate(buf))
}

View file

@ -15,11 +15,6 @@
"./platform/gzip.js": "./platform/gzip.web.js"
},
"dependencies": {
"long": "4.0.0",
"crc-32": "1.2.0",
"pako": "2.0.2"
},
"devDependencies": {
"@types/long": "4.0.1"
"crc-32": "1.2.0"
}
}

View file

@ -21,10 +21,12 @@
"long": "^4.0.0"
},
"devDependencies": {
"@mtcute/tl-utils": "^1.0.0",
"@mtcute/core": "^1.0.0",
"@mtcute/tl-utils": "workspace:^1.0.0",
"@mtcute/core": "workspace:^1.0.0",
"cheerio": "^1.0.0-rc.5",
"csv-parser": "^3.0.0",
"js-yaml": "^4.0.0"
"js-yaml": "^4.0.0",
"node-fetch": "^2.6.1",
"@types/node-fetch": "^2.5.10"
}
}

3606
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load diff

2
pnpm-workspace.yaml Normal file
View file

@ -0,0 +1,2 @@
packages:
- packages/*

6652
yarn.lock

File diff suppressed because it is too large Load diff