diff --git a/src/Client.js b/src/Client.js index cb8672af2..1bd934042 100644 --- a/src/Client.js +++ b/src/Client.js @@ -5,7 +5,7 @@ * @format */ -import type {SonarPlugin} from './plugin.js'; +import type {FlipperPlugin} from './plugin.js'; import type {App} from './App.js'; import type Logger from './fb-stubs/Logger.js'; @@ -88,7 +88,7 @@ export default class Client extends EventEmitter { |}, >; - supportsPlugin(Plugin: Class>): boolean { + supportsPlugin(Plugin: Class>): boolean { return this.plugins.includes(Plugin.id); } diff --git a/src/MenuBar.js b/src/MenuBar.js index 7d788bf23..4ed913fbd 100644 --- a/src/MenuBar.js +++ b/src/MenuBar.js @@ -5,7 +5,7 @@ * @format */ -import type {SonarBasePlugin} from './plugin.js'; +import type {FlipperBasePlugin} from './plugin.js'; import {devicePlugins} from './device-plugins/index.js'; import plugins from './plugins/index.js'; @@ -70,7 +70,7 @@ export function setupMenuBar() { // collect all keyboard actions from all plugins const registeredActions: Set = new Set( [...devicePlugins, ...plugins] - .map((plugin: Class>) => plugin.keyboardActions || []) + .map((plugin: Class>) => plugin.keyboardActions || []) .reduce((acc: KeyboardActions, cv) => acc.concat(cv), []) .map( (action: DefaultKeyboardAction | KeyboardAction) => @@ -133,7 +133,7 @@ function appendMenuItem( } } -export function activateMenuItems(activePlugin: SonarBasePlugin<>) { +export function activateMenuItems(activePlugin: FlipperBasePlugin<>) { // disable all keyboard actions for (const item of menuItems) { item[1].enabled = false; diff --git a/src/PluginContainer.js b/src/PluginContainer.js index a683a6e00..4fb903227 100644 --- a/src/PluginContainer.js +++ b/src/PluginContainer.js @@ -4,13 +4,13 @@ * LICENSE file in the root directory of this source tree. * @format */ -import type {SonarPlugin, SonarBasePlugin} from './plugin.js'; +import type {FlipperPlugin, FlipperBasePlugin} from './plugin.js'; import type LogManager from './fb-stubs/Logger'; import type Client from './Client.js'; import type BaseDevice from './devices/BaseDevice.js'; import type {Props as PluginProps} from './plugin'; -import {SonarDevicePlugin} from './plugin.js'; +import {FlipperDevicePlugin} from './plugin.js'; import { ErrorBoundary, Component, @@ -55,7 +55,7 @@ type Props = { }; type State = { - activePlugin: ?Class>, + activePlugin: ?Class>, target: Client | BaseDevice | null, pluginKey: string, }; @@ -63,7 +63,7 @@ type State = { function computeState(props: Props): State { // plugin changed let activePlugin = devicePlugins.find( - (p: Class>) => p.id === props.selectedPlugin, + (p: Class>) => p.id === props.selectedPlugin, ); let target = props.selectedDevice; let pluginKey = 'unknown'; @@ -74,7 +74,7 @@ function computeState(props: Props): State { (client: Client) => client.id === props.selectedApp, ); activePlugin = plugins.find( - (p: Class>) => p.id === props.selectedPlugin, + (p: Class>) => p.id === props.selectedPlugin, ); if (!activePlugin || !target) { throw new Error( @@ -92,7 +92,7 @@ function computeState(props: Props): State { } class PluginContainer extends Component { - plugin: ?SonarBasePlugin<>; + plugin: ?FlipperBasePlugin<>; constructor(props: Props) { super(); @@ -109,7 +109,7 @@ class PluginContainer extends Component { } } - refChanged = (ref: ?SonarBasePlugin<>) => { + refChanged = (ref: ?FlipperBasePlugin<>) => { if (this.plugin) { this.plugin._teardown(); this.plugin = null; diff --git a/src/chrome/MainSidebar.js b/src/chrome/MainSidebar.js index c18e7aab2..d856db061 100644 --- a/src/chrome/MainSidebar.js +++ b/src/chrome/MainSidebar.js @@ -6,9 +6,9 @@ */ import type { - SonarPlugin, - SonarDevicePlugin, - SonarBasePlugin, + FlipperPlugin, + FlipperDevicePlugin, + FlipperBasePlugin, } from '../plugin.js'; import type BaseDevice from '../devices/BaseDevice.js'; import type Client from '../Client.js'; @@ -97,7 +97,7 @@ function PluginIcon({ class PluginSidebarListItem extends Component<{ onClick: () => void, isActive: boolean, - plugin: Class>, + plugin: Class>, app?: ?string, }> { render() { @@ -185,7 +185,7 @@ class MainSidebar extends Component { {selectedDevice && devicePlugins .filter(selectedDevice.supportsPlugin) - .map((plugin: Class>) => ( + .map((plugin: Class>) => ( { {client.query.app} {plugins .filter( - (p: Class>) => + (p: Class>) => client.plugins.indexOf(p.id) > -1, ) - .map((plugin: Class>) => ( + .map((plugin: Class>) => ( = AppendAndUpdateAction | ResetAndUpdateAction; * the client in an unknown state. */ export function createTablePlugin(props: Props) { - return class extends SonarPlugin, Actions> { + return class extends FlipperPlugin, Actions> { static title = props.title; static id = props.id; static icon = props.icon; diff --git a/src/device-plugins/cpu/index.js b/src/device-plugins/cpu/index.js index 69fff9482..cc6bf6cf7 100644 --- a/src/device-plugins/cpu/index.js +++ b/src/device-plugins/cpu/index.js @@ -5,7 +5,7 @@ * @format */ -import {SonarDevicePlugin} from 'sonar'; +import {FlipperDevicePlugin} from 'sonar'; var adb = require('adbkit-fb'); import { @@ -98,7 +98,7 @@ function formatFrequency(freq) { } } -export default class CPUFrequencyTable extends SonarDevicePlugin { +export default class CPUFrequencyTable extends FlipperDevicePlugin { static id = 'DeviceCPU'; static title = 'CPU'; static icon = 'underline'; diff --git a/src/device-plugins/index.js b/src/device-plugins/index.js index 4ed825e85..4aac05f82 100644 --- a/src/device-plugins/index.js +++ b/src/device-plugins/index.js @@ -5,13 +5,13 @@ * @format */ -import type {SonarDevicePlugin} from '../plugin.js'; +import type {FlipperDevicePlugin} from '../plugin.js'; import {GK} from 'sonar'; import logs from './logs/index.js'; import cpu from './cpu/index.js'; -const plugins: Array>> = [logs]; +const plugins: Array>> = [logs]; if (GK.get('sonar_uiperf')) { plugins.push(cpu); diff --git a/src/device-plugins/logs/index.js b/src/device-plugins/logs/index.js index 98d1d78eb..6c2465876 100644 --- a/src/device-plugins/logs/index.js +++ b/src/device-plugins/logs/index.js @@ -25,7 +25,7 @@ import { FlexColumn, Glyph, SonarSidebar, - SonarDevicePlugin, + FlipperDevicePlugin, SearchableTable, styled, } from 'sonar'; @@ -238,7 +238,7 @@ function pad(chunk: mixed, len: number): string { return str; } -export default class LogTable extends SonarDevicePlugin< +export default class LogTable extends FlipperDevicePlugin< State, Actions, PersistedState, diff --git a/src/devices/BaseDevice.js b/src/devices/BaseDevice.js index a196c22ed..07bdf29e9 100644 --- a/src/devices/BaseDevice.js +++ b/src/devices/BaseDevice.js @@ -6,7 +6,7 @@ */ import type stream from 'stream'; -import {SonarDevicePlugin} from 'sonar'; +import {FlipperDevicePlugin} from 'sonar'; export type LogLevel = | 'unknown' @@ -69,7 +69,7 @@ export default class BaseDevice { return os.toLowerCase() === this.os.toLowerCase(); } - supportsPlugin = (DevicePlugin: Class>): boolean => { + supportsPlugin = (DevicePlugin: Class>): boolean => { return this.supportedPlugins.includes(DevicePlugin.id); }; diff --git a/src/index.js b/src/index.js index d2c337503..22e8dce05 100644 --- a/src/index.js +++ b/src/index.js @@ -10,7 +10,11 @@ export * from './ui/index.js'; export * from './utils/index.js'; export {default as GK} from './fb-stubs/GK.js'; -export {SonarBasePlugin, SonarPlugin, SonarDevicePlugin} from './plugin.js'; +export { + FlipperBasePlugin, + FlipperPlugin, + FlipperDevicePlugin, +} from './plugin.js'; export {createTablePlugin} from './createTablePlugin.js'; export {default as SonarSidebar} from './chrome/SonarSidebar.js'; diff --git a/src/plugin.js b/src/plugin.js index c83c288ca..d1ea82987 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -31,7 +31,7 @@ export type Props = { target: PluginTarget, }; -export class SonarBasePlugin< +export class FlipperBasePlugin< State = *, Actions = *, PersistedState = *, @@ -84,7 +84,7 @@ export class SonarBasePlugin< } } -export class SonarDevicePlugin extends SonarBasePlugin< +export class FlipperDevicePlugin extends FlipperBasePlugin< S, A, P, @@ -101,7 +101,11 @@ export class SonarDevicePlugin extends SonarBasePlugin< } } -export class SonarPlugin extends SonarBasePlugin { +export class FlipperPlugin extends FlipperBasePlugin< + S, + A, + P, +> { constructor(props: Props<*>) { super(props); const {id} = this.constructor; diff --git a/src/plugins/index.js b/src/plugins/index.js index 429ff795b..00119932e 100644 --- a/src/plugins/index.js +++ b/src/plugins/index.js @@ -9,7 +9,7 @@ import {GK} from 'sonar'; import React from 'react'; import ReactDOM from 'react-dom'; import * as Sonar from 'sonar'; -import {SonarPlugin, SonarBasePlugin} from '../plugin.js'; +import {FlipperPlugin, FlipperBasePlugin} from '../plugin.js'; import {remote} from 'electron'; const plugins = new Map(); @@ -54,7 +54,7 @@ bundledPlugins })) .forEach(addIfNotAdded); -const exportedPlugins: Array>> = Array.from( +const exportedPlugins: Array>> = Array.from( plugins.values(), ) .map(plugin => { @@ -78,7 +78,7 @@ const exportedPlugins: Array>> = Array.from( } }) .filter(Boolean) - .filter(plugin => plugin.prototype instanceof SonarBasePlugin) + .filter(plugin => plugin.prototype instanceof FlipperBasePlugin) .sort((a, b) => (a.title || '').localeCompare(b.title || '')); export default exportedPlugins; diff --git a/src/plugins/layout/index.js b/src/plugins/layout/index.js index 40c9fb7da..92fcff435 100644 --- a/src/plugins/layout/index.js +++ b/src/plugins/layout/index.js @@ -12,7 +12,7 @@ import { FlexRow, FlexColumn, Toolbar, - SonarPlugin, + FlipperPlugin, ElementsInspector, InspectorSidebar, LoadingIndicator, @@ -186,7 +186,7 @@ class LayoutSearchInput extends Component< } } -export default class Layout extends SonarPlugin { +export default class Layout extends FlipperPlugin { static title = 'Layout'; static id = 'Inspector'; static icon = 'target'; diff --git a/src/plugins/leak_canary/index.js b/src/plugins/leak_canary/index.js index 4efcc5440..31435a475 100644 --- a/src/plugins/leak_canary/index.js +++ b/src/plugins/leak_canary/index.js @@ -14,7 +14,7 @@ import { Sidebar, Toolbar, Checkbox, - SonarPlugin, + FlipperPlugin, Button, styled, } from 'sonar'; @@ -53,7 +53,7 @@ const ToolbarItem = styled(FlexRow)({ marginLeft: '8px', }); -export default class LeakCanary extends SonarPlugin { +export default class LeakCanary extends FlipperPlugin { static title = 'LeakCanary'; static id = 'LeakCanary'; static icon = 'bird'; diff --git a/src/plugins/network/index.js b/src/plugins/network/index.js index e2218b26c..67a61aa2f 100644 --- a/src/plugins/network/index.js +++ b/src/plugins/network/index.js @@ -18,7 +18,7 @@ import { SonarSidebar, styled, } from 'sonar'; -import {SonarPlugin, SearchableTable} from 'sonar'; +import {FlipperPlugin, SearchableTable} from 'sonar'; import RequestDetails from './RequestDetails.js'; import {URL} from 'url'; @@ -109,7 +109,7 @@ const TextEllipsis = styled(Text)({ paddingTop: 4, }); -export default class extends SonarPlugin { +export default class extends FlipperPlugin { static title = 'Network'; static id = 'Network'; static icon = 'internet'; diff --git a/src/plugins/sandbox/index.js b/src/plugins/sandbox/index.js index 7a17a844c..7f272ee65 100644 --- a/src/plugins/sandbox/index.js +++ b/src/plugins/sandbox/index.js @@ -5,7 +5,7 @@ * @format */ -import {SonarPlugin} from 'sonar'; +import {FlipperPlugin} from 'sonar'; import {FlexColumn} from 'sonar'; import {ButtonGroup, Button, styled, colors} from 'sonar'; @@ -31,7 +31,7 @@ const ButtonContainer = styled(FlexColumn)({ padding: 20, }); -export default class SandboxView extends SonarPlugin { +export default class SandboxView extends FlipperPlugin { state = { sandboxes: [], customSandbox: '', diff --git a/src/plugins/shared_preferences/index.js b/src/plugins/shared_preferences/index.js index c52f12053..b322a52f9 100644 --- a/src/plugins/shared_preferences/index.js +++ b/src/plugins/shared_preferences/index.js @@ -15,7 +15,7 @@ import { DataInspector, styled, } from 'sonar'; -import {SonarPlugin} from 'sonar'; +import {FlipperPlugin} from 'sonar'; const {clone} = require('lodash'); @@ -66,7 +66,7 @@ const ChangelogColumn = styled(FlexColumn)({ padding: '16px', }); -export default class extends SonarPlugin { +export default class extends FlipperPlugin { static title = 'Shared Preferences Viewer'; static id = 'Preferences';