Commit Graph

29 Commits

Author SHA1 Message Date
Michel Weststrate
f9c8bf8941 Fix dark mode startup error
Summary:
Changelog: Fixed startup error when loading default theme

The theme defaulted to `auto`, instead of `system`, causing an startup exception. Fixed by adding types and having a more defensive startup check.

Fixes https://github.com/facebook/flipper/issues/2835

Reviewed By: jknoxville

Differential Revision: D30866648

fbshipit-source-id: 83b6d9fc235eaa0a7e959df4276d3f378eed7d1f
2021-09-10 07:04:43 -07:00
ZHANG Qichuan
9a4d94c971 Add option for automatic dark theme (#2759)
Summary:
Add an setting option to allow automatic dark theme

A feature requested by swrobel https://github.com/facebook/flipper/issues/2708

## Changelog

### UI change
Replace the `Enable Dark Theme` Toggle button with a Radio group containing three Radio buttons.

The available options are `Dark`, `Light` and `Use System Default`, of which `Use System Default` is the default value

<img width="548" alt="Screenshot 2021-08-31 at 3 32 44 PM" src="https://user-images.githubusercontent.com/410850/131462798-4e74f757-41fc-4a3f-ba28-53d00fc1cf03.png">

### Data structure change

The `darkMode` property of [Settings](c0cd32564a/desktop/app/src/reducers/settings.tsx (L20)) is changed from `boolean` to `string`, the available values are `dark`, `light` and `auto`

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

Test Plan:
### Test 1
- Step: Choose `Dark` in the Settings page and click on `Apply and Restart` button
- Expect: The application is displayed in Dark mode
### Test 2
- Step: Choose `Light` in the Settings page and click on `Apply and Restart` button
- Expect: The application is displayed in Light mode
### Test 3
- Step: Choose `Use System Default` in the Settings page and click on `Apply and Restart` button
- Expect: The application is displayed in System Default mode

Reviewed By: mweststrate

Differential Revision: D30666966

Pulled By: passy

fbshipit-source-id: a63e91f2d0dbff96890e267062cb75bffd0007f4
2021-09-08 03:28:35 -07:00
Anton Nikolaev
cc4064ec9f Force Sec-Fetch-Site header to 'none'
Reviewed By: bartoszniemczura

Differential Revision: D30047497

fbshipit-source-id: 0d9376c09d63176031291f19bfe82a56d5677641
2021-08-05 02:40:41 -07:00
Anton Nikolaev
142859f0ed Intercept click to links in the embedded documentation and redirect them to the default browser
Summary: Intercept click to links in the embedded documentation and redirect them to the default browser.

Reviewed By: passy

Differential Revision: D29426270

fbshipit-source-id: 1d3d9613ff827f80287883768452b93701e95d96
2021-06-29 13:02:05 -07:00
Michel Weststrate
014e571f74 Start application in the right theme
Summary:
Changelog: Improved dark mode support!

This diff makes sure that the dark mode preference is written to the Flipper config, and applied during startup, so that the ugly light/dark flash when starting Flipper in dark mode disappears

Reviewed By: passy

Differential Revision: D29436059

fbshipit-source-id: 0f762149848298512026fbd216d9a9e0bf4276db
2021-06-29 08:39:34 -07:00
Michel Weststrate
617f8a928c Use dark scrollbar and system elements
Summary:
This diff adds OS support for dark mode (at least on Mac), by making sure system elements are styled according to system dark theme.

For some unknown reason, this does apply to all system dialogs, titlebars etc, but not for scrollbars, so they got custom themed.

Differential Revision: D29436058

fbshipit-source-id: bac649b6cd81f0142c607ed567eeb00f41625041
2021-06-29 08:39:34 -07:00
Anton Nikolaev
4cafa9ab1a Fix bug with multiple handling of deep link after window reload
Summary: This diff fixed the issue when deep link handled multiple times in case Flipper window reloaded. See test plan for videos.

Reviewed By: fabiomassimo

Differential Revision: D29100221

fbshipit-source-id: 0ff6f1a645d5488d205b4fba44942f4d39f59088
2021-06-14 06:51:09 -07:00
Anton Nikolaev
3f55ceac8f Added few eslint rules checking promises
Summary:
Added rules to ensure we properly propagate errors from promises.

Also found and fixed a place where promise function parameter was mismatched.

Reviewed By: mweststrate

Differential Revision: D28537820

fbshipit-source-id: b93f44274fc76544049813f645508cb78e432880
2021-05-19 09:30:42 -07:00
Michel Weststrate
e29222fba7 Update and patch loading React DevTools
Summary:
When trying to run some React component performance profiles, the updates registered made absolutely no sense (components rerendering without any parent or other cause causing them to render etc). That turned out to be caused by having an outdated version of the React devTools in Flipper.

Sadly the newer version of the React DevTools didn't work with our current Electron version anymore. Some horrible hacking is needed to work around that.

To help with updating the tools in the future (they are by default cached forever on the local machine), I've introduced the `FLIPPER_UPDATE_DEV_TOOLS` variable.

The plugin loading work around is inspired by https://github.com/electron/electron/issues/23662#issuecomment-787420799

Reviewed By: passy

Differential Revision: D27685981

fbshipit-source-id: c35e49aff9b2457b63122eeee0d5c042ddd3b08b
2021-04-15 07:48:33 -07:00
Tuomas Jaakola
3a0d6a3acc App icon for Linux (#2116)
Summary:
Fixes https://github.com/facebook/flipper/issues/1369
It seems that electron-builder has an issue when trying to set the app icon for Linux zip builds. A workaround for this is to set `icon` option for `BrowserWindow`.

I created a new PNG file for this, it seems that 64x64 looks the best.

## Changelog

App icon for Linux fixed.

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

Test Plan: ![Screenshot from 2021-03-29 13-50-48](https://user-images.githubusercontent.com/490260/112826545-d00d6e00-9095-11eb-984f-227e923f275e.png)

Reviewed By: mweststrate

Differential Revision: D27461758

Pulled By: passy

fbshipit-source-id: 0be3d6b356d1332e89c3df6c137269900417f9ba
2021-03-31 06:33:15 -07:00
Pascal Hartig
81252edf33 Upgrade to Electron 12.0.1
Summary: Changelog: Upgraded to Electron 12.0.1

Reviewed By: fabiomassimo

Differential Revision: D27084184

fbshipit-source-id: 5d45c632f7fec78635287f1919ef1cf0b2b458ad
2021-03-17 16:32:39 -07:00
Michel Weststrate
727c99b729 Introduce support for no hardware acceleration
Summary: Start flipper with `--no-launcher --disable-gpu` to disable hardware acceleration

Reviewed By: passy

Differential Revision: D25994355

fbshipit-source-id: e75bb209c8e3325135a114bec1f25889187d2728
2021-01-22 05:31:00 -08:00
Michel Weststrate
ffeb47ed75 Move title bar functionality to rail (#1816)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/1816

Now that Sandy is the default in OSS builds as well, we can remove the temporarily title bar and switch to small topbar windows in Electron.

This diff removes any remaining elements in the titlebar

- version number went into the title bar
- the update check warning is shown on top of the bottom section of the left rail (orange triangle)
- the development only perf graphs are moved to the left bar as well and are now aligned vertically.

Reviewed By: jknoxville

Differential Revision: D25805957

fbshipit-source-id: fba4b60c246b8f5d99a93087af31af9ac55defe8
2021-01-18 06:48:03 -08:00
Anton Nikolaev
d4debc4185 Use dotenv for dev mode customisation
Summary: Allow using of .env file to pass env vars to be used in dev mode. Currently this allow to configure defaults for enabling fast refresh, automatic opening of dev tools and plugins to load.

Reviewed By: passy

Differential Revision: D24398938

fbshipit-source-id: 30a5d86b7906a7723a404cf84a1b8d50ae497dbc
2020-10-22 11:35:53 -07:00
Michel Weststrate
54d36876b6 Upgrade to Electron 10 (#1532)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/1532

Upgrade to Electron 10, in an attempt to fix random hard Electron crashes. Didn't fix it, but given the changelog of Electron with all the bug fixes, seems to be a good idea nonetheless :)

Changelog: Flipper now uses Electron 10

Reviewed By: nikoant

Differential Revision: D23565000

fbshipit-source-id: 3f07b8cf8c438147bde5314698d20046ac9f94cf
2020-09-17 09:44:27 -07:00
Anton Nikolaev
f03d5d94ed Remove plugin compilation and loading from startup hot path
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
2020-09-16 06:32:58 -07:00
Chaiwat Ekkaewnumchai
c8af6da236 Disable Web Security in Command Line
Summary:
We've disabled web security in `BrowserWindow` (https://fburl.com/diffusion/0l0q669m). However, there is a bug in Electron 9 that makes this doesn't work as expected (https://github.com/electron/electron/issues/23664). Earlier, we've resolved this problem by specifying `no-cors` mode in requests. This strikes again in other plugin.

This diff applies a workaround commented inside the issue to allow to make CORS requests.

Reviewed By: nikoant

Differential Revision: D22306977

fbshipit-source-id: ea0f5e3f1c4080037df258a6c5ce1fc89d433c3b
2020-06-30 06:52:07 -07:00
Anton Nikolaev
eeded4e32f Install plugins to pending directory first to enable installing new versions of existing plugins
Summary:
Install plugins to pending directory first to enable installing new versions of existing plugins. On startup Flipper moves all the plugins from pending directory into installed plugins directory.

Auto-update, after downloading a plugin package, will also extract it to "pending", so after restart update will automatically be applied.

Reviewed By: mweststrate

Differential Revision: D21929713

fbshipit-source-id: 141b106415e941156ae598cf810ab3bed8c76ced
2020-06-09 04:58:36 -07:00
Anton Nikolaev
8addd43f09 Flag "--open-dev-tools" to automatically open dev tools on startup
Summary:
Just a convenient feature: `yarn start --open-dev-tools` opens Dev Tools window alongside with Flipper window.

Changelog: new command-line flag "--open-dev-tools" to automatically open Chrome Dev Tools for Flipper debugging.

Reviewed By: mweststrate

Differential Revision: D21074769

fbshipit-source-id: 12ae33ab74a3d35c54051321396d8701d72c7e32
2020-04-17 06:19:26 -07:00
Anton Nikolaev
553c54b63e Include default plugins into app bundle (#998)
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
2020-04-14 07:20:39 -07:00
Michel Weststrate
220052d70d measure clean versus unclean exits
Summary:
This adds another field to the exit data to record whether we had a clean exit where the app was closed as it should.

Note that doing a reload inside Flipper will be recorded as an unclean exit.

Reviewed By: passy

Differential Revision: D20915481

fbshipit-source-id: 240192d7a69bf620bfaa316e3e5cb0f45d6a34cc
2020-04-08 06:26:30 -07:00
Anton Nikolaev
c1bb656a0d Re-use babel transformations
Summary:
SORRY FOR BIG DIFF, but it's really hard to split it as all these changes are cross-dependent and should be made at once:
1. Moved transformations to separate package "flipper-babel-transformer" and linked it using yarn workspaces to "static" and "pkg" packages where they are re-used. Removed double copies of transformations we had before int these two packages.
2. Converted transformations to typescript
3. Refactored transformations to avoid relying on file system paths for customisation (FB stubs and Electron stubs for headless build)
4. As babel transformations must be built before other builds - enabled incremental build for them and changed scripts to invoke the transformations build before other build scripts
5. As we need to deploy all the dependencies including the fresh "flipper-babel-transformer" as a part of "static" - implemented script which copies package with all the dependencies taking in account yarn workspaces (hoisting and symlinks)

Reviewed By: passy, mweststrate

Differential Revision: D20690662

fbshipit-source-id: 38a275b60d3c91e01ec21d1dbd72d03c05cfac0b
2020-03-27 03:26:51 -07:00
Pascal Hartig
fc9ed65762 prettier 2
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
2020-03-24 09:38:11 -07:00
Michel Weststrate
068f19461a Use http://localhost for origin instead of https
Summary:
Follow up of D20454562

We now set an origin header, but use https instead of http, which is currently not supported by the public RN version (for the internal RN version support was added in D20526486).

However, not promoting ourselves as running on a secured connection seems like the more trustworthy thing to do, and better reflects reality.

Reviewed By: nikoant

Differential Revision: D20534363

fbshipit-source-id: e26fabd77013920e4c58fdbf552bb909f0499cae
2020-03-19 06:26:01 -07:00
Michel Weststrate
ddf5df98c7 Track flipper crashes / restarts
Summary:
In this diff we persist data about the state of the app when exiting, and to make sure we capture it in crashes, do that as part of track-usage events as well.

with the exit data we also capture what kind of device and plugin the user was using, so that we can detect anomalies like flipper needing restarting more often for certain plugins

during startup, we will always send an event how long it was since the last startup, including the above information

Reviewed By: passy

Differential Revision: D20515200

fbshipit-source-id: ead971e05542e0ef58ed5e5b204af70b51a15b9b
2020-03-19 02:50:48 -07:00
Pascal Hartig
28e735a4c5 Fix prettier error (#893)
Summary:
^
Pull Request resolved: https://github.com/facebook/flipper/pull/893

Test Plan: eyes

Reviewed By: nikoant

Differential Revision: D20469555

Pulled By: passy

fbshipit-source-id: 70e3ebbc8a65de5f2fc407b9435d5b249f158f00
2020-03-16 11:00:57 -07:00
Pritesh Nandgaonkar
d75be90522 Fix the graph API failures
Summary:
Currenty in the prod version of Flipper the endpoints of media upload and flipper trace fail with status code 400. Reason being different origin and refferer as compared to the dev version. This diff matches the origin and the refferer with the dev one.

I referenced Anton's diff D20278701.

Reviewed By: nikoant

Differential Revision: D20454562

fbshipit-source-id: 20f80a731878fb491d08a208d64fc9260e442fa3
2020-03-16 05:23:15 -07:00
Anton Nikolaev
10d990c32c Move plugins to "sonar/desktop/plugins"
Summary:
Plugins moved from "sonar/desktop/src/plugins" to "sonar/desktop/plugins".

Fixed all the paths after moving.

New "desktop" folder structure:
- `src` - Flipper desktop app JS code executing in Electron Renderer (Chrome) process.
- `static` - Flipper desktop app JS code executing in Electron Main (Node.js) process.
- `plugins` - Flipper desktop JS plugins.
- `pkg` - Flipper packaging lib and CLI tool.
- `doctor` - Flipper diagnostics lib and CLI tool.
- `scripts` - Build scripts for Flipper desktop app.
- `headless` - Headless version of Flipper desktop app.
- `headless-tests` - Integration tests running agains Flipper headless version.

Reviewed By: mweststrate

Differential Revision: D20344186

fbshipit-source-id: d020da970b2ea1e001f9061a8782bfeb54e31ba0
2020-03-14 14:35:18 -07:00
Anton Nikolaev
85c13bb1f3 Move desktop-related code to "desktop" subfolder (#872)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/872
Move all the JS code related to desktop app to "desktop" subfolder.

The structure of "desktop" folder:
- `src` - JS code of Flipper desktop app executing in Electron Renderer (Chrome) process. This folder also contains all the Flipper plugins in subfolder "src/plugins".
- `static` - JS code of Flipper desktop app bootstrapping executing in Electron Main (Node.js) process
- `pkg` - Flipper packaging lib and CLI tool
- `doctor` - Flipper diagnostics lib and CLI tool
- `scripts` - Build scripts for Flipper desktop app
- `headless` - Headless version of Flipper app
- `headless-tests` - Integration tests running agains Flipper headless version

Reviewed By: passy

Differential Revision: D20249304

fbshipit-source-id: 9a51c63b51b92b758a02fc8ebf7d3d116770efe9
2020-03-14 14:35:17 -07:00