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
@@ -9,6 +9,7 @@
|
||||
|
||||
import {SandyPluginDefinition} from './SandyPluginDefinition';
|
||||
import {BasePluginInstance, BasePluginClient} from './PluginBase';
|
||||
import {FlipperLib} from './FlipperLib';
|
||||
|
||||
export type DeviceLogListener = (entry: DeviceLogEntry) => void;
|
||||
|
||||
@@ -69,11 +70,12 @@ export class SandyDevicePluginInstance extends BasePluginInstance {
|
||||
client: DevicePluginClient;
|
||||
|
||||
constructor(
|
||||
realDevice: RealFlipperDevice,
|
||||
flipperLib: FlipperLib,
|
||||
definition: SandyPluginDefinition,
|
||||
realDevice: RealFlipperDevice,
|
||||
initialStates?: Record<string, any>,
|
||||
) {
|
||||
super(definition, initialStates);
|
||||
super(flipperLib, definition, initialStates);
|
||||
const device: Device = {
|
||||
// N.B. we model OS as string, not as enum, to make custom device types possible in the future
|
||||
os: realDevice.os,
|
||||
|
||||
Reference in New Issue
Block a user