Commit Graph

6367 Commits

Author SHA1 Message Date
Michel Weststrate
92a743cc59 Processed some earlier review comments
Summary: Per title, processed some pending review comments made earlier in this stack

Reviewed By: aigoncharov

Differential Revision: D32916920

fbshipit-source-id: 01db85883596b5c85b77efc9cddadeac23cc4ef5
2021-12-08 04:30:57 -08:00
Michel Weststrate
3c6668a8b9 Make sure devices and clients are registered on session startup
Summary: This diff makes sure that when the client starts, it fetches all known devices and clients first, as it might have missed the 'connect' events for those. For Electron this wasn't needed, since the server starts with the UI, but this makes sure that a browser reload or a second connection sees the same devices & apps

Reviewed By: aigoncharov

Differential Revision: D32881589

fbshipit-source-id: 7b1cb3d296044f83dedcf3f3d8d02864690b6666
2021-12-08 04:30:57 -08:00
Michel Weststrate
943d535e86 Move sending intern requests from client to server
Summary: This diff moves send intern request from the browser to the server. The reason to make this change is that making such requests from a browser environment causes CORS restrictions to kick in.

Reviewed By: nikoant

Differential Revision: D32835449

fbshipit-source-id: e8e92e51ca963aa50b3c859bb61c2381171e85ae
2021-12-08 04:30:57 -08:00
Michel Weststrate
ad4a55f263 move node types, stub node modules
Summary: This diff stubs all node modules when running in the browser, so that, albeit with a lot of errors and without plugins, the UI loads in a browser. To be continued in the rest of this diff

Reviewed By: antonk52

Differential Revision: D32665705

fbshipit-source-id: 4632e241f59c5b9712a41d01a26878afb01f69b5
2021-12-08 04:30:57 -08:00
Michel Weststrate
d0402d7268 Move unloadModule to RenderHost
Summary: Define unload module on RenderHost. Not sure how to do that the browser and not sure how meaning full it is in a browser context.

Reviewed By: nikoant

Differential Revision: D32827050

fbshipit-source-id: 87025c6f5c2b950880712bff8df1c92a044a222e
2021-12-08 04:30:57 -08:00
Michel Weststrate
6c7a139554 Replace WebView with Iframe
Summary: This diff replaces the WebView we use to render plugin docs with an Iframe.

Reviewed By: nikoant, aigoncharov

Differential Revision: D32797111

fbshipit-source-id: 8ea0e0bd1cbea33dd7e389600951c020a88e4267
2021-12-08 04:30:57 -08:00
Michel Weststrate
2b2cbb1103 Move offline icon storage to app/
Summary:
This diff splits Facebook management into a ui-core and electron part:

* Cleaned up code and introduces a uniform Icon type to describe a requested icon
* Computing icon urls is done in the ui-core
* Introduced a RenderHost hook that can transform the request icon into a different url, in this case, a url to load icons from disk in production builds

For the browser UI, the urls are currently no rewritten since we have only dev builds (which always used only FB urls already). We could do the same rewrite in the future and download the static assets during build time. But for now this means that in the browser implementation we depend on normal browser caching, with the biggest downside that icons might not appear if the user has no internet connections.

With this change we lost our last usage of staticPath computations in ui-core

Reviewed By: aigoncharov

Differential Revision: D32767426

fbshipit-source-id: d573b6a373e649c7dacd380cf63a50c2dbbd9e70
2021-12-08 04:30:57 -08:00
Michel Weststrate
86995e0d11 Introduce static resource URLs
Summary: Introduced an API that converts a filepath, relatively to the `desktop/static/` folder in a url that can be resolved by the render environment. This will generate `file://` urls in Electron, and root relative `/` urls in browser envs

Reviewed By: aigoncharov

Differential Revision: D32767427

fbshipit-source-id: 378da7709bcb19449873358a8703b9c5a5809c57
2021-12-08 04:30:57 -08:00
Michel Weststrate
129cbd6f7b Move changelog loading to server
Summary: per title

Reviewed By: aigoncharov

Differential Revision: D32723706

fbshipit-source-id: ce5108da9f5da6fdfa7d1a66a31a4f8f430eb78d
2021-12-08 04:30:56 -08:00
Michel Weststrate
eab4f0d3d3 Bits & pieces
Summary: Added a command to let a file be opened by the OS, and some other small bits and pieces to make Flipper browser compatible.

Reviewed By: lblasa

Differential Revision: D32721748

