Merge branch 'master' into fcm-rewrite

# Conflicts:
#	lib/modules/core/firebase.js
#	tests/ios/Podfile.lock
This commit is contained in:
Chris Bianca
2018-03-08 09:32:57 +00:00
55 changed files with 6982 additions and 2425 deletions

View File

@@ -32,13 +32,14 @@ export default {
},
apps(): Array<App> {
// $FlowBug: Object.values always returns mixed type: https://github.com/facebook/flow/issues/2221
// $FlowExpectedError: Object.values always returns mixed type: https://github.com/facebook/flow/issues/2221
return Object.values(APPS);
},
/**
*
* @param statics
* @param app
* @param namespace
* @param InstanceClass
* @return {function()}
* @private
@@ -152,8 +153,9 @@ export default {
/**
*
* @param namespace
* @param statics
* @param InstanceClass
* @param moduleName
* @return {function(App=)}
*/
moduleAndStatics<M: FirebaseModule, S: FirebaseStatics>(
@@ -174,7 +176,7 @@ export default {
if (namespace === 'crashlytics') {
return _app.fabric[namespace]();
}
// $FlowBug: Flow doesn't support indexable signatures on classes: https://github.com/facebook/flow/issues/1323
// $FlowExpectedError: Flow doesn't support indexable signatures on classes: https://github.com/facebook/flow/issues/1323
const module = _app[namespace];
return module();
};

View File

@@ -201,7 +201,7 @@ class EventEmitter {
* }); // removes the listener if already registered
*
*/
removeListener(eventType: String, listener) {
removeListener(eventType: string, listener) {
const subscriptions: ?[EmitterSubscription] = (this._subscriber.getSubscriptionsForType(eventType): any);
if (subscriptions) {
for (let i = 0, l = subscriptions.length; i < l; i++) {

View File

@@ -170,12 +170,6 @@ export function tryJSONStringify(data: mixed): string | null {
}
}
export const windowOrGlobal =
// eslint-disable-next-line no-restricted-globals
(typeof self === 'object' && self.self === self && self) ||
(typeof global === 'object' && global.global === global && global) ||
this;
/**
* No operation func
*/
@@ -282,7 +276,7 @@ export function typeOf(value: any): string {
// * @param string
// * @return {string}
// */
// export function capitalizeFirstLetter(string: String) {
// export function capitalizeFirstLetter(string: string) {
// return `${string.charAt(0).toUpperCase()}${string.slice(1)}`;
// }

View File

@@ -21,35 +21,35 @@ const GRADLE_DEPS = {
};
const PLAY_SERVICES_CODES = {
// $FlowBug: Doesn't like numerical object keys: https://github.com/facebook/flow/issues/380
// $FlowExpectedError: Doesn't like numerical object keys: https://github.com/facebook/flow/issues/380
1: {
code: 'SERVICE_MISSING',
message: 'Google Play services is missing on this device.',
},
// $FlowBug: Doesn't like numerical object keys: https://github.com/facebook/flow/issues/380
// $FlowExpectedError: Doesn't like numerical object keys: https://github.com/facebook/flow/issues/380
2: {
code: 'SERVICE_VERSION_UPDATE_REQUIRED',
message:
'The installed version of Google Play services on this device is out of date.',
},
// $FlowBug: Doesn't like numerical object keys: https://github.com/facebook/flow/issues/380
// $FlowExpectedError: Doesn't like numerical object keys: https://github.com/facebook/flow/issues/380
3: {
code: 'SERVICE_DISABLED',
message:
'The installed version of Google Play services has been disabled on this device.',
},
// $FlowBug: Doesn't like numerical object keys: https://github.com/facebook/flow/issues/380
// $FlowExpectedError: Doesn't like numerical object keys: https://github.com/facebook/flow/issues/380
9: {
code: 'SERVICE_INVALID',
message:
'The version of the Google Play services installed on this device is not authentic.',
},
// $FlowBug: Doesn't like numerical object keys: https://github.com/facebook/flow/issues/380
// $FlowExpectedError: Doesn't like numerical object keys: https://github.com/facebook/flow/issues/380
18: {
code: 'SERVICE_UPDATING',
message: 'Google Play services is currently being updated on this device.',
},
// $FlowBug: Doesn't like numerical object keys: https://github.com/facebook/flow/issues/380
// $FlowExpectedError: Doesn't like numerical object keys: https://github.com/facebook/flow/issues/380
19: {
code: 'SERVICE_MISSING_PERMISSION',
message:

View File

@@ -1,18 +1,10 @@
/*
* @flow
*/
import { windowOrGlobal } from './';
import INTERNALS from './internals';
import type ModuleBase from './ModuleBase';
(base => {
window = base || window;
// $FlowFixMe: Why are we using localStorage at all?
if (!window.localStorage) window.localStorage = {};
})(windowOrGlobal);
// clean up time
const NATIVE_LOGGERS: { [string]: Object } = {};
const getModuleKey = (module: ModuleBase): string =>
@@ -23,22 +15,33 @@ export const getLogger = (module: ModuleBase) => {
return NATIVE_LOGGERS[key];
};
export const LEVELS = {
debug: 0,
info: 1,
warn: 2,
error: 3,
};
export const initialiseLogger = (module: ModuleBase, logNamespace: string) => {
const key = getModuleKey(module);
if (!NATIVE_LOGGERS[key]) {
// eslint-disable-next-line global-require
NATIVE_LOGGERS[key] = require('bows')(`🔥 ${logNamespace.toUpperCase()}`);
const prefix = `🔥 ${logNamespace.toUpperCase()}`;
NATIVE_LOGGERS[key] = {
debug(...args) {
if (__DEV__ && LEVELS.debug >= LEVELS[INTERNALS.OPTIONS.logLevel])
console.log(...[prefix, ...args]);
},
info(...args) {
if (__DEV__ && LEVELS.info >= LEVELS[INTERNALS.OPTIONS.logLevel])
console.log(...[prefix, ...args]);
},
warn(...args) {
if (__DEV__ && LEVELS.warn >= LEVELS[INTERNALS.OPTIONS.logLevel])
console.warn(...args);
},
error(...args) {
console.error(...args);
},
};
}
};
export default class Log {
static createLogger(namespace: string) {
// eslint-disable-next-line global-require
return require('bows')(namespace);
}
static setLevel(booleanOrDebugString: boolean | string) {
window.localStorage.debug = booleanOrDebugString;
window.localStorage.debugColors = !!booleanOrDebugString;
}
}