Commit Graph

30 Commits

Author SHA1 Message Date
Andrey Goncharov
b80755721c Draft communication with server add-ons from the client side
Reviewed By: nikoant

Differential Revision: D34075379

fbshipit-source-id: 09f575f5cced866ad7b9290d7739ce60f38edeee
2022-02-28 03:50:34 -08:00
Andrey Goncharov
3b390b74ff Track client connections and autostop server add-ons when all clients leave
Reviewed By: mweststrate

Differential Revision: D34045584

fbshipit-source-id: 1ad0cfffb9d304f0359c973d76d6956f7e932f72
2022-02-28 03:50:34 -08:00
Andrey Goncharov
9113006851 Make Client initialize server add-ons
Reviewed By: mweststrate

Differential Revision: D34044353

fbshipit-source-id: 99bcb1559787b2a904bdd796233666a7a4783ea4
2022-02-28 03:50:34 -08:00
Andres Suarez
79023ee190 Update copyright headers from Facebook to Meta
Reviewed By: bhamodi

Differential Revision: D33331422

fbshipit-source-id: 016e8dcc0c0c7f1fc353a348b54fda0d5e2ddc01
2021-12-27 14:31:45 -08:00
Andrey Goncharov
731749b41f Move crash reporting listener to the server
Summary: Changelog: Move crash watcher to the server. Add 'device-crash' event. Add 'device-start-crash-watcher', 'device-stop-crash-watcher' commands. Add 'onDeviceCrash' method to Plugin Client.

Reviewed By: mweststrate

Differential Revision: D33089810

fbshipit-source-id: ed62ee7c1129e5e25af18b444744b0796f567b72
2021-12-20 11:39:00 -08:00
Michel Weststrate
accef856fc Remove remaining Node imports from core
Summary:
Removed remaining path / fs imports from Flipper core.

`expand-tide` needed replacement too, but noticed that it never actually rewrites paths since all use cases were already using absolute paths, so removed it instead.

Reviewed By: aigoncharov

Differential Revision: D33017654

fbshipit-source-id: e12f66ef68b5f9e4279411c94445a2fb87249e9a
2021-12-13 05:48:17 -08:00
Michel Weststrate
91d96774f6 Move files to flipper-common
Summary: Moved Logger, sleep, timeout and server contract types to flipper-common packages.

Reviewed By: passy

Differential Revision: D31475790

fbshipit-source-id: 42d2147698875f9e919ad5250f9953f3bff3ec2d
2021-10-12 16:00:52 -07:00
Michel Weststrate
3882357579 Factor out realDevice [7/n]
Summary: `device.realDevice` was the escape hatch used in Sandy plugins to give access to device specific features like taking screenshots, clearing logs or accessing `adb`. Since in decapitated Flipper that won't be possible anymore (since plugins run in the client but device implementations on the server), all escape hatches have been bridged in this stack, and we can get of the `realDevice` interaction, by explicitly exposing those cases, which makes it type safe as well.

Reviewed By: passy

Differential Revision: D31079509

fbshipit-source-id: c9ec2e044d0dec0ccb1de287cf424907b198f818
2021-09-22 09:03:33 -07:00
Michel Weststrate
8cf182cc26 Restore adb executeShell [5/n]
Summary: Expose executeShell explicitly through the device interface

Reviewed By: jameslawson

Differential Revision: D31055959

fbshipit-source-id: b14395d0783ede265c6ae39c397ea93a85a78336
2021-09-22 09:03:32 -07:00
Michel Weststrate
2d838efd4d Separate device in server and client version [2/n]
Summary:
This stack takes care of handling care of moving all device interactions over the (possible) async channel FlipperServer. The FlipperServer interface (see previous diff) allows listening to specific server events using `on`, and emit commands to be executed by the server by using `exec` (e.g. `exec('take-screenshot', serial) => Promise<buffer>`).

FlipperServerImpl implements this interface on the server side.

The device implementations are split as follows

```
server / backend process:

ServerDevice
- iOSDevice
- AndroidDevice
- MetroDevice
- DummyDevice
- Mac/Windows Device

frontend / ui:

BaseDevice: a normal connected, device, implements device apis as they already existed
- ArchivedDevice (note that this doesn't have a server counterpart)
- TestDevice (for unit tests, with stubbed backend communication)

```