fbshipit-source-id: a4ad1c2f662f4651ddf6c20c57e5af1e123914a8
2021-12-08 04:30:56 -08:00
Michel Weststrate
f5f9608098 Remove crypto dependency
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
2021-12-08 04:30:56 -08:00
Michel Weststrate
058785a509 Remove remaining process.env
Summary: Per title

Reviewed By: passy

Differential Revision: D32721205

fbshipit-source-id: 8e8a7fcac7d73f32d7fb59f852a8099cfe20e542
2021-12-08 04:30:56 -08:00
Michel Weststrate
2b4981c7cb Remove remaing from 'os' imports
Summary: Per title.

Reviewed By: passy

Differential Revision: D32721206

fbshipit-source-id: 9e465d0ed60c0c6da33c462aa76468faac620626
2021-12-08 04:30:56 -08:00
Michel Weststrate
2480ed30c5 Move flipper-doctor check running to flipper-server-core
Summary: Per title. Two new server API's: get-healthchecks, and run-healtcheck. Types have all been moved to flipper-common, so that they can be used by doctor, server-core and ui-core packages. Since it were quite some, moved them into a FlipperDoctor namespace.

Reviewed By: nikoant

Differential Revision: D32720510

fbshipit-source-id: 37aa35cde6ebd58479cf0dffec5b7b2da6d22198
2021-12-08 04:30:56 -08:00
Michel Weststrate
2a4fe77404 Extract environment config initialisation to server-core
Summary: This diff makes most stuff that is read from the `os` package, and version info etc available from the `serverConfig` object, so that flipper-ui-core no longer needs the `os` package.

Reviewed By: passy

Differential Revision: D32694848

fbshipit-source-id: 93af1e95d898da9aaf351a6970b5a7652ee835c8
2021-12-08 04:30:56 -08:00
Michel Weststrate
de59bbedd2 Make plugin loading async
Summary: This diff makes plugin loading async, which we'd need in a browser env (either because we'd use `import()` or we need to fetch the source and than eval it), and deals with all the fallout of that

Reviewed By: timur-valiev

Differential Revision: D32669995

fbshipit-source-id: 73babf38a6757c451b8200c3b320409f127b8b5b
2021-12-08 04:30:56 -08:00
Michel Weststrate
64747dc417 move plugin management from ui-core to server-core
Summary:
Follow up of D32665064, this diff moves all plugin management logic from flipper-ui to flipper-server. Things like downloading, installing, querying new plugins.

Loading plugins is handled separately in the next diff.

Reviewed By: nikoant

Differential Revision: D32666537

fbshipit-source-id: 9786b82987f00180bb26200e38735b334dc4d5c3
2021-12-08 04:30:56 -08:00
Michel Weststrate
f9b72ac69e Move RenderHost initialisation to Jest
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
2021-12-08 04:30:55 -08:00
Michel Weststrate
e7f841b6d2 Move flipper plugin from flipper-lib types to flipper-common
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
2021-12-08 04:30:55 -08:00
Michel Weststrate
2bf8ae2364 Get rid of perf_hooks package in Flipper UI
Summary:
perf_hooks is no longer needed as these APIs are widely available in both browser and electron.

Still needed in unit tests, as they run from Node

Reviewed By: lblasa, aigoncharov

Differential Revision: D32648253

fbshipit-source-id: 5718ea99b57f96f6858311fd0815ad18c476c99e
2021-12-08 04:30:55 -08:00
Michel Weststrate
9c913151bc Fix issue server-core not cleaning up devices properly
Summary:
Notice during debugging that devices keep unregistering. Doesn't lead to any practical issues, but still incorrect.

Also noticed that the server didn't restart when changing flipper-server-core, or recompile its deps, so fixed that as well.

Reviewed By: passy

Differential Revision: D32644276

fbshipit-source-id: 5384a30c9d293acda04b6e6f940268ddcd65a870
2021-12-08 04:30:55 -08:00
Michel Weststrate
5d45bd741b Initialise flipper-ui-browser with socket connection
Summary:
This diff sets up the socket connection between flipper-browser and flipper-server, and verifies that the initial UI initialisation work (e.g. `get-config` command works). The initial RenderHost is initialised as well based on the config and browser APIs.

Note that flipper-ui-core itself isn't started yet, as that has still a plethora of node imports, so Metro will correctly refuse to bundle

Not in this diff
* remove Node usage from flipper-ui-core
* implement all RenderHost APIs

Reviewed By: aigoncharov

