Remove classic plugin infra

Summary:
This removes all code duplication / old plugin infra that isn't needed anymore when all plugin run on the Sandy plugin infra structure.

The diff is quite large, but the minimal one that passes tests and compiles. Existing tests are preserved by wrapping all remaining tests in `wrapSandy` for classic plugins where needed

Reviewed By: passy

Differential Revision: D29394738

fbshipit-source-id: 1315fabd9f048576aed15ed5f1cb6414d5fdbd40
This commit is contained in:
Michel Weststrate
2021-06-30 10:40:50 -07:00
committed by Facebook GitHub Bot
parent 9d6abd62c6
commit 16154e1343
31 changed files with 564 additions and 2330 deletions

View File

@@ -18,11 +18,7 @@ import {
createState,
_getFlipperLibImplementation,
} from 'flipper-plugin';
import {
DevicePluginDefinition,
DevicePluginMap,
FlipperDevicePlugin,
} from '../plugin';
import {PluginDefinition, DevicePluginMap} from '../plugin';
import {DeviceSpec, OS as PluginOS, PluginDetails} from 'flipper-plugin-lib';
export type DeviceShell = {
@@ -191,9 +187,9 @@ export default class BaseDevice {
return null;
}
supportsPlugin(plugin: DevicePluginDefinition | PluginDetails) {
supportsPlugin(plugin: PluginDefinition | PluginDetails) {
let pluginDetails: PluginDetails;
if (isDevicePluginDefinition(plugin)) {
if (plugin instanceof _SandyPluginDefinition) {
pluginDetails = plugin.details;
if (!pluginDetails.pluginType && !pluginDetails.supportedDevices) {
// TODO T84453692: this branch is to support plugins defined with the legacy approach. Need to remove this branch after some transition period when
@@ -205,7 +201,7 @@ export default class BaseDevice {
false)
);
} else {
return plugin.supportsDevice(this);
return (plugin as any).supportsDevice(this);
}
}
} else {
@@ -240,7 +236,7 @@ export default class BaseDevice {
}
}
loadDevicePlugin(plugin: DevicePluginDefinition, initialState?: any) {
loadDevicePlugin(plugin: PluginDefinition, initialState?: any) {
if (!this.supportsPlugin(plugin)) {
return;
}
@@ -286,12 +282,3 @@ export default class BaseDevice {
this.sandyPluginStates.clear();
}
}
function isDevicePluginDefinition(
definition: any,
): definition is DevicePluginDefinition {
return (
(definition as any).prototype instanceof FlipperDevicePlugin ||
(definition instanceof _SandyPluginDefinition && definition.isDevicePlugin)
);
}