Separate interfaces for installed, bundled and downloadable plugins

Summary:
I've re-designed interfaces describing plugins as I found that mental overhead working with them became too expensive because of slightly flawed design. However this cascaded changes in many files so you can see how extensively these interfaces used in our codebase.

Before this change we had one interface PluginDetails which described three different entities: 1) plugins installed on the disk 2) plugins bundled into Flipper 3) plugins available on Marketplace. It's hard to use this "general" PluginDetails interface because of this as you always need to think about all three use cases everywhere.

After this change we have 3 separate interfaces: InstalledPluginDetails, BundledPluginDetails and DownloadablePluginDetails and things became much type-safer now.

Reviewed By: mweststrate

Differential Revision: D25530383

fbshipit-source-id: b93593916a980c04e36dc6ffa168797645a0ff9c
This commit is contained in:
Anton Nikolaev
2020-12-15 09:28:58 -08:00
committed by Facebook GitHub Bot
parent efb82e80b5
commit 5383017299
27 changed files with 327 additions and 216 deletions

View File

@@ -7,7 +7,7 @@
* @format
*/
import {PluginDetails} from 'flipper-plugin-lib';
import {ActivatablePluginDetails} from 'flipper-plugin-lib';
import {PluginFactory, FlipperPluginComponent} from './Plugin';
import {DevicePluginPredicate, DevicePluginFactory} from './DevicePlugin';
@@ -42,7 +42,7 @@ export type FlipperPluginModule<Factory extends PluginFactory<any, any>> = {
export class SandyPluginDefinition {
id: string;
module: FlipperPluginModule<any> | FlipperDevicePluginModule;
details: PluginDetails;
details: ActivatablePluginDetails;
isDevicePlugin: boolean;
// TODO: Implement T68683476
@@ -58,10 +58,10 @@ export class SandyPluginDefinition {
| undefined = undefined;
constructor(
details: PluginDetails,
details: ActivatablePluginDetails,
module: FlipperPluginModule<any> | FlipperDevicePluginModule,
);
constructor(details: PluginDetails, module: any) {
constructor(details: ActivatablePluginDetails, module: any) {
this.id = details.id;
this.details = details;
if (module.supportsDevice) {
@@ -123,8 +123,8 @@ export class SandyPluginDefinition {
return this.details.version;
}
get isDefault() {
return this.details.isDefault;
get isBundled() {
return this.details.isBundled;
}
get keyboardActions() {