From 4a932241511915a002f48f0bca6ddc2f060339b7 Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Mon, 6 Dec 2021 12:40:16 -0800 Subject: [PATCH] Differentiate Flipper in logging from standalone app Summary: This commit makes it so when we load DevTools from within Flipper we log it as a Flipper load and not a regular standalone app load. Note that the logging only applies internally. Reviewed By: bvaughn Differential Revision: D32884616 fbshipit-source-id: 90d0962bac9c1abdde36a70fd361251d7e607b57 --- desktop/plugins/public/reactdevtools/index.tsx | 4 +++- .../reactdevtools/react-devtools-core.d.tsx | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/desktop/plugins/public/reactdevtools/index.tsx b/desktop/plugins/public/reactdevtools/index.tsx index f6af704f7..80ae93852 100644 --- a/desktop/plugins/public/reactdevtools/index.tsx +++ b/desktop/plugins/public/reactdevtools/index.tsx @@ -237,7 +237,9 @@ export function devicePlugin(client: DevicePluginClient) { // TODO: since devToolsInstance is an instance, we are probably leaking memory here setStatus(ConnectionStatus.Initializing, status); }) - .startServer(DEV_TOOLS_PORT) as any; + .startServer(DEV_TOOLS_PORT, 'localhost', undefined, { + surface: 'flipper', + }); setStatus(ConnectionStatus.Initializing, 'Waiting for device...'); } catch (e) { console.error('Failed to initalize React DevTools' + e); diff --git a/desktop/plugins/public/reactdevtools/react-devtools-core.d.tsx b/desktop/plugins/public/reactdevtools/react-devtools-core.d.tsx index 755fdae9f..cfe8179fd 100644 --- a/desktop/plugins/public/reactdevtools/react-devtools-core.d.tsx +++ b/desktop/plugins/public/reactdevtools/react-devtools-core.d.tsx @@ -7,10 +7,24 @@ * @format */ +type ServerOptions = { + key?: string; + cert?: string; +}; + +type LoggerOptions = { + surface?: string; +}; + declare module 'react-devtools-core/standalone' { interface DevTools { setContentDOMNode(node: HTMLElement): this; - startServer(port: number): this; + startServer( + port?: number, + host?: string, + httpsOptions?: ServerOptions, + loggerOptions?: LoggerOptions, + ): {close: () => void}; setStatusListener(listener: (message: string) => void): this; } const DevTools: DevTools;