Skip to content

Commit 268772b

Browse files
committed
feat(ts) migrate JitsiMeetJS to TS
1 parent 0ed1e07 commit 268772b

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed

JitsiMeetJS.js JitsiMeetJS.ts

+31-15
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,11 @@ const USER_MEDIA_SLOW_PROMISE_TIMEOUT = 1000;
5555
* @returns {*} the attributes to attach to analytics events.
5656
*/
5757
function getAnalyticsAttributesFromOptions(options) {
58-
const attributes = {
59-
'audio_requested':
60-
options.devices.includes('audio'),
61-
'video_requested':
62-
options.devices.includes('video'),
63-
'screen_sharing_requested':
64-
options.devices.includes('desktop')
65-
};
58+
const attributes: any = {};
59+
60+
attributes['audio_requested'] = options.devices.includes('audio');
61+
attributes['video_requested'] = options.devices.includes('video');
62+
attributes['screen_sharing_requested'] = options.devices.includes('desktop');
6663

6764
if (attributes.video_requested) {
6865
attributes.resolution = options.resolution;
@@ -71,6 +68,25 @@ function getAnalyticsAttributesFromOptions(options) {
7168
return attributes;
7269
}
7370

71+
interface ICreateLocalTrackOptions {
72+
cameraDeviceId?: string;
73+
devices?: any[];
74+
firePermissionPromptIsShownEvent?: boolean;
75+
fireSlowPromiseEvent?: boolean;
76+
micDeviceId?: string;
77+
resolution?: string;
78+
}
79+
80+
interface IJitsiMeetJSOptions {
81+
enableAnalyticsLogging?: boolean;
82+
enableUnifiedOnChrome?: boolean;
83+
enableWindowOnErrorHandler?: boolean;
84+
externalStorage?: Storage;
85+
flags?: {
86+
enableUnifiedOnChrome?: boolean;
87+
}
88+
}
89+
7490
/**
7591
* The public API of the Jitsi Meet library (a.k.a. {@code JitsiMeetJS}).
7692
*/
@@ -114,9 +130,9 @@ export default {
114130
JitsiTrackError
115131
},
116132
logLevels: Logger.levels,
117-
mediaDevices: JitsiMediaDevices,
118-
analytics: Statistics.analytics,
119-
init(options = {}) {
133+
mediaDevices: JitsiMediaDevices as unknown,
134+
analytics: Statistics.analytics as unknown,
135+
init(options: IJitsiMeetJSOptions = {}) {
120136
Settings.init(options.externalStorage);
121137
Statistics.init(options);
122138
const flags = options.flags || {};
@@ -265,16 +281,15 @@ export default {
265281
* that returns an array of created JitsiTracks if resolved, or a
266282
* JitsiConferenceError if rejected.
267283
*/
268-
createLocalTracks(options = {}, oldfirePermissionPromptIsShownEvent) {
284+
createLocalTracks(options: ICreateLocalTrackOptions = {}, oldfirePermissionPromptIsShownEvent) {
269285
let promiseFulfilled = false;
270286

271287
const { firePermissionPromptIsShownEvent, fireSlowPromiseEvent, ...restOptions } = options;
272288
const firePermissionPrompt = firePermissionPromptIsShownEvent || oldfirePermissionPromptIsShownEvent;
273289

274290
if (firePermissionPrompt && !RTC.arePermissionsGrantedForAvailableDevices()) {
275-
JitsiMediaDevices.emitEvent(
276-
JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN,
277-
browser.getName());
291+
// @ts-ignore
292+
JitsiMediaDevices.emitEvent(JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN, browser.getName());
278293
} else if (fireSlowPromiseEvent) {
279294
window.setTimeout(() => {
280295
if (!promiseFulfilled) {
@@ -289,6 +304,7 @@ export default {
289304
window.connectionTimes['obtainPermissions.start']
290305
= window.performance.now();
291306

307+
// @ts-ignore
292308
return RTC.obtainAudioAndVideoPermissions(restOptions)
293309
.then(tracks => {
294310
promiseFulfilled = true;

globals.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export {};
2+
3+
declare global {
4+
interface Window {
5+
connectionTimes: any;
6+
}
7+
}

modules/connectivity/NetworkInfo.js

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export class NetworkInfo extends Listenable {
2626

2727
/**
2828
* Updates the network info state.
29-
* @param {boolean} isOnline - {@code true} if internet is online or {@code false} otherwise.
3029
*/
3130
updateNetworkInfo({ isOnline }) {
3231
logger.debug('updateNetworkInfo', { isOnline });

0 commit comments

Comments
 (0)