mirror of
https://github.com/status-im/react-native.git
synced 2025-01-14 11:34:23 +00:00
Support loading source maps
Reviewed By: davidaurelio Differential Revision: D4121492 fbshipit-source-id: e2f9c42de3e28cd231580d8b7d3230d47e300d2e
This commit is contained in:
parent
f571d28e68
commit
2cc57d05a4
@ -131,6 +131,13 @@ class Device {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: This should be handled way earlier, preferably in the inspector itself.
|
||||
// That is how it works it newer versions but it requires installing hooks.
|
||||
if (message.indexOf('Network.loadResourceForFrontend') !== -1) {
|
||||
this._loadResourceForFrontend(socket, JSON.parse(message));
|
||||
return;
|
||||
}
|
||||
|
||||
this._send({
|
||||
event: 'wrappedEvent',
|
||||
payload: {
|
||||
@ -224,6 +231,36 @@ class Device {
|
||||
this._removeConnection(pageId);
|
||||
}
|
||||
}
|
||||
|
||||
_loadResourceForFrontend(socket: WebSocket, event: Object) {
|
||||
const id: number = nullthrows(event.id);
|
||||
const url: string = nullthrows(nullthrows(event.params).url);
|
||||
debug('loadResourceForFrontend:', url);
|
||||
http.get(this._normalizeUrl(url), (response) => {
|
||||
// $FlowFixMe callback is optional
|
||||
response.setTimeout(0);
|
||||
let data = '';
|
||||
response.on('data', (chunk) => { data += chunk; });
|
||||
response.on('end', () => {
|
||||
socket.send(JSON.stringify({
|
||||
id: id,
|
||||
result: {
|
||||
statusCode: response.statusCode,
|
||||
content: data,
|
||||
responseHeaders: response.headers,
|
||||
},
|
||||
}));
|
||||
});
|
||||
response.on('error', (error) => {
|
||||
console.error('Failed to get resource', error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_normalizeUrl(url: string): string {
|
||||
return url.replace('http://10.0.3.2', 'http://localhost')
|
||||
.replace('http://10.0.2.2', 'http://localhost');
|
||||
}
|
||||
}
|
||||
|
||||
class InspectorProxy {
|
||||
|
Loading…
x
Reference in New Issue
Block a user