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';
|
||||
|
||||
// @ts-ignore
|
||||
import UIEvents from '../../../../service/UI/UIEvents';
|
||||
// @ts-ignore
|
||||
import { createAudioOnlyChangedEvent, sendAnalytics } from '../../analytics';
|
||||
|
||||
import { SET_AUDIO_ONLY } from './actionTypes';
|
||||
import logger from './logger';
|
||||
|
||||
|
||||
declare var APP: Object;
|
||||
declare let APP: any;
|
||||
|
||||
/**
|
||||
* Sets the audio-only flag for the current JitsiConference.
|
||||
|
@ -24,7 +25,7 @@ declare var APP: Object;
|
|||
* ensureVideoTrack: boolean
|
||||
* }}
|
||||
*/
|
||||
export function setAudioOnly(audioOnly: boolean, ensureVideoTrack: boolean = false) {
|
||||
export function setAudioOnly(audioOnly: boolean, ensureVideoTrack = false) {
|
||||
return (dispatch: Dispatch<any>, getState: Function) => {
|
||||
const { enabled: oldValue } = getState()['features/base/audio-only'];
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
// @flow
|
||||
|
||||
import { getLogger } from '../logging/functions';
|
||||
|
||||
export default getLogger('features/base/audio-only');
|
|
@ -1,5 +1,6 @@
|
|||
// Re-export JitsiMeetJS from the library lib-jitsi-meet to (the other features
|
||||
// of) the project jitsi-meet.
|
||||
// @ts-ignore
|
||||
import JitsiMeetJS from './_';
|
||||
export { JitsiMeetJS as default };
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
// @flow
|
||||
|
||||
declare var APP: Object;
|
||||
declare let APP: any;
|
||||
|
||||
/**
|
||||
* Constructs a log transport object for use with external API.
|
||||
|
@ -10,8 +8,8 @@ declare var APP: Object;
|
|||
* @returns {Object} - The transport object.
|
||||
*/
|
||||
function buildTransport(levels: Array<string>) {
|
||||
return levels.reduce((logger, level) => {
|
||||
logger[level] = (...args) => {
|
||||
return levels.reduce((logger: any, level) => {
|
||||
logger[level] = (...args: any) => {
|
||||
APP.API.notifyLog(level, args);
|
||||
};
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
*
|
||||
*/
|
||||
export default class JitsiMeetInMemoryLogStorage {
|
||||
logs: string[] = [];
|
||||
|
||||
/**
|
||||
* Creates new <tt>JitsiMeetInMemoryLogStorage</tt>.
|
||||
|
@ -34,7 +35,7 @@ export default class JitsiMeetInMemoryLogStorage {
|
|||
* representing log lines or aggregated lines objects.
|
||||
* @returns {void}
|
||||
*/
|
||||
storeLogs(logEntries) {
|
||||
storeLogs(logEntries: (string|{text: string})[]) {
|
||||
for (let i = 0, len = logEntries.length; i < len; i++) {
|
||||
const logEntry = logEntries[i];
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
// @ts-ignore
|
||||
import { getCurrentConference } from '../conference';
|
||||
|
||||
/**
|
||||
|
@ -6,13 +6,15 @@ import { getCurrentConference } from '../conference';
|
|||
* logs are sent to CallStats.
|
||||
*/
|
||||
export default class JitsiMeetLogStorage {
|
||||
counter: number;
|
||||
getState: Function;
|
||||
|
||||
/**
|
||||
* Creates new <tt>JitsiMeetLogStorage</tt>.
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
|
@ -51,7 +53,7 @@ export default class JitsiMeetLogStorage {
|
|||
* representing log lines or aggregated lines objects.
|
||||
* @returns {void}
|
||||
*/
|
||||
storeLogs(logEntries) {
|
||||
storeLogs(logEntries: Array<string|any>) {
|
||||
const conference = getCurrentConference(this.getState());
|
||||
|
||||
if (!conference || !conference.isCallstatsEnabled()) {
|
|
@ -1,5 +1,3 @@
|
|||
// @flow
|
||||
|
||||
import { NativeModules } from 'react-native';
|
||||
import { format } from 'util';
|
||||
|
||||
|
@ -14,7 +12,7 @@ const { LogBridge } = NativeModules;
|
|||
* @param {Error} e - The error.
|
||||
* @returns {string} - The stack trace.
|
||||
*/
|
||||
function stackToString(e) {
|
||||
function stackToString(e: any) {
|
||||
let ce;
|
||||
let s = e.stack;
|
||||
|
||||
|
@ -38,13 +36,15 @@ function buildTransport() {
|
|||
'log',
|
||||
'warn',
|
||||
'error'
|
||||
].reduce((logger, logName) => {
|
||||
].reduce((logger: any, logName) => {
|
||||
logger[logName] = (timestamp: string, ...args: Array<string>) => {
|
||||
// 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) {
|
||||
const errorBody = {
|
||||
message: arg.message,
|
||||
|
||||
// @ts-ignore
|
||||
code: arg.code,
|
||||
stack: stackToString(arg)
|
||||
};
|
|
@ -1,5 +1,3 @@
|
|||
/* @flow */
|
||||
|
||||
import { SET_LOG_COLLECTOR, SET_LOGGING_CONFIG } from './actionTypes';
|
||||
|
||||
/**
|
||||
|
@ -13,7 +11,7 @@ import { SET_LOG_COLLECTOR, SET_LOGGING_CONFIG } from './actionTypes';
|
|||
* logCollector: Object
|
||||
* }}
|
||||
*/
|
||||
export function setLogCollector(logCollector: ?Object) {
|
||||
export function setLogCollector(logCollector?: Object) {
|
||||
return {
|
||||
type: SET_LOG_COLLECTOR,
|
||||
logCollector
|
|
@ -1,8 +1,8 @@
|
|||
// @flow
|
||||
|
||||
// @ts-ignore
|
||||
import Logger, { getLogger as _getLogger } from '@jitsi/logger';
|
||||
import _ from 'lodash';
|
||||
|
||||
// @ts-ignore
|
||||
import LogTransport from './LogTransport';
|
||||
|
||||
/**
|
||||
|
@ -33,6 +33,7 @@ export const _initLogging = _.once(() => {
|
|||
}
|
||||
|
||||
// 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/_');
|
||||
|
||||
Logger.setGlobalOptions(DEFAULT_RN_OPTS);
|
|
@ -1,14 +1,16 @@
|
|||
/* @flow */
|
||||
|
||||
/* eslint-disable lines-around-comment */
|
||||
// @ts-ignore
|
||||
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 JitsiMeetJS, {
|
||||
JitsiConferenceEvents
|
||||
} from '../lib-jitsi-meet';
|
||||
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 buildExternalApiLogTransport from './ExternalApiLogTransport';
|
||||
|
@ -17,7 +19,7 @@ import JitsiMeetLogStorage from './JitsiMeetLogStorage';
|
|||
import { SET_LOGGING_CONFIG } from './actionTypes';
|
||||
import { setLogCollector } from './actions';
|
||||
|
||||
declare var APP: Object;
|
||||
declare let APP: any;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* specified {@code action}.
|
||||
*/
|
||||
function _appWillMount({ getState }, next, action) {
|
||||
function _appWillMount({ getState }: {getState: Function}, next: Function, action: any) {
|
||||
const { config } = getState()['features/base/logging'];
|
||||
|
||||
_setLogLevels(Logger, config);
|
||||
|
@ -84,7 +86,7 @@ function _appWillMount({ getState }, next, action) {
|
|||
* @private
|
||||
* @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
|
||||
// will be ready.
|
||||
|
@ -131,7 +133,8 @@ function _conferenceJoined({ getState }, next, action) {
|
|||
* @private
|
||||
* @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'];
|
||||
|
||||
// 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
|
||||
* 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
|
||||
// LIB_WILL_INIT action for web in initLib action.
|
||||
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
|
||||
* 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 newValue = getState()['features/base/logging'].config;
|
||||
const isTestingEnabled = isTestModeEnabled(getState());
|
||||
|
@ -244,7 +248,7 @@ function _setLoggingConfig({ dispatch, getState }, next, action) {
|
|||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
function _setLogLevels(logger, config) {
|
||||
function _setLogLevels(logger: any, config: any) {
|
||||
// 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.
|
||||
|
Loading…
Reference in New Issue