@player-devtools/client-flipper 0.14.2 → 0.14.3--canary.24.1158

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ import type { InstalledPluginDetails } from "flipper-common";
1
2
  import type { CommunicationLayerMethods, Transport } from "@player-devtools/types";
2
3
  export declare class FlipperServerTransport implements Transport {
3
4
  private options;
@@ -9,14 +10,84 @@ export declare class FlipperServerTransport implements Transport {
9
10
  * plugin — these are the clients we send outbound messages to.
10
11
  */
11
12
  private activeClientIds;
13
+ /**
14
+ * Client IDs currently connected to flipper-server, regardless of whether
15
+ * the devtools plugin has been activated for them. Used by `enablePlugin`'s
16
+ * "all connected clients" convenience.
17
+ */
18
+ private connectedClientIds;
12
19
  constructor(options?: {
13
20
  /** Flipper server host; defaults to "localhost" */
14
21
  host?: string;
15
22
  /** Flipper server WebSocket port; defaults to 52342 */
16
23
  port?: number;
24
+ /**
25
+ * Whether to open a browser/PWA UI once the server is up. Defaults to
26
+ * `false` — an agent driving this transport has no use for a browser
27
+ * tab, unlike a human running `flipper-server` directly.
28
+ */
29
+ open?: boolean;
30
+ /**
31
+ * URL to open in the browser when `open` is true. Defaults to
32
+ * `http://localhost:{port}`. `flipper-server` itself always binds to
33
+ * localhost regardless of this value — this only controls what URL
34
+ * gets opened, so a custom host (e.g. a branded domain) must already
35
+ * resolve to this machine (e.g. via `/etc/hosts`) for it to work.
36
+ */
37
+ url?: string;
38
+ /**
39
+ * Activate the devtools plugin automatically for every client that
40
+ * connects, instead of requiring an explicit `enablePlugin()` call per
41
+ * client. Off by default so a caller can choose when/whether to
42
+ * activate a given device; turn this on for a fully hands-off session
43
+ * where every connecting device should be watched immediately.
44
+ */
45
+ autoEnablePlugin?: boolean;
17
46
  });
18
47
  connect(): Promise<void>;
19
48
  sendMessage: CommunicationLayerMethods["sendMessage"];
49
+ /**
50
+ * Ensures `flipper-plugin-player-ui-devtools` is installed on the attached
51
+ * flipper-server, installing the published npm package if it's missing.
52
+ *
53
+ * This is Flipper's own documented plugin-install RPC (the same
54
+ * `exec(...)` commands the desktop UI's "Install Plugin" button calls) —
55
+ * not a filesystem workaround. It's opt-in: callers that manage plugin
56
+ * installation themselves (or run against a flipper-server that already
57
+ * has it) can skip calling this.
58
+ */
59
+ ensurePluginInstalled(): Promise<InstalledPluginDetails>;
60
+ /**
61
+ * Activates the devtools plugin for a connected client by sending the
62
+ * `init` handshake `js-flipper`'s device SDK requires before it will open
63
+ * a live plugin connection (`onConnect`/`FlipperConnection`) and start
64
+ * relaying `client-message`s for our api. Nothing in flipper-server itself
65
+ * sends this automatically for a non-background plugin like ours unless a
66
+ * full Flipper desktop app is attached and its tab is selected — this
67
+ * method lets a caller trigger the same handshake directly, without
68
+ * needing a desktop UI at all.
69
+ *
70
+ * Calls `ensurePluginInstalled()` first, every time — the plugin can be
71
+ * installed/removed on the attached flipper-server independently of this
72
+ * transport (e.g. a human using the desktop UI concurrently), so there's
73
+ * no snapshot of "already installed" we can trust across calls.
74
+ *
75
+ * Pass a specific `clientId`, or omit it to enable for every client
76
+ * currently connected to flipper-server that we don't already believe is
77
+ * active (see `activeClientIds`) — `init` is otherwise harmless to repeat,
78
+ * but there's no reason to re-send it to a client already talking to us.
79
+ */
80
+ enablePlugin(clientId?: string): Promise<void>;
81
+ /**
82
+ * Symmetric counterpart to `enablePlugin` — releases the plugin connection
83
+ * without disconnecting the client from flipper-server.
84
+ *
85
+ * Pass a specific `clientId`, or omit it to disable for every client we
86
+ * currently believe is active (see `activeClientIds`) — there's nothing to
87
+ * release for a client that was never activated.
88
+ */
89
+ disablePlugin(clientId?: string): Promise<void>;
90
+ private sendLifecycleMessage;
20
91
  addListener: CommunicationLayerMethods["addListener"];
21
92
  removeListener: CommunicationLayerMethods["removeListener"];
22
93
  close(): Promise<void>;