ref(TS) Convert some base files to TS (#12226)
This commit is contained in:
parent
7cbb377a66
commit
4ee77b1f65
|
@ -1,4 +1,5 @@
|
||||||
import { IStore } from "./react/features/app/types";
|
import { IStore } from "./react/features/app/types";
|
||||||
|
import { IConfig } from "./react/features/base/config/configType";
|
||||||
|
|
||||||
export {};
|
export {};
|
||||||
|
|
||||||
|
@ -10,4 +11,8 @@ declare global {
|
||||||
conference: any;
|
conference: any;
|
||||||
};
|
};
|
||||||
const interfaceConfig: any;
|
const interfaceConfig: any;
|
||||||
|
|
||||||
|
interface Window {
|
||||||
|
config?: IConfig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,6 +301,7 @@ export interface IConfig {
|
||||||
disableTopPanel?: boolean;
|
disableTopPanel?: boolean;
|
||||||
minParticipantCountForTopPanel?: number;
|
minParticipantCountForTopPanel?: number;
|
||||||
};
|
};
|
||||||
|
firefox_fake_device?: string;
|
||||||
flags?: {
|
flags?: {
|
||||||
sendMultipleVideoStreams?: boolean;
|
sendMultipleVideoStreams?: boolean;
|
||||||
sourceNameSignaling?: boolean;
|
sourceNameSignaling?: boolean;
|
||||||
|
|
|
@ -75,7 +75,6 @@ export interface IConfigState extends IConfig {
|
||||||
obfuscateRoomName?: boolean;
|
obfuscateRoomName?: boolean;
|
||||||
};
|
};
|
||||||
error?: Error;
|
error?: Error;
|
||||||
firefox_fake_device?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReducerRegistry.register<IConfigState>('features/base/config', (state = _getInitialState(), action): IConfigState => {
|
ReducerRegistry.register<IConfigState>('features/base/config', (state = _getInitialState(), action): IConfigState => {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/* @flow */
|
// @ts-ignore
|
||||||
|
|
||||||
import jwtDecode from 'jwt-decode';
|
import jwtDecode from 'jwt-decode';
|
||||||
|
|
||||||
|
import { IState } from '../../app/types';
|
||||||
import { getLocalParticipant } from '../participants/functions';
|
import { getLocalParticipant } from '../participants/functions';
|
||||||
import { parseURLParams } from '../util';
|
import { parseURLParams } from '../util/parseURLParams';
|
||||||
|
|
||||||
import { MEET_FEATURES } from './constants';
|
import { MEET_FEATURES } from './constants';
|
||||||
|
|
||||||
|
@ -16,17 +16,18 @@ import { MEET_FEATURES } from './constants';
|
||||||
* @returns {string} The JSON Web Token (JWT), if any, defined by the specified
|
* @returns {string} The JSON Web Token (JWT), if any, defined by the specified
|
||||||
* {@code url}; otherwise, {@code undefined}.
|
* {@code url}; otherwise, {@code undefined}.
|
||||||
*/
|
*/
|
||||||
export function parseJWTFromURLParams(url: URL = window.location) {
|
export function parseJWTFromURLParams(url: URL | Location = window.location) {
|
||||||
|
// @ts-ignore
|
||||||
return parseURLParams(url, true, 'search').jwt;
|
return parseURLParams(url, true, 'search').jwt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the user name after decoding the jwt.
|
* Returns the user name after decoding the jwt.
|
||||||
*
|
*
|
||||||
* @param {Object} state - The app state.
|
* @param {IState} state - The app state.
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export function getJwtName(state: Object) {
|
export function getJwtName(state: IState) {
|
||||||
const { user } = state['features/base/jwt'];
|
const { user } = state['features/base/jwt'];
|
||||||
|
|
||||||
return user?.name;
|
return user?.name;
|
||||||
|
@ -35,12 +36,12 @@ export function getJwtName(state: Object) {
|
||||||
/**
|
/**
|
||||||
* Check if the given JWT feature is enabled.
|
* Check if the given JWT feature is enabled.
|
||||||
*
|
*
|
||||||
* @param {Object} state - The app state.
|
* @param {IState} state - The app state.
|
||||||
* @param {string} feature - The feature we want to check.
|
* @param {string} feature - The feature we want to check.
|
||||||
* @param {boolean} ifNoToken - Default value if there is no token.
|
* @param {boolean} ifNoToken - Default value if there is no token.
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export function isJwtFeatureEnabled(state: Object, feature: string, ifNoToken: boolean = false) {
|
export function isJwtFeatureEnabled(state: IState, feature: string, ifNoToken = false) {
|
||||||
const { jwt } = state['features/base/jwt'];
|
const { jwt } = state['features/base/jwt'];
|
||||||
|
|
||||||
if (!jwt) {
|
if (!jwt) {
|
||||||
|
@ -54,7 +55,7 @@ export function isJwtFeatureEnabled(state: Object, feature: string, ifNoToken: b
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return String(features[feature]) === 'true';
|
return String(features[feature as keyof typeof features]) === 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,7 +65,7 @@ export function isJwtFeatureEnabled(state: Object, feature: string, ifNoToken: b
|
||||||
* @param {any} timestamp - A UNIX timestamp in seconds as stored in the jwt.
|
* @param {any} timestamp - A UNIX timestamp in seconds as stored in the jwt.
|
||||||
* @returns {boolean} - Whether the timestamp is indeed a valid UNIX timestamp or not.
|
* @returns {boolean} - Whether the timestamp is indeed a valid UNIX timestamp or not.
|
||||||
*/
|
*/
|
||||||
function isValidUnixTimestamp(timestamp: any) {
|
function isValidUnixTimestamp(timestamp: number | string) {
|
||||||
return typeof timestamp === 'number' && timestamp * 1000 === new Date(timestamp * 1000).getTime();
|
return typeof timestamp === 'number' && timestamp * 1000 === new Date(timestamp * 1000).getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ function isValidUnixTimestamp(timestamp: any) {
|
||||||
* @returns {Array<string>} - An array containing all jwt validation errors.
|
* @returns {Array<string>} - An array containing all jwt validation errors.
|
||||||
*/
|
*/
|
||||||
export function validateJwt(jwt: string) {
|
export function validateJwt(jwt: string) {
|
||||||
const errors = [];
|
const errors: string[] = [];
|
||||||
|
|
||||||
if (!jwt) {
|
if (!jwt) {
|
||||||
return errors;
|
return errors;
|
||||||
|
@ -103,7 +104,7 @@ export function validateJwt(jwt: string) {
|
||||||
} = payload;
|
} = payload;
|
||||||
|
|
||||||
// JaaS only
|
// JaaS only
|
||||||
if (sub && sub.startsWith('vpaas-magic-cookie')) {
|
if (sub?.startsWith('vpaas-magic-cookie')) {
|
||||||
const { kid } = header;
|
const { kid } = header;
|
||||||
|
|
||||||
// if Key ID is missing, we return the error immediately without further validations.
|
// if Key ID is missing, we return the error immediately without further validations.
|
||||||
|
@ -165,7 +166,7 @@ export function validateJwt(jwt: string) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e: any) {
|
||||||
errors.push(e ? e.message : '- unspecified jwt error');
|
errors.push(e ? e.message : '- unspecified jwt error');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
import { getLogger } from '../logging/functions';
|
import { getLogger } from '../logging/functions';
|
||||||
|
|
||||||
export default getLogger('features/base/jwt');
|
export default getLogger('features/base/jwt');
|
|
@ -1,22 +1,20 @@
|
||||||
// @flow
|
// @ts-ignore
|
||||||
|
|
||||||
import jwtDecode from 'jwt-decode';
|
import jwtDecode from 'jwt-decode';
|
||||||
|
import { AnyAction } from 'redux';
|
||||||
|
|
||||||
import { SET_CONFIG } from '../config';
|
import { IStore } from '../../app/types';
|
||||||
import { SET_LOCATION_URL } from '../connection';
|
import { SET_CONFIG } from '../config/actionTypes';
|
||||||
import {
|
import { SET_LOCATION_URL } from '../connection/actionTypes';
|
||||||
getLocalParticipant,
|
import { participantUpdated } from '../participants/actions';
|
||||||
participantUpdated
|
import { getLocalParticipant } from '../participants/functions';
|
||||||
} from '../participants';
|
import { Participant } from '../participants/types';
|
||||||
import { MiddlewareRegistry } from '../redux';
|
import MiddlewareRegistry from '../redux/MiddlewareRegistry';
|
||||||
|
|
||||||
import { SET_JWT } from './actionTypes';
|
import { SET_JWT } from './actionTypes';
|
||||||
import { setJWT } from './actions';
|
import { setJWT } from './actions';
|
||||||
import { parseJWTFromURLParams } from './functions';
|
import { parseJWTFromURLParams } from './functions';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
|
|
||||||
declare var APP: Object;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Middleware to parse token data upon setting a new room URL.
|
* Middleware to parse token data upon setting a new room URL.
|
||||||
*
|
*
|
||||||
|
@ -51,13 +49,14 @@ MiddlewareRegistry.register(store => next => action => {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function _overwriteLocalParticipant(
|
function _overwriteLocalParticipant(
|
||||||
{ dispatch, getState },
|
{ dispatch, getState }: IStore,
|
||||||
{ avatarURL, email, id: jwtId, name, features }) {
|
{ avatarURL, email, id: jwtId, name, features }:
|
||||||
|
{ avatarURL?: string; email?: string; features?: any; id?: string; name?: string; }) {
|
||||||
let localParticipant;
|
let localParticipant;
|
||||||
|
|
||||||
if ((avatarURL || email || name)
|
if ((avatarURL || email || name)
|
||||||
&& (localParticipant = getLocalParticipant(getState))) {
|
&& (localParticipant = getLocalParticipant(getState))) {
|
||||||
const newProperties: Object = {
|
const newProperties: Participant = {
|
||||||
id: localParticipant.id,
|
id: localParticipant.id,
|
||||||
local: true
|
local: true
|
||||||
};
|
};
|
||||||
|
@ -97,7 +96,7 @@ function _overwriteLocalParticipant(
|
||||||
* @returns {Object} The new state that is the result of the reduction of the
|
* @returns {Object} The new state that is the result of the reduction of the
|
||||||
* specified {@code action}.
|
* specified {@code action}.
|
||||||
*/
|
*/
|
||||||
function _setConfigOrLocationURL({ dispatch, getState }, next, action) {
|
function _setConfigOrLocationURL({ dispatch, getState }: IStore, next: Function, action: AnyAction) {
|
||||||
const result = next(action);
|
const result = next(action);
|
||||||
|
|
||||||
const { locationURL } = getState()['features/base/connection'];
|
const { locationURL } = getState()['features/base/connection'];
|
||||||
|
@ -122,8 +121,8 @@ function _setConfigOrLocationURL({ dispatch, getState }, next, action) {
|
||||||
* @returns {Object} The new state that is the result of the reduction of the
|
* @returns {Object} The new state that is the result of the reduction of the
|
||||||
* specified {@code action}.
|
* specified {@code action}.
|
||||||
*/
|
*/
|
||||||
function _setJWT(store, next, action) {
|
function _setJWT(store: IStore, next: Function, action: AnyAction) {
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const { jwt, type, ...actionPayload } = action;
|
const { jwt, type, ...actionPayload } = action;
|
||||||
|
|
||||||
if (!Object.keys(actionPayload).length) {
|
if (!Object.keys(actionPayload).length) {
|
||||||
|
@ -186,13 +185,13 @@ function _setJWT(store, next, action) {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function _undoOverwriteLocalParticipant(
|
function _undoOverwriteLocalParticipant(
|
||||||
{ dispatch, getState },
|
{ dispatch, getState }: IStore,
|
||||||
{ avatarURL, name, email }) {
|
{ avatarURL, name, email }: { avatarURL?: string; email?: string; name?: string; }) {
|
||||||
let localParticipant;
|
let localParticipant;
|
||||||
|
|
||||||
if ((avatarURL || name || email)
|
if ((avatarURL || name || email)
|
||||||
&& (localParticipant = getLocalParticipant(getState))) {
|
&& (localParticipant = getLocalParticipant(getState))) {
|
||||||
const newProperties: Object = {
|
const newProperties: Participant = {
|
||||||
id: localParticipant.id,
|
id: localParticipant.id,
|
||||||
local: true
|
local: true
|
||||||
};
|
};
|
||||||
|
@ -226,8 +225,10 @@ function _undoOverwriteLocalParticipant(
|
||||||
* hidden-from-recorder: ?boolean
|
* hidden-from-recorder: ?boolean
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
function _user2participant({ avatar, avatarUrl, email, id, name, 'hidden-from-recorder': hiddenFromRecorder }) {
|
function _user2participant({ avatar, avatarUrl, email, id, name, 'hidden-from-recorder': hiddenFromRecorder }:
|
||||||
const participant = {};
|
{ avatar: any; avatarUrl: string; email: string; 'hidden-from-recorder': string | boolean;
|
||||||
|
id: string; name: string; }) {
|
||||||
|
const participant: any = {};
|
||||||
|
|
||||||
if (typeof avatarUrl === 'string') {
|
if (typeof avatarUrl === 'string') {
|
||||||
participant.avatarURL = avatarUrl.trim();
|
participant.avatarURL = avatarUrl.trim();
|
|
@ -11,6 +11,9 @@ export interface IJwtState {
|
||||||
jwt?: string;
|
jwt?: string;
|
||||||
server?: string;
|
server?: string;
|
||||||
tenant?: string;
|
tenant?: string;
|
||||||
|
user?: {
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
/* @flow */
|
/* eslint-disable lines-around-comment */
|
||||||
|
// @ts-ignore
|
||||||
import { jitsiLocalStorage } from '@jitsi/js-utils';
|
import { jitsiLocalStorage } from '@jitsi/js-utils';
|
||||||
import type { Dispatch } from 'redux';
|
|
||||||
|
|
||||||
|
import { IStore } from '../../app/types';
|
||||||
import { isOnline } from '../net-info/selectors';
|
import { isOnline } from '../net-info/selectors';
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
import JitsiMeetJS from './_';
|
import JitsiMeetJS from './_';
|
||||||
import {
|
import {
|
||||||
LIB_DID_DISPOSE,
|
LIB_DID_DISPOSE,
|
||||||
|
@ -13,17 +14,16 @@ import {
|
||||||
LIB_WILL_DISPOSE,
|
LIB_WILL_DISPOSE,
|
||||||
LIB_WILL_INIT
|
LIB_WILL_INIT
|
||||||
} from './actionTypes';
|
} from './actionTypes';
|
||||||
|
// @ts-ignore
|
||||||
import { isAnalyticsEnabled } from './functions';
|
import { isAnalyticsEnabled } from './functions';
|
||||||
|
|
||||||
declare var APP: Object;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disposes (of) lib-jitsi-meet.
|
* Disposes (of) lib-jitsi-meet.
|
||||||
*
|
*
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
export function disposeLib() {
|
export function disposeLib() {
|
||||||
return (dispatch: Dispatch<any>) => {
|
return (dispatch: IStore['dispatch']) => {
|
||||||
dispatch({ type: LIB_WILL_DISPOSE });
|
dispatch({ type: LIB_WILL_DISPOSE });
|
||||||
|
|
||||||
// TODO Currently, lib-jitsi-meet doesn't have the functionality to
|
// TODO Currently, lib-jitsi-meet doesn't have the functionality to
|
||||||
|
@ -39,7 +39,7 @@ export function disposeLib() {
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
export function initLib() {
|
export function initLib() {
|
||||||
return (dispatch: Dispatch<any>, getState: Function): void => {
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const config = state['features/base/config'];
|
const config = state['features/base/config'];
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ export function initLib() {
|
||||||
isOnline: isOnline(state)
|
isOnline: isOnline(state)
|
||||||
});
|
});
|
||||||
dispatch({ type: LIB_DID_INIT });
|
dispatch({ type: LIB_DID_INIT });
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
dispatch(libInitError(error));
|
dispatch(libInitError(error));
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
import { IStateful } from '../app/types';
|
||||||
|
import { toState } from '../redux/functions';
|
||||||
import { toState } from '../redux';
|
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
import JitsiMeetJS from './_';
|
import JitsiMeetJS from './_';
|
||||||
|
|
||||||
const JitsiConferenceErrors = JitsiMeetJS.errors.conference;
|
const JitsiConferenceErrors = JitsiMeetJS.errors.conference;
|
||||||
|
@ -18,7 +18,7 @@ const JitsiConnectionErrors = JitsiMeetJS.errors.connection;
|
||||||
*
|
*
|
||||||
* @returns {Promise<JitsiLocalTrack>}
|
* @returns {Promise<JitsiLocalTrack>}
|
||||||
*/
|
*/
|
||||||
export function createLocalTrack(type: string, deviceId: string, timeout: ?number, additionalOptions: ?Object) {
|
export function createLocalTrack(type: string, deviceId: string, timeout?: number, additionalOptions?: Object) {
|
||||||
return (
|
return (
|
||||||
JitsiMeetJS.createLocalTracks({
|
JitsiMeetJS.createLocalTracks({
|
||||||
cameraDeviceId: deviceId,
|
cameraDeviceId: deviceId,
|
||||||
|
@ -26,23 +26,23 @@ export function createLocalTrack(type: string, deviceId: string, timeout: ?numbe
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
firefox_fake_device:
|
firefox_fake_device:
|
||||||
window.config && window.config.firefox_fake_device,
|
window.config?.firefox_fake_device,
|
||||||
micDeviceId: deviceId,
|
micDeviceId: deviceId,
|
||||||
timeout,
|
timeout,
|
||||||
...additionalOptions
|
...additionalOptions
|
||||||
})
|
})
|
||||||
.then(([ jitsiLocalTrack ]) => jitsiLocalTrack));
|
.then(([ jitsiLocalTrack ]: any[]) => jitsiLocalTrack));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether analytics is enabled in a specific redux {@code store}.
|
* Determines whether analytics is enabled in a specific redux {@code store}.
|
||||||
*
|
*
|
||||||
* @param {Function|Object} stateful - The redux store, state, or
|
* @param {IStateful} stateful - The redux store, state, or
|
||||||
* {@code getState} function.
|
* {@code getState} function.
|
||||||
* @returns {boolean} If analytics is enabled, {@code true}; {@code false},
|
* @returns {boolean} If analytics is enabled, {@code true}; {@code false},
|
||||||
* otherwise.
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
export function isAnalyticsEnabled(stateful: Function | Object) {
|
export function isAnalyticsEnabled(stateful: IStateful) {
|
||||||
const { disableThirdPartyRequests, analytics = {} } = toState(stateful)['features/base/config'];
|
const { disableThirdPartyRequests, analytics = {} } = toState(stateful)['features/base/config'];
|
||||||
|
|
||||||
return !(disableThirdPartyRequests || analytics.disabled);
|
return !(disableThirdPartyRequests || analytics.disabled);
|
||||||
|
@ -56,13 +56,13 @@ export function isAnalyticsEnabled(stateful: Function | Object) {
|
||||||
* that category. I've currently named the category fatal because it appears to
|
* that category. I've currently named the category fatal because it appears to
|
||||||
* be used in the cases of unrecoverable errors that necessitate a reload.
|
* be used in the cases of unrecoverable errors that necessitate a reload.
|
||||||
*
|
*
|
||||||
* @param {Object|string} error - The {@code JitsiConferenceErrors} instance to
|
* @param {Error|string} error - The {@code JitsiConferenceErrors} instance to
|
||||||
* categorize/classify or an {@link Error}-like object.
|
* categorize/classify or an {@link Error}-like object.
|
||||||
* @returns {boolean} If the specified {@code JitsiConferenceErrors} instance
|
* @returns {boolean} If the specified {@code JitsiConferenceErrors} instance
|
||||||
* indicates a fatal {@code JitsiConference} error, {@code true}; otherwise,
|
* indicates a fatal {@code JitsiConference} error, {@code true}; otherwise,
|
||||||
* {@code false}.
|
* {@code false}.
|
||||||
*/
|
*/
|
||||||
export function isFatalJitsiConferenceError(error: Object | string) {
|
export function isFatalJitsiConferenceError(error: Error | string) {
|
||||||
if (typeof error !== 'string') {
|
if (typeof error !== 'string') {
|
||||||
error = error.name; // eslint-disable-line no-param-reassign
|
error = error.name; // eslint-disable-line no-param-reassign
|
||||||
}
|
}
|
||||||
|
@ -83,13 +83,13 @@ export function isFatalJitsiConferenceError(error: Object | string) {
|
||||||
* that category. I've currently named the category fatal because it appears to
|
* that category. I've currently named the category fatal because it appears to
|
||||||
* be used in the cases of unrecoverable errors that necessitate a reload.
|
* be used in the cases of unrecoverable errors that necessitate a reload.
|
||||||
*
|
*
|
||||||
* @param {Object|string} error - The {@code JitsiConnectionErrors} instance to
|
* @param {Error|string} error - The {@code JitsiConnectionErrors} instance to
|
||||||
* categorize/classify or an {@link Error}-like object.
|
* categorize/classify or an {@link Error}-like object.
|
||||||
* @returns {boolean} If the specified {@code JitsiConnectionErrors} instance
|
* @returns {boolean} If the specified {@code JitsiConnectionErrors} instance
|
||||||
* indicates a fatal {@code JitsiConnection} error, {@code true}; otherwise,
|
* indicates a fatal {@code JitsiConnection} error, {@code true}; otherwise,
|
||||||
* {@code false}.
|
* {@code false}.
|
||||||
*/
|
*/
|
||||||
export function isFatalJitsiConnectionError(error: Object | string) {
|
export function isFatalJitsiConnectionError(error: Error | string) {
|
||||||
if (typeof error !== 'string') {
|
if (typeof error !== 'string') {
|
||||||
error = error.name; // eslint-disable-line no-param-reassign
|
error = error.name; // eslint-disable-line no-param-reassign
|
||||||
}
|
}
|
|
@ -1,5 +1,3 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
export * from './functions.any';
|
export * from './functions.any';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,7 +6,7 @@ export * from './functions.any';
|
||||||
* @param {string} url - The URL to load.
|
* @param {string} url - The URL to load.
|
||||||
* @returns {Promise<Object>}
|
* @returns {Promise<Object>}
|
||||||
*/
|
*/
|
||||||
export async function loadConfig(url: string): Promise<Object> { // eslint-disable-line no-unused-vars
|
export async function loadConfig(url: string) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
// Return "the config.js file" from the global scope - that is how the
|
// Return "the config.js file" from the global scope - that is how the
|
||||||
// Web app on both the client and the server was implemented before the
|
// Web app on both the client and the server was implemented before the
|
||||||
// React Native app was even conceived.
|
// React Native app was even conceived.
|
|
@ -1,5 +1,3 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
import { getLogger } from '../logging/functions';
|
import { getLogger } from '../logging/functions';
|
||||||
|
|
||||||
export default getLogger('features/base/lib-jitsi-meet');
|
export default getLogger('features/base/lib-jitsi-meet');
|
|
@ -1,14 +1,16 @@
|
||||||
import { SET_CONFIG } from '../config';
|
import { AnyAction } from 'redux';
|
||||||
import { SET_NETWORK_INFO } from '../net-info';
|
|
||||||
import { PARTICIPANT_LEFT } from '../participants';
|
|
||||||
import { MiddlewareRegistry } from '../redux';
|
|
||||||
|
|
||||||
|
import { IStore } from '../../app/types';
|
||||||
|
import { SET_CONFIG } from '../config/actionTypes';
|
||||||
|
import { SET_NETWORK_INFO } from '../net-info/actionTypes';
|
||||||
|
import { PARTICIPANT_LEFT } from '../participants/actionTypes';
|
||||||
|
import MiddlewareRegistry from '../redux/MiddlewareRegistry';
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
import JitsiMeetJS from './_';
|
import JitsiMeetJS from './_';
|
||||||
import { LIB_WILL_INIT } from './actionTypes';
|
import { LIB_WILL_INIT } from './actionTypes';
|
||||||
import { disposeLib, initLib } from './actions';
|
import { disposeLib, initLib } from './actions';
|
||||||
|
|
||||||
declare var APP: Object;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Middleware that captures PARTICIPANT_LEFT action for a local participant
|
* Middleware that captures PARTICIPANT_LEFT action for a local participant
|
||||||
* (which signalizes that we finally left the app) and disposes lib-jitsi-meet.
|
* (which signalizes that we finally left the app) and disposes lib-jitsi-meet.
|
||||||
|
@ -60,7 +62,7 @@ MiddlewareRegistry.register(store => next => action => {
|
||||||
* @returns {Object} The new state that is the result of the reduction of the
|
* @returns {Object} The new state that is the result of the reduction of the
|
||||||
* specified action.
|
* specified action.
|
||||||
*/
|
*/
|
||||||
function _setConfig({ dispatch, getState }, next, action) {
|
function _setConfig({ dispatch, getState }: IStore, next: Function, action: AnyAction) {
|
||||||
const { initialized } = getState()['features/base/lib-jitsi-meet'];
|
const { initialized } = getState()['features/base/lib-jitsi-meet'];
|
||||||
|
|
||||||
// XXX Since the config is changing, the library lib-jitsi-meet must be
|
// XXX Since the config is changing, the library lib-jitsi-meet must be
|
||||||
|
@ -93,8 +95,8 @@ function _setErrorHandlers() {
|
||||||
|
|
||||||
// eslint-disable-next-line max-params
|
// eslint-disable-next-line max-params
|
||||||
window.onerror = (message, source, lineno, colno, error) => {
|
window.onerror = (message, source, lineno, colno, error) => {
|
||||||
const errMsg = message || (error && error.message);
|
const errMsg = message || error?.message;
|
||||||
const stack = error && error.stack;
|
const stack = error?.stack;
|
||||||
|
|
||||||
JitsiMeetJS.getGlobalOnErrorHandler(errMsg, source, lineno, colno, stack);
|
JitsiMeetJS.getGlobalOnErrorHandler(errMsg, source, lineno, colno, stack);
|
||||||
|
|
||||||
|
@ -107,7 +109,7 @@ function _setErrorHandlers() {
|
||||||
|
|
||||||
window.onunhandledrejection = function(event) {
|
window.onunhandledrejection = function(event) {
|
||||||
let message = event.reason;
|
let message = event.reason;
|
||||||
let stack = 'n/a';
|
let stack: string | undefined = 'n/a';
|
||||||
|
|
||||||
if (event.reason instanceof Error) {
|
if (event.reason instanceof Error) {
|
||||||
({ message, stack } = event.reason);
|
({ message, stack } = event.reason);
|
||||||
|
@ -116,6 +118,7 @@ function _setErrorHandlers() {
|
||||||
JitsiMeetJS.getGlobalOnErrorHandler(message, null, null, null, stack);
|
JitsiMeetJS.getGlobalOnErrorHandler(message, null, null, null, stack);
|
||||||
|
|
||||||
if (oldOnUnhandledRejection) {
|
if (oldOnUnhandledRejection) {
|
||||||
|
// @ts-ignore
|
||||||
oldOnUnhandledRejection(event);
|
oldOnUnhandledRejection(event);
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -1,7 +1,5 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
import { SET_NETWORK_INFO, _STORE_NETWORK_INFO_CLEANUP } from './actionTypes';
|
import { SET_NETWORK_INFO, _STORE_NETWORK_INFO_CLEANUP } from './actionTypes';
|
||||||
import type { NetworkInfo } from './types';
|
import { NetworkInfo } from './types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Up[dates the network info state.
|
* Up[dates the network info state.
|
||||||
|
@ -14,7 +12,7 @@ import type { NetworkInfo } from './types';
|
||||||
* details: Object
|
* details: Object
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
export function setNetworkInfo({ isOnline, networkType, details }: NetworkInfo): Object {
|
export function setNetworkInfo({ isOnline, networkType, details }: NetworkInfo) {
|
||||||
return {
|
return {
|
||||||
type: SET_NETWORK_INFO,
|
type: SET_NETWORK_INFO,
|
||||||
isOnline,
|
isOnline,
|
||||||
|
@ -33,7 +31,7 @@ export function setNetworkInfo({ isOnline, networkType, details }: NetworkInfo):
|
||||||
* }}
|
* }}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
export function _storeNetworkInfoCleanup(cleanup: Function): Object {
|
export function _storeNetworkInfoCleanup(cleanup?: Function) {
|
||||||
return {
|
return {
|
||||||
type: _STORE_NETWORK_INFO_CLEANUP,
|
type: _STORE_NETWORK_INFO_CLEANUP,
|
||||||
cleanup
|
cleanup
|
|
@ -1,5 +1,3 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
import { getLogger } from '../logging/functions';
|
import { getLogger } from '../logging/functions';
|
||||||
|
|
||||||
export default getLogger('features/base/net-info');
|
export default getLogger('features/base/net-info');
|
|
@ -1,8 +1,7 @@
|
||||||
// @flow
|
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app/actionTypes';
|
||||||
|
import MiddlewareRegistry from '../redux/MiddlewareRegistry';
|
||||||
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app';
|
|
||||||
import { MiddlewareRegistry } from '../redux';
|
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
import NetworkInfoService from './NetworkInfoService';
|
import NetworkInfoService from './NetworkInfoService';
|
||||||
import { _storeNetworkInfoCleanup, setNetworkInfo } from './actions';
|
import { _storeNetworkInfoCleanup, setNetworkInfo } from './actions';
|
||||||
import { STORE_NAME } from './constants';
|
import { STORE_NAME } from './constants';
|
|
@ -1,11 +1,13 @@
|
||||||
|
import { IState } from '../../app/types';
|
||||||
|
|
||||||
import { STORE_NAME } from './constants';
|
import { STORE_NAME } from './constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A selector for the internet online status.
|
* A selector for the internet online status.
|
||||||
*
|
*
|
||||||
* @param {Object} state - The redux state.
|
* @param {IState} state - The redux state.
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
export function isOnline(state) {
|
export function isOnline(state: IState) {
|
||||||
return state[STORE_NAME].isOnline;
|
return state[STORE_NAME].isOnline;
|
||||||
}
|
}
|
|
@ -1,5 +1,3 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
import { NetInfoCellularGeneration, NetInfoStateType } from '@react-native-community/netinfo';
|
import { NetInfoCellularGeneration, NetInfoStateType } from '@react-native-community/netinfo';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,32 +6,32 @@ import { NetInfoCellularGeneration, NetInfoStateType } from '@react-native-commu
|
||||||
*/
|
*/
|
||||||
export type NetworkInfo = {
|
export type NetworkInfo = {
|
||||||
|
|
||||||
/**
|
|
||||||
* Tells whether or not the internet is reachable.
|
|
||||||
*/
|
|
||||||
isOnline: boolean,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The network type. Currently reported only on Android/iOS. Can be one of the constants defined by
|
|
||||||
* the 'react-native-netinfo' library.
|
|
||||||
*/
|
|
||||||
networkType: ?NetInfoStateType,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Any extra info provided by the OS. Should be JSON and is OS specific. Reported only by iOS and Android and
|
* Any extra info provided by the OS. Should be JSON and is OS specific. Reported only by iOS and Android and
|
||||||
* the format is whatever comes out of the 'react-native-netinfo' library which is network type dependent.
|
* the format is whatever comes out of the 'react-native-netinfo' library which is network type dependent.
|
||||||
*/
|
*/
|
||||||
details: ?{
|
details?: {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If {@link networkType} is {@link NetInfoStateType.cellular} then it may provide the info about the type of
|
* If {@link networkType} is {@link NetInfoStateType.cellular} then it may provide the info about the type of
|
||||||
* cellular network.
|
* cellular network.
|
||||||
*/
|
*/
|
||||||
cellularGeneration: ?NetInfoCellularGeneration;
|
cellularGeneration?: NetInfoCellularGeneration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether or not the connection is expensive.
|
* Indicates whether or not the connection is expensive.
|
||||||
*/
|
*/
|
||||||
isConnectionExpensive: ?boolean;
|
isConnectionExpensive?: boolean;
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Tells whether or not the internet is reachable.
|
||||||
|
*/
|
||||||
|
isOnline: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The network type. Currently reported only on Android/iOS. Can be one of the constants defined by
|
||||||
|
* the 'react-native-netinfo' library.
|
||||||
|
*/
|
||||||
|
networkType?: NetInfoStateType;
|
||||||
|
};
|
|
@ -19,6 +19,7 @@ export interface Participant {
|
||||||
isReplaced?: boolean;
|
isReplaced?: boolean;
|
||||||
isReplacing?: number;
|
isReplacing?: number;
|
||||||
isVirtualScreenshareParticipant?: boolean;
|
isVirtualScreenshareParticipant?: boolean;
|
||||||
|
jwtId?: string;
|
||||||
loadableAvatarUrl?: string;
|
loadableAvatarUrl?: string;
|
||||||
loadableAvatarUrlUseCORS?: boolean;
|
loadableAvatarUrlUseCORS?: boolean;
|
||||||
local?: boolean;
|
local?: boolean;
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
import { getLogger } from '../logging/functions';
|
import { getLogger } from '../logging/functions';
|
||||||
|
|
||||||
export default getLogger('features/base/sounds');
|
export default getLogger('features/base/sounds');
|
|
@ -1,6 +1,5 @@
|
||||||
// @flow
|
import { IStore } from '../../app/types';
|
||||||
|
import MiddlewareRegistry from '../redux/MiddlewareRegistry';
|
||||||
import { MiddlewareRegistry } from '../redux';
|
|
||||||
|
|
||||||
import { PLAY_SOUND, STOP_SOUND } from './actionTypes';
|
import { PLAY_SOUND, STOP_SOUND } from './actionTypes';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
|
@ -32,7 +31,7 @@ MiddlewareRegistry.register(store => next => action => {
|
||||||
* @private
|
* @private
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function _playSound({ getState }, soundId) {
|
function _playSound({ getState }: IStore, soundId: string) {
|
||||||
const sounds = getState()['features/base/sounds'];
|
const sounds = getState()['features/base/sounds'];
|
||||||
const sound = sounds.get(soundId);
|
const sound = sounds.get(soundId);
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ function _playSound({ getState }, soundId) {
|
||||||
* @private
|
* @private
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function _stopSound({ getState }, soundId) {
|
function _stopSound({ getState }: IStore, soundId: string) {
|
||||||
const sounds = getState()['features/base/sounds'];
|
const sounds = getState()['features/base/sounds'];
|
||||||
const sound = sounds.get(soundId);
|
const sound = sounds.get(soundId);
|
||||||
|
|
Loading…
Reference in New Issue