Skip to content

Commit

Permalink
tdl rework
Browse files Browse the repository at this point in the history
A semver-major update. Modernizes and simplifies many things.

The tdl client is tidied up and some long-planned changes are implemented.

The non-deprecated API mostly remains the same.

- Dropped suport for tdlib < v1.8.0
- Dropped suport for node.js < v16
- Dropped compatibility with tdl-tdlib-addon
- Removed many deprecated things
- Rewrote the code of the tdl package in TypeScript (from an old version of Flow)
  Some other packages still use Flow-in-comments (that's pretty ok)
- Removed the use of babel
- Removed the custom config of eslint
- Updated the dev dependencies
- client.login is finally a normal update handler
- client.login can now accept the object directly besides a thunk function
- TDLib errors are now wrapped in the TDLibError (extends Error) class
  (this hasn't been done for many years because of backward compatibility)
- Added client.createBareClient() instead of the bare option
- TdlError is replaced with UnknownError and wraps only non-Error exceptions
- Added a possibility to iterate via async js iterators
- Removed the eventemitter3 dependency
- client.off() now returns boolean instead of void; the once? argument is removed
- Added examples/custom-login.js
- removed null from the return type of execute
- tdl-install-types now generates Execute from marked-as-sync functions only
- tdl-install-types now also generates $Function (union of all tdlib function
  codomains)
- See the CHANGELOG update for other changes
  • Loading branch information
eilvelia committed Apr 27, 2024
1 parent 59bfb51 commit 2cd160f
Show file tree
Hide file tree
Showing 52 changed files with 9,393 additions and 11,305 deletions.
12 changes: 7 additions & 5 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
node_modules/
dist/
flow-typed/
flow/
scripts/
vendor/
examples/
/test.js
*.ts
typings-tests/
/temp.js
tests/integration/
tests/types/
typings/
/jest.config.js
/setup-jest.js
*.d.ts
*.js.flow
24 changes: 18 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
{
"parser": "@babel/eslint-parser",
"env": {
"browser": false,
"node": true,
"es6": true
"es2021": true
},
"extends": [
"@bannerets/eslint-config-flow"
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"rules": {
"semi": ["warn", "never"],
"no-redeclare": 0,
"valid-jsdoc": 0
}
"valid-jsdoc": 0,
"no-undef": 0,
"no-constant-condition": 0,
"no-case-declarations": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/no-unused-vars": 0,
"@typescript-eslint/ban-ts-comment": 0
},
"root": true
}
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
*.h linguist-language=C++
*.snap linguist-generated=true
*.shot linguist-generated=true
tdlib-types.d.ts linguist-vendored=true
flow-typed/*.js linguist-vendored=true
tdlib-types.d.ts linguist-generated=true
flow-typed/*.js linguist-generated=true
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ jobs:
node:
- 20
include:
# tdl should still work with node v12 and v14, however the dev
# deps in this repository don't support those versions
- node: 16
os: ubuntu-latest
- node: 18
Expand All @@ -38,14 +36,12 @@ jobs:
run: |
$ErrorActionPreference = "Stop"
$tds = @(
"td-1.8.27",
"td-1.8.26",
"td-1.8.25",
"td-1.8.19",
"td-1.8.14",
"td-1.8.5",
"td-1.8.0",
"td-1.7.0",
"td-1.5.0"
"td-1.8.0"
)
foreach ($td in $tds) {
mkdir $td
Expand Down
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,53 @@

<!-- Hi! -->

## Unreleased tdl@8.0.0

- The compatibility with `tdl-tdlib-addon` is removed. `Client` is no longer
exported.
- TDLib < v1.8.0 is no longer supported.
- Node.js < v16.0.0 is no longer supported.
- The new tdjson interface is now used by default. The `useNewTdjsonInterface`
option in `tdl.configure` is removed; `useOldTdjsonInterface` is added
instead.
- Added `client.iterUpdates()` to receive updates via async iterators as an
alternative to `client.on('update', ...)`. Example:
```javascript
for await (const update of client.iterUpdates()) {
if (update._ === 'updateOption' && update.name === 'my_id') {
console.log(`My ID is ${update.value.value}!`)
break
}
}
```
- The semantics of `client.login` are slightly changed and simplified (the
documentation is updated).
- The TDLib errors are now wrapped in a new `TDLibError` class; `TdlError`
is removed and replaced with `UnknownError`.
- Removed deprecated client options: `receiveTimeout`, `useDefaultVerbosityLevel`,
`disableAuth`, `useMutableRename`, `verbosityLevel`.
- Removed the `bare` client option. `tdl.createBareClient(): Client` is added
instead.
- Removed deprecated client methods: `destroy`, `pause`, `resume`, `connect`,
`connectAndLogin`, `getBackendName`, `setLogFatalErrorCallback`
(`tdl.setLogFatalErrorCallback` is added instead, though still deprecated).
- Removed deprecated exports: `TDL`, `Tdl`.
- Removed deprecated events: `response`, `auth-needed`, `auth-not-needed`. The
`destroy` event is renamed to `close`.
- `client.off` now returns `boolean` instead of `void`; the `once` parameter is
removed. (The `eventemitter3` dependency is also dropped.)
- Internal: The `tdl` client code was rewritten to TypeScript.

## Unreleased tdl-install-types@0.2.0

- Added a `--github-repo` CLI option.
- Added `-h` and `--version` aliases.
- The generator now indicates that the `bytes` parameters are base64.
- The version of `tdl-install-types` is now included in the header of the
generated files.
- No longer generates `null` for return types of `Execute`.
- Functions not marked as synchronous are no longer generated in `Execute`.
- Added `$Function`.

## tdl@7.4.1 (2024-02-16)

Expand Down
20 changes: 0 additions & 20 deletions CONTRIBUTING.md

This file was deleted.

Loading

0 comments on commit 2cd160f

Please sign in to comment.