Commit Graph

405 Commits

Author SHA1 Message Date
Michel Weststrate
9f3df3406d Bless "Layout" and "theme"
Summary: This blesses the `Layout` and `theme` components and exposes them from `flipper-plugin`, so that they can be used in (public) Sandy plugins. Also marked old abstractions as going to be deprecated.

Reviewed By: cekkaewnumchai

Differential Revision: D24503560

fbshipit-source-id: a8f384667b8f66e3b9f00771a123fe5c9d755eb3
2020-10-27 05:21:23 -07:00
Chaiwat Ekkaewnumchai
402ea2fc14 Convert to Shared Preference Plugin to Sandy
Summary:
per title

In addition, this diff adds `startUnactivated` option to allow setting up `onSend` mock implementation.

Reviewed By: mweststrate

Differential Revision: D24477989

fbshipit-source-id: f913574ebacdd436e8511baa43744249a014e90b
2020-10-23 06:22:02 -07:00
generatedunixname89002005306973
0f23f409ab Flipper Release: v0.63.0
Summary: Releasing version 0.63.0

Reviewed By: nikoant

Differential Revision: D24423408

fbshipit-source-id: 0bc12c49d8bf77d8dbf9688adb07dc176b210548
2020-10-20 11:13:12 -07:00
generatedunixname89002005306973
ca271dd7c3 Flipper Release: v0.62.0
Summary: Releasing version 0.62.0

Reviewed By: nikoant

Differential Revision: D24248944

fbshipit-source-id: 05742031294f6a77c78c0bdccbdffe7d82427f05
2020-10-12 06:03:03 -07:00
generatedunixname89002005306973
ad929b23d0 Flipper Release: v0.61.0
Summary: Releasing version 0.61.0

Reviewed By: mweststrate

Differential Revision: D24132584

fbshipit-source-id: 7ae6ad5144561d356effe8eda5eaf472445365e6
2020-10-06 03:43:56 -07:00
Michel Weststrate
7b758d2697 Support supportsMethod in FlipperPlugin
Summary: `supportsMethod` wasn't implemented in the new sandy APIs so far, but is needed for D24108772

Reviewed By: cekkaewnumchai

Differential Revision: D24109496

fbshipit-source-id: 694344b423c1805baa193e4f2e1ad5f28483378b
2020-10-05 13:33:49 -07:00
generatedunixname89002005306973
8054f6446f Flipper Release: v0.60.0
Summary: Releasing version 0.60.0

Reviewed By: priteshrnandgaonkar

Differential Revision: D24017297

fbshipit-source-id: ff193e95edc7d236c204bddf83aba56a7f009469
2020-09-30 09:28:54 -07:00
generatedunixname89002005306973
c0e8cef466 Flipper Release: v0.59.0
Summary: Releasing version 0.59.0

Reviewed By: priteshrnandgaonkar

Differential Revision: D23985341

fbshipit-source-id: a477f9c05f7a62db3a59758c8c5fe06651ffa6f2
2020-09-29 08:11:39 -07:00
Michel Weststrate
ecf4cff7cf Fix most lint warnings
Summary:
I noticed that after the typescript upgrade, I got several weird positives from ESLint (like unused parameters in a type definition, which are obviously always unused, e.g. `type onClick = (e: Event) => void`). After some investigation, it turned out these warnings are generated by eslint, but that those rules should be performaned by typescript/eslint instead. For future reference to which rules this applies:

https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/README.md#extension-rules

Updated the config, and while at it, fixed all warnings in our codebase, except for `react-hooks/exhaustive-deps` warnings, since those require semantic changes.

This reduces the amount of eslint warnings from 86 to 39.

Reviewed By: passy

Differential Revision: D23905630

fbshipit-source-id: 0557708fd9ec6b17840a3c191e7d3baf225bdf23
2020-09-28 01:42:48 -07:00
Michel Weststrate
191df465b7 Updated to typescript 4
Summary:
allow-large-files

Updated to typescript 4. Note that this is no new major, the way TS numbers is that 4.0 is simply the number after 3.9 (so they refuse to use 3.10).

