UNPKG

2.2 kBTypeScriptView Raw
1import type { LifeCycleMethods, PluginCreator } from "./reactotron-core-client";
2import NodeWebSocket from "ws";
3type BrowserWebSocket = WebSocket;
4/**
5 * Configuration options for the Reactotron Client.
6 */
7export interface ClientOptions<Client> extends Omit<LifeCycleMethods, "onCommand"> {
8 /**
9 * A function which returns a websocket.
10 *
11 * This is over-engineered because we need the ability to create different
12 * types of websockets for React Native, React, and NodeJS. :|
13 */
14 createSocket?: ((path: string) => BrowserWebSocket) | ((path: string) => NodeWebSocket) | null;
15 /**
16 * The hostname or ip address of the server. Default: localhost.
17 */
18 host?: string | null;
19 /**
20 * The port to connect to the server on. Default: 9090.
21 */
22 port?: number | null;
23 /**
24 * The name of this client. Usually the app name.
25 */
26 name?: string;
27 /**
28 * Will we be connecting via SSL?
29 */
30 secure?: boolean;
31 /**
32 * A list of plugins.
33 */
34 plugins?: PluginCreator<Client>[];
35 /**
36 * Performs safety checks when serializing. Default: true.
37 *
38 * Will do things like:
39 * - remap falsy values to transport-friendly version
40 * - remove any circular dependencies
41 * - remap functions to something that shows their name
42 *
43 * Hooray for JavaScript!
44 */
45 safeRecursion?: boolean;
46 /**
47 * Fires when the server sends a command.
48 */
49 onCommand?: ((command: any) => void) | null;
50 /**
51 * Fires when we connect to the server.
52 */
53 onConnect?: () => void;
54 /**
55 * Fires when we disconnect from the server.
56 */
57 onDisconnect?: () => void;
58 /**
59 * The NODE_ENV environment, if any.
60 */
61 environment?: string;
62 /**
63 * A way for the client libraries to identify themselves.
64 */
65 client?: Record<string, string | number | boolean>;
66 /**
67 * Save the client id provided by the server
68 */
69 setClientId?: (clientId: string) => Promise<void>;
70 /**
71 * Get the client id provided by the server
72 */
73 getClientId?: (name: string) => Promise<string>;
74 proxyHack?: boolean;
75}
76export {};