Summary: Move from adding adb path in tracery plugin to adding flipper as a whole. Se discussion here: D16494684
Reviewed By: jknoxville
Differential Revision: D16542414
fbshipit-source-id: abb2f4989693025a8bfe7d12f4c328870a962204
Summary:
In my last plugin for React VR I used spawn heavily to call adb and python2. It worked out well, but after Flipper released, I noticed that all my spawn commands were broken.
I found that Electron start in different way when bundled as production bundle, and because of it, it does not inherit process.env.PATH in a same way as it do this for development mode. (only linux/mac issue)
In this diff I used npm package which detects linux/mac and executes bash command which returns all the env variables from the system. After it, it takes PATH and merge it with process.env.PATH.
Reviewed By: passy
Differential Revision: D16457847
fbshipit-source-id: 60226f2d7977f1dfec49de6e889f3115d8688991
Summary:
Compilation is a mixture of I/O and CPU work, so there's some good optimisation potential even on a single thread by running the promises concurrently. The downside is that the output is a bit garbled, but it's quite a bit faster for me.
To test this, I applied this diff so I could just `time yarn start` for an entire run.
```
diff --git a/xplat/sonar/src/init.js b/xplat/sonar/src/init.js
--- a/xplat/sonar/src/init.js
+++ b/xplat/sonar/src/init.js
@@ -80,4 +80,5 @@
dispatcher(store, logger);
// make init function callable from outside
window.Flipper.init = init;
+ window.close();
});
```
## Before
**Cold Start**
```
696.89user 93.21system 4:21.44elapsed 302%CPU (0avgtext+0avgdata 1111448maxresident)k
1416inputs+372824outputs (3major+28155897minor)pagefaults 0swaps
```
**Hot Start**
```
6.87user 1.62system 0:17.32elapsed 49%CPU (0avgtext+0avgdata 249264maxresident)k
216inputs+182912outputs (0major+251426minor)pagefaults 0swaps
```
## After
**Cold Start**
```
736.86user 95.47system 1:53.13elapsed 735%CPU (0avgtext+0avgdata 970616maxresident)k
42864inputs+356776outputs (42major+25299531minor)pagefaults 0swaps
```
**Hot Start**
```
6.85user 1.60system 0:15.93elapsed 53%CPU (0avgtext+0avgdata 269420maxresident)k
2592inputs+197904outputs (0major+260099minor)pagefaults 0swaps
```
## Summary
It's beneficial in both cases, but the wall clock time for cold start goes from *4:21.44* to *1:53.13* for me (mind that this is a single sample). This is a 2.3x speed-up!
Reviewed By: jknoxville
Differential Revision: D16359215
fbshipit-source-id: 62257ec3bdefbf98356f5ac9418c4906f7cb4b1b
Summary:
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.5 to 4.17.14.
<details>
<summary>Commits</summary>
- [`be87d30`](be87d30394) Bump to v4.17.14.
- [`a6fe6b1`](a6fe6b1e17) Rebuild lodash and docs.
- [`e371828`](e37182845f) Bump to v4.17.13.
- [`357e899`](357e899e68) Rebuild lodash and docs.
- [`fd9a062`](fd9a062d57) Bump to v4.17.12.
- [`e77d681`](e77d68121f) Rebuild lodash and docs.
- [`629d186`](629d186579) Update OpenJS references.
- [`2406eac`](2406eac542) Fix minified build.
- [`17a34bc`](17a34bc585) Fix test bootstrap for core build.
- [`53838a3`](53838a38f8) Fix tests in older browsers.
- Additional commits viewable in [compare view](https://github.com/lodash/lodash/compare/4.17.5...4.17.14)
</details>
<br />
[](https://help.github.com/articles/configuring-automated-security-fixes)
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 ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major 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)
- `dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/flipper/network/alerts).
</details>
Pull Request resolved: https://github.com/facebook/flipper/pull/493
Reviewed By: jknoxville
Differential Revision: D16323535
Pulled By: passy
fbshipit-source-id: 9511b4050306a872295a7053f465ae46b9c5fa8a
Summary: When Trace has been uploaded, load it inside a webview in Flipper.
Reviewed By: habond
Differential Revision: D16185763
fbshipit-source-id: 3217211f1d5035fc16d733ef48db44d8f8d9d360
Summary: This one snuck in while rebasing my new rules onto master.
Reviewed By: bnelo12
Differential Revision: D16180472
fbshipit-source-id: b715c218ff1886c1901c7730a6b8dac67beb3968
Summary: Taking another stab at adding some lint rules to make it harder to shoot yourself in the foot. Hopefully nothing too controversial. Preferring spread and rest should lead is more readable and there's no downside when using ES6. The "useless" rules are just things like renaming imports to the original name which should only happen during refactors.
Reviewed By: jknoxville
Differential Revision: D16180453
fbshipit-source-id: 1cf6851b7726c0aee953ec7cf7dd6fa0aca32253
Summary:
Non-final identifiers make code harder to understand.
This is particularly true for JavaScript where even the *type*
can change as a value gets reassigned later.
This enforces to use `const` whereever possible, but doesn't
"outlaw" `let`. Mixed destructuring is also still allowed.
Used `eslint --fix` to change all existing cases.
Reviewed By: jknoxville
Differential Revision: D16131329
fbshipit-source-id: 2eceaca7c603b71b36e005be5d135e1849f2518d
Summary: updating to the latest metro version
Reviewed By: passy
Differential Revision: D15986739
fbshipit-source-id: 83fba99bf7cc0903590831aeb852d14dde576901
Summary:
On Windows fs.watch fires multiple times after a single edit causing multiple instances of plugin compilation threads to start bogging down system resources.
This diff delays compilation by 1 second, soaking additional watch events fired for that plugin in that time window.
Reviewed By: danielbuechele
Differential Revision: D16109076
fbshipit-source-id: bc4f89d83f04487a3d32ee5cc2105fe0a8b7366c
Summary: Keytar binaries weren't updated when upgrading the electron version. This diff updates the binaries to match electron's node version.
Reviewed By: passy
Differential Revision: D15821734
fbshipit-source-id: 04688f1e465d2f7bdefecfdda8e2f3868de18780
Summary:
We in React VR were need newer Chrome DevTools version to make our plugin work properly. Chromium version with required fixes were shipped in electron 5.0.0.
This diff bumps electron version and explicitly allows node integration (accessing require, process and other node related functions from window object in index.html), because it was disabled by default in 5.0.0.
Reviewed By: jknoxville
Differential Revision: D15693539
fbshipit-source-id: 4f71a07b2afaa489aec46940c924f4ad30ad0413
Summary: Eslint doesn't like them and me neither.
Reviewed By: danielbuechele
Differential Revision: D14798690
fbshipit-source-id: 5ee7108b9ecfbb05cf2d54cfce68931d16d69a73
Summary:
`process.platform` is used to require the native-module for keytar. On Windows this returns `win32` (No matter if 64bit or 32bit system). The native module was named `keytar-win.node`. This diff renames it to `keytar-win32.node`.
This is the code that requires the module from `user.js`:
```
keytar = global.electronRequire(
path.join(
isProduction() ? remote.app.getAppPath() : process.cwd(),
'native-modules',
`keytar-${process.platform}.node`,
),
);
```
Reviewed By: priteshrnandgaonkar
Differential Revision: D14771646
fbshipit-source-id: cd48d25cb5921e07e472eb46636fa2599c8ff721
Summary:
Just minor version bumps so this doesn't have any noticeable effects.
Doing some cleanups after danielbuechele pointed out that it's important
for us to stay close to the upstream releases in the last team meeting.
Reviewed By: jknoxville
Differential Revision: D14665264
fbshipit-source-id: 91efb0663693823f394284457550716f22c40938
Summary:
Flipper Electron delegates to the Launcher if it is found right on startup to fetch the most recent/compatible version of Flipper. The Launcher then opens the downloaded app with a `--no-launcher` option to avoid bouncing back and forth between the Electron app and the Launcher.
This depends on the argument processing working unchanged. In the past this has been somewhat difficult to guarantee as this doesn't happen in one place and dev/prod builds have handled arguments different due to Electron weirdness (requiring a `--` passed in, for instance).
If anything here goes wrong, we end up in a very nasty scenario where the launcher and the Electron app rapidly open and close, making it nearly impossible for users to escape that vicious cycle. `pkill -f Flipper` being the best option, if you can focus a terminal for long enough.
In order to avoid this from ever happening in the future, this introduces a quick check for the last startup is written with a timestamp and if this is less than 5s in the past, we will skip delegating to the Launcher altogether, keeping the current instance running.
Reviewed By: jknoxville
Differential Revision: D14598136
fbshipit-source-id: b3335ce7ec7dc3e5e014d459db31df4c8a774fc6
Summary:
When passing --file or --url explicitly on startup, they should
be used in the same way that event handlers are used.
Reviewed By: jknoxville
Differential Revision: D14598688
fbshipit-source-id: 07179227da3b6c754a4d3a9e15342474e39d72b7
Summary:
Changes where we delegate to the launcher to a later point so we can successfully intercept file open events and custom URI events.
There's more information in Phase 1 in this paragraph of the doc: https://fb.quip.com/tpqnAbxnJw1w#UNZACAnVVGs
Reviewed By: danielbuechele
Differential Revision: D14563585
fbshipit-source-id: a8757a6072386e56102f15b0668456369a44aad7
Summary:
This fixes headless not terminating due to the `package.json` not being readable.
I instead write this to the `global` object in the same way that the version is
set.
Reviewed By: jknoxville
Differential Revision: D14579316
fbshipit-source-id: 238afe912366c423552305e120088f4abac4c20b
Summary:
Positional arguments with yargs are a mess, so I'm adding a `--file` instead.
This can then be used to pass parameters on through the launcher.
Reviewed By: danielbuechele
Differential Revision: D14525320
fbshipit-source-id: f04ebed85b6eb9e3c82e76736695d41e7bafb301
Summary:
Adding support for downloading archived Flipper data using a URL handler.
A URL looks like `flipper://import/?url=` and will download the file specified in the url param. While downloading the file, a spinner is shown in the app's titlebar.
Reviewed By: jknoxville
Differential Revision: D14262763
fbshipit-source-id: 6538fc78c07a48cef7b71b3f7bdbcb712d054593
Summary:
`keytar` is developped by the Nuclide team and allows cross-platform access to the system's keychain. As `keytar` has a native dependency, we need to make sure Metro doesn't try to bundle it as part of our JS bundle. We are adding another rule to our electron-transform, to not bundle `.node` files (which are native node modules).
Secondly, we need to make sure, the native module is compiled for the correct version of node.js. Usually native modules are compiled for the node version that is running on the system it is installed on. However, we need to make sure it is compiled with the node version that is bundled with electron. That's exactly what `electron-rebuild` does: It recompiles all native modules with the electron's node version.
More on native modules: https://electronjs.org/docs/tutorial/using-native-node-modules
Reviewed By: jknoxville
Differential Revision: D14224402
fbshipit-source-id: 6414a53391a861a23a5d95bf6f18cd0058d9178f
Summary:
Started with upgrading electron from 3.0.0 to 4.0.5. This required a bunch of subsequent updates:
* upgrading `electron-builder` to latest version, because the old version couldn't build electron 4 apps.
* `appDir` is deprecated in builder config, `projectDir` is used instead, which we already had set, so its fine to just remove this ([see GitHub commit](a5e457163e)).
* upgrading `jest-runner/electron` because the old version couldn't run electron 4 tests.
* upgrading our custom dependency resolution to use electron 4.0.5, because the test runner still resolves to 2.0.8 ([see GitHub issue](https://github.com/facebook-atom/jest-electron-runner/issues/31)).
* updating `sandcastle.sh` to use the new cache files from D14131344.
* removing `package-lock.json` as is was causing warnings. We use `yarn` and `yarn.lock` anyways. This file must have been committed by accident.
* updating our check to only run one version of Flipper at a time to use the new electron API `app.requestSingleInstanceLock` as the old one was removed in electron 4.
* updating the snapshot test that checks App rendering, which changed a little due to the electron upgrade.
* upgrading flow-type definitions to `electron-v4.0.5.js` generated by [electron-flowtype-definitions](https://github.com/danielbuechele/electron-flowtype-definitions).
**PS: Best new feature in Electron 4: Copy&paste working in dev tools**
Reviewed By: jknoxville
Differential Revision: D14131360
fbshipit-source-id: d7ed9643875629a1fa1860bb61b11dd0c64112ab
Summary:
Builds in flipper-public are failing, because duplicate imports: https://our.intern.facebook.com/intern/sandcastle/job/22517998213713260
That's most likely because the `flipper-public` is not blacklisted in metro, so let's add it!
Reviewed By: passy
Differential Revision: D14134423
fbshipit-source-id: 52f87196957c8578b8ac7f578efa74e3c13fe1bb
Summary: The electron stub is used by the headless version of Flipper. For that reason, the version number was always `1`. The headless version has a the actual version written to a global variable. So let's use it here.
Reviewed By: passy
Differential Revision: D14149692
fbshipit-source-id: c4781987fd3201e67897eaf31627b0bb2970ffcb
Summary:
To make it more obvious how to disable this if unwanted (e.g. when
testing local builds).
Pull Request resolved: https://github.com/facebook/flipper/pull/373
Reviewed By: jknoxville
Differential Revision: D14130771
Pulled By: passy
fbshipit-source-id: 82c83c1ad14737c8c7791de71a1ee23fcea5ec18
Summary: as per title. see explanation in code comment
Reviewed By: jknoxville
Differential Revision: D14125820
fbshipit-source-id: 9b8e31214a65a184397852544cebd7b69ea0aadb
Summary: Plugin files in subfolders were not watched. Adding recursive flag to reload plugins, even when there are changes in any of the plugin's subdirectories.
Reviewed By: jknoxville
Differential Revision: D14100394
fbshipit-source-id: 2a0b5e35df4bbbfe6cf8a0fafd5271222d99a46c
Summary:
Allows the launcher to provide messages to the user. Currently, in the form
of the red notification bar at the bottom. This is just meant as a temporary measure
during the alpha to have some clearly noticeable way of getting the user's attention.
I consider removing this a blocker for the release as this mechanism is not well
suited for this in many ways.
The current use case for this is providing a warning if a cached version is used
instead of the requested one, e.g. "Could not fetch requested Flipper version 'deadbeef', using cached version instead."
Reviewed By: jknoxville, priteshrnandgaonkar
Differential Revision: D14073687
fbshipit-source-id: 85630347027063103315eeb1286731fe2478e261
Summary:
For the production version, if the Launcher is installed and no `--no-launcher` (note the double-negation) is supplied, then
let the launcher start the app instead.
The launcher will pass the `--no-launcher` option back to prevent this from looping.
Reviewed By: jknoxville
Differential Revision: D14066620
fbshipit-source-id: 27d305efac36005e5e1082076829f10ef14aba0d
Summary: This diff imports and exports data in a `.flipper` file extension. This diff also adds the support to open flipper app by double clicking on the `.flipper` file.
Reviewed By: danielbuechele
Differential Revision: D14042846
fbshipit-source-id: 17e6b55bf2796d9abdf985411fce799600f7792b
Summary: Per title. Required as Scribe is now being used for device tests.
Reviewed By: jknoxville, danielbuechele
Differential Revision: D13971892
fbshipit-source-id: 2df36d44d4e45a579cc9cca0d4cad9105ba8a383
Summary:
It's a bit hacky but apparently the recommended solution:
https://stackoverflow.com/questions/28615293/is-there-a-jest-config-that-will-fail-tests-on-console-warn
This will bail when a call to `console.error` is used in a test.
If you *need to* use console.error in a test, then mock it.
This will likely not pass yet, but let's fix all failures and then land it.
Reviewed By: danielbuechele
Differential Revision: D13898383
fbshipit-source-id: 0ca222a07433a9a311dc6bdf0d264342a59208be
Summary:
- create a zip-file when building the headless version of Flipper
- restore pkg cache in Sandcastle from pantri
- run build script in sandcastle.
Changes need to go together with D13942919
Reviewed By: passy
Differential Revision: D13942701
fbshipit-source-id: caac7d6cda99fec2a6836c652957ff609a0bf8bb
Summary:
This seems like a better approach than ad-hoc lookup in
`electron.remove.argv`. Left a note to a task to provide
a better interface to this.
I also need this in order to ensure we're starting
Flipper through the launcher which needs to happen
before we start the Electron runtime.
Reviewed By: jknoxville
Differential Revision: D13881355
fbshipit-source-id: 69c70d71035a47084f789ddb4dc969b45ba4648b
Summary:
Instead of replacing the tilde with home-dirs on an incomplete, ad-hoc
basis, let's use a package for this. It also supports `~USER` resolution
which someone might reasonbly expect to work if `~/DIR` is working.
Reviewed By: jknoxville
Differential Revision: D13940956
fbshipit-source-id: 5bfa9b8b2540fed8c05c856ff736e48e925f985d
Summary:
Just splitting the diff adding the dep from using it
because this is always quite noisy.
Reviewed By: jknoxville
Differential Revision: D13940957
fbshipit-source-id: b31a953a7ebdce9a6611c47ee007c051cdcac147
Summary:
Upgrading to flow 0.91, fixing a bunch of `$FloxFixMe`s that were introduced by upgrading to 0.86.
Also fixing some linting issues.
Reviewed By: priteshrnandgaonkar
Differential Revision: D13900794
fbshipit-source-id: 5d0a1b62371f3b5d34b909bae0876583acb6f977
Summary:
We were using `window.performance` to measure performance. This was because the equivalent node.js API `perf_hooks` wasn't available in the electron version we were using back then.
However, `perf_hooks` has landed in electron meanwhile, so I am moving to this API, as it works for the headless version and jest tests, too.
This allows us to delete the babel transform that was used for node-based tests, where the browser API was replaced with the node API
Reviewed By: jknoxville
Differential Revision: D13860133
fbshipit-source-id: cf1395004fac046dd55751ff465af494173b2cbf
Summary:
Fixes required to be able to run Flipper in node.js:
* Adds checks if the `window`-object exists before using it, to allow running in node.
* Imports from within Flipper should directly reference the file they are requiring instead of `import from 'flipper'`. This was done in most of the places. Fixed a few occurrences where this wasn't the case. This is to prevent cyclic dependencies in node.
* shared packages (React, ReactDOM and Flipper) were exposed on the `window` before, changed this to `global` as this works in browser and node.
* Adds some missing methods to our electron stubs (used for testing and headless Flipper)
Reviewed By: passy
Differential Revision: D13786577
fbshipit-source-id: 145d560f1446e7d0bdec2acd8dd54dae983d7b36
Summary:
* Adds `build-headless.js` to bundle the app using metro
* the build script replaces the prelude code added by metro with our own to make it work in node. Metro will add an API to add custom prelude code in the next version.
* Pins down metro's dependency of `temp` to `v0.9.0` (instead of `0.8.3`) to be compatible with node 10. (This will be fixed in a metro upgrade)
Reviewed By: passy
Differential Revision: D13786574
fbshipit-source-id: bddb3542c370c068d90a90c4b59337f995e4fa3f
Summary:
`static/index.js` is called by Electron's main process, it does the setup required to run Flipper. However, some of this setup is electron specific, other is not. This moves all non-Electron specific code into `setup.js` which later can be called from node, too. All Electron specific stuff is still in `static/index.js`.
On a side note, this remove the renaming from `.sonar` to `.flipper` config folder, as I think most users should have been migrated by now, users that are not yet migrated will lose their settings, which isn't too much of an issue as our settings are very minimal anyways.
Reviewed By: passy
Differential Revision: D13638253
fbshipit-source-id: 22ab2a65ffec87b40bd86899630d582d9dc5d05c
Summary:
First add a Flow Strict config, then enable Flow Strict Local for 13 files in xplat/sonar.
each change can land seperately:
drop-conflicts
Reviewed By: passy
Differential Revision: D13368791
fbshipit-source-id: 5bc1f9d3a179f4b9a554cc8cc629db0fda468a36