Reload single device plugin on auto-update
Summary: The same as D23729972 (0982dc06a0), but now it is also possible to reload device plugins independently.
Reviewed By: jknoxville
Differential Revision: D23960058
fbshipit-source-id: 01e0edb29a62ed173dfe6f5946466269adee453a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1b4c08b282
commit
80c7c76ef9
@@ -9,14 +9,13 @@
|
||||
|
||||
import stream from 'stream';
|
||||
import type {DeviceLogListener} from 'flipper';
|
||||
import {sortPluginsByName} from '../utils/pluginUtils';
|
||||
import {
|
||||
DeviceLogEntry,
|
||||
SandyDevicePluginInstance,
|
||||
SandyPluginDefinition,
|
||||
DeviceType,
|
||||
} from 'flipper-plugin';
|
||||
import type {DevicePluginMap, FlipperDevicePlugin} from '../plugin';
|
||||
import type {DevicePluginDefinition, DevicePluginMap} from '../plugin';
|
||||
import {getFlipperLibImplementation} from '../utils/flipperLibImplementation';
|
||||
|
||||
export type DeviceShell = {
|
||||
@@ -170,13 +169,12 @@ export default class BaseDevice {
|
||||
return;
|
||||
}
|
||||
const plugins = Array.from(devicePlugins.values());
|
||||
plugins.sort(sortPluginsByName);
|
||||
for (const plugin of plugins) {
|
||||
this.loadDevicePlugin(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
loadDevicePlugin(plugin: typeof FlipperDevicePlugin | SandyPluginDefinition) {
|
||||
loadDevicePlugin(plugin: DevicePluginDefinition) {
|
||||
if (plugin instanceof SandyPluginDefinition) {
|
||||
if (plugin.asDevicePluginModule().supportsDevice(this as any)) {
|
||||
this.devicePlugins.push(plugin.id);
|
||||
@@ -195,4 +193,13 @@ export default class BaseDevice {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unloadDevicePlugin(pluginId: string) {
|
||||
const instance = this.sandyPluginStates.get(pluginId);
|
||||
if (instance) {
|
||||
instance.destroy();
|
||||
this.sandyPluginStates.delete(pluginId);
|
||||
}
|
||||
this.devicePlugins.splice(this.devicePlugins.indexOf(pluginId), 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user