-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modernize #23
Conversation
Make it be similar to mediasoup-client repo. - [x] Update NPM deps. - [x] Update TypeScript. - [x] Update ESLint. - [x] Remove `lib` from the repo. - [x] Move test to TypeScript. - [ ] Make `FakeRTCDataChannel` properly implement `RTCDataChannel` (see below). - [ ] Add event listener TS types. - [ ] Probably add a `types.ts` and export it. - [ ] Update Python deps?. - [ ] Add CI. ### TODO 1: TypeScript error in `FakeRTCDataChannel` It doesn't implement properly the official `RTCDataChannel` interface. Probably related to its events: ``` src/FakeRTCDataChannel.ts:23:14 - error TS2420: Class 'FakeRTCDataChannel' incorrectly implements interface 'RTCDataChannel'. Types of property 'addEventListener' are incompatible. Type '{ <T extends string>(type: T, callback?: EventListener<this, Event<string>> | null | undefined, options?: AddOptions | undefined): void; (type: string, callback?: EventListener<...> | ... 1 more ... | undefined, options?: AddOptions | undefined): void; <T extends string>(type: T, callback: EventListener<...> | ... 1...' is not assignable to type '{ <K extends keyof RTCDataChannelEventMap>(type: K, listener: (this: RTCDataChannel, ev: RTCDataChannelEventMap[K]) => any, options?: boolean | ... 1 more ... | undefined): void; (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | ... 1 more ... | undefined): void; }'. Types of parameters 'callback' and 'listener' are incompatible. Type '(this: RTCDataChannel, ev: any) => any' is not assignable to type 'EventListener<this, Event<string>> | null | undefined'. Type '(this: RTCDataChannel, ev: any) => any' is not assignable to type 'CallbackFunction<this, Event<string>>'. The 'this' types of each signature are incompatible. Type 'this' is not assignable to type 'RTCDataChannel'. Type 'FakeRTCDataChannel' is not assignable to type 'RTCDataChannel'. Types of property 'addEventListener' are incompatible. Type '{ <T extends string>(type: T, callback?: EventListener<this, Event<string>> | null | undefined, options?: AddOptions | undefined): void; (type: string, callback?: EventListener<...> | ... 1 more ... | undefined, options?: AddOptions | undefined): void; <T extends string>(type: T, callback: EventListener<...> | ... 1...' is not assignable to type '{ <K extends keyof RTCDataChannelEventMap>(type: K, listener: (this: RTCDataChannel, ev: RTCDataChannelEventMap[K]) => any, options?: boolean | ... 1 more ... | undefined): void; (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | ... 1 more ... | undefined): void; }'. Types of parameters 'callback' and 'listener' are incompatible. Type '(this: RTCDataChannel, ev: any) => any' is not assignable to type 'EventListener<this, Event<string>> | null | undefined'. 23 export class FakeRTCDataChannel extends EventTarget implements RTCDataChannel ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Is there any reason for keep passing loop
in channel.py since now it's not used anymore?
No, and in fact I forgot to remove it. I'll do tomorrow. |
RTCPeerConnection, | ||
RTCRtpTransceiver, | ||
RTCSessionDescription, | ||
RTCStatsReport | ||
) | ||
from aiortc import RTCDataChannel # noqa: F401 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this to make linter happy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Let me explain:
npm run lint:python
which runs:
executeCmd(`cd worker && ${PYTHON} -m flake8 && cd ..`);
executeCmd(`cd worker && ${PYTHON} -m mypy . && cd ..`);
Indeed we don't use RTCDataChannel
in hander.py
so flake8
complains due to "unused var". However we cannot remove it since this:
# dictionary of dataChannelds mapped by internal id
self._dataChannels = dict() # type: Dict[str, RTCDataChannel]
Believe me or not, but such a # type: Dict[str, RTCDataChannel]
comment is checked by mypy
and it needs to know what RTCDataChannel
is. So here two conflicting linters / type checkers / whatever. So we must make both happy.
Then you may thing "why not this instead of importing twice from aiortc
?":
from aiortc import (
RTCConfiguration,
RTCPeerConnection,
RTCRtpTransceiver,
RTCSessionDescription,
RTCStatsReport,
RTCDataChannel # noqa: F401
)
or this:
from aiortc import (
RTCConfiguration,
RTCPeerConnection,
RTCRtpTransceiver,
RTCSessionDescription,
RTCStatsReport,
# noqa: F401
RTCDataChannel
)
or this:
# noqa: F401
from aiortc import (
RTCConfiguration,
RTCPeerConnection,
RTCRtpTransceiver,
RTCSessionDescription,
RTCStatsReport,
RTCDataChannel
)
Well, because none of those work. I've tried everything. Python ecosystem sucks a lot.
Done. |
Make it be similar to mediasoup-client repo.
lib
from the repo.src
and temp files/folders inworker
from the NPM package.Breaking Changes
PYTHON3
env is nowPYTHON
.PYP3
env (note that it was a typo anyway) is nowPIP
.Notes