All features of devices are for simplicity unified (since the deviations are small), where specific device types might not implement certain features like taking screenshots or running shell commands.

To avoid making this diff unnecessarily big, some open Todo's will be addressed later in this stack, and it shouldn't be landed alone.

Reviewed By: timur-valiev

Differential Revision: D30909346

fbshipit-source-id: cce0bee94fdd5db59bebe3577a6084219a038719
2021-09-22 09:03:32 -07:00
Michel Weststrate
845d0755f1 Move common types to flipper-plugin [1/n]
Summary: This is the first diff in a stack of many where server and UI logic is further decoupled to be only communication through an event listener / emitting commands, where all data going over these media is json serializable. In this diff we extract the common interfaces that are to be used by both server and UI layer.

Reviewed By: passy

Differential Revision: D30899609

fbshipit-source-id: dc3c783707d47671f1d0f5dbf99cde17a8f69062
2021-09-22 09:03:32 -07:00
Anton Nikolaev
7bc38c1735 Allow selecting disabled, unsupported and not installed plugins
Summary:
This diffs removes restrictions on selecting disabled, uninstalled and unsupported plugins. Now it will be possible to select them, however for now empty view will be shown in such case.

In next diffs I'll add Plugin Info view which will be shown in case disabled plugin is selected. It will show static info about plugin - readme, version, oncall, user feedback group etc. This will make it possible for users to browse info about all plugins, even unsupported by selected device/app.

There is one problem that our analytics will be screwed by this change as even disabled plugins will be counted as used. I'll address this later in this stack.

If you see other potential problems with removing restrictions on selecting disabled plugins - please let me know.

Reviewed By: passy

Differential Revision: D29186005

fbshipit-source-id: 2e55c5fd3bb402594f4dbace6e287725de65bc6f
2021-06-29 13:02:05 -07:00
Michel Weststrate
e26a8c5ad0 Provide standardised MasterDetail
Summary:
Noticed in reviews during the convertathon there is still quite some boilerplate in things that happen on the boundary of UI and plugin state, such as setting up menu entries and providing common functionality like clear, master/detail layout, etc.

This diff introduces the `MasterDetail` component, which takes a higher level approach by merely needing to provide the state atoms and desired features, and taking care of the wiring.

Applied it to createTablePlugin, to prove that going from `createTablePlugin` to `MasterDetail` will be a much smaller step now.

Verified on the funnel logger plugin

Reviewed By: passy

Differential Revision: D28090362

fbshipit-source-id: 146f8c315fea903901ad4e3e46711642f16cf0e6
2021-04-29 07:31:54 -07:00
Michel Weststrate
87c5fab607 Convert crash reporter plugin to Sandy (non UI only)
Summary:
This diff converts the CrashReporter plugin to Sandy. The main driver is that it allows us to fix the connection management of logs in a next diff.