Primarily reason is that it allows us to use `/** deprecated */`. although there are definitely more interesting improvements

Reviewed By: passy, nikoant

Differential Revision: D23869445

fbshipit-source-id: 54e251b398b8698d9b18898ce66c3203b32aa356
2020-09-24 05:58:29 -07:00
generatedunixname89002005306973
32315c2d97 Flipper Release: v0.58.0
Summary: Releasing version 0.58.0

Reviewed By: cekkaewnumchai

Differential Revision: D23872448

fbshipit-source-id: b74483db292311719a0231f9b2fed78122e9f339
2020-09-23 12:06:38 -07:00
generatedunixname89002005306973
2fcab458bf Flipper Release: v0.57.0
Summary: Releasing version 0.57.0

Reviewed By: passy

Differential Revision: D23729543

fbshipit-source-id: 0156c0214b3665815ca648e995b78bb7cb2eba42
2020-09-16 04:27:08 -07:00
generatedunixname89002005306973
a47ac961f7 Flipper Release: v0.56.0
Summary: Releasing version 0.56.0

Reviewed By: jknoxville

Differential Revision: D23597790

fbshipit-source-id: e0f141eebe81e46619c71c8174fb78b1aaf2c035
2020-09-09 06:46:54 -07:00
Michel Weststrate
cd197aeaaf Make sure network plugin doesn't crash on invalid URLs
Summary: In the attached task an IPv6 address ended up in the URL send from IG. Since that URL couldn't be parsed, it crashed the network plugin. This change makes sure the plugin doesn't crash on invalid urls.

Reviewed By: cekkaewnumchai

Differential Revision: D23344503

fbshipit-source-id: c7ac2068e407a764d59e632bef1be7c4239c8c8a
2020-09-02 05:13:06 -07:00
root@sandcastle1585.atn1.facebook.com
66692dd722 Flipper Release: v0.55.0
Summary: Releasing version 0.55.0

Reviewed By: priteshrnandgaonkar

Differential Revision: D23444759

fbshipit-source-id: b569ff8e8dce76028e323f906e7415689ae8b1c5
2020-09-01 03:54:11 -07:00
root@sandcastle962.atn2.facebook.com
36825675d1 Flipper Release: v0.54.0
Summary: Releasing version 0.54.0

Reviewed By: mweststrate

Differential Revision: D23314243

fbshipit-source-id: ce2561b356f082613f656fedac9c08b440845bb1
2020-08-25 08:25:04 -07: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
744fe01922 Some renames
Summary:
Some non-semantic changes. Mostly an earlier rename that was accidentally done only locally rather than across the codebase

Also support `.spec` test extension, which is more idiomatic Jest, since we don't use the `.node` and `.electron` distinction anymore anyway.

Reviewed By: jknoxville

Differential Revision: D22976438

fbshipit-source-id: f3abedb36cbac1e835295177117ccbca492a67a1
2020-08-20 13:32:47 -07:00
Michel Weststrate
bce3d48e71 Better handle no (valid) plugin selection
Summary: Little ux tweak, there are some rare scenarios where you can end up in an empty plugin screen, made a small message.

Reviewed By: jknoxville

Differential Revision: D22846396

fbshipit-source-id: 0ad19f1c252112d78a5587e6633fee2d9542d5e1
2020-08-20 13:32:47 -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
root@sandcastle1328.prn2.facebook.com
f1c3bf8697 Flipper Release: v0.53.0
Summary: Releasing version 0.53.0

Reviewed By: priteshrnandgaonkar

Differential Revision: D23213490

fbshipit-source-id: 66dfa59dbae33d372bad9e284f9773e2ab88487b
2020-08-19 08:22:00 -07:00
generatedunixname89002005306973
d15ae99601 Flipper Release: v0.52.1
Summary: Releasing version 0.52.1

Reviewed By: passy

Differential Revision: D22976342

fbshipit-source-id: a4857df03cd1142615754a52f69d0f1578175f18
2020-08-06 10:14:30 -07:00
Michel Weststrate
7c6065889d support createPaste
Summary:
Added support for `createPaste` in Sandy plugins

