Skip to content
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

WIP decorator support #1151

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"importOrder": ["<THIRD_PARTY_MODULES>", "^[./]"],
"importOrderSeparation": false,
"importOrderSortSpecifiers": true,
"importOrderParserPlugins": ["typescript"],
"importOrderParserPlugins": ["typescript", "decorators"],
"plugins": ["@trivago/prettier-plugin-sort-imports"]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"size-limit": "size-limit"
},
"dependencies": {
"@aloreljs/bound-decorator": "^3.0.3",
"@livekit/protocol": "1.16.0",
"events": "^3.3.0",
"loglevel": "^1.8.0",
Expand Down
16 changes: 12 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/room/PCTransport.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BoundMethod } from '@aloreljs/bound-decorator';
import { EventEmitter } from 'events';
import type { MediaDescription } from 'sdp-transform';
import { parse, write } from 'sdp-transform';
Expand Down Expand Up @@ -431,7 +432,8 @@ export default class PCTransport extends EventEmitter {
return candidates.get(selectedID);
}

close = () => {
@BoundMethod()
close() {
if (!this._pc) {
return;
}
Expand All @@ -448,7 +450,7 @@ export default class PCTransport extends EventEmitter {
this._pc.onconnectionstatechange = null;
this._pc.oniceconnectionstatechange = null;
this._pc = null;
};
}

private async setMungedSDP(sd: RTCSessionDescriptionInit, munged?: string, remote?: boolean) {
if (munged) {
Expand Down
12 changes: 8 additions & 4 deletions src/room/Room.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BoundMethod } from '@aloreljs/bound-decorator';
import {
ConnectionQualityUpdate,
type DataPacket,
Expand Down Expand Up @@ -716,7 +717,8 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
/**
* disconnects the room, emits [[RoomEvent.Disconnected]]
*/
disconnect = async (stopTracks = true) => {
@BoundMethod()
async disconnect(stopTracks = true) {
const unlock = await this.disconnectLock.lock();
try {
if (this.state === ConnectionState.Disconnected) {
Expand Down Expand Up @@ -752,7 +754,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
} finally {
unlock();
}
};
}

/**
* retrieves a participant by identity
Expand Down Expand Up @@ -903,9 +905,11 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
* some form of user interaction (click/tap/etc).
* In those cases, audio will be silent until a click/tap triggering one of the following
* - `startAudio`
*
* - `getUserMedia`
*/
startAudio = async () => {
@BoundMethod()
async startAudio() {
const elements: Array<HTMLMediaElement> = [];
const browser = getBrowser();
if (browser && browser.os === 'iOS') {
Expand Down Expand Up @@ -974,7 +978,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
this.handleAudioPlaybackFailed(err);
throw err;
}
};
}

startVideo = async () => {
const elements: HTMLMediaElement[] = [];
Expand Down
Loading