There are few changes to highlight:
* A bunch of the old unit tests are removed, as they primarily verified that persistedState abstraction works, a concept that doesn't exist anymore with Sandy (as a result all the logic in error handling and crash reporter plugin has become a lot more trivial as well)
* Added additional unit tests to verify that the integration with notifications from Sandy, and the integration of crashes in combination with CrashReporter plugin works (this wasn't the case before)
* Plugin errors were always suppressed in production builds of Flipper. However, that makes error reporting pretty pointless in the first place, so enabled it by default, but made it a setting in case this results in too many errors suddenly.
* The integration with clicking OS crash notification -> bringing the user to a sensible place _doesn't_ work, but it didn't work before this diff either, so will address that later
* This doesn't upgrade the Crash reporter UI to sandy yet, will do that later in a separate diff

Changelog: Crash reporter will now report errors triggered from the device / client plugins by default. This can be disabled in settings.

Reviewed By: priteshrnandgaonkar

Differential Revision: D27044507

fbshipit-source-id: 8233798f5cce668d61460c948c24bdf92ed7c834
2021-03-16 15:03:48 -07:00
Michel Weststrate
2ca52f81d2 Introduce pluginKey
Summary: Exposed the `pluginKey` to sandy plugins (which we will use later for storing table preferences per plugin). And a little moving code around because circular deps problem roared its ugly head again.

Reviewed By: nikoant

Differential Revision: D27009721

fbshipit-source-id: 7ad29e72ff8028c9daae270c4749b657bd8ff049
2021-03-16 15:03:47 -07:00
Michel Weststrate
43c68c0e7c Separate the concepts of archived and disconnected devices
Summary:
Minor code cleanup to avoid future confusion:

- archived: a device that was imported from a Flipper trace, and only has persisted state
- (dis)connected: a real stateful device that might or might not have an active connection

Reviewed By: nikoant

Differential Revision: D26275459

fbshipit-source-id: eba554b37c39711e367c3795ff4456329a303c22
2021-02-09 04:16:26 -08:00
Michel Weststrate
bb529411b5 Expose current connection status to Sandy plugins
Summary:
Introduced `isConnected` flag on device and plugin client to reflect whether a connection is still available for the plugins, or that they have been disconnected.

Potentially we could expose the (readonly) `connected` state atom for this as well, or an `onDisconnect` event for device pugins, to create a responsive UI, but there might be no need for that, in which case this suffices.

Reviewed By: nikoant

Differential Revision: D26249346

fbshipit-source-id: b8486713fdf2fcd520488ce54f771bd038fd13f8
2021-02-09 04:16:24 -08:00
Anton Nikolaev
d7cfcb5d8e Extend device plugin metadata to include supported devices
Summary: Plugin metadata format extended to include type of each plugin (client / device) and list of supported devices (android/ios/..., emulator/physical, etc). This will allow to detect plugins supported by device even if they are not installed and only available on Marketplace.

Reviewed By: mweststrate

Differential Revision: D26073531

fbshipit-source-id: e331f1be1af1046cd4220a286a1d52378c26cc53
2021-01-27 17:31:41 -08:00
Michel Weststrate
52862f6083 Introduce isPluginAvailable and selectPlugin
Summary:
Introduced API to replace the deprecated `selectPlugin` in Sandy.

The API can be used to navigate from `device plugin -> device plugin`, or` client plugin -> device / client plugin`

Introduced `isPluginAvailable` as well, so that the user interaction an be fine tuned in case the plugin is not disabled.

Reviewed By: jknoxville

Differential Revision: D25422370

fbshipit-source-id: c6c603f1c68e6291280b3d0883e474448754ded1
2020-12-09 14:36:18 -08:00
Michel Weststrate
1157976eef Expose more meta information for plugins
Summary: expose `appName`, `appId` and `device` to Sandy plugins. Will be used in next diff to migrate navigation plugin

Reviewed By: cekkaewnumchai

Differential Revision: D24857253

fbshipit-source-id: 03ac3d376d5d1950bcf3d78386a65ce167b517e3
2020-11-11 07:58:55 -08:00
Michel Weststrate
8a5860cb78 API reference documentation
Summary:
Documented all exposed Sandy APIs plugin developers should know about.

Honestly didn't proof-read it myself yet, but wanted to publish this diff at least before PTO, so that the information is available to anyone interested / playing with sandy

Reviewed By: jknoxville

Differential Revision: D22976373

fbshipit-source-id: c30918201d2feeb306ca0d9a3ae1ec10bdf7e2f5
2020-08-24 04:57:02 -07:00
Michel Weststrate
685cc09b3b DeviceLogs plugin to Sandy
Summary:
Converted the DeviceLogs plugin to sandy.

Kept logic and UI the same (so same batching, localstorage mechanisms etc). But used sandy api's for log subscribing, state, and separating the logical part of the component from the UI.

Note that some mechanisms work slightly different, like deeplinking and scrollToBottom handling, to reflect the fact that plugins are now long lived

Reviewed By: jknoxville

Differential Revision: D22845466

fbshipit-source-id: 7c98b2ddd9121dc730768ee1bece7e71bb5bec16
2020-08-20 13:32:47 -07:00
Michel Weststrate
9c202a4a10 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
2020-08-04 07:47:14 -07:00
Michel Weststrate
d538b66088 Cleaned up deviceType enum
Summary:
The device type enum was mixing two different concepts (emulator vs physical) and (archived vs not), and we already have a separate `isArchived` field. So cleaned this up to not leak it into sandy.

If anybody can think of any unforeseen consequences of this, lemme know :)

Reviewed By: jknoxville

Differential Revision: D22763506

