Files
flipper/src/devices/BaseDevice.js
Daniel Büchele cbab597236 show only one device in sidbar
Summary:
Refactors the plugin architecture of Sonar:
- Before plugin rendering had it's own implementation of the react lifecycle. This means the `render`-function was not called by react, but rather by the application it self. In this diff, the render method is now called from react, which enables better debugging and allows react to do optimizations.
- Business logic for querying emulators is moved away from the view components into its own dispatcher
- All plugin handling is moved from `App.js` to `PluginContainer`.
- The sidebar only shows one selected device. This allows us to add the screenshot feature as part of the Sonar main app and not a plugin.
- This also fixes the inconsistency between the devices button and the sidebar

Reviewed By: jknoxville

Differential Revision: D8186933

fbshipit-source-id: 46404443025bcf18d6eeba0679e098d5440822d5
2018-06-25 10:04:00 -07:00

79 lines
1.7 KiB
JavaScript

/**
* Copyright 2018-present Facebook.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* @format
*/
import type stream from 'stream';
import {SonarDevicePlugin} from 'sonar';
export type DeviceLogEntry = {
date: Date,
pid: number,
tid: number,
app?: string,
type: 'unknown' | 'verbose' | 'debug' | 'info' | 'warn' | 'error' | 'fatal',
tag: string,
message: string,
};
export type DeviceShell = {
stdout: stream.Readable,
stderr: stream.Readable,
stdin: stream.Writable,
};
export type DeviceLogListener = (entry: DeviceLogEntry) => void;
export type DeviceType = 'emulator' | 'physical';
export default class BaseDevice {
constructor(serial: string, deviceType: DeviceType, title: string) {
this.serial = serial;
this.title = title;
this.deviceType = deviceType;
}
// operating system of this device
os: string;
// human readable name for this device
title: string;
// type of this device
deviceType: DeviceType;
// serial number for this device
serial: string;
// supported device plugins for this platform
supportedPlugins: Array<string> = [];
// possible src of icon to display next to the device title
icon: ?string;
supportsPlugin = (DevicePlugin: Class<SonarDevicePlugin<>>): boolean => {
return this.supportedPlugins.includes(DevicePlugin.id);
};
// ensure that we don't serialise devices
toJSON() {
return null;
}
teardown() {}
supportedColumns(): Array<string> {
throw new Error('unimplemented');
}
addLogListener(listener: DeviceLogListener) {
throw new Error('unimplemented');
}
spawnShell(): DeviceShell {
throw new Error('unimplemented');
}
}