Differential Revision: D32644074

fbshipit-source-id: 2c8065caf0191771a3867b69a431ca50eeb7a5a3
2021-12-08 04:30:55 -08:00
Michel Weststrate
29a907c733 Remove usage of 'events' package
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
2021-12-08 04:30:55 -08:00
Michel Weststrate
1308edc790 Start FlipperServerImpl as part of flipper-server
Summary: The previous started up a dev / web server for bundling in flipper-server, this diff starts the flipper server itself, so that we can connect the client to it (done in next diffs)

Reviewed By: passy, aigoncharov

Differential Revision: D32627390

fbshipit-source-id: b48de20f076e1e13842368d16a090708d533b69e
2021-12-08 04:30:55 -08:00
Michel Weststrate
0dfc73da93 setup webserver for flipper-server
Summary:
This sets up the metro bundler for flipper-server, to be able to serve the front end.

Note that this is a setup that is only relevant for development purposes

Done in this diff:

* setup metro
* setup fast refresh
* setup nodemon to be able to refresh on server changes

Not done in this diff

* Setup FlipperServerImpl in the flipper-server
* Load flipper-ui-core in flipper-ui-browser
* Load plugins
* Support options, env vars etc etc
* Make flipper-server stand alone (it is largely self contained, but still requires some static resources like theming)

Reviewed By: passy, aigoncharov

Differential Revision: D32626137

fbshipit-source-id: 47f580356ddf0993392d3b583082b187661727e9
2021-12-08 04:30:55 -08:00
Michel Weststrate
2b81be6c29 Cleanup plugin watch folders
Summary:
Watch folders weren't updated for cross plugin/flipper boundaries that have recently been removed

Fix changes in several source folders not being picked up when fast refresh wasn't enabled

Reviewed By: passy, aigoncharov

Differential Revision: D32626139

fbshipit-source-id: 2c830ec8154ff859ce1e3ee101e5963162d2e0a2
2021-12-08 04:30:54 -08:00
Michel Weststrate
e742322eb1 Move keychain storage to server, some constants cleanup
Summary: This diff moves keychain storage to the server. Figured to leave request logic itself in the UI-core, as basically all use cases happen there, except for streaming download for mobile build plugin, so sending the requests from the backend doesn't really seem to add value, unless we run into some CORS issues later.

Reviewed By: passy

Differential Revision: D32596715

fbshipit-source-id: f5ab9d794f91a6eb8a8dc07ae723bf2890726771
2021-12-08 04:30:54 -08:00
Michel Weststrate
bca169df73 Move settings, launcherSettings, GKs to app / flipper-server-core
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
2021-12-08 04:30:54 -08:00
Michel Weststrate
eed19b3a3d Move FlipperServer initialisation out of flipper-core
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
2021-12-08 04:30:54 -08:00
Michel Weststrate
d48f22b8dc Factor out GK fetch logic
Summary:
Removed loadGKs and loadDistilleryGKs from the `flipper` API, as it leaked implementation details of GK that didn't work well with decapitation later in this diff, and refactored it to using `getFlipperLib().GK`.

After that discovered that those APIs are actuallly only used by nt-shared's performGKcheck, which was already removed from all usages in D27736036, so just removed the code altogether. But left loading distillery GKs in place, since that is good infra structure to provide anyway(?), although we don't have active use cases atm

Reviewed By: jknoxville

Differential Revision: D32529600

fbshipit-source-id: a03fb14ada21018d329eea78a59f1b20610b2fd3
2021-12-08 04:30:54 -08:00
Juan Tejada
e75238cbd2 Properly make use of status events provided by DevTools server
Summary: Uses the new statuses emitted by DevTools in https://github.com/facebook/react/pull/22848 to better handle the connection state when connecting to DevTools from Flipper.

Reviewed By: bvaughn

Differential Revision: D32891240

fbshipit-source-id: 142d9996e05b5113e6dca28074c461d5a5acd38f
2021-12-07 10:53:06 -08:00
Juan Tejada
297697c209 Upgrade OSS react-devtools to v4.21.0
Summary:
Update `react-devtools-core` and `react-devtools` dependencies for RN, VSCode, Sonar, etc.

`js1 upgrade react-devtools -v 4.21.0`

# Changelog:

[General][Changed] - Upgraded react-devtools-core dependency to 4.19.1

Reviewed By: lunaruan

Differential Revision: D32889680

