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
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
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
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
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:
By default docusaurus generates pages and routes for every mdx file it finds under the root dir. So even for the mdx files which are only used as includes and don't even have headers, page is still created, then index and often looks very weird, e.g. title is the same as file name etc. See e.g. this one: https://www.internalfb.com/intern/staticdocs/flipper/docs/fb/portal-troubleshooting/
I went through Flipper docs and renamed all mdx files which are only used as includes to prepend them with underscore. Everything which name is starting with underscore, or which is inside a folder which name is starting with underscore is considered private by docusaurus and skipped.
Reviewed By: passy
Differential Revision: D32722547
fbshipit-source-id: 0524d4dd56960714fbdd2b01ad8383cd16de4948
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:
This diff moves all UI code from app/src to app/flipper-ui-core. That is now slightly too much (e.g. node deps are not removed yet), but from here it should be easier to move things out again, as I don't want this diff to be open for too long to avoid too much merge conflicts.
* But at least flipper-ui-core is Electron free :)
* Killed all cross module imports as well, as they where now even more in the way
* Some unit test needed some changes, most not too big (but emotion hashes got renumbered in the snapshots, feel free to ignore that)
* Found some files that were actually meaningless (tsconfig in plugins, WatchTools files, that start generating compile errors, removed those
Follow up work:
* make flipper-ui-core configurable, and wire up flipper-server-core in Electron instead of here
* remove node deps (aigoncharov)
* figure out correct place to load GKs, plugins, make intern requests etc., and move to the correct module
* clean up deps
Reviewed By: aigoncharov
Differential Revision: D32427722
fbshipit-source-id: 14fe92e1ceb15b9dcf7bece367c8ab92df927a70
Summary: Follow up on D31992230 (2e7015388c) to replace `require('electron')` with `global.electronRequire('electron')`. However, during testing noticed that the Hermes debugger works just fine even with Electron DevTools open, so removed the logic altogether.
Reviewed By: aigoncharov
Differential Revision: D32167673
fbshipit-source-id: c6c6c07f07ac8c44e0f6959d56bf4c16725c186e
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: 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: Removed the usage of electron's native context menus, and replaces it with Antd based context menu's.
Reviewed By: passy
Differential Revision: D31990756
fbshipit-source-id: 0312cbac5fd20a1a30603ce1058c03f4291b23b1
Summary: The date type for crash reports was updated in D29327501 (aff02b2ca1) from `Date` to `number`. Unset values were previously `null` but became `NaN` in this change. `NaN` is nonnull so the backup value of `Date.now()` was not getting triggered properly and leading to "Invalid Date" to show up in the UI.
Reviewed By: passy
Differential Revision: D31702757
fbshipit-source-id: da93b1f79eb633b2f49dcffbe680d56d47a23ea0
Summary: Moved Logger, sleep, timeout and server contract types to flipper-common packages.
Reviewed By: passy
Differential Revision: D31475790
fbshipit-source-id: 42d2147698875f9e919ad5250f9953f3bff3ec2d
Summary: This stack gets rid of Flippers old sheet abstraction that relies on native (Electron) overlays, and implements it using Ant dialogs instead. Also removes a lot of code by making dialog API imperative, rather than reducer organised, like done in the deeplink handling.
Reviewed By: passy
Differential Revision: D30192001
fbshipit-source-id: 9bca3274bd039207e58f8f9394027515e391671d
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: Fix potentially unhandled promise rejection in Layout inspector. Not really reproducible, and probably originating from old Flipper versions (no trace is available either), since we have a lot of connection check in place. Just in case still handled the exception, for example if something goes wrong on client side
Reviewed By: passy
Differential Revision: D31267465
fbshipit-source-id: d1b384db7bb010af8d2aa12ae29110f343fb14af
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:
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