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

Output single TypeScript declaration file #2406

Closed
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ indent_style = space
max_line_length = 80
trim_trailing_whitespace = true

[*.json]
indent_size = 2

[*.md]
max_line_length = 120
trim_trailing_whitespace = false
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ npm-*.log
stats.json
.vscode
dist
index.d.ts
types/auto
types/types-comparer/auto.json
types/types-comparer/hand-crafted.json
Expand Down
4 changes: 2 additions & 2 deletions JitsiConference.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getLogger } from '@jitsi/logger';
import EventEmitter from 'events';
import $ from 'jquery';
import isEqual from 'lodash.isequal';
import { Strophe } from 'strophe.js';
Expand Down Expand Up @@ -39,6 +38,7 @@ import LocalStatsCollector from './modules/statistics/LocalStatsCollector';
import SpeakerStatsCollector from './modules/statistics/SpeakerStatsCollector';
import Statistics from './modules/statistics/statistics';
import GlobalOnErrorHandler from './modules/util/GlobalOnErrorHandler';
import Listenable from './modules/util/Listenable';
import RandomUtil from './modules/util/RandomUtil';
import ComponentsVersions from './modules/version/ComponentsVersions';
import VideoSIPGW from './modules/videosipgw/VideoSIPGW';
Expand Down Expand Up @@ -150,7 +150,7 @@ export default function JitsiConference(options) {
logger.error(errmsg);
throw new Error(errmsg);
}
this.eventEmitter = new EventEmitter();
this.eventEmitter = new Listenable();
this.options = options;
this.eventManager = new JitsiConferenceEventManager(this);

Expand Down
37 changes: 5 additions & 32 deletions JitsiMediaDevices.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import EventEmitter from 'events';

import * as JitsiMediaDevicesEvents from './JitsiMediaDevicesEvents';
import RTC from './modules/RTC/RTC';
import browser from './modules/browser';
import Listenable from './modules/util/Listenable';
import { MediaType } from './service/RTC/MediaType';
import RTCEvents from './service/RTC/RTCEvents';