fbshipit-source-id: 25230927c3fb9d3e82db8e842d7bd7fbb4008e5e
2021-12-06 13:11:38 -08:00
Juan Tejada
4a93224151 Differentiate Flipper in logging from standalone app
Summary:
This commit makes it so when we load DevTools from within Flipper we log it as a Flipper load and not a regular standalone app load.

Note that the logging only applies internally.

Reviewed By: bvaughn

Differential Revision: D32884616

fbshipit-source-id: 90d0962bac9c1abdde36a70fd361251d7e607b57
2021-12-06 12:41:51 -08:00
Juan Tejada
f9547e024e Allow switching between internal and OSS DevTools (#3139)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/3139

This commit adds new UI in the top level toolbar to allow internal FB users to switch between the internal build of devtools and the OSS one.

## Scenarios

**Internal (when `client.isFB`)**

- DevTools version will default to the internal version, and will render a `Select` component with option to switch to the OSS version.
- If a global install of DevTools is present, the selection menu will also offer the option to switch to the global DevTools version.

**External (when `!client.isFB`)**
Will preserve previous behavior:

- Uses the OSS version by default, and doesn't provide option to switch to internal version.
- If a global installation is present, will render a `Switch` component that allows switching between OSS and global installation.

### Implementation

This commit refactors some parts of the DevTools plugin to provide a bit more clarity in the loading sequence by renaming and modifying some of the messaging, and fixing lint warnings.

A change introduced here is that when switching or loading devtools, when we attempt to reload the device via Metro, don't immediately show a "Retry" button, since at that point nothing has gone wrong, and the Retry button will only occur if the Metro reload doesn't occur after a few seconds.

In a future commit, this [PR in Devtools](https://github.com/facebook/react/pull/22848) will allow us to clear any loading messages once DevTools has successfully connected.

Reviewed By: lunaruan, mweststrate

Differential Revision: D32773200

fbshipit-source-id: aa15ffecba7b2b2ea74e109e9f16334d47bf5868
2021-12-06 12:41:51 -08:00
Juan Tejada
618670d00a Update Flipper DevTools plugin to use internal build
Summary:
This commit update the React DevTools Flipper plugin to use the internal build of `react-devtools-core/standalone`.

The internal build of `react-devtools-core/standalone` is generated by the new sync script: `js1 upgrade react-devtools-core`, which places the build under  `xplat/sonar/desktop/plugins/public/reactdevtools/fb`.

As a follow up, we can add a dropdown to allow users to select which version of React DevTools they'd like to use.

Reviewed By: mweststrate

Differential Revision: D31904288

fbshipit-source-id: ce0880284bd7f9ccaa6258a7c2956f20771e81a9
2021-12-06 12:41:51 -08:00
Juan Tejada
5a0627fdc3 Update react-devtools-core
Summary: This build was created from git revision 90e5d3638844414e1b9df0fe66c3fc46b211d210.

Reviewed By: lunaruan

Differential Revision: D31866508

fbshipit-source-id: 104cc38647f9a43d1cd2862c0ae412ecabe05bdf
2021-12-06 12:41:50 -08:00
Lorenzo Blasa
2d89c2f3eb Close resource as we cannot inline (#3125)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/3125

Better stream creation and disposal.

A report was generated with the following error:
StrictMode policy violation: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.

Changelog: Close input stream after use which was causing strict mode policy violation crashes and possibly leaking resources.

Reviewed By: passy

Differential Revision: D32830690

fbshipit-source-id: de3ffaf1b600590c4060a381fae66e73e08745cb
2021-12-03 12:58:44 -08:00
John Knox
b7a29ac0b3 Fix disconnect during init logging
Summary:
When a client disconnects while it's still initialising, we get a critical error.
But this is expected to happen now and again, so adding a specific error for it, and handling it accordingly.
It doesn't change the control flow, just the logging.

Reviewed By: nikoant

Differential Revision: D32794062

fbshipit-source-id: cf27fb9c345aa6369d338838a46e75a6b7afde41
2021-12-03 06:28:19 -08:00
Andrey Goncharov
9fc1d3cfb9 Ignore stale replies
Summary: Changelog: ignore stale replies

Reviewed By: lblasa

Differential Revision: D32829739

fbshipit-source-id: 267f43f8e8f3dea60ee86187f7a7709fea09e5af
2021-12-03 05:31:16 -08:00
Lorenzo Blasa
0d94120928 Remove Request Identifier from message
Summary:
{F684271717}
^
This is causing the error being reported quite a lot. The identifier doesn't provide much information to the person analysing the error. Only ever useful if debugging.

Reviewed By: antonk52, mweststrate

Differential Revision: D32828150

fbshipit-source-id: f29fbf6bfe389fec6ef888fc01be6c058193709d
2021-12-03 03:40:26 -08:00
Pascal Hartig
77d7ec2efb Guard against screenshot capture failure
Summary:
Bit off an odd one but according to the crash report in T107008330,
the screenshot can sometimes be not a real buffer. This may not actually
fix things but should give us some more insights into what's up.

Changelog: Better handling of screenshot taking in navigation

Reviewed By: mweststrate

Differential Revision: D32797863

fbshipit-source-id: 6d16ccb82fb8258591f9bc5f79c00811b18b9c51
2021-12-03 03:30:23 -08:00
facebook-flipper-bot
c9f623edf3 Automated: Update Podfile.lock (#3121)
Summary:
This is an automated PR to update the Podfile.lock.
- Make sure that the Podfile.lock contains latest FlipperKit and Flipper pod versions.
- Also make sure that all the dependencies are updated to the latest one.
- This is auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request)

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

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

**Static Docs Preview: flipper**
|[Full Site](https://our.intern.facebook.com/intern/staticdocs/eph/D32794374/V2/flipper/)|

|**Modified Pages**|
|[docs/getting-started/ios-native](https://our.intern.facebook.com/intern/staticdocs/eph/D32794374/V2/flipper/docs/getting-started/ios-native/)|

Reviewed By: nikoant

Differential Revision: D32794374

Pulled By: lblasa

fbshipit-source-id: 952f8c44118d392ac6cc2b0847e2a9f9c96dc89a
2021-12-02 15:54:22 -08:00
Andrey Goncharov
0799edbca0 Fix excessive error reporting
Summary:
Currently, we register global error handlers inside of ErrorReporter. To make these global error visible to the user we pipe them to `console.error`. All console methods are monkey-patched in our Logger. Logger uses ErrorReporter to report errors to LogView. It leads to duplicate errors in LogView.
In this diff, we extract startGlobalErrorHandling which should help us avoid duplication.

Reviewed By: passy

Differential Revision: D32759909

fbshipit-source-id: 6376e193c0ba6f0b46aaccc139ecf5066a04da11
2021-12-02 10:08:18 -08:00
Andrey Goncharov
5610f8f058 Remove 'path' from plugins
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
2021-12-02 04:14:51 -08:00
Lorenzo Blasa
6a4a867f74 Enable WebSockets for Android
Summary: This change effectively prioritises WebSocket over RSocket connections for Android.

Reviewed By: passy

Differential Revision: D32490095

fbshipit-source-id: 836438970f0668521ca6e7fab6c106e77f951652
2021-12-02 02:28:50 -08:00
Pascal Hartig
3db072557b Start docs for on demand
Summary: Starting just with Android On Demand. iOS will follow shortly.

Reviewed By: antonk52

Differential Revision: D32724229

fbshipit-source-id: b4276aae2a7349815d691b854adcfc531b702ae7
2021-12-01 10:51:54 -08:00
Pascal Hartig
ea94c9d1a5 Demote exchange error
Summary: The errors files for this aren't actionable and cannot be deduplicated because of the information included. Better to treat this as a warning.

Reviewed By: nikoant

Differential Revision: D32758656

fbshipit-source-id: 5255d694b8783b7bb49f981933741063d012df98
2021-12-01 10:49:19 -08:00
Pascal Hartig
3e258c6969 Demote connection loop error
Summary: We can't action tasks based on this report, so better to raise it as a warning.

Reviewed By: nikoant

Differential Revision: D32758850

fbshipit-source-id: 2e8ff984f40d2d0431db192e8f2d983d52b77ccd
2021-12-01 10:46:41 -08:00
Flipper Bot
a721e689be Flipper Snapshot Bump: v0.123.1-SNAPSHOT
Summary: Releasing snapshot version 0.123.1-SNAPSHOT

Reviewed By: lblasa

Differential Revision: D32753693

fbshipit-source-id: c6afec3c71b448d2bad9569bee3777195d474a71
2021-12-01 10:22:25 -08:00
Flipper Bot
902242b3b6 Flipper Release: v0.123.0
Summary: Releasing version 0.123.0

Reviewed By: lblasa

Differential Revision: D32753694

fbshipit-source-id: 70aa24c8711e99c7555346bc44106897ca6753db
2021-12-01 10:22:24 -08:00