Move server add-on interfaces to flipper-common

Reviewed By: antonk52

Differential Revision: D34169419

fbshipit-source-id: 69fcc8da7d98f59818fbb5b486a488f19830cd81
This commit is contained in:
Andrey Goncharov
2022-02-28 03:50:34 -08:00
committed by Facebook GitHub Bot
parent b9294645d3
commit 04eab80c98
8 changed files with 59 additions and 48 deletions

View File

@@ -7,9 +7,45 @@
* @format
*/
import {FlipperServerCommands} from './server-types';
import {
FlipperServer,
FlipperServerCommands,
FlipperServerEvents,
} from './server-types';
export interface ServerAddOnControls {
start: FlipperServerCommands['plugins-server-add-on-start'];
stop: FlipperServerCommands['plugins-server-add-on-stop'];
}
// TODO: Share with js-flipper? Is it worth it?
export type FlipperPluginReceiverRes =
| object
| string
| number
| boolean
| null
| undefined
| void;
export type FlipperPluginReceiver = (
data: any,
) => FlipperPluginReceiverRes | Promise<FlipperPluginReceiverRes>;
export interface ServerAddOnPluginConnection {
send(method: string, params: unknown): void;
receive(method: string, receiver: FlipperPluginReceiver): void;
}
export interface FlipperServerForServerAddOn extends FlipperServer {
emit(
event: 'plugins-server-add-on-message',
payload: FlipperServerEvents['plugins-server-add-on-message'],
): void;
}
export type ServerAddOnCleanup = () => Promise<void>;
export type ServerAddOn = (
connection: ServerAddOnPluginConnection,
{flipperServer}: {flipperServer: FlipperServerForServerAddOn},
) => Promise<ServerAddOnCleanup>;

View File

@@ -51,3 +51,4 @@ export * from './clientUtils';
export * from './settings';
export * from './PluginDetails';
export * from './doctor';
export * from './ServerAddOn';