UNPKG

6.11 kBTypeScriptView Raw
1import * as WebSocket from "ws";
2import { ClientOptions } from "./client-options";
3export declare const corePlugins: (((reactotron: Reactotron<ReactotronCore>) => {
4 features: {
5 log: (...args: any[]) => void;
6 logImportant: (...args: any[]) => void;
7 debug: (message: any, important?: boolean) => void;
8 warn: (message: any) => void;
9 error: (message: any, stack: any) => void;
10 };
11}) | ((reactotron: Reactotron<ReactotronCore>) => {
12 features: {
13 image: ({ uri, preview, filename, width, height, caption }: {
14 uri: any;
15 preview: any;
16 filename: any;
17 width: any;
18 height: any;
19 caption: any;
20 }) => void;
21 };
22}) | ((reactotron: Reactotron<ReactotronCore>) => {
23 features: {
24 benchmark: (title: any) => {
25 step: (stepTitle: any) => void;
26 stop: (stopTitle: any) => void;
27 last: (stopTitle: any) => void;
28 };
29 };
30}) | ((reactotron: Reactotron<ReactotronCore>) => {
31 features: {
32 stateActionComplete: (name: any, action: any, important?: boolean) => void;
33 stateValuesResponse: (path: any, value: any, valid?: boolean) => void;
34 stateKeysResponse: (path: any, keys: any, valid?: boolean) => void;
35 stateValuesChange: (changes: any) => void;
36 stateBackupResponse: (state: any) => void;
37 };
38}) | ((reactotron: Reactotron<ReactotronCore>) => {
39 features: {
40 apiResponse: (request: any, response: any, duration: any) => void;
41 };
42}) | ((reactotron: Reactotron<ReactotronCore>) => {
43 features: {
44 clear: () => void;
45 };
46}) | ((reactotron: Reactotron<ReactotronCore>) => {
47 onCommand: ({ type, payload }: {
48 type: string;
49 payload?: any;
50 }) => void;
51 features: {
52 repl: (name: string, value: import("./plugins/repl").AcceptableRepls) => void;
53 };
54}))[];
55export declare enum ArgType {
56 String = "string"
57}
58export interface CustomCommandArg {
59 name: string;
60 type: ArgType;
61}
62export interface CustomCommand {
63 id?: number;
64 command: string;
65 handler: (args?: any) => void;
66 title?: string;
67 description?: string;
68 args?: CustomCommandArg[];
69}
70export interface ReactotronCore {
71 startTimer: () => () => number;
72 close: () => void;
73 send: (type: any, payload?: any, important?: boolean) => void;
74 display: (config?: any) => void;
75 reportError: (this: any, error: any) => void;
76 onCustomCommand: (config: CustomCommand | string, optHandler?: () => void) => () => void;
77 apiResponse?: (request: any, response: any, duration: any) => void;
78 benchmark?: (title: string) => {
79 step: (stepName: string) => void;
80 stop: (stopTitle: string) => void;
81 last: (stopTitle: string) => void;
82 };
83 clear?: () => void;
84 image?: (options: {
85 uri: any;
86 preview: any;
87 filename: any;
88 width: any;
89 height: any;
90 caption: any;
91 }) => void;
92 log?: (...args: any[]) => void;
93 logImportant?: (...args: any[]) => void;
94 debug?: (message: any, important?: boolean) => void;
95 warn?: (message: any) => void;
96 error?: (message: any, stack: any) => void;
97 stateActionComplete?: (name: any, action: any, important?: boolean) => void;
98 stateValuesResponse?: (path: any, value: any, valid?: boolean) => void;
99 stateKeysResponse?: (path: any, keys: any, valid?: boolean) => void;
100 stateValuesChange?: (changes: any) => void;
101 stateBackupResponse?: (state: any) => void;
102 repl?: (name: string, value: object | Function | string | number) => void;
103}
104export interface Reactotron<ReactotronSubtype = ReactotronCore> extends ReactotronCore {
105 /**
106 * Set the configuration options.
107 */
108 configure: (options?: ClientOptions) => Reactotron<ReactotronSubtype> & ReactotronSubtype;
109 use: (pluginCreator?: (client: Reactotron<ReactotronSubtype> & ReactotronSubtype) => any) => Reactotron<ReactotronSubtype> & ReactotronSubtype;
110 connect: () => Reactotron<ReactotronSubtype> & ReactotronSubtype;
111}
112export declare class ReactotronImpl<ReactotronSubtype = ReactotronCore> implements Reactotron<ReactotronSubtype> {
113 options: ClientOptions;
114 /**
115 * Are we connected to a server?
116 */
117 connected: boolean;
118 /**
119 * The socket we're using.
120 */
121 socket: WebSocket;
122 /**
123 * Available plugins.
124 */
125 plugins: any[];
126 /**
127 * Messages that need to be sent.
128 */
129 sendQueue: any[];
130 /**
131 * Are we ready to start communicating?
132 */
133 isReady: boolean;
134 /**
135 * The last time we sent a message.
136 */
137 lastMessageDate: Date;
138 /**
139 * The registered custom commands
140 */
141 customCommands: CustomCommand[];
142 /**
143 * The current ID for custom commands
144 */
145 customCommandLatestId: number;
146 /**
147 * Starts a timer and returns a function you can call to stop it and return the elapsed time.
148 */
149 startTimer: () => () => number;
150 /**
151 * Set the configuration options.
152 */
153 configure(options?: ClientOptions): Reactotron<ReactotronSubtype> & ReactotronSubtype;
154 close(): void;
155 /**
156 * Connect to the Reactotron server.
157 */
158 connect(): Reactotron<ReactotronSubtype> & ReactotronSubtype;
159 /**
160 * Sends a command to the server
161 */
162 send: (type: any, payload?: {}, important?: boolean) => void;
163 /**
164 * Sends a custom command to the server to displays nicely.
165 */
166 display(config?: any): void;
167 /**
168 * Client libraries can hijack this to report errors.
169 */
170 reportError(this: any, error: any): void;
171 /**
172 * Adds a plugin to the system
173 */
174 use(pluginCreator?: (client: Reactotron<ReactotronSubtype> & ReactotronSubtype) => any): Reactotron<ReactotronSubtype> & ReactotronSubtype;
175 onCustomCommand(config: CustomCommand | string, optHandler?: () => void): () => void;
176}
177export declare function createClient<ReactotronSubtype = ReactotronCore>(options?: ClientOptions): Reactotron<ReactotronSubtype> & ReactotronSubtype;