ref: Convert some files to TS (#11947)
This commit is contained in:
parent
0fa0e99ffa
commit
d3c7b074d4
|
@ -1,15 +1,16 @@
|
||||||
// @flow
|
/* eslint-disable lines-around-comment */
|
||||||
|
|
||||||
import type { Dispatch } from 'redux';
|
import type { Dispatch } from 'redux';
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
import UIEvents from '../../../../service/UI/UIEvents';
|
import UIEvents from '../../../../service/UI/UIEvents';
|
||||||
|
// @ts-ignore
|
||||||
import { createAudioOnlyChangedEvent, sendAnalytics } from '../../analytics';
|
import { createAudioOnlyChangedEvent, sendAnalytics } from '../../analytics';
|
||||||
|
|
||||||
import { SET_AUDIO_ONLY } from './actionTypes';
|
import { SET_AUDIO_ONLY } from './actionTypes';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
|
|
||||||
|
|
||||||
declare var APP: Object;
|
declare let APP: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the audio-only flag for the current JitsiConference.
|
* Sets the audio-only flag for the current JitsiConference.
|
||||||
|
@ -24,7 +25,7 @@ declare var APP: Object;
|
||||||
* ensureVideoTrack: boolean
|
* ensureVideoTrack: boolean
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
export function setAudioOnly(audioOnly: boolean, ensureVideoTrack: boolean = false) {
|
export function setAudioOnly(audioOnly: boolean, ensureVideoTrack = false) {
|
||||||
return (dispatch: Dispatch<any>, getState: Function) => {
|
return (dispatch: Dispatch<any>, getState: Function) => {
|
||||||
const { enabled: oldValue } = getState()['features/base/audio-only'];
|
const { enabled: oldValue } = getState()['features/base/audio-only'];
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
import { getLogger } from '../logging/functions';
|
import { getLogger } from '../logging/functions';
|
||||||
|
|
||||||
export default getLogger('features/base/audio-only');
|
export default getLogger('features/base/audio-only');
|
|
@ -1,5 +1,6 @@
|
||||||
// Re-export JitsiMeetJS from the library lib-jitsi-meet to (the other features
|
// Re-export JitsiMeetJS from the library lib-jitsi-meet to (the other features
|
||||||
// of) the project jitsi-meet.
|
// of) the project jitsi-meet.
|
||||||
|
// @ts-ignore
|
||||||
import JitsiMeetJS from './_';
|
import JitsiMeetJS from './_';
|
||||||
export { JitsiMeetJS as default };
|
export { JitsiMeetJS as default };
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
// @flow
|
declare let APP: any;
|
||||||
|
|
||||||
declare var APP: Object;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a log transport object for use with external API.
|
* Constructs a log transport object for use with external API.
|
||||||
|
@ -10,8 +8,8 @@ declare var APP: Object;
|
||||||
* @returns {Object} - The transport object.
|
* @returns {Object} - The transport object.
|
||||||
*/
|
*/
|
||||||
function buildTransport(levels: Array<string>) {
|
function buildTransport(levels: Array<string>) {
|
||||||
return levels.reduce((logger, level) => {
|
return levels.reduce((logger: any, level) => {
|
||||||
logger[level] = (...args) => {
|
logger[level] = (...args: any) => {
|
||||||
APP.API.notifyLog(level, args);
|
APP.API.notifyLog(level, args);
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export default class JitsiMeetInMemoryLogStorage {
|
export default class JitsiMeetInMemoryLogStorage {
|
||||||
|
logs: string[] = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new <tt>JitsiMeetInMemoryLogStorage</tt>.
|
* Creates new <tt>JitsiMeetInMemoryLogStorage</tt>.
|
||||||
|
@ -34,7 +35,7 @@ export default class JitsiMeetInMemoryLogStorage {
|
||||||
* representing log lines or aggregated lines objects.
|
* representing log lines or aggregated lines objects.
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
storeLogs(logEntries) {
|
storeLogs(logEntries: (string|{text: string})[]) {
|
||||||
for (let i = 0, len = logEntries.length; i < len; i++) {
|
for (let i = 0, len = logEntries.length; i < len; i++) {
|
||||||
const logEntry = logEntries[i];
|
const logEntry = logEntries[i];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
// @ts-ignore
|
||||||
import { getCurrentConference } from '../conference';
|
import { getCurrentConference } from '../conference';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,13 +6,15 @@ import { getCurrentConference } from '../conference';
|
||||||
* logs are sent to CallStats.
|
* logs are sent to CallStats.
|
||||||
*/
|
*/
|
||||||
export default class JitsiMeetLogStorage {
|
export default class JitsiMeetLogStorage {
|
||||||
|
counter: number;
|
||||||
|
getState: Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new <tt>JitsiMeetLogStorage</tt>.
|
* Creates new <tt>JitsiMeetLogStorage</tt>.
|
||||||
*
|
*
|
||||||
* @param {Function} getState - The Redux store's {@code getState} method.
|
* @param {Function} getState - The Redux store's {@code getState} method.
|
||||||
*/
|
*/
|
||||||
constructor(getState) {
|
constructor(getState: Function) {
|
||||||
/**
|
/**
|
||||||
* Counts each log entry, increases on every batch log entry stored.
|
* Counts each log entry, increases on every batch log entry stored.
|
||||||
*
|
*
|
||||||
|
@ -51,7 +53,7 @@ export default class JitsiMeetLogStorage {
|
||||||
* representing log lines or aggregated lines objects.
|
* representing log lines or aggregated lines objects.
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
storeLogs(logEntries) {
|
storeLogs(logEntries: Array<string|any>) {
|
||||||
const conference = getCurrentConference(this.getState());
|
const conference = getCurrentConference(this.getState());
|
||||||
|
|
||||||
if (!conference || !conference.isCallstatsEnabled()) {
|
if (!conference || !conference.isCallstatsEnabled()) {
|
|
@ -1,5 +1,3 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
import { NativeModules } from 'react-native';
|
import { NativeModules } from 'react-native';
|
||||||
import { format } from 'util';
|
import { format } from 'util';
|
||||||
|
|
||||||
|
@ -14,7 +12,7 @@ const { LogBridge } = NativeModules;
|
||||||
* @param {Error} e - The error.
|
* @param {Error} e - The error.
|
||||||
* @returns {string} - The stack trace.
|
* @returns {string} - The stack trace.
|
||||||
*/
|
*/
|
||||||
function stackToString(e) {
|
function stackToString(e: any) {
|
||||||
let ce;
|
let ce;
|
||||||
let s = e.stack;
|
let s = e.stack;
|
||||||
|
|
||||||
|
@ -38,13 +36,15 @@ function buildTransport() {
|
||||||
'log',
|
'log',
|
||||||
'warn',
|
'warn',
|
||||||
'error'
|
'error'
|
||||||
].reduce((logger, logName) => {
|
].reduce((logger: any, logName) => {
|
||||||
logger[logName] = (timestamp: string, ...args: Array<string>) => {
|
logger[logName] = (timestamp: string, ...args: Array<string>) => {
|
||||||
// It ignores the timestamp argument, because LogBridge will add it on the native side anyway
|
// It ignores the timestamp argument, because LogBridge will add it on the native side anyway
|
||||||
const nargs = args.map(arg => {
|
const nargs = args.map((arg: any) => {
|
||||||
if (arg instanceof Error) {
|
if (arg instanceof Error) {
|
||||||
const errorBody = {
|
const errorBody = {
|
||||||
message: arg.message,
|
message: arg.message,
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
code: arg.code,
|
code: arg.code,
|
||||||
stack: stackToString(arg)
|
stack: stackToString(arg)
|
||||||
};
|
};
|
|
@ -1,5 +1,3 @@
|
||||||
/* @flow */
|
|
||||||
|
|
||||||
import { SET_LOG_COLLECTOR, SET_LOGGING_CONFIG } from './actionTypes';
|
import { SET_LOG_COLLECTOR, SET_LOGGING_CONFIG } from './actionTypes';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,7 +11,7 @@ import { SET_LOG_COLLECTOR, SET_LOGGING_CONFIG } from './actionTypes';
|
||||||
* logCollector: Object
|
* logCollector: Object
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
export function setLogCollector(logCollector: ?Object) {
|
export function setLogCollector(logCollector?: Object) {
|
||||||
return {
|
return {
|
||||||
type: SET_LOG_COLLECTOR,
|
type: SET_LOG_COLLECTOR,
|
||||||
logCollector
|
logCollector
|
|
@ -1,8 +1,8 @@
|
||||||
// @flow
|
// @ts-ignore
|
||||||
|
|
||||||
import Logger, { getLogger as _getLogger } from '@jitsi/logger';
|
import Logger, { getLogger as _getLogger } from '@jitsi/logger';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
import LogTransport from './LogTransport';
|
import LogTransport from './LogTransport';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,6 +33,7 @@ export const _initLogging = _.once(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lazy load it to avoid cycles in early web bootstrap code.
|
// Lazy load it to avoid cycles in early web bootstrap code.
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const { default: JitsiMeetJS } = require('../lib-jitsi-meet/_');
|
const { default: JitsiMeetJS } = require('../lib-jitsi-meet/_');
|
||||||
|
|
||||||
Logger.setGlobalOptions(DEFAULT_RN_OPTS);
|
Logger.setGlobalOptions(DEFAULT_RN_OPTS);
|
|
@ -1,14 +1,16 @@
|
||||||
/* @flow */
|
/* eslint-disable lines-around-comment */
|
||||||
|
// @ts-ignore
|
||||||
import Logger from '@jitsi/logger';
|
import Logger from '@jitsi/logger';
|
||||||
|
|
||||||
import { APP_WILL_MOUNT } from '../app';
|
import { APP_WILL_MOUNT } from '../app/actionTypes';
|
||||||
|
// @ts-ignore
|
||||||
import { CONFERENCE_JOINED, getCurrentConference } from '../conference';
|
import { CONFERENCE_JOINED, getCurrentConference } from '../conference';
|
||||||
import JitsiMeetJS, {
|
import JitsiMeetJS, {
|
||||||
JitsiConferenceEvents
|
JitsiConferenceEvents
|
||||||
} from '../lib-jitsi-meet';
|
} from '../lib-jitsi-meet';
|
||||||
import { LIB_WILL_INIT } from '../lib-jitsi-meet/actionTypes';
|
import { LIB_WILL_INIT } from '../lib-jitsi-meet/actionTypes';
|
||||||
import { MiddlewareRegistry } from '../redux';
|
import MiddlewareRegistry from '../redux/MiddlewareRegistry';
|
||||||
|
// @ts-ignore
|
||||||
import { isTestModeEnabled } from '../testing';
|
import { isTestModeEnabled } from '../testing';
|
||||||
|
|
||||||
import buildExternalApiLogTransport from './ExternalApiLogTransport';
|
import buildExternalApiLogTransport from './ExternalApiLogTransport';
|
||||||
|
@ -17,7 +19,7 @@ import JitsiMeetLogStorage from './JitsiMeetLogStorage';
|
||||||
import { SET_LOGGING_CONFIG } from './actionTypes';
|
import { SET_LOGGING_CONFIG } from './actionTypes';
|
||||||
import { setLogCollector } from './actions';
|
import { setLogCollector } from './actions';
|
||||||
|
|
||||||
declare var APP: Object;
|
declare let APP: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Redux middleware of the feature base/logging.
|
* The Redux middleware of the feature base/logging.
|
||||||
|
@ -58,7 +60,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 {@code action}.
|
* specified {@code action}.
|
||||||
*/
|
*/
|
||||||
function _appWillMount({ getState }, next, action) {
|
function _appWillMount({ getState }: {getState: Function}, next: Function, action: any) {
|
||||||
const { config } = getState()['features/base/logging'];
|
const { config } = getState()['features/base/logging'];
|
||||||
|
|
||||||
_setLogLevels(Logger, config);
|
_setLogLevels(Logger, config);
|
||||||
|
@ -84,7 +86,7 @@ function _appWillMount({ getState }, next, action) {
|
||||||
* @private
|
* @private
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
function _conferenceJoined({ getState }, next, action) {
|
function _conferenceJoined({ getState }: { getState: Function }, next: Function, action: any) {
|
||||||
|
|
||||||
// Wait until the joined event is processed, so that the JitsiMeetLogStorage
|
// Wait until the joined event is processed, so that the JitsiMeetLogStorage
|
||||||
// will be ready.
|
// will be ready.
|
||||||
|
@ -131,7 +133,8 @@ function _conferenceJoined({ getState }, next, action) {
|
||||||
* @private
|
* @private
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function _initLogging({ dispatch, getState }, loggingConfig, isTestingEnabled) {
|
function _initLogging({ dispatch, getState }: {dispatch: Function, getState: Function},
|
||||||
|
loggingConfig: any, isTestingEnabled: boolean) {
|
||||||
const { logCollector } = getState()['features/base/logging'];
|
const { logCollector } = getState()['features/base/logging'];
|
||||||
|
|
||||||
// Create the LogCollector and register it as the global log transport. It
|
// Create the LogCollector and register it as the global log transport. It
|
||||||
|
@ -188,7 +191,7 @@ function _initLogging({ dispatch, getState }, loggingConfig, isTestingEnabled) {
|
||||||
* @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 _libWillInit({ getState }, next, action) {
|
function _libWillInit({ getState }: { getState: Function }, next: Function, action: any) {
|
||||||
// Adding the if in order to preserve the logic for web after enabling
|
// Adding the if in order to preserve the logic for web after enabling
|
||||||
// LIB_WILL_INIT action for web in initLib action.
|
// LIB_WILL_INIT action for web in initLib action.
|
||||||
if (typeof APP === 'undefined') {
|
if (typeof APP === 'undefined') {
|
||||||
|
@ -212,7 +215,8 @@ function _libWillInit({ 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 _setLoggingConfig({ dispatch, getState }, next, action) {
|
function _setLoggingConfig({ dispatch, getState }: { dispatch: Function, getState: Function },
|
||||||
|
next: Function, action: any) {
|
||||||
const result = next(action);
|
const result = next(action);
|
||||||
const newValue = getState()['features/base/logging'].config;
|
const newValue = getState()['features/base/logging'].config;
|
||||||
const isTestingEnabled = isTestModeEnabled(getState());
|
const isTestingEnabled = isTestModeEnabled(getState());
|
||||||
|
@ -244,7 +248,7 @@ function _setLoggingConfig({ dispatch, getState }, next, action) {
|
||||||
* @private
|
* @private
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function _setLogLevels(logger, config) {
|
function _setLogLevels(logger: any, config: any) {
|
||||||
// XXX The loggers of the library lib-jitsi-meet and the application
|
// XXX The loggers of the library lib-jitsi-meet and the application
|
||||||
// jitsi-meet are separate, so the log levels have to be set in both.
|
// jitsi-meet are separate, so the log levels have to be set in both.
|
||||||
|
|
Loading…
Reference in New Issue