Skip to content

Commit

Permalink
Typing event emitters (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
unao authored Feb 22, 2022
1 parent 3615511 commit fe5b3ab
Show file tree
Hide file tree
Showing 50 changed files with 547 additions and 91 deletions.
16 changes: 14 additions & 2 deletions node/lib/ActiveSpeakerObserver.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { RtpObserver } from './RtpObserver';
import { RtpObserver, RtpObserverEvents, RtpObserverObserverEvents } from './RtpObserver';
import { Producer } from './Producer';
import { EnhancedEventEmitter } from './EnhancedEventEmitter';
export interface ActiveSpeakerObserverOptions {
interval?: number;
/**
Expand All @@ -13,14 +14,25 @@ export interface ActiveSpeakerObserverActivity {
*/
producer: Producer;
}
export declare class ActiveSpeakerObserver extends RtpObserver {
export declare type ActiveSpeakerObserverEvents = RtpObserverEvents & {
dominantspeaker: [{
producer: Producer;
}];
};
export declare type ActiveSpeakerObserverObserverEvents = RtpObserverObserverEvents & {
dominantspeaker: [{
producer: Producer;
}];
};
export declare class ActiveSpeakerObserver extends RtpObserver<ActiveSpeakerObserverEvents> {
/**
* @private
*/
constructor(params: any);
/**
* Observer.
*/
get observer(): EnhancedEventEmitter<ActiveSpeakerObserverObserverEvents>;
private handleWorkerNotifications;
}
//# sourceMappingURL=ActiveSpeakerObserver.d.ts.map
2 changes: 1 addition & 1 deletion node/lib/ActiveSpeakerObserver.d.ts.map

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

4 changes: 3 additions & 1 deletion node/lib/ActiveSpeakerObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ class ActiveSpeakerObserver extends RtpObserver_1.RtpObserver {
/**
* Observer.
*/
// get observer(): EnhancedEventEmitter
get observer() {
return super.observer;
}
handleWorkerNotifications() {
this.channel.on(this.internal.rtpObserverId, (event, data) => {
switch (event) {
Expand Down
14 changes: 12 additions & 2 deletions node/lib/AudioLevelObserver.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { RtpObserver } from './RtpObserver';
import { RtpObserver, RtpObserverEvents, RtpObserverObserverEvents } from './RtpObserver';
import { Producer } from './Producer';
import { EnhancedEventEmitter } from './EnhancedEventEmitter';
export interface AudioLevelObserverOptions {
/**
* Maximum number of entries in the 'volumes”' event. Default 1.
Expand Down Expand Up @@ -30,7 +31,15 @@ export interface AudioLevelObserverVolume {
*/
volume: number;
}
export declare class AudioLevelObserver extends RtpObserver {
export declare type AudioLevelObserverEvents = RtpObserverEvents & {
volumes: [AudioLevelObserverVolume[]];
silence: [];
};
export declare type AudioLevelObserverObserverEvents = RtpObserverObserverEvents & {
volumes: [AudioLevelObserverVolume[]];
silence: [];
};
export declare class AudioLevelObserver extends RtpObserver<AudioLevelObserverEvents> {
/**
* @private
* @emits volumes - (volumes: AudioLevelObserverVolume[])
Expand All @@ -48,6 +57,7 @@ export declare class AudioLevelObserver extends RtpObserver {
* @emits volumes - (volumes: AudioLevelObserverVolume[])
* @emits silence
*/
get observer(): EnhancedEventEmitter<AudioLevelObserverObserverEvents>;
private handleWorkerNotifications;
}
//# sourceMappingURL=AudioLevelObserver.d.ts.map
2 changes: 1 addition & 1 deletion node/lib/AudioLevelObserver.d.ts.map

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

4 changes: 3 additions & 1 deletion node/lib/AudioLevelObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class AudioLevelObserver extends RtpObserver_1.RtpObserver {
* @emits volumes - (volumes: AudioLevelObserverVolume[])
* @emits silence
*/
// get observer(): EnhancedEventEmitter
get observer() {
return super.observer;
}
handleWorkerNotifications() {
this.channel.on(this.internal.rtpObserverId, (event, data) => {
switch (event) {
Expand Down
23 changes: 21 additions & 2 deletions node/lib/Consumer.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// <reference types="node" />
import { EnhancedEventEmitter } from './EnhancedEventEmitter';
import { Channel } from './Channel';
import { PayloadChannel } from './PayloadChannel';
Expand Down Expand Up @@ -123,7 +124,25 @@ export declare type ConsumerStat = {
* Consumer type.
*/
export declare type ConsumerType = 'simple' | 'simulcast' | 'svc' | 'pipe';
export declare class Consumer extends EnhancedEventEmitter {
export declare type ConsumerEvents = {
transportclose: [];
producerclose: [];
producerpause: [];
producerresume: [];
score: [ConsumerScore];
layerschange: [ConsumerLayers?];
trace: [ConsumerTraceEventData];
rtp: [Buffer];
};
export declare type ConsumerObserverEvents = {
close: [];
pause: [];
resume: [];
score: [ConsumerScore];
layerschange: [ConsumerLayers?];
trace: [ConsumerTraceEventData];
};
export declare class Consumer extends EnhancedEventEmitter<ConsumerEvents> {
#private;
/**
* @private
Expand Down Expand Up @@ -215,7 +234,7 @@ export declare class Consumer extends EnhancedEventEmitter {
* @emits layerschange - (layers: ConsumerLayers | undefined)
* @emits trace - (trace: ConsumerTraceEventData)
*/
get observer(): EnhancedEventEmitter;
get observer(): EnhancedEventEmitter<ConsumerObserverEvents>;
/**
* @private
* Just for testing purposes.
Expand Down
2 changes: 1 addition & 1 deletion node/lib/Consumer.d.ts.map

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

14 changes: 12 additions & 2 deletions node/lib/DataConsumer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,17 @@ export declare type DataConsumerStat = {
* DataConsumer type.
*/
export declare type DataConsumerType = 'sctp' | 'direct';
export declare class DataConsumer extends EnhancedEventEmitter {
export declare type DataConsumerEvents = {
transportclose: [];
dataproducerclose: [];
message: [Buffer, number];
sctpsendbufferfull: [];
bufferedamountlow: [number];
};
export declare type DataConsumerObserverEvents = {
close: [];
};
export declare class DataConsumer extends EnhancedEventEmitter<DataConsumerEvents> {
#private;
/**
* @private
Expand Down Expand Up @@ -107,7 +117,7 @@ export declare class DataConsumer extends EnhancedEventEmitter {
*
* @emits close
*/
get observer(): EnhancedEventEmitter;
get observer(): EnhancedEventEmitter<DataConsumerObserverEvents>;
/**
* Close the DataConsumer.
*/
Expand Down
Loading

0 comments on commit fe5b3ab

Please sign in to comment.