Files
flipper/js/js-flipper
dependabot[bot] aafc7da5de Bump ts-jest from 27.0.7 to 27.1.2 in /js/js-flipper (#3274)
Summary:
Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 27.0.7 to 27.1.2.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/kulshekhar/ts-jest/blob/main/CHANGELOG.md">ts-jest's changelog</a>.</em></p>
<blockquote>
<h2><a href="https://github.com/kulshekhar/ts-jest/compare/v27.1.1...v27.1.2">27.1.2</a> (2021-12-15)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>stimulate <code>esbuild</code> type to avoid importing <code>esbuild</code> directly (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3147">https://github.com/facebook/flipper/issues/3147</a>) (<a href="9ace0a9991">9ace0a9</a>)</li>
</ul>
<h2><a href="https://github.com/kulshekhar/ts-jest/compare/v27.1.0...v27.1.1">27.1.1</a> (2021-12-07)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>bring back <code>afterProcess</code> hook (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3132">https://github.com/facebook/flipper/issues/3132</a>) (<a href="2b6b86e01d">2b6b86e</a>)</li>
<li>make <code>esbuild</code> as optional peer dependency (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/pull/3129">https://github.com/facebook/flipper/issues/3129</a>) (<a href="20258de54c">20258de</a>)</li>
</ul>
<h1><a href="https://github.com/kulshekhar/ts-jest/compare/v27.0.7...v27.1.0">27.1.0</a> (2021-11-30)</h1>
<h3>Features</h3>
<ul>
<li>allow subclasses to extend <code>processAsync</code> and <code>getCacheKeyAsync</code> (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3047">https://github.com/facebook/flipper/issues/3047</a>) (<a href="571a880007">571a880</a>)</li>
<li><strong>config:</strong> support custom AST transformers written in TypeScript (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3063">https://github.com/facebook/flipper/issues/3063</a>) (<a href="340a30573e">340a305</a>), closes <a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/2831">#2831</a></li>
<li>export <code>ts-jest</code> public apis from <code>index.js</code> (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3080">https://github.com/facebook/flipper/issues/3080</a>) (<a href="53175dd042">53175dd</a>), closes <a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3045">https://github.com/facebook/flipper/issues/3045</a></li>
</ul>
<h3>Code Refactoring</h3>
<ul>
<li><strong>utils:</strong> deprecate <code>mocked</code> util function (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3102">https://github.com/facebook/flipper/issues/3102</a>) (<a href="55e69f12f6">55e69f1</a>)</li>
<li>define clear type for <code>compiler</code> option (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3087">https://github.com/facebook/flipper/issues/3087</a>) (<a href="cc42daf795">cc42daf</a>)</li>
<li><strong>transformers</strong>: deprecate <code>path-mapping</code> AST transformer (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3088">https://github.com/facebook/flipper/issues/3088</a>) (<a href="d8f6b9624e">d8f6b96</a>)</li>
<li><strong>transformers</strong>: use ts <code>factory</code> API for <code>hoisting</code> AST transformer (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3058">https://github.com/facebook/flipper/issues/3058</a>) (<a href="a72f51d9b7">a72f51d</a>)</li>
</ul>
<h2>DEPRECATIONS</h2>
<ul>
<li><strong>transformers</strong>: <code>path-mapping</code> AST transformer is deprecated and will be removed in <strong>v28.0.0</strong>. One should use an alternative one like <a href="https://github.com/LeDDGroup/typescript-transform-paths">https://github.com/LeDDGroup/typescript-transform-paths</a> instead.</li>
<li><strong>utils</strong>: <code>mocked</code> function is deprecated and will be removed in <strong>v28.0.0</strong>. The function has been integrated into <code>jest-mock</code> package as a part of Jest <strong>27.4.0</strong>, see <a href="https://github-redirect.dependabot.com/facebook/jest/pull/12089">facebook/jest#12089</a>. One should use the one from Jest instead</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="b39673f0a1"><code>b39673f</code></a> chore(release): 27.1.2 (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3148">https://github.com/facebook/flipper/issues/3148</a>)</li>
<li><a href="b818e00831"><code>b818e00</code></a> build(deps-dev): bump <code>@​typescript-eslint/eslint-plugin</code> (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3153">https://github.com/facebook/flipper/issues/3153</a>)</li>
<li><a href="bb51a789b2"><code>bb51a78</code></a> build(deps-dev): bump <code>@​types/node</code> from 16.11.12 to 16.11.13 (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3156">https://github.com/facebook/flipper/issues/3156</a>)</li>
<li><a href="1934d481c0"><code>1934d48</code></a> build(deps-dev): bump <code>@​typescript-eslint/parser</code> from 5.6.0 to 5.7.0 (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3154">https://github.com/facebook/flipper/issues/3154</a>)</li>
<li><a href="9ace0a9991"><code>9ace0a9</code></a> fix: stimulate <code>esbuild</code> type to avoid importing <code>esbuild</code> directly (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3147">https://github.com/facebook/flipper/issues/3147</a>)</li>
<li><a href="0e8f829828"><code>0e8f829</code></a> build(deps-dev): bump eslint-plugin-jsdoc from 37.1.0 to 37.2.0 (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3143">https://github.com/facebook/flipper/issues/3143</a>)</li>
<li><a href="3b1424b6a1"><code>3b1424b</code></a> build(deps-dev): bump typescript from 4.5.2 to 4.5.3 (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3144">https://github.com/facebook/flipper/issues/3144</a>)</li>
<li><a href="201ef78e38"><code>201ef78</code></a> chore(release): 27.1.1 (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3136">https://github.com/facebook/flipper/issues/3136</a>)</li>
<li><a href="bae293a2f4"><code>bae293a</code></a> build(deps-dev): bump <code>@​types/node</code> from 16.11.11 to 16.11.12 (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3140">https://github.com/facebook/flipper/issues/3140</a>)</li>
<li><a href="fe0c63bb1b"><code>fe0c63b</code></a> build(deps-dev): bump <code>@​types/babel</code>__core from 7.1.16 to 7.1.17 (<a href="https://github-redirect.dependabot.com/kulshekhar/ts-jest/issues/3139">https://github.com/facebook/flipper/issues/3139</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/kulshekhar/ts-jest/compare/v27.0.7...v27.1.2">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=ts-jest&package-manager=npm_and_yarn&previous-version=27.0.7&new-version=27.1.2)](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/3274

Reviewed By: antonk52

Differential Revision: D33565483

Pulled By: passy

fbshipit-source-id: a7790a3d1316e3870c0244f53d34ce6b69b6a68e
2022-01-14 03:44:16 -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
2021-10-21 04:28:21 -07:00
2022-01-13 08:16:15 -08: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!).