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 {
|
import {
|
||||||
getLogger,
|
getLogger,
|
||||||
getStringFromErrorLike,
|
getStringFromErrorLike,
|
||||||
|
isProduction,
|
||||||
setLoggerInstance,
|
setLoggerInstance,
|
||||||
} from 'flipper-common';
|
} from 'flipper-common';
|
||||||
import {init as initLogger} from './fb-stubs/Logger';
|
import {init as initLogger} from './fb-stubs/Logger';
|
||||||
@@ -51,6 +52,34 @@ async function start() {
|
|||||||
|
|
||||||
const params = new URL(location.href).searchParams;
|
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 tokenProvider = () => {
|
||||||
const providerParams = new URL(location.href).searchParams;
|
const providerParams = new URL(location.href).searchParams;
|
||||||
let token = providerParams.get('token');
|
let token = providerParams.get('token');
|
||||||
|
|||||||
@@ -101,35 +101,6 @@
|
|||||||
window.flipperShowMessage = showMessage;
|
window.flipperShowMessage = showMessage;
|
||||||
window.flipperHideMessage = hideMessage;
|
window.flipperHideMessage = hideMessage;
|
||||||
|
|
||||||
const params = new URL(location.href).searchParams;
|
|
||||||
let token = params.get('token');
|
|
||||||
if (!token) {
|
|
||||||
token = window.flipperConfig.authToken
|
|
||||||
}
|
|
||||||
|
|
||||||
const socket = new WebSocket(`ws://${location.host}?token=${token}`);
|
|
||||||
window.devSocket = socket;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// load correct theme (n.b. this doesn't handle system value specifically, will assume light in such cases)
|
// load correct theme (n.b. this doesn't handle system value specifically, will assume light in such cases)
|
||||||
try {
|
try {
|
||||||
if (window.flipperConfig.theme === 'dark') {
|
if (window.flipperConfig.theme === 'dark') {
|
||||||
|
|||||||
Reference in New Issue
Block a user