Commit Graph

55 Commits

Author SHA1 Message Date
Andrey Goncharov
0345d7d533 Handle onMessage errors when client is not connected
Reviewed By: lblasa

Differential Revision: D47397641

fbshipit-source-id: ac9c057050a3bac0c5149f5ce2998657fededb61
2023-07-14 03:31:20 -07:00
Andrey Goncharov
ca009d1233 Ignoring errors from "send"
Summary: "send" returns "void" which means we do not care about the execution result, including errors

Reviewed By: lblasa

Differential Revision: D47398015

fbshipit-source-id: ef185575f6e91d69356ab88c7f3d213033759da8
2023-07-13 03:23:56 -07:00
Andrey Goncharov
84e481e7e9 Expose dark mode flag to plugin authors
Summary:
Should be available now with
```
getFlipperLib().settings().isDarkMode
```

Differential Revision: D46685851

fbshipit-source-id: 0777437b7ca06051cc3fd4dc1b794242f453f2b5
2023-06-13 08:18:14 -07:00
Lorenzo Blasa
2815ba0fb8 Copy/Paste implementation
Summary: ^

Reviewed By: aigoncharov

Differential Revision: D46515194

fbshipit-source-id: 0ee6931569d5248d5643b391683e230e0c095e41
2023-06-07 06:04:46 -07:00
Anton Kastritskiy
c01b6b9f16 expose isHeadlessBuild to flipper plugins
Reviewed By: passy

Differential Revision: D46364476

