Device plugin management (1/n): use static metadata for checking plugin compatibility with devices

Summary:
*Stack summary*: this stack adds ability to manage device plugins in the same way as client plugins: install, update, uninstall, enable (star) and disable (unstar) them.

*Diff summary*: changed the way how plugin compatibility with devices is checked from dynamic call to "supportsDevice" to static checks of "supportedDevices" metadata property which make it possible to check compatibility without even downloading plugin from Marketplace.

Changelog: plugin compatibility with devices is now checked according to metadata in property "supportedDevices" in package.json

Reviewed By: mweststrate

Differential Revision: D26315848

fbshipit-source-id: 6e4b052c4ea0507ee185fc17999b6211cdb11093
This commit is contained in:
Anton Nikolaev
2021-02-16 10:46:11 -08:00
committed by Facebook GitHub Bot
parent 19f2fccc79
commit 899fcd0783
16 changed files with 263 additions and 65 deletions

View File

@@ -16,7 +16,7 @@ import {DevicePluginPredicate, DevicePluginFactory} from './DevicePlugin';
*/
export type FlipperDevicePluginModule = {
/** predicate that determines if this plugin applies to the currently selcted device */
supportsDevice: DevicePluginPredicate;
supportsDevice: DevicePluginPredicate; // TODO T84453692: remove this function after some transition period in favor of BaseDevice.supportsPlugin.
/** the factory function that initializes a plugin instance */
devicePlugin: DevicePluginFactory;
/** the component type that can render this plugin */
@@ -52,7 +52,7 @@ export class SandyPluginDefinition {
constructor(details: ActivatablePluginDetails, module: any) {
this.id = details.id;
this.details = details;
if (module.supportsDevice) {
if (details.pluginType === 'device' || module.supportsDevice) {
// device plugin
this.isDevicePlugin = true;
if (!module.devicePlugin || typeof module.devicePlugin !== 'function') {