Introduce Sandy wrapper for legacy plugins
Summary: This diff introduces loading classic Flipper plugins in a Sandy container. By wrapping plugins into Sandy we will be able to remove a lot of code / logic duplication related to state, queue processing, serialization etc. This will allow us to remove most or all of the complex plugin logic from the old system, only keeping onto the legacy components which have a lower maintenance burden. Until all plugins are Sandy. This diff is not feature complete but only implements the core mechanisms for (persisted) state and communication. Keyboard support, serialization, and rewiring tests etc will be added in next diff. The feature is introduced behind GK flipper_use_sandy_plugin_wrapper to have kill switch. Tests will be added later in this diff by redirection a part of the current mechanisms to wrapped plugins. (Will land the stack as a whole) Reviewed By: passy Differential Revision: D29165866 fbshipit-source-id: 57f84794a4a5f898bf765ce2de13cc759267fbc6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
07199323d1
commit
c1860ec19c
@@ -9,7 +9,7 @@
|
||||
|
||||
import type {Store} from '../reducers/index';
|
||||
import type {Logger} from '../fb-interfaces/Logger';
|
||||
import type {PluginDefinition} from '../plugin';
|
||||
import {PluginDefinition} from '../plugin';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import adbkit from 'adbkit';
|
||||
@@ -54,6 +54,7 @@ import {isDevicePluginDefinition} from '../utils/pluginUtils';
|
||||
import isPluginCompatible from '../utils/isPluginCompatible';
|
||||
import isPluginVersionMoreRecent from '../utils/isPluginVersionMoreRecent';
|
||||
import {getStaticPath} from '../utils/pathUtils';
|
||||
import {createSandyPluginWrapper} from '../utils/createSandyPluginWrapper';
|
||||
let defaultPluginsIndex: any = null;
|
||||
|
||||
export default async (store: Store, logger: Logger) => {
|
||||
@@ -317,6 +318,13 @@ const requirePluginInternal = (
|
||||
plugin.packageName = pluginDetails.name;
|
||||
plugin.details = pluginDetails;
|
||||
|
||||
if (GK.get('flipper_use_sandy_plugin_wrapper')) {
|
||||
return new _SandyPluginDefinition(
|
||||
pluginDetails,
|
||||
createSandyPluginWrapper(plugin),
|
||||
);
|
||||
}
|
||||
|
||||
// set values from package.json as static variables on class
|
||||
Object.keys(pluginDetails).forEach((key) => {
|
||||
if (key !== 'name' && key !== 'id') {
|
||||
|
||||
Reference in New Issue
Block a user