From bdbf79e3e1c5ac1779f153c48631cd24d7c2da67 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Mon, 28 Feb 2022 03:50:34 -0800 Subject: [PATCH] Limit events and methods in server contact to strings only Reviewed By: antonk52 Differential Revision: D34300854 fbshipit-source-id: 79cd3e3da9bb5dbac75243ac90118f32e12d8177 --- desktop/flipper-plugin/src/plugin/PluginBase.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/desktop/flipper-plugin/src/plugin/PluginBase.tsx b/desktop/flipper-plugin/src/plugin/PluginBase.tsx index 3e1c1b27a..dd04db979 100644 --- a/desktop/flipper-plugin/src/plugin/PluginBase.tsx +++ b/desktop/flipper-plugin/src/plugin/PluginBase.tsx @@ -142,7 +142,7 @@ export interface BasePluginClient< * Messages can only arrive if the plugin is enabled and connected. * For background plugins messages will be batched and arrive the next time the plugin is connected. */ - onServerAddOnMessage( + onServerAddOnMessage( event: Event, callback: (params: ServerAddOnEvents[Event]) => void, ): void; @@ -159,7 +159,7 @@ export interface BasePluginClient< /** * Send a message to the server add-on */ - sendToServerAddOn( + sendToServerAddOn( method: Method, ...params: Parameters extends [] ? [] @@ -382,14 +382,13 @@ export abstract class BasePluginInstance { sendToServerAddOn: (method, params) => this.serverAddOnControls.sendMessage( this.definition.packageName, - // TODO: Remove type cast - method as string, + method, params, ), onServerAddOnMessage: (event, cb) => { this.serverAddOnControls.receiveMessage( this.definition.packageName, - event as string, + event, batched(cb), ); },