Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
ref: Convert files to TS (#11840)
Robert Pintiliif31a7f31e6a2
diff --git a/react/features/app/types.ts b/react/features/app/types.tsindex 7817178c75..896371e599 100644--- a/react/features/app/types.ts+++ b/react/features/app/types.ts@@ -5,6 +5,7 @@ import { IAppState } from '../base/app/reducer';import { IAudioOnlyState } from '../base/audio-only/reducer';import { IConferenceState } from '../base/conference/reducer';import { IConfig } from '../base/config/configType';+import { IConnectionState } from '../base/connection/reducer';export interface IStore {getState: Function,@@ -19,4 +20,5 @@ export interface IState {'features/base/audio-only': IAudioOnlyState,'features/base/conference': IConferenceState,'features/base/config': IConfig,+ 'features/base/connection': IConnectionState}diff --git a/react/features/authentication/reducer.ts b/react/features/authentication/reducer.tsindex 53641f9a93..c7c4c2c5e2 100644--- a/react/features/authentication/reducer.ts+++ b/react/features/authentication/reducer.ts@@ -1,7 +1,4 @@-/* eslint-disable import/order */import ReducerRegistry from '../base/redux/ReducerRegistry';--// @ts-ignoreimport { assign } from '../base/redux/functions';import {diff --git a/react/features/base/conference/reducer.ts b/react/features/base/conference/reducer.tsindex 8b2fb39b40..9e6a666cd1 100644--- a/react/features/base/conference/reducer.ts+++ b/react/features/base/conference/reducer.ts@@ -8,8 +8,7 @@ import { CONNECTION_WILL_CONNECT, SET_LOCATION_URL } from '../connection';// @ts-ignoreimport { JitsiConferenceErrors } from '../lib-jitsi-meet';-// @ts-ignore-import { assign, set } from '../redux';+import { assign, set } from '../redux/functions';import ReducerRegistry from '../redux/ReducerRegistry';import {@@ -58,6 +57,14 @@ export interface IConferenceState {passwordRequired: boolean|undefined;authEnabled?: boolean|undefined;authLogin?: string|undefined;+ subject?: string;+ localSubject?: string;+ conferenceTimestamp?: number;+ authRequired?: Object;+ followMeEnabled?: boolean;+ startReactionsMuted?: boolean;+ room?: Object;+ pendingSubjectChange?: string;}/**diff --git a/react/features/base/config/reducer.ts b/react/features/base/config/reducer.tsindex f7f2b27c03..5c97063217 100644--- a/react/features/base/config/reducer.ts+++ b/react/features/base/config/reducer.ts@@ -3,8 +3,7 @@ import _ from 'lodash';import { CONFERENCE_INFO } from '../../conference/components/constants';-// @ts-ignore-import { equals } from '../redux';+import { equals } from '../redux/functions';import ReducerRegistry from '../redux/ReducerRegistry';import {diff --git a/react/features/base/connection/reducer.js b/react/features/base/connection/reducer.tssimilarity index 77%rename from react/features/base/connection/reducer.jsrename to react/features/base/connection/reducer.tsindex bb983bbf65..fe868af72d 100644--- a/react/features/base/connection/reducer.js+++ b/react/features/base/connection/reducer.ts@@ -1,8 +1,11 @@-/* @flow */+/* eslint-disable import/order */-import { SET_ROOM } from '../conference';+import { SET_ROOM } from '../conference/actionTypes';++// @ts-ignoreimport { JitsiConnectionErrors } from '../lib-jitsi-meet';-import { assign, set, ReducerRegistry } from '../redux';+import { assign, set } from '../redux/functions';+import ReducerRegistry from '../redux/ReducerRegistry';import {CONNECTION_DISCONNECTED,@@ -12,14 +15,26 @@ import {SET_LOCATION_URL,SHOW_CONNECTION_INFO} from './actionTypes';-import type { ConnectionFailedError } from './actions.native';++// @ts-ignore+import { ConnectionFailedError } from './actions.native';++export interface IConnectionState {+ connection?: Object;+ connecting?: Object;+ timeEstablished?: number;+ error?: ConnectionFailedError;+ passwordRequired?: Object;+ locationURL?: URL;+ showConnectionInfo?: boolean;+}/*** Reduces the Redux actions of the feature base/connection.*/ReducerRegistry.register('features/base/connection',- (state: Object = {}, action: Object) => {+ (state: IConnectionState = {}, action: any) => {switch (action.type) {case CONNECTION_DISCONNECTED:return _connectionDisconnected(state, action);@@ -50,14 +65,14 @@ ReducerRegistry.register(* Reduces a specific Redux action CONNECTION_DISCONNECTED of the feature* base/connection.*- * @param {Object} state - The Redux state of the feature base/connection.+ * @param {IConnectionState} state - The Redux state of the feature base/connection.* @param {Action} action - The Redux action CONNECTION_DISCONNECTED to reduce.* @private* @returns {Object} The new state of the feature base/connection after the* reduction of the specified action.*/function _connectionDisconnected(- state: Object,+ state: IConnectionState,{ connection }: { connection: Object }) {const connection_ = _getCurrentConnection(state);@@ -76,14 +91,14 @@ function _connectionDisconnected(* Reduces a specific Redux action CONNECTION_ESTABLISHED of the feature* base/connection.*- * @param {Object} state - The Redux state of the feature base/connection.+ * @param {IConnectionState} state - The Redux state of the feature base/connection.* @param {Action} action - The Redux action CONNECTION_ESTABLISHED to reduce.* @private* @returns {Object} The new state of the feature base/connection after the* reduction of the specified action.*/function _connectionEstablished(- state: Object,+ state: IConnectionState,{ connection, timeEstablished }: {connection: Object,timeEstablished: number@@ -101,14 +116,14 @@ function _connectionEstablished(* Reduces a specific Redux action CONNECTION_FAILED of the feature* base/connection.*- * @param {Object} state - The Redux state of the feature base/connection.+ * @param {IConnectionState} state - The Redux state of the feature base/connection.* @param {Action} action - The Redux action CONNECTION_FAILED to reduce.* @private* @returns {Object} The new state of the feature base/connection after the* reduction of the specified action.*/function _connectionFailed(- state: Object,+ state: IConnectionState,{ connection, error }: {connection: Object,error: ConnectionFailedError@@ -133,14 +148,14 @@ function _connectionFailed(* Reduces a specific Redux action CONNECTION_WILL_CONNECT of the feature* base/connection.*- * @param {Object} state - The Redux state of the feature base/connection.+ * @param {IConnectionState} state - The Redux state of the feature base/connection.* @param {Action} action - The Redux action CONNECTION_WILL_CONNECT to reduce.* @private* @returns {Object} The new state of the feature base/connection after the* reduction of the specified action.*/function _connectionWillConnect(- state: Object,+ state: IConnectionState,{ connection }: { connection: Object }) {return assign(state, {connecting: connection,@@ -159,12 +174,12 @@ function _connectionWillConnect(* The current (similar to getCurrentConference in base/conference/functions.any.js)* connection which is {@code connection} or {@code connecting}.*- * @param {Object} baseConnectionState - The current state of the+ * @param {IConnectionState} baseConnectionState - The current state of the* {@code 'base/connection'} feature.* @returns {JitsiConnection} - The current {@code JitsiConnection} if any.* @private*/-function _getCurrentConnection(baseConnectionState: Object): ?Object {+function _getCurrentConnection(baseConnectionState: IConnectionState): IConnectionState|undefined {return baseConnectionState.connection || baseConnectionState.connecting;}@@ -172,15 +187,15 @@ function _getCurrentConnection(baseConnectionState: Object): ?Object {* Reduces a specific redux action {@link SET_LOCATION_URL} of the feature* base/connection.*- * @param {Object} state - The redux state of the feature base/connection.+ * @param {IConnectionState} state - The redux state of the feature base/connection.* @param {Action} action - The redux action {@code SET_LOCATION_URL} to reduce.* @private* @returns {Object} The new state of the feature base/connection after the* reduction of the specified action.*/function _setLocationURL(- state: Object,- { locationURL }: { locationURL: ?URL }) {+ state: IConnectionState,+ { locationURL }: { locationURL?: URL }) {return set(state, 'locationURL', locationURL);}@@ -188,12 +203,12 @@ function _setLocationURL(* Reduces a specific redux action {@link SET_ROOM} of the feature* base/connection.*- * @param {Object} state - The redux state of the feature base/connection.+ * @param {IConnectionState} state - The redux state of the feature base/connection.* @private* @returns {Object} The new state of the feature base/connection after the* reduction of the specified action.*/-function _setRoom(state: Object) {+function _setRoom(state: IConnectionState) {return assign(state, {error: undefined,passwordRequired: undefined@@ -204,14 +219,14 @@ function _setRoom(state: Object) {* Reduces a specific redux action {@link SHOW_CONNECTION_INFO} of the feature* base/connection.*- * @param {Object} state - The redux state of the feature base/connection.+ * @param {IConnectionState} state - The redux state of the feature base/connection.* @param {Action} action - The redux action {@code SHOW_CONNECTION_INFO} to reduce.* @private* @returns {Object} The new state of the feature base/connection after the* reduction of the specified action.*/function _setShowConnectionInfo(- state: Object,+ state: IConnectionState,{ showConnectionInfo }: { showConnectionInfo: boolean }) {return set(state, 'showConnectionInfo', showConnectionInfo);}diff --git a/react/features/base/redux/functions.js b/react/features/base/redux/functions.tssimilarity index 79%rename from react/features/base/redux/functions.jsrename to react/features/base/redux/functions.tsindex ad9beccb82..a0b268c110 100644--- a/react/features/base/redux/functions.js+++ b/react/features/base/redux/functions.ts@@ -1,22 +1,22 @@-// @flow-import _ from 'lodash';import { connect as reduxConnect } from 'react-redux';+import { IStore } from '../../app/types';+/*** Sets specific properties of a specific state to specific values and prevents* unnecessary state changes.*- * @param {Object} target - The state on which the specified properties are to+ * @param {T} target - The state on which the specified properties are to* be set.- * @param {Object} source - The map of properties to values which are to be set+ * @param {T} source - The map of properties to values which are to be set* on the specified target.- * @returns {Object} The specified target if the values of the specified+ * @returns {T} The specified target if the values of the specified* properties equal the specified values; otherwise, a new state constructed* from the specified target by setting the specified properties to the* specified values.*/-export function assign(target: Object, source: Object) {+export function assign<T extends Object>(target: T, source: T): T {let t = target;for (const property in source) { // eslint-disable-line guard-for-in@@ -30,13 +30,13 @@ export function assign(target: Object, source: Object) {* Wrapper function for the react-redux connect function to avoid having to* declare function types for flow, but still let flow warn for other errors.*- * @param {Function?} mapStateToProps - Redux mapStateToProps function.+ * @param {any} mapStateToProps - Redux mapStateToProps function.* @param {Function?} mapDispatchToProps - Redux mapDispatchToProps function.* @returns {Connector}*/export function connect(- mapStateToProps?: Function, mapDispatchToProps?: Function) {- return reduxConnect<*, *, *, *, *, *>(mapStateToProps, mapDispatchToProps);+ mapStateToProps?: any, mapDispatchToProps?: Function) {+ return reduxConnect(mapStateToProps, mapDispatchToProps);}/**@@ -57,18 +57,18 @@ export function equals(a: any, b: any) {* unnecessary state changes (when the specified {@code value} is equal to the* value of the specified {@code property} of the specified {@code state}).*- * @param {Object} state - The (Redux) state from which a new state is to be+ * @param {T} state - The (Redux) state from which a new state is to be* constructed by setting the specified {@code property} to the specified* {@code value}.* @param {string} property - The property of {@code state} which is to be* assigned the specified {@code value} (in the new state).* @param {*} value - The value to assign to the specified {@code property}.- * @returns {Object} The specified {@code state} if the value of the specified+ * @returns {T} The specified {@code state} if the value of the specified* {@code property} equals the specified <tt>value/tt>; otherwise, a new state* constructed from the specified {@code state} by setting the specified* {@code property} to the specified {@code value}.*/-export function set(state: Object, property: string, value: any) {+export function set<T extends Object>(state: T, property: keyof T, value: any): T {return _set(state, property, value, /* copyOnWrite */ true);}@@ -79,7 +79,7 @@ export function set(state: Object, property: string, value: any) {* unnecessary state changes (when the specified {@code value} is equal to the* value of the specified {@code property} of the specified {@code state}).*- * @param {Object} state - The (Redux) state from which a state is to be+ * @param {T} state - The (Redux) state from which a state is to be* constructed by setting the specified {@code property} to the specified* {@code value}.* @param {string} property - The property of {@code state} which is to be@@ -87,17 +87,17 @@ export function set(state: Object, property: string, value: any) {* @param {*} value - The value to assign to the specified {@code property}.* @param {boolean} copyOnWrite - If the specified {@code state} is to not be* modified, {@code true}; otherwise, {@code false}.- * @returns {Object} The specified {@code state} if the value of the specified+ * @returns {T} The specified {@code state} if the value of the specified* {@code property} equals the specified <tt>value/tt> or {@code copyOnWrite}* is truthy; otherwise, a new state constructed from the specified* {@code state} by setting the specified {@code property} to the specified* {@code value}.*/-function _set(- state: Object,- property: string,+function _set<T extends Object>(+ state: T,+ property: keyof T,value: any,- copyOnWrite: boolean) {+ copyOnWrite: boolean): T {// Delete state properties that are to be set to undefined. (It is a matter// of personal preference, mostly.)if (typeof value === 'undefined'@@ -130,12 +130,12 @@ function _set(* be related to the redux state (e.g. The redux store, the redux* {@code getState} function).*- * @param {Function|Object} stateful - The entity such as the redux store or the+ * @param {Function|IStore} stateful - The entity such as the redux store or the* redux {@code getState} function from which the redux state is to be* returned.* @returns {Object} The redux state.*/-export function toState(stateful: Function | Object) {+export function toState(stateful: Function | IStore) {if (stateful) {if (typeof stateful === 'function') {return stateful();