Files
flipper/js/js-flipper
dependabot[bot] e1f952549e Bump eslint-plugin-import from 2.25.4 to 2.26.0 in /js/js-flipper (#3624)
Summary:
Bumps [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import) from 2.25.4 to 2.26.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/import-js/eslint-plugin-import/blob/main/CHANGELOG.md">eslint-plugin-import's changelog</a>.</em></p>
<blockquote>
<h2>[2.26.0] - 2022-04-05</h2>
<h3>Added</h3>
<ul>
<li>[<code>no-named-default</code>, <code>no-default-export</code>, <code>prefer-default-export</code>, <code>no-named-export</code>, <code>export</code>, <code>named</code>, <code>namespace</code>, <code>no-unused-modules</code>]: support arbitrary module namespace names (<a href="https://github-redirect.dependabot.com/import-js/eslint-plugin-import/issues/2358">https://github.com/facebook/flipper/issues/2358</a>, thanks [<a href="https://github.com/sosukesuzuki"><code>@​sosukesuzuki</code></a>])</li>
<li>[<code>no-dynamic-require</code>]: support dynamic import with espree (<a href="https://github-redirect.dependabot.com/import-js/eslint-plugin-import/issues/2371">https://github.com/facebook/flipper/issues/2371</a>, thanks [<a href="https://github.com/sosukesuzuki"><code>@​sosukesuzuki</code></a>])</li>
<li>[<code>no-relative-packages</code>]: add fixer (<a href="https://github-redirect.dependabot.com/import-js/eslint-plugin-import/issues/2381">https://github.com/facebook/flipper/issues/2381</a>, thanks [<a href="https://github.com/forivall"><code>@​forivall</code></a>])</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>[<code>default</code>]: <code>typescript-eslint-parser</code>: avoid a crash on exporting as namespace (thanks [<a href="https://github.com/ljharb"><code>@​ljharb</code></a>])</li>
<li>[<code>export</code>]/TypeScript: false positive for typescript namespace merging (<a href="https://github-redirect.dependabot.com/import-js/eslint-plugin-import/issues/1964">https://github.com/facebook/flipper/issues/1964</a>, thanks [<a href="https://github.com/magarcia"><code>@​magarcia</code></a>])</li>
<li>[<code>no-duplicates</code>]: ignore duplicate modules in different TypeScript module declarations (<a href="https://github-redirect.dependabot.com/import-js/eslint-plugin-import/issues/2378">https://github.com/facebook/flipper/issues/2378</a>, thanks [<a href="https://github.com/remcohaszing"><code>@​remcohaszing</code></a>])</li>
<li>[<code>no-unused-modules</code>]: avoid a crash when processing re-exports (<a href="https://github-redirect.dependabot.com/import-js/eslint-plugin-import/issues/2388">https://github.com/facebook/flipper/issues/2388</a>, thanks [<a href="https://github.com/ljharb"><code>@​ljharb</code></a>])</li>
</ul>
<h3>Changed</h3>
<ul>
<li>[Tests] <code>no-nodejs-modules</code>: add tests for node protocol URL (<a href="https://github-redirect.dependabot.com/import-js/eslint-plugin-import/issues/2367">https://github.com/facebook/flipper/issues/2367</a>, thanks [<a href="https://github.com/sosukesuzuki"><code>@​sosukesuzuki</code></a>])</li>
<li>[Tests] <code>default</code>, <code>no-anonymous-default-export</code>, <code>no-mutable-exports</code>, <code>no-named-as-default-member</code>, <code>no-named-as-default</code>: add tests for arbitrary module namespace names (<a href="https://github-redirect.dependabot.com/import-js/eslint-plugin-import/issues/2358">https://github.com/facebook/flipper/issues/2358</a>, thanks [<a href="https://github.com/sosukesuzuki"><code>@​sosukesuzuki</code></a>])</li>
<li>[Docs] [<code>no-unresolved</code>]: Fix RegExp escaping in readme (<a href="https://github-redirect.dependabot.com/import-js/eslint-plugin-import/issues/2332">https://github.com/facebook/flipper/issues/2332</a>, thanks [<a href="https://github.com/stephtr"><code>@​stephtr</code></a>])</li>
<li>[Refactor] <code>namespace</code>: try to improve performance (<a href="https://github-redirect.dependabot.com/import-js/eslint-plugin-import/issues/2340">https://github.com/facebook/flipper/issues/2340</a>, thanks [<a href="https://github.com/ljharb"><code>@​ljharb</code></a>])</li>
<li>[Docs] make rule doc titles consistent (<a href="https://github-redirect.dependabot.com/import-js/eslint-plugin-import/issues/2393">https://github.com/facebook/flipper/issues/2393</a>, thanks [<a href="https://github.com/TheJaredWilcurt"><code>@​TheJaredWilcurt</code></a>])</li>
<li>[Docs] <code>order</code>: TS code examples should use TS code blocks (<a href="https://github-redirect.dependabot.com/import-js/eslint-plugin-import/issues/2411">https://github.com/facebook/flipper/issues/2411</a>, thanks [<a href="https://github.com/MM25Zamanian"><code>@​MM25Zamanian</code></a>])</li>
<li>[Docs] <code>no-unresolved</code>: fix link (<a href="https://github-redirect.dependabot.com/import-js/eslint-plugin-import/issues/2417">https://github.com/facebook/flipper/issues/2417</a>, thanks [<a href="https://github.com/kylemh"><code>@​kylemh</code></a>])</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="d1602854ea"><code>d160285</code></a> Bump to 2.26.0</li>
<li><a href="0e80ee37cc"><code>0e80ee3</code></a> [Deps] update <code>tsconfig-paths</code></li>
<li><a href="d8633c35ba"><code>d8633c3</code></a> [Docs] <code>no-unresolved</code>: fix link</li>
<li><a href="98bbb2cb30"><code>98bbb2c</code></a> [Docs] <code>order</code>: TS code examples should use TS code blocks</li>
<li><a href="21304bdf01"><code>21304bd</code></a> [Deps] update <code>tsconfig-paths</code></li>
<li><a href="8b7000ec75"><code>8b7000e</code></a> [Fix] <code>no-unused-modules</code>: avoid a crash when processing re-exports</li>
<li><a href="747d6dc5b9"><code>747d6dc</code></a> [Docs] make rule doc titles consistent</li>
<li><a href="b0e6f7f489"><code>b0e6f7f</code></a> [Refactor] <code>namespace</code>: try to improve performance</li>
<li><a href="00a4edee35"><code>00a4ede</code></a> [Deps] update <code>minimatch</code></li>
<li><a href="35bd3a576c"><code>35bd3a5</code></a> [Dev Deps] update <code>angular-eslint/template-parser</code>, <code>chai</code></li>
<li>Additional commits viewable in <a href="https://github.com/import-js/eslint-plugin-import/compare/v2.25.4...v2.26.0">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=eslint-plugin-import&package-manager=npm_and_yarn&previous-version=2.25.4&new-version=2.26.0)](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/3624

Reviewed By: antonk52

Differential Revision: D35893323

Pulled By: lblasa

fbshipit-source-id: 2680ee21efcfd7906f07ec4df83d68a3f5b848fe
2022-04-25 09:26:43 -07:00
..
2021-10-21 04:28:21 -07:00
2022-01-18 07:46:05 -08:00
2021-10-21 04:28:21 -07:00
2021-10-21 04:28:21 -07:00
2021-10-21 04:28:21 -07:00
2022-04-20 10:26:59 -07:00
2021-10-21 04:28:21 -07:00

js-flipper

This package exposes JavaScript bindings to talk from web / Node.js directly to flipper.

Installation

yarn add js-flipper

Usage

How to build Flipper plugins is explained in the flipper documentation: Creating a Flipper plugin. Building a Flipper plugin involves building a plugin for the Desktop app, and a plugin that runs on a Device (web or Node.js). This package is only needed for the plugin that runs on the device (web / Node.js), and wants to use the WebSocket connection to communicate to Flipper.

This package exposes a flipperClient. It has:

  • addPlugin method. It accepts a plugin parameter, that registers a client plugin and will fire the relevant callbacks if the corresponding desktop plugin is selected in the Flipper Desktop. The full plugin API is documented here.
  • start method. It starts the client. It has two arguments:
    • appName - (required) the name dsplayed in Flipper
    • options which conforms to the infterface
      interface FlipperClientOptions {
        // Make the client connect to a different URL
        urlBase?: string;
        // Override WebSocket implementation (Node.js folks, it is for you!)
        websocketFactory?: (url: string) => FlipperWebSocket;
        // Override how errors are handled (it is simple `console.error` by default)
        onError?: (e: unknown) => void;
        // Timeout after which client tries to reconnect to Flipper
        reconnectTimeout?: number;
      }
      

Example (web)

An example plugin can be found in FlipperTicTacToe.js.

The corresponding Desktop plugin ships by default in Flipper, so importing the above file and dropping the <FlipperTicTacToe /> component somewhere in your application should work out of the box.

The sources of the corresponding Desktop plugin can be found here.

Node.js

Node.js does not have a built-in WebSocket implementation. You need to install any implmentation of WebSockets for Node.js that is compatible with the interface of the web version.

import flipperClient from 'js-flipper';
// Say, you decided to go with 'ws'
// https://github.com/websockets/ws
import WebSocket from 'ws';

// Start the client and pass some options
// You might ask yourself why there is the second argument `{ origin: 'localhost:' }`
// Flipper Desktop verifies the `Origin` header for every WS connection. You need to set it to one of the whitelisted values (see `VALID_WEB_SOCKET_REQUEST_ORIGIN_PREFIXES`).
flipperClient.start('My cool nodejs app', { websocketFactory: url => new WebSocket(url, {origin: 'localhost:'}) });

An example plugin should be somewhat similar to what we have for React. It is currently WIP (do not confuse with RIP!).