Commit Graph

28 Commits

Author SHA1 Message Date
Michel Weststrate
4e76256d6d Avoid confusion variable reassignments in transformer
Summary:
While trying to find a simple fix for the broken source maps when unit testing (see previous diff), I noticed that control flow in the transformer was unnecessarily complicated.

This doesn't fix the sourcemap issue btw

Reviewed By: passy

Differential Revision: D19158367

fbshipit-source-id: 7dfe4b28eabd4534a32dcb655e534d0f418f0db4
2019-12-19 02:38:07 -08:00
Michel Weststrate
16b2addbc2 Enable null coalescing operator
Summary: Enable using the `??` operator in plugin code

Reviewed By: passy

Differential Revision: D18906291

fbshipit-source-id: b0a9b29ebb2896ede10540ba2e4cfd937fb99c7d
2019-12-11 03:46:48 -08:00
Michel Weststrate
ad90f98a0e enable optional chaining in plugins
Summary: Enable transpilation of optional chaining in plugins

Reviewed By: jknoxville

Differential Revision: D18451930

fbshipit-source-id: a55aa8d7a65ee8e6568e61ae377c199acfd158f4
2019-11-13 08:36:55 -08:00
Michel Weststrate
3963535610 Fix buffer warning when starting CPU / kaois plugin
Summary:
When the CPU or kaois plugins are started, they show a buffer deprecated warning, caused by the fact that they ship their own adbkit version, which is unpatched.

This diff makes sure that the adbkit as shipped with Flipper is used instead.

Reviewed By: jknoxville

Differential Revision: D18327441

fbshipit-source-id: 9cab23b9701adc070210cc4133fc8760031bd1d7
2019-11-05 11:10:16 -08:00
John Knox
fdee0ef7b7 Use jest to mock electron in tests
Summary:
Replacing our custom electron-stubs transform with a mocked module.

This will now be the default impl for tests, and we can override it by mocking as needed.

Reviewed By: passy

Differential Revision: D17979659

fbshipit-source-id: a26994158d439fa7dc1ca38225294106fc4e1559
2019-10-18 10:09:02 -07:00
Andres Suarez
0675dd924d Tidy up Flipper license headers [1/2]
Reviewed By: passy

Differential Revision: D17863711

fbshipit-source-id: 259dc77826fb803ff1b88c88529d7f679d3b74d8
2019-10-11 13:46:45 -07:00
Daniel Büchele
2c66e3d4d0 install dependencies
Summary:
In the previous implementation plugins were downloaded from npm, but dependencies weren't. This diff uses the `live-plugin-manager` which does mostly what we want. It install a package from NPM with all its dependencies.
live-plugin-manager puts the plugin and its dependencies in the same folder. We expect the plugins to be in `node_modules`. For this reason, we are installing the plugin into `$pluginName/node_modules` and move the plugin after the installation out of the `node_modules` folder.

* Fixed plugin loading path for thirdparty plugins.
* Disabled hot reloading for plugins in the flipper folder to prevent reloads when moving around files and installing dependencies here.
* an empty `.watchmanconfig` is created, because metro requires it
* tsx files are added to the list of supported extensions for metro

Reviewed By: passy

Differential Revision: D17570413

fbshipit-source-id: ecbedc60841b36188fec9c83da41ef1f27e5e155
2019-09-26 07:57:54 -07:00
Daniel Büchele
5f53087c7e client server
Summary: Migrating Server, Client and UninitializedClient to TypeScript

Reviewed By: passy

Differential Revision: D16687855

fbshipit-source-id: 402e4dbcd5d283d3e280d4d8b312662829457886
2019-08-08 11:00:38 -07:00
Benjamin Elo
77811c3c1b Fix for Jest tests failing with typescript
Summary: Tests were failing as they were not being transformed correctly. Class properties (proposed syntax) was only partially added for Typescript files. This fixes the issue.

Reviewed By: passy

Differential Revision: D16686613

fbshipit-source-id: 2108cf77eb688bb6825d016960480ea55fcc2620
2019-08-08 02:36:36 -07:00
Daniel Büchele
80b2929992 babel pipeline
Summary: adding babel transpile pipeline for TypeScript files

Reviewed By: jknoxville

Differential Revision: D16651124

fbshipit-source-id: e9215ba2da467f58005271916b65d6da4f6e36b7
2019-08-06 02:50:06 -07:00
Pascal Hartig
147f120a42 Fix fb-stubs typo
Summary: Per title.

Reviewed By: bnelo12

Differential Revision: D16332419

fbshipit-source-id: cbe3354561ab2251064f76c01ec1660aef59a7bb
2019-07-17 06:52:01 -07:00
Pascal Hartig
c588b650ae Prefer const wherever possible
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
2019-07-10 03:28:25 -07:00
Pascal Hartig
662db20948 Disallow var
Summary: We're ES6 and `var`s scoping rules are weird. Let's block this.

Reviewed By: jknoxville

Differential Revision: D16131290

fbshipit-source-id: ba67d16bb8a185a4bb59a657a97b00230dbacafe
2019-07-10 03:28:25 -07:00
Daniel Büchele
8d134ba89e disable babel cache
Summary: as per title. see explanation in code comment