fbshipit-source-id: bd2f7dbd1d2d2e6942ba7c6ddd8dc91ee34d591d
2020-08-04 07:47:13 -07:00
Michel Weststrate
642261c0d0 Cleanup and some code reuse between Device- and normal Plugins
Summary: Introducing a base abstract class (blegh) to share some life cycle management between Device- and normal plugins. Cleaned up the test utils a bit as well + some old TODO's that now have been taken care of

Reviewed By: nikoant

Differential Revision: D22727089

fbshipit-source-id: 507816f1bfdbc6e7e71d4bd365b881b6710ca917
2020-08-04 07:08:32 -07:00
Michel Weststrate
b9c9e89b53 Support activate and deactivate in normal plugins
Summary:
Device plugins have an activate and deactivate hook, that reflects the plugin being selected in the UI. Added these same hooks to client plugins as well. In practice they are called at the same times as `onConnect` and `onDisconnect`, except for background plugins, which connect only once, so it is pretty useful to be still able to make the distinction.

Since there is now quite some common functionality between plugins and device plugins, will clean things a bit up in a next diff

[Interesting] as it explains the difference between the different lifecycle methods of plugins, and the impact of being a background plugin

LIfecycle summary:

1. app connects
2. for background plugins: connect them (`onConnect`)
3. user selects a plugin, triggers `onActivate`. will also trigger `onConnect` the plugin if it _isnt_ a bg plugin
4. user selects a different plugin, triggers `onDeactivate`. will also trigger `onDisconnect` if it isn't a bg plugin.
5. app is unloaded. Triggers `onDisconnect` for bg plugins. Triggers `onDestroy` for all plugins,

Reviewed By: jknoxville

Differential Revision: D22724791

fbshipit-source-id: 9fe2e666eb37fa2e0bd00fa61d78d2d4b1080137
2020-08-04 07:08:31 -07:00
Michel Weststrate
f8ff6dc393 added deeplink support to sandy device plugins
Summary:
Make sure device plugins can be deeplinked as well.

(note that the duplication between `Plugin` and `DevicePlugin` is cleaned up again in D22727089, first wanted to make it work and tested, then clean)

DeepLink no longer have to be strings, per popular requests, as that makes direct linking between plugins easier (online links from the outside world have to arrive as strings)

Reviewed By: jknoxville, nikoant

Differential Revision: D22727091

fbshipit-source-id: 523c90b1e1fbf3700fdb4f62699dd57070cbc980
2020-08-04 07:08:31 -07:00
Michel Weststrate
b621dcf754 Make sure sandy device plugins are rendered
Summary: Now that we can load device plugins, let's make sure they are rendered as well.

Reviewed By: passy, nikoant

Differential Revision: D22693927

fbshipit-source-id: 22574ec6e629e6dd66e42193b406ceb7dfcf1836
2020-08-04 07:08:31 -07:00
Michel Weststrate
1e956e1bf5 Make sure Sandy Device Plugins can be unit testsed
Summary: Add unit tests to verify that the unit test utilities for for Sandy device plugins work as expected. Fixed a bug revealed by that and cleaned up some TODO's

Reviewed By: jknoxville, passy, nikoant

Differential Revision: D22693928

fbshipit-source-id: 93162db19d826d0cd7f642cef1447fd756261ac8
2020-08-04 07:08:31 -07:00
Michel Weststrate
91ed4e31c0 Introduce DevicePlugin APIs
Summary:
This stack introduces Sandy device plugins, they are quite similar to normal plugins, but, a devicePlugin module is organized as

```
export function supportsDevice(device): boolean

export function devicePlugin(devicePluginClient)

export function Component
```

Device plugins get access to the device meta data and can subscribe to the `onLogEntry` callback and `onDestroy` lifecycle.

They will be able to store state just as normal plugins, but can't send or receive methods, so devicePluginClient is a bit limited.

This diff only sets up most of the new data structures, and makes sure everything still compiles and no existing tests fail.

To prevent this diff from becoming to big, actually loading, rendering and testing device plugins will be done in next diffs

Please take a critical look at the api proposed and the (especially) the public names used :)

Reviewed By: passy, nikoant

Differential Revision: D22691351

fbshipit-source-id: bdbbd7f86d14b646fc9a693ad19f33583a76f26d
2020-08-04 07:08:31 -07:00