From 5d45bd741bcec2a0ca184d44c222d256030c9e42 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Wed, 8 Dec 2021 04:25:28 -0800 Subject: [PATCH] Initialise flipper-ui-browser with socket connection Summary: This diff sets up the socket connection between flipper-browser and flipper-server, and verifies that the initial UI initialisation work (e.g. `get-config` command works). The initial RenderHost is initialised as well based on the config and browser APIs. Note that flipper-ui-core itself isn't started yet, as that has still a plethora of node imports, so Metro will correctly refuse to bundle Not in this diff * remove Node usage from flipper-ui-core * implement all RenderHost APIs Reviewed By: aigoncharov Differential Revision: D32644074 fbshipit-source-id: 2c8065caf0191771a3867b69a431ca50eeb7a5a3 --- desktop/app/src/init.tsx | 28 +++- .../src/transform-browser.ts | 35 +++++ .../src/FlipperServerImpl.tsx | 9 ++ desktop/flipper-server/package.json | 2 +- desktop/flipper-server/src/index.tsx | 9 +- .../flipper-server/src/startBaseServer.tsx | 7 +- .../flipper-server/src/startFlipperServer.tsx | 13 +- .../flipper-server/src/startSocketServer.tsx | 51 ++++++++ .../flipper-server/src/startWebServerDev.tsx | 9 +- desktop/flipper-ui-browser/package.json | 6 +- desktop/flipper-ui-browser/src/HMRClient.tsx | 2 +- .../src/flipperServerConnection.tsx | 120 ++++++++++++++++++ desktop/flipper-ui-browser/src/global.ts | 25 ++++ desktop/flipper-ui-browser/src/index.tsx | 82 ++++++++++++ .../src/initializeRenderHost.tsx | 74 +++++++++++ desktop/flipper-ui-browser/tsconfig.json | 3 + desktop/flipper-ui-core/src/RenderHost.tsx | 6 +- .../src/startFlipperDesktop.tsx | 20 --- desktop/static/index.web.dev.html | 12 +- desktop/yarn.lock | 102 ++++++++++++++- 20 files changed, 570 insertions(+), 45 deletions(-) create mode 100644 desktop/babel-transformer/src/transform-browser.ts create mode 100644 desktop/flipper-server/src/startSocketServer.tsx create mode 100644 desktop/flipper-ui-browser/src/flipperServerConnection.tsx create mode 100644 desktop/flipper-ui-browser/src/global.ts create mode 100644 desktop/flipper-ui-browser/src/initializeRenderHost.tsx diff --git a/desktop/app/src/init.tsx b/desktop/app/src/init.tsx index 9dea3a39d..2442d8dc4 100644 --- a/desktop/app/src/init.tsx +++ b/desktop/app/src/init.tsx @@ -26,7 +26,13 @@ import { loadSettings, setupPrefetcher, } from 'flipper-server-core'; -import {getLogger, isTest, Logger, setLoggerInstance} from 'flipper-common'; +import { + getLogger, + isTest, + Logger, + setLoggerInstance, + Settings, +} from 'flipper-common'; import constants from './fb-stubs/constants'; import {initializeElectron} from './electron/initializeElectron'; import path from 'path'; @@ -99,6 +105,8 @@ async function start() { initializeElectron(flipperServer, flipperServerConfig); + setProcessState(flipperServerConfig.settings); + // By turning this in a require, we force the JS that the body of this module (init) has completed (initializeElectron), // before starting the rest of the Flipper process. // This prevent issues where the render host is referred at module initialisation level, @@ -185,3 +193,21 @@ function createDelegatedLogger(): Logger { }, }; } + +function setProcessState(settings: Settings) { + const androidHome = settings.androidHome; + const idbPath = settings.idbPath; + + if (!process.env.ANDROID_HOME && !process.env.ANDROID_SDK_ROOT) { + process.env.ANDROID_HOME = androidHome; + } + + // emulator/emulator is more reliable than tools/emulator, so prefer it if + // it exists + process.env.PATH = + ['emulator', 'tools', 'platform-tools'] + .map((directory) => path.resolve(androidHome, directory)) + .join(':') + + `:${idbPath}` + + `:${process.env.PATH}`; +} diff --git a/desktop/babel-transformer/src/transform-browser.ts b/desktop/babel-transformer/src/transform-browser.ts new file mode 100644 index 000000000..da14bd516 --- /dev/null +++ b/desktop/babel-transformer/src/transform-browser.ts @@ -0,0 +1,35 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import {default as doTransform} from './transform'; +import {default as getCacheKey} from './get-cache-key'; + +const presets = [require('@babel/preset-react')]; +const plugins = [ + require('./import-react'), + require('./app-flipper-requires'), + require('./fb-stubs'), +]; + +module.exports = { + transform, + getCacheKey, +}; + +function transform({ + filename, + options, + src, +}: { + filename: string; + options: any; + src: string; +}) { + return doTransform({filename, options, src, presets, plugins}); +} diff --git a/desktop/flipper-server-core/src/FlipperServerImpl.tsx b/desktop/flipper-server-core/src/FlipperServerImpl.tsx index 88b2ece71..92865c283 100644 --- a/desktop/flipper-server-core/src/FlipperServerImpl.tsx +++ b/desktop/flipper-server-core/src/FlipperServerImpl.tsx @@ -153,6 +153,14 @@ export class FlipperServerImpl implements FlipperServer { this.events.off(event, callback); } + onAny(callback: (event: keyof FlipperServerEvents, payload: any) => void) { + this.events.on('*', callback); + } + + offAny(callback: (event: keyof FlipperServerEvents, payload: any) => void) { + this.events.off('*', callback); + } + /** * @internal */ @@ -161,6 +169,7 @@ export class FlipperServerImpl implements FlipperServer { payload: FlipperServerEvents[Event], ): void { this.events.emit(event, payload); + this.events.emit('*', event, payload); } exec( diff --git a/desktop/flipper-server/package.json b/desktop/flipper-server/package.json index f44ddf3f0..786a761c3 100644 --- a/desktop/flipper-server/package.json +++ b/desktop/flipper-server/package.json @@ -32,7 +32,7 @@ "reset": "rimraf lib *.tsbuildinfo", "build": "tsc -b", "prepack": "yarn reset && yarn build", - "start": "cross-env NODE_ENV=development nodemon --watch './src/*.tsx' --exec '../ts-node' src/index.tsx" + "start": "cross-env NODE_ENV=development nodemon --watch './src/**/*.tsx' --watch '../flipper-server-core/src/**/*.tsx' --exec '../ts-node' src/index.tsx" }, "files": [ "lib/**/*" diff --git a/desktop/flipper-server/src/index.tsx b/desktop/flipper-server/src/index.tsx index a4f2879de..a1ffc8288 100644 --- a/desktop/flipper-server/src/index.tsx +++ b/desktop/flipper-server/src/index.tsx @@ -7,14 +7,15 @@ * @format */ +import chalk from 'chalk'; +import path from 'path'; // TODO: currently flipper-server is only suitable for development, // needs to be come independently runnable, prebundled, distributed, etc! // in future require conditionally import {startWebServerDev} from './startWebServerDev'; import {startFlipperServer} from './startFlipperServer'; import {startBaseServer} from './startBaseServer'; -import chalk from 'chalk'; -import path from 'path'; +import {startSocketServer} from './startSocketServer'; const PORT = 52342; const rootDir = path.resolve(__dirname, '..', '..'); @@ -27,10 +28,12 @@ async function start() { entry: 'index.web.dev.html', }); - return Promise.all([ + const [flipperServer] = await Promise.all([ startFlipperServer(rootDir, staticDir), startWebServerDev(app, server, socket, rootDir), ]); + + startSocketServer(flipperServer, socket); } start() diff --git a/desktop/flipper-server/src/startBaseServer.tsx b/desktop/flipper-server/src/startBaseServer.tsx index 9cd23da30..131776b47 100644 --- a/desktop/flipper-server/src/startBaseServer.tsx +++ b/desktop/flipper-server/src/startBaseServer.tsx @@ -64,12 +64,7 @@ function startAssetServer( } function addWebsocket(server: http.Server) { - const io = new socketio.Server(server); // 3.1.0 socket.io doesn't have type definitions - - io.on('connection', (client) => { - console.log(chalk.green(`Client connected ${client.id}`)); - }); - + const io = new socketio.Server(server); return io; } diff --git a/desktop/flipper-server/src/startFlipperServer.tsx b/desktop/flipper-server/src/startFlipperServer.tsx index 863306650..9ae4636dc 100644 --- a/desktop/flipper-server/src/startFlipperServer.tsx +++ b/desktop/flipper-server/src/startFlipperServer.tsx @@ -24,7 +24,10 @@ import { import path from 'path'; import fs from 'fs'; -export async function startFlipperServer(rootDir: string, staticDir: string) { +export async function startFlipperServer( + rootDir: string, + staticDir: string, +): Promise { if (os.platform() === 'darwin') { // By default Node.JS has its internal certificate storage and doesn't use // the system store. Because of this, it's impossible to access ondemand / devserver @@ -90,6 +93,7 @@ export async function startFlipperServer(rootDir: string, staticDir: string) { ); await flipperServer.connect(); + return flipperServer; } function createLogger(): Logger { @@ -103,7 +107,7 @@ function createLogger(): Logger { // console.warn('(skipped trackTimeSince)', args); }, debug(..._args: any[]) { - // TODO: only if verbose console.debug(...args); + // TODO: only if double verbose console.debug(...args); }, error(...args: any[]) { console.error(...args); @@ -113,8 +117,9 @@ function createLogger(): Logger { console.warn(...args); console.warn('(skipped error reporting)'); }, - info(...args: any[]) { - console.info(...args); + info(..._args: any[]) { + // TODO: only if verbose console.debug(...args); + // console.info(...args); }, }; } diff --git a/desktop/flipper-server/src/startSocketServer.tsx b/desktop/flipper-server/src/startSocketServer.tsx new file mode 100644 index 000000000..79810f4b1 --- /dev/null +++ b/desktop/flipper-server/src/startSocketServer.tsx @@ -0,0 +1,51 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import chalk from 'chalk'; +import {FlipperServerImpl} from 'flipper-server-core'; +import socketio from 'socket.io'; + +export function startSocketServer( + flipperServer: FlipperServerImpl, + socket: socketio.Server, +) { + socket.on('connection', (client) => { + console.log(chalk.green(`Client connected ${client.id}`)); + + let connected = true; + + function onServerEvent(event: string, payoad: any) { + client.emit('event', event, payoad); + } + + flipperServer.onAny(onServerEvent); + + client.on('exec', (id, command, args) => { + console.log(id, command, args); + flipperServer + .exec(command, ...args) + .then((result: any) => { + if (connected) { + client.emit('exec-response', id, result); + } + }) + .catch((error: any) => { + if (connected) { + client.emit('exec-response-error', id, error.toString()); + } + }); + }); + + client.on('disconnect', () => { + console.log(chalk.red(`Client disconnected ${client.id}`)); + connected = false; + flipperServer.offAny(onServerEvent); + }); + }); +} diff --git a/desktop/flipper-server/src/startWebServerDev.tsx b/desktop/flipper-server/src/startWebServerDev.tsx index a4ca52c96..6229b67eb 100644 --- a/desktop/flipper-server/src/startWebServerDev.tsx +++ b/desktop/flipper-server/src/startWebServerDev.tsx @@ -76,15 +76,20 @@ async function startMetroServer( watchFolders, transformer: { ...baseConfig.transformer, - babelTransformerPath: path.join(babelTransformationsDir, 'transform-app'), + babelTransformerPath: path.join( + babelTransformationsDir, + 'transform-browser', + ), }, resolver: { ...baseConfig.resolver, - resolverMainFields: ['flipperBundlerEntry', 'module', 'main'], + resolverMainFields: ['flipperBundlerEntry', 'browser', 'module', 'main'], blacklistRE: /\.native\.js$/, sourceExts: ['js', 'jsx', 'ts', 'tsx', 'json', 'mjs', 'cjs'], }, watch: true, + // only needed when medling with babel transforms + // cacheVersion: Math.random(), // only cache for current run }); const connectMiddleware = await Metro.createConnectMiddleware(config); app.use(connectMiddleware.middleware); diff --git a/desktop/flipper-ui-browser/package.json b/desktop/flipper-ui-browser/package.json index cd568a8cb..fa84657bf 100644 --- a/desktop/flipper-ui-browser/package.json +++ b/desktop/flipper-ui-browser/package.json @@ -12,9 +12,13 @@ "dependencies": {}, "devDependencies": { "invariant": "^2.2.4", + "eventemitter3": "^4.0.7", + "flipper-common": "0.0.0", + "flipper-ui-core": "0.0.0", "metro-runtime": "^0.66.2", "pretty-format": "^27.3.1", - "react-refresh": "^0.10.0" + "react-refresh": "^0.10.0", + "socket.io-client": "^4.4.0" }, "peerDependencies": {}, "scripts": { diff --git a/desktop/flipper-ui-browser/src/HMRClient.tsx b/desktop/flipper-ui-browser/src/HMRClient.tsx index 9d0bb5dde..6247b9d61 100644 --- a/desktop/flipper-ui-browser/src/HMRClient.tsx +++ b/desktop/flipper-ui-browser/src/HMRClient.tsx @@ -270,7 +270,7 @@ function showCompileError() { // Symbolicating compile errors is wasted effort // because the stack trace is meaningless: (error as any).preventSymbolication = true; - (window as any).flipperShowError?.(message); + window.flipperShowError?.(message); throw error; } diff --git a/desktop/flipper-ui-browser/src/flipperServerConnection.tsx b/desktop/flipper-ui-browser/src/flipperServerConnection.tsx new file mode 100644 index 000000000..91106a3da --- /dev/null +++ b/desktop/flipper-ui-browser/src/flipperServerConnection.tsx @@ -0,0 +1,120 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import EventEmitter from 'eventemitter3'; +import {FlipperServer} from 'flipper-common'; +import {io, Socket} from 'socket.io-client'; + +const CONNECTION_TIMEOUT = 30 * 1000; +const EXEC_TIMOUT = 10 * 1000; + +export function createFlipperServer(): Promise { + // TODO: polish this all! + window.flipperShowError?.('Connecting to server...'); + return new Promise((resolve, reject) => { + const initialConnectionTimeout = setTimeout(() => { + reject( + new Error('Failed to connect to Flipper server in a timely manner'), + ); + }, CONNECTION_TIMEOUT); + + const eventEmitter = new EventEmitter(); + // TODO: recycle the socket that is created in index.web.dev.html? + const socket: Socket = io(); + const pendingRequests: Map< + number, + { + resolve: (data: any) => void; + reject: (data: any) => void; + timeout: ReturnType; + } + > = new Map(); + let requestId = 0; + let connected = false; + + socket.on('connect', () => { + window?.flipperHideError?.(); + console.log('Socket to Flipper server connected'); + connected = true; + }); + + socket.once('connect', () => { + // only relevant for the first connect + resolve(flipperServer); + clearTimeout(initialConnectionTimeout); + }); + + socket.on('disconnect', () => { + window?.flipperShowError?.('WebSocket connection lost'); + console.warn('Socket to Flipper server disconnected'); + connected = false; + }); + + socket.on('exec-response', (id: number, data: any) => { + console.debug('exec <<<', id, data); + const entry = pendingRequests.get(id); + if (!entry) { + console.warn(`Unknown request id `, id); + } else { + pendingRequests.delete(id); + clearTimeout(entry.timeout); + entry.resolve(data); + } + }); + + socket.on('exec-response-error', (id: number, error: any) => { + console.debug('exec <<< [SERVER ERROR]', id, error); + const entry = pendingRequests.get(id); + if (!entry) { + console.warn(`Unknown request id `, id); + } else { + pendingRequests.delete(id); + clearTimeout(entry.timeout); + entry.reject(error); + } + }); + + socket.on('event', (eventType, data) => { + eventEmitter.emit(eventType, data); + }); + + const flipperServer: FlipperServer = { + async connect() {}, + close() {}, + exec(command, ...args): any { + if (connected) { + return new Promise((resolve, reject) => { + const id = ++requestId; + console.debug('exec >>>', id, command, args); + + pendingRequests.set(id, { + resolve, + reject, + timeout: setInterval(() => { + pendingRequests.delete(id); + reject(new Error(`Timeout for command '${command}'`)); + }, EXEC_TIMOUT), + }); + + socket.emit('exec', id, command, args); + }); + // socket. + } else { + throw new Error('Not connected to Flipper Server'); + } + }, + on(event, callback) { + eventEmitter.on(event, callback); + }, + off(event, callback) { + eventEmitter.off(event, callback); + }, + }; + }); +} diff --git a/desktop/flipper-ui-browser/src/global.ts b/desktop/flipper-ui-browser/src/global.ts new file mode 100644 index 000000000..cdf2b8b5b --- /dev/null +++ b/desktop/flipper-ui-browser/src/global.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import {RenderHost} from 'flipper-ui-core'; + +declare global { + interface Window { + flipperConfig: { + theme: 'light' | 'dark' | 'system'; + entryPoint: string; + debug: boolean; + }; + + FlipperRenderHostInstance: RenderHost; + + flipperShowError?(error: string): void; + flipperHideError?(): void; + } +} diff --git a/desktop/flipper-ui-browser/src/index.tsx b/desktop/flipper-ui-browser/src/index.tsx index 2ff8bb5ac..3456edbd0 100644 --- a/desktop/flipper-ui-browser/src/index.tsx +++ b/desktop/flipper-ui-browser/src/index.tsx @@ -7,4 +7,86 @@ * @format */ +import {getLogger, Logger, setLoggerInstance} from 'flipper-common'; +import {initializeRenderHost} from './initializeRenderHost'; +import {createFlipperServer} from './flipperServerConnection'; + document.getElementById('root')!.innerText = 'flipper-ui-browser started'; + +async function start() { + const logger = createDelegatedLogger(); + setLoggerInstance(logger); + + const flipperServer = await createFlipperServer(); + + await flipperServer.connect(); + const flipperServerConfig = await flipperServer.exec('get-config'); + + initializeRenderHost(flipperServer, flipperServerConfig); + + // By turning this in a require, we force the JS that the body of this module (init) has completed (initializeElectron), + // before starting the rest of the Flipper process. + // This prevent issues where the render host is referred at module initialisation level, + // but not set yet, which might happen when using normal imports. + // eslint-disable-next-line import/no-commonjs + // TODO: replace + window.flipperShowError?.('Connected to Flipper Server successfully'); + // TODO: require('flipper-ui-core').startFlipperDesktop(flipperServer); +} + +start().catch((e) => { + console.error('Failed to start flipper-ui-browser', e); + window.flipperShowError?.('Failed to start flipper-ui-browser: ' + e); +}); + +// getLogger() is not yet created when the electron app starts. +// we can't create it here yet, as the real logger is wired up to +// the redux store and the rest of the world. So we create a delegating logger +// that uses a simple implementation until the real one comes available +function createDelegatedLogger(): Logger { + const naiveLogger: Logger = { + track(...args: [any, any, any?, any?]) { + console.warn('(skipper track)', args); + }, + trackTimeSince(...args: [any, any, any?]) { + console.warn('(skipped trackTimeSince)', args); + }, + debug(...args: any[]) { + console.debug(...args); + }, + error(...args: any[]) { + console.error(...args); + console.warn('(skipped error reporting)'); + }, + warn(...args: any[]) { + console.warn(...args); + console.warn('(skipped error reporting)'); + }, + info(...args: any[]) { + console.info(...args); + }, + }; + // will be overwrittingen later + setLoggerInstance(naiveLogger); + + return { + track() { + // noop + }, + trackTimeSince() { + // noop + }, + debug(...args: any[]) { + getLogger().debug(...args); + }, + error(...args: any[]) { + getLogger().error(...args); + }, + warn(...args: any[]) { + getLogger().warn(...args); + }, + info(...args: any[]) { + getLogger().info(...args); + }, + }; +} diff --git a/desktop/flipper-ui-browser/src/initializeRenderHost.tsx b/desktop/flipper-ui-browser/src/initializeRenderHost.tsx new file mode 100644 index 000000000..69cb70f54 --- /dev/null +++ b/desktop/flipper-ui-browser/src/initializeRenderHost.tsx @@ -0,0 +1,74 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import {FlipperServer, FlipperServerConfig} from 'flipper-common'; + +export function initializeRenderHost( + flipperServer: FlipperServer, + flipperServerConfig: FlipperServerConfig, +) { + window.FlipperRenderHostInstance = { + processId: 0, + isProduction: window.flipperConfig.debug !== true, + readTextFromClipboard() { + // TODO: + return undefined; + }, + writeTextToClipboard(_text: string) { + // TODO: + }, + async importFile() { + throw new Error('Not implemented'); + }, + async exportFile() { + throw new Error('Not implemented'); + }, + openLink(url: string) { + window.open(url, '_blank'); + }, + registerShortcut(_shortcut, _callback) { + // TODO: + return () => {}; + }, + hasFocus() { + return document.hasFocus(); + }, + onIpcEvent(event) { + console.warn('onIpcEvent not available', event); + }, + sendIpcEvent(event, ..._args: any[]) { + console.warn('sendIpcEvent not available', event); + }, + shouldUseDarkColors() { + return !!( + window.flipperConfig.theme === 'dark' || + (window.flipperConfig.theme === 'system' && + window.matchMedia?.('(prefers-color-scheme: dark)')) + ); + }, + restartFlipper() { + // TODO: restart server as well + window.location.reload(); + }, + loadDefaultPlugins: getDefaultPluginsIndex, + serverConfig: flipperServerConfig, + GK(gatekeeper) { + return flipperServerConfig.gatekeepers[gatekeeper] ?? false; + }, + flipperServer, + }; +} + +function getDefaultPluginsIndex() { + // TODO: + return {}; + // eslint-disable-next-line import/no-unresolved + // const index = require('../defaultPlugins'); + // return index.default || index; +} diff --git a/desktop/flipper-ui-browser/tsconfig.json b/desktop/flipper-ui-browser/tsconfig.json index 6a7070447..4b5b02242 100644 --- a/desktop/flipper-ui-browser/tsconfig.json +++ b/desktop/flipper-ui-browser/tsconfig.json @@ -5,6 +5,9 @@ "rootDir": "src" }, "references": [ + { + "path": "../flipper-common" + }, { "path": "../flipper-ui-core" } diff --git a/desktop/flipper-ui-core/src/RenderHost.tsx b/desktop/flipper-ui-core/src/RenderHost.tsx index a5b5427de..86db85d8b 100644 --- a/desktop/flipper-ui-core/src/RenderHost.tsx +++ b/desktop/flipper-ui-core/src/RenderHost.tsx @@ -17,9 +17,6 @@ import { ReleaseChannel, Tristate, } from 'flipper-common'; -// TODO: those imports are only used for testing, require conditionally? -import {tmpdir} from 'os'; -import {resolve} from 'path'; // Events that are emitted from the main.ts ovr the IPC process bridge in Electron type MainProcessEvents = { @@ -116,6 +113,9 @@ export function getRenderHostInstance(): RenderHost { } if (process.env.NODE_ENV === 'test') { + const {tmpdir} = require('os'); + const {resolve} = require('path'); + const rootPath = resolve(__dirname, '..', '..'); const stubConfig: FlipperServerConfig = { env: {...process.env}, diff --git a/desktop/flipper-ui-core/src/startFlipperDesktop.tsx b/desktop/flipper-ui-core/src/startFlipperDesktop.tsx index 8e27047bf..5580f130d 100644 --- a/desktop/flipper-ui-core/src/startFlipperDesktop.tsx +++ b/desktop/flipper-ui-core/src/startFlipperDesktop.tsx @@ -17,7 +17,6 @@ import dispatcher from './dispatcher/index'; import TooltipProvider from './ui/components/TooltipProvider'; import {setPersistor} from './utils/persistor'; import React from 'react'; -import path from 'path'; import {getStore} from './store'; import {cache} from '@emotion/css'; import {CacheProvider} from '@emotion/react'; @@ -142,24 +141,6 @@ class AppFrame extends React.Component< } } -function setProcessState(settings: Settings) { - const androidHome = settings.androidHome; - const idbPath = settings.idbPath; - - if (!process.env.ANDROID_HOME && !process.env.ANDROID_SDK_ROOT) { - process.env.ANDROID_HOME = androidHome; - } - - // emulator/emulator is more reliable than tools/emulator, so prefer it if - // it exists - process.env.PATH = - ['emulator', 'tools', 'platform-tools'] - .map((directory) => path.resolve(androidHome, directory)) - .join(':') + - `:${idbPath}` + - `:${process.env.PATH}`; -} - function init(flipperServer: FlipperServer) { const settings = getRenderHostInstance().serverConfig.settings; const store = getStore(); @@ -173,7 +154,6 @@ function init(flipperServer: FlipperServer) { // rehydrate app state before exposing init const persistor = persistStore(store, undefined, () => { // Make sure process state is set before dispatchers run - setProcessState(settings); dispatcher(store, logger); }); diff --git a/desktop/static/index.web.dev.html b/desktop/static/index.web.dev.html index 6a4c005f0..49abfe4f0 100644 --- a/desktop/static/index.web.dev.html +++ b/desktop/static/index.web.dev.html @@ -10,6 +10,7 @@ window.flipperConfig = { theme: 'light', entryPoint: 'flipper-ui-browser/src/index-fast-refresh.bundle?platform=web&dev=true&minify=false', + debug: true, }