Reviewed By: jknoxville

Differential Revision: D14125820

fbshipit-source-id: 9b8e31214a65a184397852544cebd7b69ea0aadb
2019-02-18 12:49:34 -08:00
Pascal Hartig
09a93cd9e6 Upgrading flow and fixing lint errors
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
2019-02-01 06:51:01 -08:00
Daniel Büchele
500007ccca use perf_hooks
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
2019-01-29 09:32:05 -08:00
Daniel Büchele
771be72b3f remove window dependency
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
2019-01-25 12:19:07 -08:00
Daniel Büchele
7ac6a09af1 build headless version
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
2019-01-25 12:19:07 -08:00
John Knox
54d09aa951 Fix open source yarn start
Summary: The fb-stubs transform is getting applied when it shouldn't. Fix it by only applying it if src/fb exists.

Reviewed By: danielbuechele

Differential Revision: D13236217

fbshipit-source-id: 940def377839d16f34c49504948cb062916a3d6a
2018-11-29 08:50:24 -08:00
John Knox
76d40e7ddf Use node's perf_hooks
Summary:
I tried switching Flipper to use the node.js module: https://nodejs.org/api/perf_hooks.html instead of electrons window.performance. But the module couldn't be found.

So instead, I'm just replacing it in the pure node tests.

This means tests without node can work without issues.

Reviewed By: danielbuechele

Differential Revision: D10302114

fbshipit-source-id: b3b8aa5fb350a8246fcdfc2a80cc72daec2448d7
2018-10-22 09:00:38 -07:00
John Knox
87830ff106 Add transform for stubbing electron
Summary:
The idea behind this is to enable tests running in pure node, without electron, because electron requires display drivers and complicated things.

I've been lazy and only added the bare minimum electron api's for the connection test to pass.
It would be awesome to auto generate it properly.

Reviewed By: danielbuechele

Differential Revision: D10238132

fbshipit-source-id: d4a2da2baf5f8964184b532a581c3a75ee33ef06
2018-10-22 09:00:38 -07:00
John Knox
4889f5dc6a Allow plugins to require from /static/
Summary:
Disallowing plugins from requiring anything but flipper or their own package broke lots of plugins at yarn start.
The ones that broke, require from the static directory.
Allowing them for now to unblock people.

Reviewed By: passy

Differential Revision: D10358733

fbshipit-source-id: 37077c806e022a6eb7ecf9bc95a455bf6f9a34d8
2018-10-12 05:48:24 -07:00
Daniel Büchele
992ad68517 error plugin import from outside
Summary:
Plugins can not require files outside their folder, to make sure they don't pull in any dependencies from Flipper which are not exported by the main app.

However, those imports simply resolve to `undefined`. This diff adds a check in the babel-transform for plugins and throws an error if something from outside the plugin is required.

Reviewed By: passy

Differential Revision: D10297980

fbshipit-source-id: 1606f3211103281f9f4aa7bb2f3ca4d085d0ea1b
2018-10-11 07:11:18 -07:00
Daniel Büchele
a455520ecb adding jest test setup
Summary:
Adds a test runner for jest test and adds three simple test cases:
- render the app
- start a server
- client connecting to the app

Test can be run using `yarn test`.

To make the test runner work, some changes needed to be made:
- remove the export of `init()` from `'flipper'`, because it was a cyclic dependency
- updating Button.js to the new ref-API

Reviewed By: jknoxville

Differential Revision: D10027078

fbshipit-source-id: 49107b0dd4dec666b92ecd841422fe7e6b3a7756
2018-09-28 06:42:08 -07:00
Daniel Büchele
7825d9247c optional chaining
Summary: Adds support for optional chaining to the codebase, enables flow and eslint support for it.

Reviewed By: passy

Differential Revision: D9940732

fbshipit-source-id: 730aa76653bd22a8fa17a73e72b3a7329de0226c
2018-09-20 04:27:48 -07:00
Daniel Büchele
5a492951f5 babel upgrade
Summary: upgrading to babel 7 and upgrading all presets and plugins as well

Reviewed By: passy

Differential Revision: D9940733

fbshipit-source-id: 24f45c78a9452899e6fb140a56028dd9fa0b5ea3
2018-09-20 04:27:48 -07:00
Daniel Büchele
66e77075be Rename package to 'flipper'
Summary:
- rename package `'sonar'` > `'flipper'`
- rename package `'sonar-static'` > `'flipper-static'`
- rename package export from `window.Sonar` to `window.Flipper`

Reviewed By: passy

Differential Revision: D9851181

fbshipit-source-id: 34d4447c3b287496b3d20ddb54471ce777ec74e1
2018-09-18 07:01:16 -07:00
Daniel Büchele
fbbf8cf16b Initial commit 🎉
fbshipit-source-id: b6fc29740c6875d2e78953b8a7123890a67930f2
Co-authored-by: Sebastian McKenzie <sebmck@fb.com>
Co-authored-by: John Knox <jknox@fb.com>
Co-authored-by: Emil Sjölander <emilsj@fb.com>
Co-authored-by: Pritesh Nandgaonkar <prit91@fb.com>
2018-06-01 11:03:58 +01:00