js api improvements: responnders, communication protocol

Summary:
A few improvements to JS API:
1) non-dummy responders - now we can reply to flipper
2) respecting flipper communication protocol: getPlugins, getBackgroundplugins, init, deinit, execute

adding linters

Reviewed By: jknoxville

Differential Revision: D22307525

fbshipit-source-id: 2f629210f398d118cc0cb99097c9d473bb466e57
This commit is contained in:
Timur Valiev
2020-07-17 04:53:09 -07:00
committed by Facebook GitHub Bot
parent 3814c8fdfc
commit 7dbcfc89b0
8 changed files with 2069 additions and 87 deletions

View File

@@ -7,10 +7,19 @@
* @format
*/
import {FlipperClient, AbstractFlipperPlugin} from './api';
import {FlipperClient, FlipperConnection, FlipperPlugin} from './api';
import {newWebviewClient} from './webviewImpl';
class SeaMammalPlugin extends AbstractFlipperPlugin {
export class SeaMammalPlugin implements FlipperPlugin {
protected connection: FlipperConnection | null | undefined;
onConnect(connection: FlipperConnection): void {
this.connection = connection;
}
onDisconnect(): void {
this.connection = null;
}
getId(): string {
return 'sea-mammals';
}
@@ -19,10 +28,9 @@ class SeaMammalPlugin extends AbstractFlipperPlugin {
return true;
}
newRow(row: {id: string, url: string, title: string}) {
this.connection?.send("newRow", row)
}
newRow(row: {id: string; url: string; title: string}) {
this.connection?.send('newRow', row);
}
}
class FlipperManager {