Move dev socket
Summary: Not entirely sure what the use of this socket is, but it can definitely be defined inside flipper-ui-browser instead. Reviewed By: aigoncharov Differential Revision: D51307090 fbshipit-source-id: 36eb336536e8672fb0b2bcf12dad31c7fbc00a39
This commit is contained in:
committed by
Facebook GitHub Bot
parent
af3f11521b
commit
65d2ce7ed5
@@ -10,6 +10,7 @@
|
||||
import {
|
||||
getLogger,
|
||||
getStringFromErrorLike,
|
||||
isProduction,
|
||||
setLoggerInstance,
|
||||
} from 'flipper-common';
|
||||
import {init as initLogger} from './fb-stubs/Logger';
|
||||
@@ -51,6 +52,34 @@ async function start() {
|
||||
|
||||
const params = new URL(location.href).searchParams;
|
||||
|
||||
if (!isProduction()) {
|
||||
let token = params.get('token');
|
||||
if (!token) {
|
||||
token = window.flipperConfig.authToken;
|
||||
}
|
||||
|
||||
const socket = new WebSocket(`ws://${location.host}?token=${token}`);
|
||||
socket.addEventListener('message', ({data: dataRaw}) => {
|
||||
const message = JSON.parse(dataRaw.toString());
|
||||
|
||||
if (typeof message.event === 'string') {
|
||||
switch (message.event) {
|
||||
case 'hasErrors': {
|
||||
console.warn('Error message received', message.payload);
|
||||
break;
|
||||
}
|
||||
case 'plugins-source-updated': {
|
||||
window.postMessage({
|
||||
type: 'plugins-source-updated',
|
||||
data: message.payload,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const tokenProvider = () => {
|
||||
const providerParams = new URL(location.href).searchParams;
|
||||
let token = providerParams.get('token');
|
||||
|
||||
Reference in New Issue
Block a user