Introduce menu entry support
Summary:
[interesting] since it shows how Flipper APIs are exposed through sandy. However, the next diff is a much simpler example of that
This diff adds support for adding menu entries for sandy plugin (renamed keyboard actions to menus, as it always creates a menu entry, but not necessarily a keyboard shortcut)
```
client.addMenuEntry(
// custom entry
{
label: 'Reset Selection',
topLevelMenu: 'Edit',
handler: () => {
selectedID.set(null);
},
},
// based on built-in action (sets standard label, shortcut)
{
action: 'createPaste',
handler: () => {
console.log('creating paste');
},
},
);
```
Most of this diff is introducing the concept of FlipperUtils, a set of static Flipper methods (not related to a device or client) that can be used from Sandy. This will for example be used to implement things as `createPaste` as well
Reviewed By: nikoant
Differential Revision: D22766990
fbshipit-source-id: ce90af3b700e6c3d9a779a3bab4673ba356f3933
This commit is contained in:
committed by
Facebook GitHub Bot
parent
94eaaf5dca
commit
9c202a4a10
@@ -12,7 +12,7 @@ import adb, {Client as ADBClient} from 'adbkit';
|
||||
import {Priority} from 'adbkit-logcat';
|
||||
import ArchivedDevice from './ArchivedDevice';
|
||||
import {createWriteStream} from 'fs';
|
||||
import {LogLevel, DeviceType} from 'flipper-plugin';
|
||||
import type {LogLevel, DeviceType} from 'flipper-plugin';
|
||||
|
||||
const DEVICE_RECORDING_DIR = '/sdcard/flipper_recorder';
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {DeviceLogEntry, DeviceType} from 'flipper-plugin';
|
||||
import BaseDevice from './BaseDevice';
|
||||
import type {DeviceLogEntry, DeviceType} from 'flipper-plugin';
|
||||
import {OS, DeviceShell} from './BaseDevice';
|
||||
import {SupportFormRequestDetailsState} from '../reducers/supportForm';
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
import stream from 'stream';
|
||||
import {DeviceLogListener} from 'flipper';
|
||||
import type {DeviceLogListener} from 'flipper';
|
||||
import {sortPluginsByName} from '../utils/pluginUtils';
|
||||
import {
|
||||
DeviceLogEntry,
|
||||
@@ -16,7 +16,8 @@ import {
|
||||
SandyPluginDefinition,
|
||||
DeviceType,
|
||||
} from 'flipper-plugin';
|
||||
import {DevicePluginMap, FlipperDevicePlugin} from '../plugin';
|
||||
import type {DevicePluginMap, FlipperDevicePlugin} from '../plugin';
|
||||
import {getFlipperLibImplementation} from '../utils/flipperLibImplementation';
|
||||
|
||||
export type DeviceShell = {
|
||||
stdout: stream.Readable;
|
||||
@@ -180,7 +181,11 @@ export default class BaseDevice {
|
||||
this.devicePlugins.push(plugin.id);
|
||||
this.sandyPluginStates.set(
|
||||
plugin.id,
|
||||
new SandyDevicePluginInstance(this, plugin),
|
||||
new SandyDevicePluginInstance(
|
||||
getFlipperLibImplementation(),
|
||||
plugin,
|
||||
this,
|
||||
),
|
||||
); // TODO T70582933: pass initial state if applicable
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
import BaseDevice, {OS} from './BaseDevice';
|
||||
import {DeviceType} from 'flipper-plugin';
|
||||
import type {DeviceType} from 'flipper-plugin';
|
||||
|
||||
export default class FlipperSelfInspectionDevice extends BaseDevice {
|
||||
constructor(serial: string, deviceType: DeviceType, title: string, os: OS) {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {LogLevel, DeviceLogEntry, DeviceType} from 'flipper-plugin';
|
||||
import type {LogLevel, DeviceLogEntry, DeviceType} from 'flipper-plugin';
|
||||
import child_process, {ChildProcess} from 'child_process';
|
||||
import BaseDevice from './BaseDevice';
|
||||
import JSONStream from 'JSONStream';
|
||||
|
||||
Reference in New Issue
Block a user