Summary:
*Stack summary*: this stack refactors plugin management actions to perform them in a dispatcher rather than in the root reducer (store.tsx) as all of these actions has side effects. To do that, we store requested plugin management actions (install/update/uninstall, star/unstar) in a queue which is then handled by pluginManager dispatcher. This dispatcher then dispatches all required state updates.
*Diff summary*: refactored "uninstall plugin" operation to perform it in pluginManager dispatcher
Reviewed By: mweststrate
Differential Revision: D26166198
fbshipit-source-id: d74a1d690102d9036c6d3d8612d2428f5ecef4e6
Summary:
While trying to change something, discovered we have 3 different mechanisms in our code base to compute active plugins; the plugin list component, support form, and export flipper trace form had all their own, subtly different implementations of computing which plugins are available to the user.
Also removed some hardcoded exceptions for e.g. Logs plugin, which in the next diff and onward will be just a vanilla plugin without special casing
Unified that, which some how went a bit deeper than hoped, trough some hoops in in circular deps. Also unified to use the same testing utils, to avoid some gobbling objects manually together, with resulted in a bunch of unexpected NPEs. Found out that we actually still have unit tests using Flow in the process :-P. Converted one to TS.
Reviewed By: nikoant
Differential Revision: D26103172
fbshipit-source-id: 2fce2577d97d98543cb9312b3d013f24faee43aa
Summary: This diff fixes the issue when there is an error on checking GK for any of plugins and because of it the entire set of plugins failed to load. Each plugin should be loaded in isolation from others.
Reviewed By: passy
Differential Revision: D26099735
fbshipit-source-id: ba5475f4baf2d06f8922d345c9d401f5b15956ec
Summary:
Allow "uninstallation" of bundled plugins which means we mark them as uninstalled and not auto-updating anymore. Uninstalled bundled plugins are shown in "Detected in App" section together with Marketplace plugins where user can install them back.
Changelog:
Plugins can be uninstalled from sidebar in new Sandy UI.
Reviewed By: passy
Differential Revision: D25557789
fbshipit-source-id: 751cad68456313c069af639584541086efc7102b
Summary: After unbudling plugins users will need to manually install them. To simlify this transition we can auto-install favorite plugins on every app connection, so users won't need to install plugins which they marked as favorite before.
Reviewed By: passy
Differential Revision: D25538638
fbshipit-source-id: 4ac3ad0c8c026d149f7ce0c4af07da3e8b909772
Summary:
I've re-designed interfaces describing plugins as I found that mental overhead working with them became too expensive because of slightly flawed design. However this cascaded changes in many files so you can see how extensively these interfaces used in our codebase.
Before this change we had one interface PluginDetails which described three different entities: 1) plugins installed on the disk 2) plugins bundled into Flipper 3) plugins available on Marketplace. It's hard to use this "general" PluginDetails interface because of this as you always need to think about all three use cases everywhere.
After this change we have 3 separate interfaces: InstalledPluginDetails, BundledPluginDetails and DownloadablePluginDetails and things became much type-safer now.
Reviewed By: mweststrate
Differential Revision: D25530383
fbshipit-source-id: b93593916a980c04e36dc6ffa168797645a0ff9c
Summary: This diff changes uninstallation procedure for plugins. Instead of deleting plugin files immediately we are keeping them, but mark them as "uninstalled". This makes it possible to re-install plugins quickly in case when user clicked "delete" by mistake.
Reviewed By: mweststrate
Differential Revision: D25493479
fbshipit-source-id: 9ff29d717cdd5401c55388f24d479599579c8dd3
Summary:
See previous diff, if the plugin `id` on the class definition mismatches with the `package.json`, the navigation in Sandy will use the wrong id (from the meta data) causing the plugin not to open.
Since the `id` exposed on the class is the one that is used to setup the connect on the client, updated the ids in the `package.json` which have afaik no further meaning.
Pinging nikoant to verify that assumption. I can imagine this might impact historical data / plugin distribution?
Reviewed By: passy, nikoant
Differential Revision: D25302542
fbshipit-source-id: 43fe1667604eb7a28f6f9b7d260bc2a1e6e82dd3
Summary: This prefixes APIs of `flipper-plugin`, that are used by Flipper, but should not be used by plugins directly, with `_`. Also added tests to make sure we are always intentional when extending the exposed APIs
Reviewed By: passy
Differential Revision: D24991700
fbshipit-source-id: ed3700efa188fca7f5a14d5c68250598cf011e42
Summary: Currently we load all the plugins even if they are not required in dev mode, e.g. when you are developing a specific plugin. This diff adds an env var and command-line option to specify exact list of plugins to load. This makes dev mode startup faster and consume less memory.
Reviewed By: passy
Differential Revision: D24394146
fbshipit-source-id: 42a78c1ffb2632e657c2411e34e9c80fff18df3a
Summary: Implemented a way for re-loading single plugin on auto-update. This make it possible to apply update without full Flipper restart.
Reviewed By: mweststrate
Differential Revision: D23729972
fbshipit-source-id: ed30f7cde5a0537945db0b5bb6969ae8fde42cb6
Summary:
- Removed compilation on startup which is not required anymore after switching to plugin spec v2.
- Removed from Node process ("static" package) all the dependencies which are not required anymore: e.g. metro, babel etc.
- Plugin loading code from node process moved to browser process and made asyncronous.
Some expected benefits after these changes:
1) Reduced size of Flipper bundle (~4.5MB reduction for lzma package in my tests) as well as startup time. It's hard to say the exact startup time difference as it is very machine-dependent, and on my machine it was already fast ~1500ms (vs 5500ms for p95) and decreased by just 100ms. But I think we should definitely see some improvements on "launch time" analytics graph for p95/p99.
2) Plugin loading is async now and happens when UI is already shown, so perceptive startup time should be also better now.
3) All plugin loading code is now consolidated in "app/dispatcher/plugins.tsx" instead of being splitted between Node and Browser processes as before. So it will be easier to debug plugin loading.
4) Now it is possible to apply updates of plugins by simple refresh of browser window instead of full Electron process restart as before.
5) 60% less code in Node process. This is good because it is harder to debug changes in Node process than in Browser process, especially taking in account differences between dev/release builds. Because of this Node process often ended up broken after changes. Hopefully now it will be more stable.
Changelog: changed the way of plugin loading, and removed obsolete dependencies, which should reduce bundle size and startup time.
Reviewed By: passy
Differential Revision: D23682756
fbshipit-source-id: 8445c877234b41c73853cebe585e2fdb1638b2c9
Summary:
Do not list plugins packaged with format v1 in Plugin Manager.
Changelog: removed support for plugins packaged using legacy format (v1), so they won't appear in Plugin Manager anymore.
Reviewed By: passy
Differential Revision: D23681402
fbshipit-source-id: 1c9496ba6b739069d67228a0f4250f2f01aabd4d
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
Summary: Fixed error on building standalone packages for "unity" apps. The error was because "immer" imports were not transformed to use "immer" from Flipper bundle.
Reviewed By: passy
Differential Revision: D22357571
fbshipit-source-id: 590321f36208c9ed02d56d2c0c085c7cd1878018
Summary: Make sure Sandy plugins are loaded properly from disk
Reviewed By: jknoxville
Differential Revision: D22186275
fbshipit-source-id: fd2f560a7bed959b18e05db2a087909ad876ab9d
Summary:
So far there were 2 types of plugins: `FlipperPlugin` and `FlipperDevicePlugin`. This introduces a third kind: `SandyPluginDefinition`.
Unlike with the old plugins, the export of the module is not directly exposed as the plugin definition. Rather, we use class `SandyPluginDefinition` (instance) that holds a loaded definition and its meta data separately (`PluginDetails`). This means that we don't have to mix in and mutate loaded definitions, and that for unit tests we can avoid needing to provide a bunch of meta data. This also prevents a bunch of meta data existing on two places: on the loaded classes as static fields, and in the meta data field of the loaded class as well. Finally, we can now freely extends the `PluginDetails` interface in flipper, without needing to store it on the loaded classes and we are sure that no naming conflicts are caused by this in the future.
For compatibility with the existing code base, common fields are delegated from the `SandyPluginDefinition` class to the meta data.
Also cleaned up types around plugins a little bit and removed some unnecessary casts.
For all features that reason about plugins in general (such as exports), sandy plugins are ignored for now.
`SandyPluginInstance` is worked out in further diffs
The `instanceof` calls are replaced by a utility function in later diffs.
{F241363645}
Reviewed By: jknoxville
Differential Revision: D22091432
fbshipit-source-id: 3aa6b12fda5925268913779f3c3c9e84494438f8
Summary: Set up an initial library which can (should) be used by plugins in the future.
Reviewed By: jknoxville
Differential Revision: D22019554
fbshipit-source-id: 502b14b34b2c9c117cea377ab6ebbf150e6faee9
Summary:
Show notification if user has installed plugins packaged in the old format. Example text of notification:
***
Plugin "Example" will stop working after version 0.48 of Flipper released, because it is packaged using the deprecated format.
Please try to install a newer version of this plugin packaged using "Install Plugins" tab on "Manage Plugins" form.
If the latest version of the plugin is still packaged in the old format, please contact the author and consider raising a pull request for upgrading the plugin. You can find contact details on the package page https://www.npmjs.com/package/flipper-plugin-example.
If you are the author of this plugin, please migrate your plugin to the new format, and publish new version of it. See https://fbflipper.com/docs/extending/js-setup#migration-to-the-new-plugin-specification on how to migrate the plugin. See https://fbflipper.com/docs/extending/js-setup#package-format for details on plugin package format.
***
Reviewed By: passy
Differential Revision: D22065688
fbshipit-source-id: da9b9d8f62e7cdb8c926a81e24bdfb4ec67f9dff
Summary: When Flipper is running in dev mode we should always use bundled version of plugin (e.g. loaded from sources) even if a newer version is installed. Otherwise it could happen that Flipper will load installed version and it will not be possible to test your changes of plugin sources.
Reviewed By: passy
Differential Revision: D22016564
fbshipit-source-id: fbf63d5248b60034dc61688e4faa9b54890b744e
Summary: Use interface PluginDetails everywhere where plugins are handled and removed PluginDefinition type which was effectively a subset of PluginDetails
Reviewed By: mweststrate
Differential Revision: D21927456
fbshipit-source-id: 434ebeef955b922cc11757e78fbba8dec05f1060
Summary: Download updated plugins in background. This is implemented by periodical polling of Marketplace GraphQL API (interval 5 min by default). The feature is under GK flipper_plugin_auto_update, so for now it is enabled only for me.
Reviewed By: mweststrate
Differential Revision: D21863057
fbshipit-source-id: 51d8223ad4b2a928f7571ea480c10ba2efd9935d
Summary: Load either installed or bundled version of plugin depending on which is newer.
Reviewed By: mweststrate
Differential Revision: D21858965
fbshipit-source-id: aa46eafe0b5137134fadad827749672441f2c9e5
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/1052
Fixed tests failing on Windows because jest auto-mocks works differently there
Reviewed By: passy
Differential Revision: D21237618
fbshipit-source-id: 31c7e92b7f8ae84c1e65fd37428204452b3f1b00
Summary: Keep track of how often the 'reload' command is used
Reviewed By: passy
Differential Revision: D21227851
fbshipit-source-id: 112781024be16e411e93cf2403f95b2f3134d971
Summary: Fixes a regression (D20679687) of the main menu not loading immediately after application start
Reviewed By: passy, priteshrnandgaonkar
Differential Revision: D21227817
fbshipit-source-id: 37e4ddfcb73de3eac04d6162a3e028864d3e9e7f
Summary:
Added "id" field to Flipper plugin manifest which is used to match native and desktop plugin parts. Before that, "name" field was used both as npm package name and as plugin id.
The problem is that currently there are a lot of plugins which has invalid values in "name", e.g. not starting with "flipper-package-", or containing upper cased letters.
Simple renaming of "name" field can be very problematic, so we need a new field to avoid any breaking changes and keep historical analytics data which is also bound to plugin id.
Reviewed By: mweststrate
Differential Revision: D21129689
fbshipit-source-id: efd143c82a6a802cc0b5438fd3f509bd99aded0e
Summary:
Added versioning for plugin format.
The first version is where "main" points to source code entry and plugins are bundled by Flipper in run-time on loading them.
The second version is where "main" points to the already existing bundle and Flipper just loads it without bundling. The plugins of version 2 must be bundled using "flipper-pkg" tool before publishing.
Changelog: Support new packaging format for plugins.
Reviewed By: mweststrate
Differential Revision: D21074173
fbshipit-source-id: 7b70250e48e5bd5d359c96149fb5b14e67783c4d
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/998
After this diff all the default plugins (which are distributed with Flipper) will be included into the main app bundle instead of bundling each of them separately and then loading from file system. This is done by auto-generating plugins index in build-time and importing it from Flipper app bundle, so Metro can follow these imports and bundle all the plugins to the app bundle.
This provides several benefits:
1) reduced Flipper bundle size (~10% reduction of zipped Flipper archive), because Metro bundles each of re-used dependencies only once instead of bundling them for each plugin where such dependency used.
2) Faster Flipper startup because of reduced bundle and the fact that we don't need to load each plugin bundle from disk - just need to load the single bundle where everything is already included.
3) Metro dev server for plugins works in the same way as for Flipper app itself, e.g. simple refresh automatically recompiles bundled plugins too if there are changes. This also potentially should allow us to enable "fast refresh" for quicker iterations while developing plugins.
4) Faster build ("yarn build --mac" is 2 times faster on my machine after this change)
Potential downsides:
1) Currently all the plugins are identically loaded from disk. After this change some of plugins will be bundled, and some of them (third-party) will be loaded from disk.
2) In future when it will be possible to publish new versions of default plugins separately, installing new version of such plugin (e.g. with some urgent fix) will mean the "default" pre-built version will still be bundled (we cannot "unbundle" it :)), but we'll skip it and instead load new version from disk.
Changelog: Internals: include default plugins into the main bundle instead producing separate bundles for them.
Reviewed By: passy
Differential Revision: D20864002
fbshipit-source-id: 2968f3b786cdd1767d6223996090143d03894b92
Summary: See previous two diffs, this applies the abstraction to our code base
Reviewed By: passy
Differential Revision: D20679687
fbshipit-source-id: 05e340dca3f832971783a844a78d1ffd553ff9d2
Summary:
Quick notes:
- This looks worse than it is. It adds mandatory parentheses to single argument lambdas. Lots of outrage on Twitter about it, personally I'm {emoji:1f937_200d_2642} about it.
- Space before function, e.g. `a = function ()` is now enforced. I like this because both were fine before.
- I added `eslint-config-prettier` to the config because otherwise a ton of rules conflict with eslint itself.
Close https://github.com/facebook/flipper/pull/915
Reviewed By: jknoxville
Differential Revision: D20594929
fbshipit-source-id: ca1c65376b90e009550dd6d1f4e0831d32cbff03
Summary:
1) moved "sonar/desktop/src" to "sonar/desktop/app/src", so "app" is now a separate package containing the core Flipper app code
2) Configured yarn workspaces with the root in "sonar/desktop": app, static, pkg, doctor, headless-tests. Plugins are not included for now, I plan to do this later.
Reviewed By: jknoxville
Differential Revision: D20535782
fbshipit-source-id: 600b2301960f37c7d72166e0d04eba462bec9fc1