Nice minimalistic example of how to expose a Flipper api to Sandy.

Note that some indirection could be removed by having an interface that is shared directly between `BasePluginClient` and `FlipperLib` (e.g. `PublicFlipperLib`). In contrast to `addMenuEntries` from the previous diff, `createPaste` is basically exposed verbatim to Sandy without additional wrapping, so those cases could be made simpler. Maybe will do that later.

Reviewed By: passy

Differential Revision: D22815873

fbshipit-source-id: e6d0773a35341edfe5de0898317eaadf88de79d0
2020-08-04 07:47:14 -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
489dd1521e Make sure Sandy Devices Plugins are loaded in Flipper devices
Summary:
This diff makes sure that devices will actually instantiate applicable sandy device plugins. Similar to how client plugins are owned by Client, device plugins are directly owned by BaseDevice, which significantly simplifies life cycle management and doesn't dispatch updates to all Redux connect components whenever something irrelevant changes.

Also made sure `device.teardown()` is called. That API already existed, but wasn't used or implemented before.

Updated Flipper test utils to support testing device plugins as well (both Sandy and classic ones)

Reviewed By: passy, nikoant

Differential Revision: D22693929

fbshipit-source-id: 73b2b8666ef7a0e748ea89360db84734d37eb5be
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
generatedunixname89002005306973
f01b84be27 Flipper Release: v0.52.0
Summary: Releasing version 0.52.0

Reviewed By: passy

Differential Revision: D22921075

fbshipit-source-id: 4cab9552dcd5ff1a64d20e1e771a4f5173d54860
2020-08-04 06:15:23 -07:00
generatedunixname89002005306973
5dc98bab9d Flipper Release: v0.51.0
Summary: Releasing version 0.51.0

Reviewed By: nikoant

Differential Revision: D22728768

fbshipit-source-id: 49eabdccc7fd335401618f91b890e94fda11b23f
2020-07-24 10:03:20 -07:00
Michel Weststrate
f0c54667e0 Support handling deeplinks in plugins
Summary:
This adds support for handling incoming deeplinks in a Sandy plugin, which can be done by using a `client.onDeepLink(deepLink => { } )` listener

Also generalized deeplinks to not just support strings, but also richer objects, which is beneficial to plugin to plugin linking.

Reviewed By: jknoxville

Differential Revision: D22524749

fbshipit-source-id: 2cbe8d52f6eac91a1c1c8c8494706952920b9181
2020-07-22 04:13:59 -07:00
Michel Weststrate
6fe477f19b Make sure Sandy plugins are selectable during export
Summary:
This diff makes sure Sandy plugins show up as well in the plugin selector when making exports (and in support form as well).

Also verified that this works with the Sandy updated section plugin.

Note that persisted state now didn't need any changes in the plugin code to work :)

Commented / simplified the calculation of available plugins a little bit and fixed a confusing issue where two different redux stores where created in one unit test, which caused an issue in the new implementation.

Reviewed By: jknoxville

Differential Revision: D22434301

fbshipit-source-id: c911196bc5b105309e82204188f124f40aab487a
2020-07-14 09:06:59 -07:00
Michel Weststrate
44f99eb304 Support export data
Summary:
Made Sandy plugins part of the export / import logic

Note that in the export format there is now a `pluginStates2` field. It could have been put in `pluginStates` as well, but I started with that and it felt very weird, as the `pluginStates` are supposed to reflect what is living in the Redux stores, where sandy state doesn't live in the Redux store (not directly at least). Trying to store it in the same field made things overcomplicated and confusing.

Reviewed By: jknoxville

Differential Revision: D22432769

fbshipit-source-id: d9858e561fad4fadbf0f90858874ed444e3a836c
2020-07-14 09:06:59 -07:00
Michel Weststrate
0e4a6d659b Make sure plugins can serialize and deserialize
Summary:
This plugin adds serialization capabilities to Sandy plugins buy setting the a `persist: <key>` flag. This shouldn't be used for state that is unserializable, too big, too sensitive, or irrelevant during export / import.