fbshipit-source-id: bad584e3892cc0fb0fdaba0e8b3c79952596d34d
2023-06-02 06:49:49 -07:00
Michel Weststrate
d19fcb19a8 Don't die on timeout on fetching plugins
Summary: The error below was uncaught, showing up in our error monitoring, however, since it is a transient problem (probably an app not responding, too slow in startup, paused in a debuggger, emu being slow, whatever, this isn't actionable from our side, so lowered to warning

Reviewed By: lblasa

Differential Revision: D44717738

fbshipit-source-id: aefd5e58b4953f563ed155f7a252c130aaafe7ab
2023-04-06 03:20:42 -07:00
Andrey Goncharov
7f111a11de Expose isConnected and currentUser
Summary: Requested by antonk52 and MSYS team

Reviewed By: passy

Differential Revision: D44662243

fbshipit-source-id: 2bace476c4e79b6a05bfb89ddc3e6acb437c6c3b
2023-04-04 05:26:31 -07:00
Luke De Feo
77905f30c8 Add context to AbstractClient rawCall errors
Summary: Attempting to fix T146503217. There is no context to the error so this should make it easier in the future. In the MID it says that the layout plugin was selected i made sure to handle any promise rejections in that plugin

Reviewed By: passy

Differential Revision: D44302939

fbshipit-source-id: 987e2c4efd2dc47d2e032d1b21f90458ec5a2df5
2023-03-24 04:28:58 -07:00
Andrey Goncharov
b76c8a390c Add excessive logging for "deinit" method for Msys plugin
Summary: Debugging T141716711

Reviewed By: antonk52

Differential Revision: D44295078

fbshipit-source-id: 5269c7308e71d8b2ba7881747fcd5cbe37d81729
2023-03-22 07:34:39 -07:00
dependabot[bot]
df5ddf01a6 Bump js-base64 from 3.7.4 to 3.7.5 in /desktop (#4519)
Summary:
Bumps [js-base64](https://github.com/dankogai/js-base64) from 3.7.4 to 3.7.5.
<details>
<summary>Commits</summary>
<ul>
<li><a href="7e790b799e"><code>7e790b7</code></a> version 3.7.5</li>
<li><a href="f729053682"><code>f729053</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/dankogai/js-base64/issues/167">https://github.com/facebook/flipper/issues/167</a> from ctomacheski/main</li>
<li><a href="a9a994f367"><code>a9a994f</code></a> improve performance by stop using the mapFn param on Uint8Array.from constructor</li>
<li>See full diff in <a href="https://github.com/dankogai/js-base64/compare/3.7.4...3.7.5">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=js-base64&package-manager=npm_and_yarn&previous-version=3.7.4&new-version=3.7.5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

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 close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor 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)

</details>

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

Reviewed By: mweststrate

Differential Revision: D43305193

Pulled By: ivanmisuno

fbshipit-source-id: e10eb134c079951e325c1f4d627eb1e60510c12d
2023-02-16 06:33:32 -08:00
Pascal Hartig
bc0bdcb32f Remove client id from error
Summary: Ideally, this wouldn't fire at all as it's a timeout but removing the ID will at least allow de-duplication.

Reviewed By: ivanmisuno

Differential Revision: D42800581

fbshipit-source-id: 605f2e81c326a3203c72b253362cb0b27139a134
2023-01-30 06:33:15 -08:00
Pascal Hartig
18b6ce6f24 Dep bump
Summary: Combining a bunch of individual tasks for dep upgrades into one diff.

Reviewed By: ivanmisuno

Differential Revision: D42706074

fbshipit-source-id: 054b2545ad1295699f47f4c6eb5065b7b9a1d6a0
2023-01-25 04:35:09 -08:00
Luke De Feo
0a693f710e Plugin RPC errors should not cause crash report
Summary:
This code path is when a send results in an error being returned from the client.  We reject the promise but also raise an error on the message bus.

There is a handler for this 'error' event that is raised that is over zelous and reports a crash to the crash reporter. This should not happen

Reviewed By: lblasa

Differential Revision: D42385292

fbshipit-source-id: f668a396b0d266ee9d1c7c1ca740e7bb5ae9608a
2023-01-06 06:15:44 -08:00
Lorenzo Blasa
51ca3a6cd7 Expose env via flipperLib
Summary:
This change exposes the env variables via the FlipperLib interface used by plugins.

The variables are already white-listed and safe to be used by plugins according to documentation.

Reviewed By: antonk52

Differential Revision: D40852147

fbshipit-source-id: bbb3b052d33bf5cf75c81166af2400fe6a359256
2022-11-10 12:40:27 -08:00
Andrey Goncharov
82e5cfd368 Expose isLoggedIn to plugin creators
Summary: Re-expose one of the legacy exports we had before. Requested by MSYS

Reviewed By: passy

Differential Revision: D40979328

fbshipit-source-id: 7e8f089a182a62f392f3a720bee9b81698930f9d
2022-11-03 06:29:24 -07:00
Andrey Goncharov
226ccf91f6 Create flipper-server-client package
Summary:
FlipperServerClient is a useful abstraction for any JS-based client of headless Flipper. No need to bundle it with flipper-frontend-core, as the rest is not useful for external clients.
Currently, I am planning to add it to jest-e2e to send commands to Flipper

Reviewed By: lblasa

Differential Revision: D40765668

fbshipit-source-id: af48710bb15444ac1ecd649fe9a2ab252f3088f3
2022-10-31 04:26:43 -07:00
Lorenzo Blasa
587f428cf8 Allow plugins to use css
Summary:
Flipper plugins fail when importing css from third-party dependencies. This diff tries to fix that.

Effectively, the plugin can import the css and export it when is bundled.

When we load the plugin, we check if there's a css file for it. If there's one, we return it and try to use it.

Reviewed By: aigoncharov

Differential Revision: D40758178

fbshipit-source-id: e53afffcc481504905d5eeb1aea1f9114ee2a86b
2022-10-27 22:50:30 -07:00
Luke De Feo
c6dbfc87a4 Wait for client to initliaze on startup deep link
Summary: We were incorrectly assuming a client did not support a plugin because it was not fully initialized. This issue was only apparant on start deep links

Reviewed By: mweststrate

Differential Revision: D40477503

fbshipit-source-id: 5fd9db765f559b8eb80cc3680ee694dfd2cf9a37
2022-10-24 08:07:01 -07:00
Andrey Goncharov
9597e672a1 Provide @emotion/css to plugins
Summary: Changelog: Provide `emotion/css` to plugins

Reviewed By: antonk52

Differential Revision: D40057817

fbshipit-source-id: 1e931eb8527d62dd4312556a6d493fdf3e17b45a
2022-10-04 05:07:36 -07:00
Andrey Goncharov
228de6c542 Add custom timeout to Device.installApp
Reviewed By: lblasa

Differential Revision: D39728545

fbshipit-source-id: be77a2e7ddac4071c9cafc88e67b793ee8c7631c
2022-09-23 10:20:53 -07:00
Andrey Goncharov
3314c77ce9 Add exportFileBinary to FlipperLib
Reviewed By: antonk52

Differential Revision: D39692937

fbshipit-source-id: 7b3c78d004a9734cd8ae660d5782be1f02c00009
2022-09-21 09:26:19 -07:00
Andrey Goncharov
8716761cb3 Fix require monkey-patching in electron build
Summary:
In D39311893 (094c5bdfdd) we started monkey-patching `require` to resolve global dependencies in the plugins. Apparently, patching `globalThis.require` did not work in the electron env. On my local machine it kept working because I had the experimental `flipper-server` feature enabled which embeds flipper-server into the electron build. In flipper-server we properly patch `require` via `Module.prototype.require` which affected the global require in electron.
With this fix we now properly patch require in electron via Module.prototype.require all the time

Changelog: Fix plugin loading with experimental flipper-server disabled

Reviewed By: nikoant

Differential Revision: D39633821

fbshipit-source-id: 9554f643c625620d116075ae87f573d8447850f6
2022-09-20 01:36:56 -07:00
Andrey Goncharov
1167728b98 Freeze plugin messages
Reviewed By: mweststrate

Differential Revision: D39618330

fbshipit-source-id: 7b982d2307a021e7dea71fd84ca6140998b31366
2022-09-19 05:40:33 -07:00
Andrey Goncharov
202bce31b4 Stop freezing plugin messages
Reviewed By: lblasa

Differential Revision: D39600455

fbshipit-source-id: f829d135d4feb2a8000d094e3dad17b8b9d46cd3
2022-09-18 15:00:34 -07:00
Andrey Goncharov
ed93dfe978 Refine prod and dev deps
Summary: Move flipper local deps to prod deps, so yarn installs them later when we build a bundle

Reviewed By: lblasa

Differential Revision: D39475545

fbshipit-source-id: 5b61d15b45ee315c3b35d8e6836c114b90503b1a
2022-09-15 10:02:19 -07:00
Andrey Goncharov
650ff4bcfb Remove plugin bundling
Summary: Remove the notion of bundled plugins

Reviewed By: lblasa

Differential Revision: D39308888

fbshipit-source-id: aa88ddbf2801ad1da95f89e4c761259b697b0d66
2022-09-15 10:02:19 -07:00
Andrey Goncharov
642a3ebf81 Remove default plugin entrypoints for hot-reloading
Summary: As we stopped bundling plugins in D39276249, we no longer need the entry points for the bundled plugins (these entry points are always going to be empty)

Reviewed By: lblasa

Differential Revision: D39307565

fbshipit-source-id: 43751fe31c8bd962677c226b27cfe52093d3f2d4
2022-09-15 10:02:19 -07:00
Andrey Goncharov
a888e6affa Simplify bundled plugin setup
Summary: Stop bundling plugins into Flipper Server bundles. In later diffs, we will start building all plugins even in dev mode which removes the need to bundle them.

Reviewed By: lblasa

Differential Revision: D39276249

fbshipit-source-id: 091405cfcf58aa7e1bd2b382da40f8d9841ae6b1
2022-09-15 10:02:19 -07:00
Andrey Goncharov
a67a4e5d0f Remove babel transforms for flipper-server
Summary: Flipper server itself requires no babel transforms. We applied extra transforms only for the bundled plugins. However, we pack and ship all plugins in the /static folder. They are always available on the FS. Therefore we could stop bundling any plugins into flipper-server's source code.

Reviewed By: lblasa

Differential Revision: D38910251

fbshipit-source-id: b3e9fe5ae2ab69ce5579b01b6793ebf7e88baf66
2022-09-15 10:02:19 -07:00
Andrey Goncharov
97b8b8a1c4 Split flipper-plugin package
Summary:
flipper-server-companion depends on flipper-plugin. flipper-plugin includes dependencies that run only in a browser. Splitting flipper-plugin into core and browser packages helps to avoid including browser-only dependencies into flipper-server bundle.
As a result, bundle size could be cut in half. Subsequently, RSS usage drops as there is twice as less code to process for V8.

Note: it currently breaks external flipper-data-source package. It will be restored in subsequent diffs

Reviewed By: lblasa

Differential Revision: D38658285

fbshipit-source-id: 751b11fa9f3a2d938ce166687b8310ba8b059dee
2022-09-15 10:02:19 -07:00
Lorenzo Blasa
04220b6c7e Typo and increase timeout to 45s
Summary:
Observed that a few requests tend to timeout when using Flipper with flipper-server.

Increasing timeout to 45s as to be a bit more flexible.

'exec' operations don't have a timeout when not using flipper-server.

Reviewed By: antonk52

Differential Revision: D37955108

fbshipit-source-id: 5d8ef7f066d6b316e4b485b281a015794b5bd2de
2022-07-19 04:06:03 -07:00
Lorenzo Blasa
860cf332e1 Do not disconnect when there's a 'send' error
Summary:
Historically, RSocket used to raise an error when there was an error during send, most likely because the connection was dead.

With WS, this is no longer the case.

WS connection issues are raised through the according handlers.

Reviewed By: passy

Differential Revision: D37825821

fbshipit-source-id: 7fcda8cf26fb42eb0d8ca03b62482f11c931777f
2022-07-14 10:40:43 -07:00
Luke De Feo
6c5faf2932 Add command to install app to flipper server
Summary: There is a new flipper server command to install apps. For android it uses adb (via adb kit) For ios depending on idb availablity it will use idb or xcrun. Consumed in the next diff

Reviewed By: lblasa, aigoncharov

Differential Revision: D36936637

fbshipit-source-id: e09d34d840a9f3bf9136bcaf94fb8ca15dd27cbb
2022-07-07 07:50:14 -07:00
Lorenzo Blasa
646b9d5a5d UDS/TCP options
Summary:
Provide an option to enable/disable TCP connections on flipper-server.

The only change at this stage is that Flipper Desktop will use UDS to connect to flipper-server.

Reviewed By: passy

Differential Revision: D37519656

fbshipit-source-id: 3d02084666fde532ec76134edf8cf6a231060a48
2022-06-29 15:01:05 -07:00
Andrey Goncharov
b13bd2c092 Log supported plugins
Summary: We frequently get support requests asking why a certain plugin is not enabled for an app. This diff makes it easy to reason which plugins are enabled on the device

Differential Revision: D37381316

fbshipit-source-id: 148d6d8b6f51cb161eb625cabe0fa629b8a00cf5
2022-06-27 03:49:04 -07:00
Andrey Goncharov
3e72831699 Move most of plugin tests to flipper-frontend-core
Summary: See D37139129

Reviewed By: passy

Differential Revision: D37241829

fbshipit-source-id: d6bef24416e2b999d529fb6e275c64384c775c21
2022-06-20 12:18:40 -07:00
Andrey Goncharov
f4fc07ffd2 Move BaseDevice tests from flipper-ui-core to flipper-frontend-core
Summary: See D37139129

Reviewed By: passy

Differential Revision: D37241244

fbshipit-source-id: 3dca03e7a22c218b95702b77bb93efc983528142
2022-06-20 12:18:40 -07:00
Andrey Goncharov
115a4b7997 Use AbstractPluginInitializer from flipper-frontend-core in flipper-ui-core
Summary: See D37139129

Reviewed By: passy

Differential Revision: D37238571

fbshipit-source-id: 39d6bb87d6beacc793ef5acd71097fcc4e82969d
2022-06-20 12:18:40 -07:00
Andrey Goncharov
8768405e80 Use constants from flipper-frontend-core in flipper-ui-core
Summary: See D37139129

Reviewed By: lblasa

Differential Revision: D37238570

fbshipit-source-id: 5dbf6f179fc8957e074bad1e8f74e400644be049
2022-06-20 12:18:40 -07:00
Andrey Goncharov
fab8849c73 Use TestDevice from flipper-frontend-core in flipper-ui-core
Summary: See D37139129

Reviewed By: lblasa

Differential Revision: D37235567

fbshipit-source-id: a0596ba71fcb8722088e51361774389a7daaebb8
2022-06-20 12:18:40 -07:00
Andrey Goncharov
fd380a4c1e Use BaseDevice from flipper-frontend-core in flipper-ui-core
Summary: Use BasDevice definition from flipper-frontend-core in flipper-ui-core and remove the redundant definition from flipper-ui-core

Reviewed By: lblasa

Differential Revision: D37234785

fbshipit-source-id: 6e768090a197c1d2c49cb1cd573acea12fb65d24
2022-06-20 12:18:40 -07:00
Andrey Goncharov
ef5fa275a3 Use AbstractClient from flipper-frontend-core in fliper-ui-core
Summary: This stack attempts to start using flipper-frontend-core from flipper-ui-core. Currently, flipper-frontend-core contains lots of copy-pasted code from flipper-ui-core.

Reviewed By: lblasa

Differential Revision: D37139198

fbshipit-source-id: 042db7492c550e10ea72c32fd15001c141bf53f9
2022-06-20 12:18:40 -07:00
Andrey Goncharov
c2e3c4eb50 Add TestDeivce to flipper-frontend-core
Summary: This stack attempts to start using flipper-frontend-core from flipper-ui-core. Currently, flipper-frontend-core contains lots of copy-pasted code from flipper-ui-core.

Reviewed By: passy

Differential Revision: D37139129

fbshipit-source-id: 53ba08920735d1b40e1351fddf41a97a6352b2b6
2022-06-20 12:18:40 -07:00
Andrey Goncharov
976399b950 Move Tail to flipper-server-core
Summary: Tail is a server-side logging utility. We cannot add it to flipper-frontend-core as it is going to be included into the browser bundle then and break the build.

Reviewed By: antonk52

Differential Revision: D36771864

fbshipit-source-id: 169cdb88543f1e47f39e8c0976c3a3f45c0439d5
2022-05-31 02:58:21 -07:00
Lorenzo Blasa
49eb026769 Tail
Summary:
Added a new type, Tail. It observes changes made to a file and notifies the subscriber.

It is useful and used to tail flipper-server logs, for example.

Reviewed By: passy

Differential Revision: D36473529

fbshipit-source-id: b0f905f4f8419d9e13386440d2d2cdabd528295b
2022-05-26 09:44:30 -07:00
Lorenzo Blasa
23b551c8bf Host and port as function args
Summary:
^

Before this change, the client assumed the host and port came from location.host which is fine on the browser.

In all other cases, that object/properties may be undefined.

As such, add host and port as function args and use that instead.

Reviewed By: passy

Differential Revision: D36440423

fbshipit-source-id: 5f931f1d610d583db6a2e549e1213585f0d03dee
2022-05-17 04:20:30 -07:00
Lorenzo Blasa
bfcdb82b43 Move flipper-server client to flipper-frontend-core
Summary: ^

Reviewed By: aigoncharov

Differential Revision: D36410944

fbshipit-source-id: 2adb5904cd0f5f15d08be22c611d6774e7533f94
2022-05-17 03:54:16 -07:00
Michel Weststrate
e51e95af2e supportsMethod should return false if not connected
Summary: https://www.internalfb.com/logview/details/flipper_javascript/7e72d9f75d047791d9de43b72915cbd4/?selected-logview-tab=latest shows an exception for just checking whether a feature is supported, while the client is not connected. there is no point in checking if a feature is supported if not connected, so just returning false instead of throwing

Reviewed By: timur-valiev

Differential Revision: D36371047

fbshipit-source-id: 6e83bed6fc53cc41ddef30eeeb41d030b2c4c175
2022-05-13 06:40:06 -07:00
Andrey Goncharov
ad76060614 Expose intern graphQL reuqests to plugins
Summary: Some intern plugins use it, an dit is currently missing in FlipperLib

Reviewed By: timur-valiev

Differential Revision: D36313032

fbshipit-source-id: 5ea8e250f1d0bc8831727abd883d953286a022d4
2022-05-11 06:48:05 -07:00
Andrey Goncharov
d795117910 Expose exports from the root of flipper-frontend-core
Summary: flipper-frontend-core shares logic between different desktop flipper clients: flipper browser ui, flipper electron, flipper headless

Reviewed By: passy

Differential Revision: D36129747

fbshipit-source-id: 598382ad3897701b307a16a42dc65d4c277b3e15
2022-05-10 05:13:24 -07:00