Expand All @@ -13,19 +12,19 @@ const VIDEO_PERMISSION_NAME = 'camera';
/**
* Media devices utilities for Jitsi.
*/
class JitsiMediaDevices {
class JitsiMediaDevices extends Listenable {
/**
* Initializes a {@code JitsiMediaDevices} object. There will be a single
* instance of this class.
*/
constructor() {
this._eventEmitter = new EventEmitter();
super();
this._permissions = {};

RTC.addListener(
RTCEvents.DEVICE_LIST_CHANGED,
devices =>
this._eventEmitter.emit(
this.emit(
JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED,
devices));

Expand Down Expand Up @@ -128,7 +127,7 @@ class JitsiMediaDevices {
...this._permissions,
...permissions
};
this._eventEmitter.emit(JitsiMediaDevicesEvents.PERMISSIONS_CHANGED, this._permissions);
this.emit(JitsiMediaDevicesEvents.PERMISSIONS_CHANGED, this._permissions);

if (this._permissions[MediaType.AUDIO] || this._permissions[MediaType.VIDEO]) {
// Triggering device list update when the permissiions are granted in order to update
Expand Down Expand Up @@ -265,32 +264,6 @@ class JitsiMediaDevices {
setAudioOutputDevice(deviceId) {
return RTC.setAudioOutputDevice(deviceId);
}

/**
* Adds an event handler.
* @param {string} event - event name
* @param {function} handler - event handler
*/
addEventListener(event, handler) {
this._eventEmitter.addListener(event, handler);
}

/**
* Removes event handler.
* @param {string} event - event name
* @param {function} handler - event handler
*/
removeEventListener(event, handler) {
this._eventEmitter.removeListener(event, handler);
}

/**
* Emits an event.
* @param {string} event - event name
*/
emitEvent(event, ...args) {
this._eventEmitter.emit(event, ...args);
}
}

export default new JitsiMediaDevices();
4 changes: 2 additions & 2 deletions JitsiMeetJS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,11 @@ export default {

if (firePermissionPrompt && !RTC.arePermissionsGrantedForAvailableDevices()) {
// @ts-ignore
JitsiMediaDevices.emitEvent(JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN, browser.getName());
JitsiMediaDevices.emit(JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN, browser.getName());
} else if (fireSlowPromiseEvent) {
window.setTimeout(() => {
if (!promiseFulfilled) {
JitsiMediaDevices.emitEvent(JitsiMediaDevicesEvents.SLOW_GET_USER_MEDIA);
JitsiMediaDevices.emit(JitsiMediaDevicesEvents.SLOW_GET_USER_MEDIA);
}
}, USER_MEDIA_SLOW_PROMISE_TIMEOUT);
}
Expand Down
10 changes: 2 additions & 8 deletions modules/RTC/CodecSelection.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import EventEmitter from 'events';

import * as JitsiConferenceEvents from '../../JitsiConferenceEvents.ts';
import Listenable from '../util/Listenable.js';

Check failure on line 2 in modules/RTC/CodecSelection.spec.js

View workflow job for this annotation

GitHub Actions / Build

'Listenable' is defined but never used
import JingleSessionPC from '../xmpp/JingleSessionPC.js';
import { MockChatRoom, MockStropheConnection } from '../xmpp/MockClasses.js';
import {MockChatRoom, MockConferenceBase, MockStropheConnection} from '../xmpp/MockClasses.js';

Check failure on line 4 in modules/RTC/CodecSelection.spec.js

View workflow job for this annotation

GitHub Actions / Build

A space is required after '{'

Check failure on line 4 in modules/RTC/CodecSelection.spec.js

View workflow job for this annotation

GitHub Actions / Build

A space is required before '}'

import { CodecSelection } from './CodecSelection.js';
import { MockRTC, MockSignalingLayerImpl } from './MockClasses.js';
Expand Down Expand Up @@ -31,18 +29,14 @@
/**
* MockConference
*/
class MockConference extends Listenable {
class MockConference extends MockConferenceBase {
/**
* A constructor...
*/
constructor() {
super();
this.options = {
config: {}
};

this.activeMediaSession = undefined;
this.eventEmitter = new EventEmitter();
this.mediaSessions = [];
this.participants = [];
this._signalingLayer = new MockSignalingLayerImpl();
Expand Down
6 changes: 3 additions & 3 deletions modules/RTC/JitsiRemoteTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default class JitsiRemoteTrack extends JitsiTrack {
return;
}

this.rtc.eventEmitter.emit(RTCEvents.REMOTE_TRACK_MUTE, this);
this.rtc.emit(RTCEvents.REMOTE_TRACK_MUTE, this);
}

/**
Expand All @@ -189,7 +189,7 @@ export default class JitsiRemoteTrack extends JitsiTrack {
_onTrackUnmute() {
logger.debug(`"onunmute" event(${Date.now()}): ${this}`);

this.rtc.eventEmitter.emit(RTCEvents.REMOTE_TRACK_UNMUTE, this);
this.rtc.emit(RTCEvents.REMOTE_TRACK_UNMUTE, this);
}

/**
Expand Down Expand Up @@ -442,7 +442,7 @@ export default class JitsiRemoteTrack extends JitsiTrack {
// stage. Fire a TRACK_STREAMING_STATUS_CHANGED event if the media is already being received for the remote
// track to prevent this from happening.
!this._trackStreamingStatusImpl.isVideoTrackFrozen()
&& this.rtc.eventEmitter.emit(
&& this.rtc.emit(
JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED,
this,
this._trackStreamingStatus);
Expand Down
9 changes: 3 additions & 6 deletions modules/RTC/JitsiTrack.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { getLogger } from '@jitsi/logger';
import EventEmitter from 'events';

import * as JitsiTrackEvents from '../../JitsiTrackEvents';
import { MediaType } from '../../service/RTC/MediaType';
import browser from '../browser';
import Listenable from '../util/Listenable';

import RTCUtils from './RTCUtils';


const logger = getLogger(__filename);

/**
Expand All @@ -21,7 +22,7 @@ const trackHandler2Prop = {
/**
* Represents a single media track (either audio or video).
*/
export default class JitsiTrack extends EventEmitter {
export default class JitsiTrack extends Listenable {
/* eslint-disable max-params */
/**
* Represents a single media track (either audio or video).
Expand All @@ -44,10 +45,6 @@ export default class JitsiTrack extends EventEmitter {
videoType) {
super();

// aliases for addListener/removeListener
this.addEventListener = this.addListener;
this.removeEventListener = this.off = this.removeListener;

/**
* Array with the HTML elements that are displaying the streams.
* @type {Array}
Expand Down
2 changes: 1 addition & 1 deletion modules/RTC/RTC.js
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ export default class RTC extends Listenable {
if (this._channel && this._channel.isOpen()) {
this._channel.sendSetLastNMessage(value);
}
this.eventEmitter.emit(RTCEvents.LASTN_VALUE_CHANGED, value);
this.emit(RTCEvents.LASTN_VALUE_CHANGED, value);
}
}

Expand Down
10 changes: 1 addition & 9 deletions modules/RTC/RTCUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getLogger } from '@jitsi/logger';
import EventEmitter from 'events';
import clonedeep from 'lodash.clonedeep';
import 'webrtc-adapter';

Expand All @@ -19,7 +18,7 @@ import screenObtainer from './ScreenObtainer';

const logger = getLogger(__filename);

const eventEmitter = new EventEmitter();
const eventEmitter = new Listenable();

const AVAILABLE_DEVICES_POLL_INTERVAL_TIME = 3000; // ms

Expand Down Expand Up @@ -287,13 +286,6 @@ function onMediaDevicesListChanged(devicesReceived) {
*
*/
class RTCUtils extends Listenable {
/**
*
*/
constructor() {
super(eventEmitter);
}

/**
* Depending on the browser, sets difference instance methods for
* interacting with user media and adds methods to native WebRTC-related
Expand Down
23 changes: 9 additions & 14 deletions modules/RTC/TraceablePeerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,6 @@ export default function TraceablePeerConnection(
*/
this.localSdpMunger = new LocalSdpMunger(this, this.rtc.getLocalEndpointId());

/**
* TracablePeerConnection uses RTC's eventEmitter
* @type {EventEmitter}
*/
this.eventEmitter = rtc.eventEmitter;
this.rtxModifier = new RtxModifier();

/**
Expand Down Expand Up @@ -1107,7 +1102,7 @@ TraceablePeerConnection.prototype._createRemoteTrack = function(
sourceName);

userTracksByMediaType.add(remoteTrack);
this.eventEmitter.emit(RTCEvents.REMOTE_TRACK_ADDED, remoteTrack, this);
this.rtc.emit(RTCEvents.REMOTE_TRACK_ADDED, remoteTrack, this);
};

/**
Expand Down Expand Up @@ -1218,7 +1213,7 @@ TraceablePeerConnection.prototype._removeRemoteTrack = function(toBeRemoved) {
} else if (!userTracksByMediaType.get(toBeRemoved.getType())?.delete(toBeRemoved)) {
logger.error(`${this} Failed to remove ${toBeRemoved} - type mapping messed up ?`);
}
this.eventEmitter.emit(RTCEvents.REMOTE_TRACK_REMOVED, toBeRemoved);
this.rtc.emit(RTCEvents.REMOTE_TRACK_REMOVED, toBeRemoved);
};

/**
Expand Down Expand Up @@ -2637,15 +2632,15 @@ TraceablePeerConnection.prototype.setLocalDescription = function(description) {

if (localUfrag !== this.localUfrag) {
this.localUfrag = localUfrag;
this.eventEmitter.emit(RTCEvents.LOCAL_UFRAG_CHANGED, this, localUfrag);
this.rtc.emit(RTCEvents.LOCAL_UFRAG_CHANGED, this, localUfrag);
}

this._initializeDtlsTransport();

resolve();
}, err => {
this.trace('setLocalDescriptionOnFailure', err);
this.eventEmitter.emit(RTCEvents.SET_LOCAL_DESCRIPTION_FAILED, err, this);
this.rtc.emit(RTCEvents.SET_LOCAL_DESCRIPTION_FAILED, err, this);
reject(err);
});
});
Expand Down Expand Up @@ -2698,15 +2693,15 @@ TraceablePeerConnection.prototype.setRemoteDescription = function(description) {

if (remoteUfrag !== this.remoteUfrag) {
this.remoteUfrag = remoteUfrag;
this.eventEmitter.emit(RTCEvents.REMOTE_UFRAG_CHANGED, this, remoteUfrag);
this.rtc.emit(RTCEvents.REMOTE_UFRAG_CHANGED, this, remoteUfrag);
}

this._initializeDtlsTransport();

resolve();
}, err => {
this.trace('setRemoteDescriptionOnFailure', err);
this.eventEmitter.emit(RTCEvents.SET_REMOTE_DESCRIPTION_FAILED, err, this);
this.rtc.emit(RTCEvents.SET_REMOTE_DESCRIPTION_FAILED, err, this);
reject(err);
});
});
Expand Down Expand Up @@ -2836,7 +2831,7 @@ TraceablePeerConnection.prototype._updateVideoSenderEncodings = function(frameHe

return videoSender.setParameters(parameters).then(() => {
localVideoTrack.maxEnabledResolution = frameHeight;
this.eventEmitter.emit(RTCEvents.LOCAL_TRACK_MAX_ENABLED_RESOLUTION_CHANGED, localVideoTrack);
this.rtc.emit(RTCEvents.LOCAL_TRACK_MAX_ENABLED_RESOLUTION_CHANGED, localVideoTrack);
});
};

Expand Down Expand Up @@ -3074,7 +3069,7 @@ TraceablePeerConnection.prototype._createOfferOrAnswer = function(
? RTCEvents.CREATE_OFFER_FAILED
: RTCEvents.CREATE_ANSWER_FAILED;

this.eventEmitter.emit(eventType, err, this);
this.rtc.emit(eventType, err, this);

rejectFn(err);
};
Expand Down Expand Up @@ -3173,7 +3168,7 @@ TraceablePeerConnection.prototype._processLocalSSRCsMap = function(ssrcMap) {
if (newSSRCNum !== oldSSRCNum) {
oldSSRCNum && logger.error(`${this} Overwriting SSRC for track=${track}] with ssrc=${newSSRC}`);
this.localSSRCs.set(track.rtcId, newSSRC);
this.eventEmitter.emit(RTCEvents.LOCAL_TRACK_SSRC_UPDATED, track, newSSRCNum);
this.rtc.emit(RTCEvents.LOCAL_TRACK_SSRC_UPDATED, track, newSSRCNum);
}
} else if (!track.isVideoTrack() && !track.isMuted()) {
// It is normal to find no SSRCs for a muted video track in
Expand Down
4 changes: 2 additions & 2 deletions modules/RTCStats/RTCStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getLogger } from '@jitsi/logger';

import rtcstatsInit from '@jitsi/rtcstats/rtcstats';
import traceInit from '@jitsi/rtcstats/trace-ws';
import EventEmitter from 'events';
import Listenable from '../util/Listenable';

import {
CONFERENCE_JOINED,
Expand All @@ -22,7 +22,7 @@ const logger = getLogger(__filename);
class RTCStats {
private _initialized: boolean = false;
private _trace: any = null;
public events: EventEmitter = new EventEmitter();
public events: Listenable = new Listenable();

/**
* RTCStats "proxies" WebRTC functions such as GUM and RTCPeerConnection by rewriting the global objects.
Expand Down
Loading
Loading