add headless entry point
Summary: Adding `headless/index.js` This is the entry point to the headless version of Flipper. This creates a redux store, and initializes the dispatchers. As all business logic (adb connections, etc.) are managed by dispatchers, this spins up a working version of Flipper, listening on our ports, allowing connections to devices. For APIs not available in node.js, we are adding polyfills. `WebSocket` is used by redux-devtools, `fetch` is used in a couple of places throughout the application. These polyfills are added to the global namespace, so the app can run the same as in the browser. Reviewed By: passy Differential Revision: D13786573 fbshipit-source-id: 685f67e1c0d2948de7c43b8a1e2dc10dc69aa743
This commit is contained in:
committed by
Facebook Github Bot
parent
78cd40e890
commit
dab50ec5c4
29
headless/index.js
Normal file
29
headless/index.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright 2018-present Facebook.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {createStore} from 'redux';
|
||||
import reducers from '../src/reducers/index.js';
|
||||
import dispatcher from '../src/dispatcher/index.js';
|
||||
import Logger, {init} from '../src/fb-stubs/Logger.js';
|
||||
// $FlowFixMe this file exist, trust me, flow!
|
||||
import setup from '../static/setup.js';
|
||||
|
||||
// Polyfills
|
||||
global.WebSocket = require('ws'); // used for redux devtools
|
||||
global.fetch = require('node-fetch/lib/index');
|
||||
|
||||
// needs to be required after WebSocket polyfill is loaded
|
||||
const devToolsEnhancer = require('remote-redux-devtools').default;
|
||||
|
||||
setup();
|
||||
const store = createStore(
|
||||
reducers,
|
||||
devToolsEnhancer({realtime: true, hostname: 'localhost', port: 8181}),
|
||||
);
|
||||
const logger = new Logger(store);
|
||||
init(store);
|
||||
dispatcher(store, logger);
|
||||
Reference in New Issue
Block a user