Skip to content

Commit b03ae54

Browse files
committed
Merge remote-tracking branch 'origin/apollo' into apollo
# Conflicts: # app/middlewares/debuggerAPI.js # app/worker/index.js
2 parents d918322 + 768bcaf commit b03ae54

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"__PLATFORM__",
2525
"__REPORT_REACT_DEVTOOLS_PORT__",
2626
"__FETCH_SUPPORT__",
27-
"__NETWORK_INSPECT__"
27+
"__NETWORK_INSPECT__",
28+
"__APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__"
2829
]
2930
}
3031
],

app/middlewares/debuggerAPI.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ const workerOnMessage = message => {
3434
const { data } = message;
3535

3636
if (data.source === 'apollo-devtools-backend') {
37+
if (!window.__APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__) {
38+
window.__APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__ = true;
39+
}
40+
3741
postMessage({
3842
source: 'apollo-devtools-backend',
3943
payload: data,
40-
}, "*");
44+
}, '*');
4145
}
4246

4347
if (data && (data.__IS_REDUX_NATIVE_MESSAGE__ || data.__REPORT_REACT_DEVTOOLS_PORT__)) {
@@ -53,9 +57,10 @@ const workerOnMessage = message => {
5357

5458
const onWindowMessage = e => {
5559
if (e.data && e.data.source === 'apollo-devtools-proxy') {
56-
worker.postMessage({source: 'apollo-devtools-proxy', ...e.data.payload});
60+
const message = typeof e.data.payload === 'string' ? { event: e.data.payload } : e.data.payload;
61+
worker.postMessage({ source: 'apollo-devtools-proxy', ...message });
5762
}
58-
}
63+
};
5964

6065
const createJSRuntime = () => {
6166
// This worker will run the application javascript code,

app/worker/apollo/backend/index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
// This is the agent that is injected into the page that an Apollo Client app lives in
22
// when the Apollo Devtools panel is activated.
3-
import { initBroadCastEvents } from "./broadcastQueries";
4-
import { initLinkEvents } from "./links";
5-
import { checkVersions } from "./checkVersions";
3+
import { initBroadCastEvents } from './broadcastQueries';
4+
import { initLinkEvents } from './links';
5+
import { checkVersions } from './checkVersions';
66

77
// hook should have been injected before this executes.
88
let hook;
99
let bridge;
1010
let connected;
1111

12+
export const sendBridgeReady = () => {
13+
bridge.send('ready', hook.ApolloClient.version);
14+
};
15+
1216
const connect = () => {
1317
if (connected) return;
1418
connected = true;
1519
if (Number(hook.ApolloClient.version[0]) !== 1) {
1620
initLinkEvents(hook, bridge);
1721
initBroadCastEvents(hook, bridge);
1822
}
19-
bridge.log("backend ready.");
20-
bridge.send("ready", hook.ApolloClient.version);
23+
bridge.log('backend ready.');
24+
sendBridgeReady();
2125
checkVersions(hook, bridge);
2226
};
2327

24-
export const initBackend = (b, h) => {
28+
export const initBackend = (b, h, uuid) => {
2529
bridge = b;
2630
hook = h;
27-
connect();
31+
connect(uuid);
2832
};

app/worker/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import * as RemoteDev from './remotedev';
1818
import { getRequiredModules, ignoreRNDIntervalSpy } from './utils';
1919
import { toggleNetworkInspect } from './networkInspect';
2020
import Bridge from './apollo/bridge';
21-
import { initBackend } from './apollo/backend';
21+
import { initBackend, sendBridgeReady } from './apollo/backend';
2222

2323
/* eslint-disable no-underscore-dangle */
2424
self.__REMOTEDEV__ = RemoteDev;
@@ -59,28 +59,31 @@ const setupRNDebugger = async message => {
5959
clearInterval(interval);
6060

6161
const hook = {
62-
ApolloClient: self.__APOLLO_CLIENT__
62+
ApolloClient: self.__APOLLO_CLIENT__,
6363
};
6464

6565
let listener;
6666

6767
const bridge = new Bridge({
6868
listen(fn) {
69-
listener = self.addEventListener("message", evt =>
70-
{
71-
if (evt.data.source === "apollo-devtools-proxy" && evt.data.payload) {
69+
listener = self.addEventListener('message', evt => {
70+
if (evt.data.source === 'apollo-devtools-proxy') {
7271
return fn(evt.data);
7372
}
7473
});
7574
},
7675
send(data) {
7776
postMessage({
7877
...data,
79-
source: 'apollo-devtools-backend'
78+
source: 'apollo-devtools-backend',
8079
});
8180
},
8281
});
8382

83+
bridge.on('init', () => {
84+
sendBridgeReady();
85+
});
86+
8487
bridge.on("shutdown", () => {
8588
self.removeEventListener('message', listener);
8689
});

0 commit comments

Comments
 (0)