Make crash reporter plugin device only
Summary: Makes a crash reporter plugin as a device plugin Reviewed By: passy Differential Revision: D13203954 fbshipit-source-id: 02ef2aff05d5a240eaff588f9b515d3d610fc182
This commit is contained in:
committed by
Facebook Github Bot
parent
7ffdb36cc5
commit
14431e6b76
@@ -5,7 +5,7 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type {FlipperPlugin} from './plugin.js';
|
import type {FlipperPlugin, FlipperBasePlugin} from './plugin.js';
|
||||||
import type {App} from './App.js';
|
import type {App} from './App.js';
|
||||||
import type Logger from './fb-stubs/Logger.js';
|
import type Logger from './fb-stubs/Logger.js';
|
||||||
import type {Store} from './reducers/index.js';
|
import type {Store} from './reducers/index.js';
|
||||||
@@ -153,10 +153,9 @@ export default class Client extends EventEmitter {
|
|||||||
const params = data.params;
|
const params = data.params;
|
||||||
invariant(params, 'expected params');
|
invariant(params, 'expected params');
|
||||||
|
|
||||||
const persistingPlugin: ?Class<
|
const persistingPlugin: ?Class<FlipperBasePlugin<>> =
|
||||||
FlipperPlugin<>,
|
this.store.getState().plugins.clientPlugins.get(params.api) ||
|
||||||
> = this.store.getState().plugins.clientPlugins.get(params.api);
|
this.store.getState().plugins.devicePlugins.get(params.api);
|
||||||
|
|
||||||
if (persistingPlugin && persistingPlugin.persistedStateReducer) {
|
if (persistingPlugin && persistingPlugin.persistedStateReducer) {
|
||||||
const pluginKey = `${this.id}#${params.api}`;
|
const pluginKey = `${this.id}#${params.api}`;
|
||||||
const persistedState = {
|
const persistedState = {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
import type {Store} from '../reducers/index.js';
|
import type {Store} from '../reducers/index.js';
|
||||||
import type Logger from '../fb-stubs/Logger.js';
|
import type Logger from '../fb-stubs/Logger.js';
|
||||||
import type {PluginNotification} from '../reducers/notifications';
|
import type {PluginNotification} from '../reducers/notifications';
|
||||||
import type {FlipperPlugin} from '../plugin.js';
|
import type {FlipperPlugin, FlipperDevicePlugin} from '../plugin.js';
|
||||||
|
|
||||||
import {ipcRenderer} from 'electron';
|
import {ipcRenderer} from 'electron';
|
||||||
import {selectPlugin} from '../reducers/connections';
|
import {selectPlugin} from '../reducers/connections';
|
||||||
@@ -82,7 +82,20 @@ export default (store: Store, logger: Logger) => {
|
|||||||
|
|
||||||
store.subscribe(() => {
|
store.subscribe(() => {
|
||||||
const {notifications, pluginStates} = store.getState();
|
const {notifications, pluginStates} = store.getState();
|
||||||
const pluginMap = store.getState().plugins.clientPlugins;
|
|
||||||
|
const clientPlugins: Map<string, Class<FlipperPlugin<>>> = store.getState()
|
||||||
|
.plugins.clientPlugins;
|
||||||
|
|
||||||
|
const devicePlugins: Map<
|
||||||
|
string,
|
||||||
|
Class<FlipperDevicePlugin<>>,
|
||||||
|
> = store.getState().plugins.devicePlugins;
|
||||||
|
|
||||||
|
const pluginMap: Map<
|
||||||
|
string,
|
||||||
|
Class<FlipperPlugin<> | FlipperDevicePlugin<>>,
|
||||||
|
//$FlowFixMe Flow complains that FlipperPlugin and FlipperDevicePlugin are incompatible, where as we have already mentioned the type of the class it can take in the type
|
||||||
|
> = new Map([...clientPlugins, ...devicePlugins]);
|
||||||
|
|
||||||
Object.keys(pluginStates).forEach(key => {
|
Object.keys(pluginStates).forEach(key => {
|
||||||
if (knownPluginStates.get(key) !== pluginStates[key]) {
|
if (knownPluginStates.get(key) !== pluginStates[key]) {
|
||||||
@@ -90,10 +103,9 @@ export default (store: Store, logger: Logger) => {
|
|||||||
const split = key.split('#');
|
const split = key.split('#');
|
||||||
const pluginId = split.pop();
|
const pluginId = split.pop();
|
||||||
const client = split.join('#');
|
const client = split.join('#');
|
||||||
const persistingPlugin: ?Class<FlipperPlugin<>> = pluginMap.get(
|
const persistingPlugin: ?Class<
|
||||||
pluginId,
|
FlipperPlugin<> | FlipperDevicePlugin<>,
|
||||||
);
|
> = pluginMap.get(pluginId);
|
||||||
|
|
||||||
if (persistingPlugin && persistingPlugin.getActiveNotifications) {
|
if (persistingPlugin && persistingPlugin.getActiveNotifications) {
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
setActiveNotifications({
|
setActiveNotifications({
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
export {default as styled} from 'react-emotion';
|
export {default as styled} from 'react-emotion';
|
||||||
export * from './ui/index.js';
|
export * from './ui/index.js';
|
||||||
export * from './utils/index.js';
|
export * from './utils/index.js';
|
||||||
|
|
||||||
export {default as GK} from './fb-stubs/GK.js';
|
export {default as GK} from './fb-stubs/GK.js';
|
||||||
export {
|
export {
|
||||||
FlipperBasePlugin,
|
FlipperBasePlugin,
|
||||||
|
|||||||
@@ -55,7 +55,14 @@ export class FlipperBasePlugin<
|
|||||||
static keyboardActions: ?KeyboardActions;
|
static keyboardActions: ?KeyboardActions;
|
||||||
static screenshot: ?string;
|
static screenshot: ?string;
|
||||||
static defaultPersistedState: PersistedState;
|
static defaultPersistedState: PersistedState;
|
||||||
|
static persistedStateReducer: ?(
|
||||||
|
persistedState: PersistedState,
|
||||||
|
method: string,
|
||||||
|
data: Object,
|
||||||
|
) => $Shape<PersistedState>;
|
||||||
|
static getActiveNotifications: ?(
|
||||||
|
persistedState: PersistedState,
|
||||||
|
) => Array<Notification>;
|
||||||
// forbid instance properties that should be static
|
// forbid instance properties that should be static
|
||||||
title: empty;
|
title: empty;
|
||||||
id: empty;
|
id: empty;
|
||||||
@@ -129,13 +136,6 @@ export class FlipperPlugin<S = *, A = *, P = *> extends FlipperBasePlugin<
|
|||||||
A,
|
A,
|
||||||
P,
|
P,
|
||||||
> {
|
> {
|
||||||
static persistedStateReducer: ?(
|
|
||||||
persistedState: P,
|
|
||||||
method: string,
|
|
||||||
data: Object,
|
|
||||||
) => $Shape<P>;
|
|
||||||
static getActiveNotifications: ?(persistedState: P) => Array<Notification>;
|
|
||||||
|
|
||||||
constructor(props: Props<*>) {
|
constructor(props: Props<*>) {
|
||||||
super(props);
|
super(props);
|
||||||
const {id} = this.constructor;
|
const {id} = this.constructor;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* @flow
|
* @flow
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {FlipperPlugin} from 'flipper';
|
import {FlipperDevicePlugin, Device} from 'flipper';
|
||||||
import type {Notification} from '../../plugin';
|
import type {Notification} from '../../plugin';
|
||||||
|
|
||||||
type Crash = {|
|
type Crash = {|
|
||||||
@@ -19,7 +19,7 @@ type PersistedState = {|
|
|||||||
crashes: Array<Crash>,
|
crashes: Array<Crash>,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
export default class extends FlipperPlugin {
|
export default class CrashReporterPlugin extends FlipperDevicePlugin {
|
||||||
static title = 'Crash Reporter';
|
static title = 'Crash Reporter';
|
||||||
static id = 'CrashReporter';
|
static id = 'CrashReporter';
|
||||||
static icon = 'apps';
|
static icon = 'apps';
|
||||||
@@ -28,6 +28,9 @@ export default class extends FlipperPlugin {
|
|||||||
crashes: [],
|
crashes: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static supportsDevice(device: Device) {
|
||||||
|
return device.os === 'iOS' || device.os === 'Android';
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Reducer to process incoming "send" messages from the mobile counterpart.
|
* Reducer to process incoming "send" messages from the mobile counterpart.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user