Add support for async / custom plugin export

Summary:
Sandy plugins can now set up an `onExport` handler to enable customizing the export format of a plugin: `client.onExport(callback: (idler, onStatusMessage) => Promise<state>)`

Import will be done in next diff

Reviewed By: nikoant

Differential Revision: D26124440

fbshipit-source-id: c787c79d929aa8fb484f15a9340d7c87545793cb
This commit is contained in:
Michel Weststrate
2021-02-01 11:40:20 -08:00
committed by Facebook GitHub Bot
parent 32bde8cace
commit 34c915a739
21 changed files with 264 additions and 77 deletions

View File

@@ -9,15 +9,9 @@
import {CancelledPromiseError} from './errors';
import {sleep} from './promiseTimeout';
import {Idler} from 'flipper-plugin';
export interface BaseIdler {
shouldIdle(): boolean;
idle(): Promise<void>;
cancel(): void;
isCancelled(): boolean;
}
export class Idler implements BaseIdler {
export class IdlerImpl implements Idler {
private lastIdle = performance.now();
private kill = false;
@@ -57,12 +51,16 @@ export class Idler implements BaseIdler {
}
// This smills like we should be using generators :)
export class TestIdler implements BaseIdler {
export class TestIdler implements Idler {
private resolver?: () => void;
private kill = false;
private autoRun = false;
private hasProgressed = false;
constructor(autorun = false) {
this.autoRun = autorun;
}
shouldIdle() {
if (this.kill) {
return true;