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:
committed by
Facebook GitHub Bot
parent
19f2fccc79
commit
899fcd0783
@@ -27,7 +27,6 @@ import type {
|
||||
PluginDetails,
|
||||
} from 'flipper-plugin-lib';
|
||||
import {filterNewestVersionOfEachPlugin} from '../dispatcher/plugins';
|
||||
import ArchivedDevice from '../devices/ArchivedDevice';
|
||||
|
||||
export const defaultEnabledBackgroundPlugins = ['Navigation']; // The navigation plugin is enabled always, to make sure the navigation features works
|
||||
|
||||
@@ -182,12 +181,12 @@ export function computePluginLists(
|
||||
userStarredPlugins: State['connections']['userStarredPlugins'],
|
||||
_pluginsChanged?: number, // this argument is purely used to invalidate the memoization cache
|
||||
) {
|
||||
const devicePlugins: DevicePluginDefinition[] =
|
||||
device?.devicePlugins.map((name) => plugins.devicePlugins.get(name)!) ?? [];
|
||||
const metroPlugins: DevicePluginDefinition[] =
|
||||
metroDevice?.devicePlugins.map(
|
||||
(name) => plugins.devicePlugins.get(name)!,
|
||||
) ?? [];
|
||||
const devicePlugins: DevicePluginDefinition[] = [
|
||||
...plugins.devicePlugins.values(),
|
||||
].filter((p) => device?.supportsPlugin(p));
|
||||
const metroPlugins: DevicePluginDefinition[] = [
|
||||
...plugins.devicePlugins.values(),
|
||||
].filter((p) => metroDevice?.supportsPlugin(p));
|
||||
const enabledPlugins: ClientPluginDefinition[] = [];
|
||||
const disabledPlugins: ClientPluginDefinition[] = [];
|
||||
const unavailablePlugins: [plugin: PluginDetails, reason: string][] = [];
|
||||
@@ -198,16 +197,12 @@ export function computePluginLists(
|
||||
|
||||
if (device) {
|
||||
// find all device plugins that aren't part of the current device / metro
|
||||
const detectedDevicePlugins = new Set([
|
||||
...device.devicePlugins,
|
||||
...(metroDevice?.devicePlugins ?? []),
|
||||
]);
|
||||
for (const [name, definition] of plugins.devicePlugins.entries()) {
|
||||
if (!detectedDevicePlugins.has(name)) {
|
||||
for (const p of plugins.devicePlugins.values()) {
|
||||
if (!device.supportsPlugin(p) && !metroDevice?.supportsPlugin(p)) {
|
||||
unavailablePlugins.push([
|
||||
definition.details,
|
||||
p.details,
|
||||
`Device plugin '${getPluginTitle(
|
||||
definition.details,
|
||||
p.details,
|
||||
)}' is not supported by the current device type.`,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user