File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 ],
Original file line number Diff line number Diff 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
5458const onWindowMessage = e => {
5559 if ( e . data && e . data . source === 'apollo-devtools-proxy' ) {
56- worker . postMessage ( { source : 'apollo-devtools-proxy' , event : e . data . payload . event , payload : e . data . payload . 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
6065const createJSRuntime = ( ) => {
6166 // This worker will run the application javascript code,
Original file line number Diff line number Diff line change 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.
88let hook ;
99let bridge ;
1010let connected ;
1111
12+ export const sendBridgeReady = ( ) => {
13+ bridge . send ( 'ready' , hook . ApolloClient . version ) ;
14+ } ;
15+
1216const 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} ;
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import * as RemoteDev from './remotedev';
1818import { getRequiredModules , ignoreRNDIntervalSpy } from './utils' ;
1919import { toggleNetworkInspect } from './networkInspect' ;
2020import Bridge from './apollo/bridge' ;
21- import { initBackend } from './apollo/backend' ;
21+ import { initBackend , sendBridgeReady } from './apollo/backend' ;
2222
2323/* eslint-disable no-underscore-dangle */
2424self . __REMOTEDEV__ = RemoteDev ;
@@ -59,29 +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 const bridge = new Bridge ( {
6666 listen ( fn ) {
67- self . addEventListener ( "message" , evt =>
68- {
69- if ( evt . data . source === "apollo-devtools-proxy" && evt . data . payload ) {
67+ self . addEventListener ( 'message' , evt => {
68+ if ( evt . data . source === 'apollo-devtools-proxy' ) {
7069 return fn ( evt . data ) ;
7170 }
7271 } ) ;
7372 } ,
7473 send ( data ) {
7574 postMessage ( {
7675 ...data ,
77- source : 'apollo-devtools-backend'
76+ source : 'apollo-devtools-backend' ,
7877 } ) ;
7978 } ,
8079 } ) ;
8180
81+ bridge . on ( 'init' , ( ) => {
82+ sendBridgeReady ( ) ;
83+ } ) ;
84+
8285 initBackend ( bridge , hook ) ;
8386 }
84-
8587 } , 1000 ) ;
8688} ;
8789
You can’t perform that action at this time.
0 commit comments