Using an explicit `persist` flag is done to make plugins robust to changes over time; as long as the key is kept the same, state variables can be renamed and reordered without breaking the import / export format. Also it allows us to detect some changes in the import / export format and warn about it.

Alternative designs considered but not implemented would be:
1. requiring the user to explicitly return the state from the factory (e.g. `const todos = createState([]); return { todos }`,
2. or construct the state from client (e.g. `const todos = client.createState([])`)
3. enable persistence by default, and store states in the order the states were created (much like useState in React). This was implemented in the first versions of this diff, but as pointed out in the discussions, this is too sensitive too (accidental) format changes, as the storage format would be quite implicit

A nice benefit of the current approach, especially compared with alternative approach 1, is that state being restored is immediately visible in the plugin factory. In other words, directly after initialization `const todos = createState([])`, the `todos.get()` is actually set to the state that is being restored, rather than having still the initial state which is only overridden rather. So this behaves very much like the `useState` hook in React.

Furthermore, in the future we could use the same `persist` key in combination with other options, such as `saveToLocalStorage`, in case some state acts as a 'preference' (T69989583).

`TestUtils.startPlugin` supports starting plugins with an initial state by using the optional `initialState` field

Actually wiring up the serialization and deserialization into the export / import functionality of Flipper is done in the next diff.

Reviewed By: jknoxville

Differential Revision: D22432770

fbshipit-source-id: 9a4849582c2f6f54d1e40f65a6cba73092c28fe8
2020-07-14 09:06:59 -07:00
Pascal Hartig
9d57a667ef Bump @types/testing-library__react from 10.0.0 to 10.2.0 in /desktop (#1366)
Summary:
Created a few breakages. Would appreciate some closer eyes on this.

Pull Request resolved: https://github.com/facebook/flipper/pull/1366

Reviewed By: mweststrate

Differential Revision: D22501454

fbshipit-source-id: 9b882a12aecc65da85f29101bf87bf27519a7d2a
2020-07-14 06:19:16 -07:00
generatedunixname89002005306973
fff723d5ef Flipper Release: v0.50.0
Summary: Releasing version 0.50.0

Reviewed By: passy

Differential Revision: D22501533

fbshipit-source-id: 0896efd4eb2b2bb5f557d573526db91dc5dcd1de
2020-07-13 04:15:23 -07:00
Michel Weststrate
babc88e472 Convert Seammammals plugin to Sandy {emoji:1f389}
Summary:
Converted the Seammammals plugin to use Sandy plugin infra (but the old components). Also updated lock file.

Added unittests have been added as well. The UI snapshots in there are kinda overkill, but nice demo that it works.

This completes the full roundtrip of the new Sandy infra, so this will be the last diff of this stack. I promise. I think.

Reviewed By: nikoant

Differential Revision: D22308265

fbshipit-source-id: 260e91a1951d486f6689880fe25281e80a71806a
2020-07-01 09:12:37 -07:00
Michel Weststrate
581ddafd18 Fixed re-enabling a still selected plugin
Summary: While testing manually discovered the sandy plugin infra din't cover the case that a plugin can be selected but not enabled at the same time. Added test and fixed that.

Reviewed By: nikoant

Differential Revision: D22308597

fbshipit-source-id: 6cef2b543013ee81cee449396d523dd9a657ad1c
2020-07-01 09:12:37 -07:00
Michel Weststrate
d16c6061c1 Introduce createState which can be used in components to propagate updates
Summary:
Introduced a minimal state abstraction so that state can be maintained in the plugin instance, but subscribe to by the UI.

At a later point we could pick an off the shelve solution like Recoil or MobX, or introduce cursors to read something deep etc etc, but for now that doesn't seem to be needed at all, and I think this will be pretty comprehensible for plugin authors (see also the 25th diff in this stack).

The api

```
createState(initialValue): Atom

Atom {
   get() // returns current value
   set(newValue) // sets a new value
   update(draft => { }) // updates a complex value using Immer behind the scenes
}

// hook, subscribes to the updates of the Atom and always returns the current value
useValue(atom)
```

Reviewed By: nikoant

Differential Revision: D22306673

fbshipit-source-id: c49f5af85ae9929187e4d8a051311a07c1b88eb5
2020-07-01 09:12:37 -07:00
Michel Weststrate
159c0deaf1 Added usePlugin hooks
Summary:
`usePlugin(pluginFactory)` returns the current plugin instance's api that was exposed by the plugin directory.

Passing `pluginFactory` is technically strictly not needed, but having the user pass it, we can make sure it is strongly typed

Reviewed By: nikoant

Differential Revision: D22286293

fbshipit-source-id: 4268b6849b8cd3d524103de7eadbd6c0a65c7a61
2020-07-01 09:12:37 -07:00
Michel Weststrate
bb0c8e0df0 Support receiving messages in Sandy plugins
Summary: This diffs adds the capability to listen to messages in Sandy plugins. Although API wise it looks more like the old `this.subscribe`, semantically it behaves like the `persistedStateReducer`; messages are queued if the plugin is enabled but not active.

Reviewed By: nikoant

Differential Revision: D22282711

fbshipit-source-id: 885faa702fe779ac8d593c1d224b2be13e688d47
2020-07-01 09:12:36 -07:00
Michel Weststrate
ec85dd5b01 Allow plugins to send messages
Summary: Sandy plugins can now send messages to plugins. The methods and params are strongly typed in implementation and unit tests, based on the <Methods> generic of FlipperClient.

Reviewed By: nikoant

Differential Revision: D22256972

fbshipit-source-id: 549523a402949b3eb6bb4b4ca160dedb5c5e722d
2020-07-01 09:12:36 -07:00
Michel Weststrate
8b2d8498e6 Upgrade to TypeScript 3.9
Summary:
Upgrading to TypeScript 3.9 so that we can use `// ts-expect-error`, that allows us to basically write unit tests for typings.

Fixed the typescript path in `settings.json`, because otherwise VSCode kept picking the built-in version (3.8.3 atm) of ts when opening the `sonar` folder as workspace.

Reviewed By: passy

Differential Revision: D22255818

fbshipit-source-id: ae54aedb237445f32f1797b4290656dbfb0e528f
2020-07-01 09:12:36 -07:00
Michel Weststrate
df6a8cd031 Provide initial plugin test infra for plugin devs
Summary:
This sets up the initial infra that is to be used by plugin devs to test plugins.

There is not much yet to see, as there is no state or message sending yet. But at least the life cycle of plugins can be test, things are strongly typed and everything is in the place where it should be :)

N.b. the import difference with these utils and the createFlipperMock utilities in Flipper are

1. this testing infra is entirely inside flipper-plugin package, so that plugin devs don't need flipper as a dependency
2. this testing infra doesn't provide abstractions for plugin / device / client switching; it tests plugins purely in isolation of the rest of the world (except for firing `onConnect` / `onDisconnect` which is normally the effect of switching plugins)

Reviewed By: nikoant

Differential Revision: D22255262

fbshipit-source-id: b94ccbab720d2b49428a646aed3c55af71a5bc80
2020-07-01 09:12:36 -07:00
Michel Weststrate
bde112bf85 Introduce onConnect / onDisconnect hooks
Summary:
Introduced hooks that are called whenever the plugin is connected / disconnected to it's counter part on the device.

There is some logic duplication between `PluginContainer` for old plugins, and `PluginRenderer` for new plugins, mostly caused by the fact that those lifecycles are triggered from the UI rather than from the reducers, but I figured refactoring that to be too risky.

Reviewed By: jknoxville

Differential Revision: D22232337

fbshipit-source-id: a384c45731a4c8d9b8b532a83e2becf49ce807c2
2020-07-01 09:12:36 -07:00
Michel Weststrate
f2c39aed55 Introduce PluginRenderer to render plugins
Summary: PluginContainer will now wrap Sandy plugins in PluginRenderer. PluginRenderer will also be used by plugin unit tests in the future

Reviewed By: jknoxville

Differential Revision: D22159359

fbshipit-source-id: 69f9c8f4bec9392022c1d7a14957f5aca0339d97
2020-07-01 09:12:36 -07:00