In
1ffd75c0a6
we switched to using the localStorage wrapper provided by js-utils, which
checks for window.localStorage's availability very early. Our polyfill must be
applied earlier that any such import.
Here we are importing it in the entrypoint, which means no code ran before this,
literally.
88 lines
2.6 KiB
JavaScript
88 lines
2.6 KiB
JavaScript
// @flow
|
|
|
|
// FIXME The bundler-related (and the browser-related) polyfills were born at
|
|
// the very early days of prototyping the execution of lib-jitsi-meet on
|
|
// react-native. Today, the feature base/lib-jitsi-meet should not be
|
|
// responsible for such polyfills because it is not the only feature relying on
|
|
// them. Additionally, the polyfills are usually necessary earlier than the
|
|
// execution of base/lib-jitsi-meet (which is understandable given that the
|
|
// polyfills are globals). The remaining problem to be solved here is where to
|
|
// collect the polyfills' files.
|
|
import './features/base/lib-jitsi-meet/native/polyfills-bundler';
|
|
|
|
// Polyfill localStorage early so any library that requires it sees it available.
|
|
import './features/base/storage/native/polyfills-browser';
|
|
|
|
import React, { PureComponent } from 'react';
|
|
import { AppRegistry } from 'react-native';
|
|
|
|
import { App } from './features/app';
|
|
import { IncomingCallApp } from './features/mobile/incoming-call';
|
|
|
|
// It's crucial that the native loggers are created ASAP, not to lose any data.
|
|
import { _initLogging } from './features/base/logging/functions';
|
|
|
|
declare var __DEV__;
|
|
|
|
/**
|
|
* The type of the React {@code Component} props of {@link Root}.
|
|
*/
|
|
type Props = {
|
|
|
|
/**
|
|
* The URL, if any, with which the app was launched.
|
|
*/
|
|
url: Object | string
|
|
};
|
|
|
|
/**
|
|
* React Native doesn't support specifying props to the main/root component (in
|
|
* the JS/JSX source code). So create a wrapper React Component (class) around
|
|
* features/app's App instead.
|
|
*
|
|
* @extends Component
|
|
*/
|
|
class Root extends PureComponent<Props> {
|
|
/**
|
|
* Implements React's {@link Component#render()}.
|
|
*
|
|
* @inheritdoc
|
|
* @returns {ReactElement}
|
|
*/
|
|
render() {
|
|
return (
|
|
<App
|
|
{ ...this.props } />
|
|
);
|
|
}
|
|
}
|
|
|
|
// Initialize logging.
|
|
_initLogging();
|
|
|
|
// HORRIBLE HACK ALERT! React Native logs the initial props with `console.log`. Here we are quickly patching it
|
|
// to avoid logging potentially sensitive information.
|
|
if (!__DEV__) {
|
|
/* eslint-disable */
|
|
|
|
const __orig_console_log = console.log;
|
|
const __orig_appregistry_runapplication = AppRegistry.runApplication;
|
|
|
|
AppRegistry.runApplication = (...args) => {
|
|
// $FlowExpectedError
|
|
console.log = () => {};
|
|
__orig_appregistry_runapplication(...args);
|
|
// $FlowExpectedError
|
|
console.log = __orig_console_log;
|
|
};
|
|
|
|
/* eslint-enable */
|
|
}
|
|
|
|
|
|
// Register the main/root Component of JitsiMeetView.
|
|
AppRegistry.registerComponent('App', () => Root);
|
|
|
|
// Register the main/root Component of IncomingCallView.
|
|
AppRegistry.registerComponent('IncomingCallApp', () => IncomingCallApp);
|