Summary:
Remove crypto dep, which was only used by NUX, to hash the elements that has been confirmed.
Sadly trickier than hoped; there is no uniform api in both browser and Node available that can take a sha-256 hash, and the browser APIs are async.
Reviewed By: aigoncharov
Differential Revision: D32721204
fbshipit-source-id: 32625f83bf6c60cedc4fb7096240c2fa0d8434a7
Summary:
This diff moves RenderHost initialisation to jest, which is thereby treated as just another 'Host' like flipper-ui, the electron app etc. A benefit is that it provides a mocked flipperServer by default that can be used to mock or intercept requests. See LaunchEmulator.spec as example.
Also made the jest setup scripts strongly typed by converting them to TS.
This change allows the test stub configuration, which was OS dependent, out of flipper-ui-core.
Reviewed By: nikoant
Differential Revision: D32668632
fbshipit-source-id: fac0c09812b000fd7d1acb75010c35573087c99f
Summary: Moved all types related to plugin descriptions from plugin-lib (which handles downloads and such) to flipper-common. The goal of that is to remove all plugin-lib usage from ui-core to server-core, so that the UI itself doesn't do any file operations anymore related to plugins. That will be done in next diffs, this just moves types but no code.
Reviewed By: nikoant, aigoncharov
Differential Revision: D32665064
fbshipit-source-id: 86d908e7264569b0229b09290a891171876c8e00
Summary: 'events' doesn't exist in the browser, so picked a popular package with the same API
Reviewed By: lblasa, aigoncharov
Differential Revision: D32643057
fbshipit-source-id: 91309e53e16f3279048aa976cdb098eaa4a7d7db
Summary:
This diff moves a lot of stuff from the client to the server. This diff is fairly large, as a lot of concept closely relate, although some things have split off to the earlier diffs in the stack, or are still to follow (like making intern requests).
This diff primarily moves reading and storing settings and GKs from client to server (both flipper and launcher settings). This means that settings are no longer persisted by Redux (which only exists on client). Most other changes are fallout from that. For now settings are just one big object, although we might need to separate settings that are only make sense in an Electron context. For example launcher settings.
Reviewed By: passy, aigoncharov
Differential Revision: D32498649
fbshipit-source-id: d842faf7a7f03774b621c7656e53a9127afc6192
Summary: This diff makes sure flipper-ui-core no longer depends on flipper-server-core. Currently server config is still transferred from UI to server, which doesn't really make sense in future scenarios where server might start before client, but will address that separately
Reviewed By: timur-valiev, aigoncharov
Differential Revision: D32462835
fbshipit-source-id: 498a944256ba1aabbf963b896953e64d11e27214
Summary:
1. Add `path` replacement
1. Remove Node's path for all plugins but MobileBuildsPluginContainer (it is probably going to be moved to the server)
Reviewed By: mweststrate
Differential Revision: D32766327
fbshipit-source-id: e636f273842506e752b97cf1b28ce7ac51ce9a12
Summary:
1. Replace old FileSelector with the new FileSelector
2. Remove showOpenDialog from FlipperLib
Reviewed By: mweststrate
Differential Revision: D32667103
fbshipit-source-id: be8da034c2695f83b397b6c7d35bc6aee78d66e5
Summary: Add shared FileSelector component compatibe with the new FlipperLib API
Reviewed By: mweststrate
Differential Revision: D32667100
fbshipit-source-id: dca1e8b7693d134a99617e916c7cfd30432cef78
Summary:
- Per the title, we're explicitly setting the `flex-basis` to 0 and `flex-grow` and `flex-shrink` to 1.
- We've noticed that the `Sidebar` does not allow shrinking less than half the page when `flex-basis` is 1.
- With this change, we can now resize the `Sidebar` component without issue.
- ** We're taking this approach because the linter has issues with us using `styled` with `Sidebar` **
#nocancel
Differential Revision: D32477863
fbshipit-source-id: 99a50bc047d59add833c1fc113ab159c08767e05
Summary:
1. Remove fs.readFile from some plugins
2. Add "importFile" to FlipperLib and RenderHost
See D32492149 for context
Followups:
1. Decapitate Stella's sendToPhone
2. Decapitate crash reporter
3. Figure out how to approach navigation
4. Figure out how to approach FileSelector
Reviewed By: mweststrate
Differential Revision: D32496775
fbshipit-source-id: e150aa56a2c2c1eb12a4c03c801f76cd76485a9d
Summary:
1. Remove "fs.writeFile" from plugins
2. Remove "showSaveDialog" from "FlipperLib"
3. Add "exportFile" to "FlipperLib" and "RenderHost"
As we are going to use Flipper in a browser as well, instead of providing low-level abstraction like "showSaveDialog", we should provide more high-level ones like "exportFile". In browsers it does not make too much sense to expose "showSaveDialog" as there is not way to use the returned file path to write to it.
In the end, "exportFile" is going to trigger a file download for browsers and show the save dialog and write to the returned file path for Electron.
Reviewed By: mweststrate
Differential Revision: D32492149
fbshipit-source-id: 0673119bdb7670a5872f5982c7d82dfc44eb7906
Summary: Preempting dependabot by bumping a few patch and minor releases.
Reviewed By: timur-valiev
Differential Revision: D32434931
fbshipit-source-id: 77a3ec760f08262a118e12318d7601e031730a9a
Summary:
I've decided to migrate [a desktop plugin](https://github.com/bamlab/react-native-performance) to Sandy.
When doing so, I decided to rise to the challenge from the [Flipper docs](https://fbflipper.com/docs/tutorial/js-custom#testing-plugin-logic): `we are going to pretend that we always write unit tests first` 😅
However, I've realized that when creating a plugin with `npx flipper-pkg init`, running `yarn jest` directly after creation actually fails.
There are 3 issues solved in the different commits:
1. an absolute import seem to not be resolved, since all the other imports were relative in the file, I changed it as well
2. some dependencies are missing.
They used to be included in the `flipper` dependency but when migrating to use `flipper-plugin` instead, they're not present anymore.
I don't think this is an ideal fix, I would believe a dependency like a `flipper-dev-environment` including all of those would be more appropriate. So I'm open to suggestions to fix/remove of course
3. jest.config needs to be fixed to run in jsdom environment and ensure we can test the react component
## Changelog
Fix: ensure desktop plugin template tests run
Pull Request resolved: https://github.com/facebook/flipper/pull/3039
Test Plan:
I've cloned the repo and run:
```
cd flipper/desktop/pkg
yarn
cd ../../..
./flipper/desktop/pkg/bin/run init
```
I run the tests on the newly package created, but it actually still failed because of the first issue (since it still installed `flipper-plugin` from npm`)
However, by adding this patch, it now runs!
```patch
diff --git a/node_modules/flipper-plugin/lib/ui/data-table/DataTable.js b/node_modules/flipper-plugin/lib/ui/data-table/DataTable.js
index 2e07ff5..ff3181d 100644
--- a/node_modules/flipper-plugin/lib/ui/data-table/DataTable.js
+++ b/node_modules/flipper-plugin/lib/ui/data-table/DataTable.js
@@ -39,7 +39,7 @@ const useAssertStableRef_1 = require("../../utils/useAssertStableRef");
const PluginContext_1 = require("../../plugin/PluginContext");
const lodash_1 = require("lodash");
const useInUnitTest_1 = require("../../utils/useInUnitTest");
-const createDataSource_1 = require("flipper-plugin/src/state/createDataSource");
+const createDataSource_1 = require("../../state/createDataSource");
function DataTable(props) {
var _a, _b;
const { onRowStyle, onSelect, onCopyRows, onContextMenu } = props;
```
Reviewed By: aigoncharov
Differential Revision: D32358207
Pulled By: mweststrate
fbshipit-source-id: 7761b4150c24dd5379a24c3c1deeb78bf3dda4ee
Summary: Fixed some incorrect non-null assertions that showed up in monitoring.
Reviewed By: timur-valiev
Differential Revision: D32278433
fbshipit-source-id: afe4913d8aef38c371461b4d0b817b2625153de1
Summary:
Bumps [jest-mock-console](https://github.com/bpedersen/jest-mock-console) from 1.1.0 to 1.2.3.
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/bpedersen/jest-mock-console/commits">compare view</a></li>
</ul>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
</details>
Pull Request resolved: https://github.com/facebook/flipper/pull/2989
Reviewed By: passy
Differential Revision: D32202558
Pulled By: mweststrate
fbshipit-source-id: c8a21d7639f66d2825558b7ee4e01b58a86aac83
Summary: - We are using the `Sidebar` component in our `LogViewer` implementation and we noticed that it needed some styling updates to be used properly as a vertical `Sidebar`.
Reviewed By: mweststrate
Differential Revision: D32083159
fbshipit-source-id: 441f3972ae900b5d5f353d3c7b56117c489850ba
Summary:
This diff removes most remaining Electron imports, by storing env and path constants on the RenderHost. As nice side effect those paths are all cached now as well.
To make sure RenderHost is initialised before Flipper itself, forced loading Flipper through a require. Otherwise the setup is super sensitive to circular import statements, since a lot of module initialisation code depends on those paths / env vars.
Reviewed By: nikoant
Differential Revision: D31992230
fbshipit-source-id: 91beb430902272aaf4b051b35cdf12d2fc993347
Summary: Fixed several tests that caused uncaught promise rejects to fire after the tests finished. This caused jest to fail if there are too many of them.
Reviewed By: aigoncharov
Differential Revision: D32118124
fbshipit-source-id: 50734dab6dee2efec7f056940af72858b27b1707
Summary: Current implementation uses type `string` as a key for indexing items stored in datasource. However, users can provide any key as an index which means that the type of index item can be anything, not only string. This diff introduces a more refined types for the key. It adds another requirement to provide a key property to a generic which is used to infer the index type.
Reviewed By: mweststrate, aigoncharov
Differential Revision: D31895751
fbshipit-source-id: 19ba907bd6f35df87e3fa442db5fc5cec6af174d
Summary:
- We're using the `Tabs` component from `flipper-plugin` and upon adding them, we noticed that our view being displayed within the tabs no longer scrolled and the tab internally was being stretched far off the screen. (D31538124)
- After egp did some digging, he discovered that by adding the `maxWidth` style property to the inner `Layout.Container`, the tab no longer stretched and the scrolling was restored.
- We played around by adding wrapper elements around the contents of our Tab and adding the same style prop, but this did not yield the same result.
***Would Love some input from the Flipper team as to the best way to ensure that this won't break other's plugins. Thank you!***
Reviewed By: mweststrate
Differential Revision: D31672790
fbshipit-source-id: 99cab1873f359f4c1827e4c94f2527636884c237
Summary:
Took a few iterations to make offline mirror happy, but everything is green now.
allow-large-files
Reviewed By: nikoant
Differential Revision: D31690614
fbshipit-source-id: 38d0d6cb5e3f63b3707d917a1ed6fc6144762731
Summary: Moved Logger, sleep, timeout and server contract types to flipper-common packages.
Reviewed By: passy
Differential Revision: D31475790
fbshipit-source-id: 42d2147698875f9e919ad5250f9953f3bff3ec2d
Summary: Further decoupling of `server/` from the rest of the code base. Also fixed a problem with promise chaining causing promises to create unhandled rejection errors.
Reviewed By: passy
Differential Revision: D31474919
fbshipit-source-id: 027cccbe9b57d856c94d63c093d39b6cb3e53312
Summary:
This diff introduces the packages necessary for Flipper decapitated.
* flipper-common: utilities & types shared between client, server, flipper-plugin
* flipper-server-core: all device & client management goes in here. Basically flipper's backend
* flipper-ui-core: all UI goes in here, as far as it doesn't depend on Electron
* desktop: the Electron app, will load server-core and ui-core, and glue them together, providing implementations for some electron specific stuff like dialgos
* flipper-server: A node process hosting flipper-server-core, that can be connected to over websockets. And probably can serve a browser version of the UI as well.
* flipper-ui-browser: thin wrapper around flipper-ui-core, providing some browser specific behavior / stubs.
* flipper-dump: (might remove later), but want to hack a quick and dirt flipper dump in here, as alternative way to test flipper-server-core.
This diff just creates the packages, but doesn't move any code, so it can be summarized as:
restoftheowl
Reviewed By: nikoant
Differential Revision: D30218646
fbshipit-source-id: 735598a1261a98e584f52504b5eba01ec0afa162
Summary:
This diff cleans up order remaining dialogs, the ones involved in exporting to file or url. Includes some legacy component cleanup boyscouting, but not too much.
This removes a lot of code where state of the wizard was stored globally, and makes it locally instead.
Other code that was removed involves interaction with the old UI, which allowed import / export to be running in the background as well. (which is no longer needed since we optimised the process)
Reviewed By: timur-valiev
Differential Revision: D30192000
fbshipit-source-id: 13be883c5bf217a3d58b610b78516359e9bd0ebc
Summary:
This diff moves the dialogs
* Settings
* Plugin Manager
* Doctor
* Sign in
* Changelog
To use the imperative dialog APIs, rather then organising them through reducers which adds a lot of indirection which isn't really needed but hard to follow.
Reviewed By: passy
Differential Revision: D30192002
fbshipit-source-id: ba38b2e700da3e442653786448fcbf85074981ad
Summary: This diff separates the concept of a Client as now on the UI, from the concept of a Client as known on the server, and makes all interactions with client and vice versa async.
Reviewed By: timur-valiev
Differential Revision: D31235682
fbshipit-source-id: 99089e9b390b4c5359f97f6f2b15bf4b182b6cb9
Summary:
Grey -> gray. "Cancelled" seems quite common in APIs though, so I disabled that.
A few promise cleanups
Reviewed By: aigoncharov
Differential Revision: D31323610
fbshipit-source-id: c8863d995936f451c24eb408fe5c26677187f089
Summary:
Client up `client.device` (which had no code references anymore) / `client.deviceSync`. Cleaned up feature code for old SDKs (pre 2, which is 3 years old).
This makes decapitating Client a little simpler in the rest of the stack.
Reviewed By: passy
Differential Revision: D31235436
fbshipit-source-id: 919679c1830e2b9368d0787d7b363c090305edb8
Summary: Add unit tests to test errors thrown from plugins during initialisation, as follow up for D31127969 (a72e46c792). From the 4 tests cases added (first load plugin then device, device then plugin, first load plugin then client, first client then plugin), the first case was indeed failing before the mentioned diff and not registering the device.
Reviewed By: passy
Differential Revision: D31142583
fbshipit-source-id: 8e44c667316192231d1bb5e4d76c5bf1207ba835
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
Summary: Restored support for device icons which was disabled in previous diff
Reviewed By: passy
Differential Revision: D31054802
fbshipit-source-id: 107a53f06159211534cb9a2316340af7a7ca530a
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
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