File tree Expand file tree Collapse file tree 4 files changed +30
-18
lines changed Expand file tree Collapse file tree 4 files changed +30
-18
lines changed Original file line number Diff line number Diff line change 24
24
"__PLATFORM__",
25
25
"__REPORT_REACT_DEVTOOLS_PORT__",
26
26
"__FETCH_SUPPORT__",
27
- "__NETWORK_INSPECT__"
27
+ "__NETWORK_INSPECT__",
28
+ "__APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__"
28
29
]
29
30
}
30
31
],
Original file line number Diff line number Diff line change @@ -34,10 +34,14 @@ const workerOnMessage = message => {
34
34
const { data } = message ;
35
35
36
36
if ( data . source === 'apollo-devtools-backend' ) {
37
+ if ( ! window . __APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__ ) {
38
+ window . __APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__ = true ;
39
+ }
40
+
37
41
postMessage ( {
38
42
source : 'apollo-devtools-backend' ,
39
43
payload : data ,
40
- } , "*" ) ;
44
+ } , '*' ) ;
41
45
}
42
46
43
47
if ( data && ( data . __IS_REDUX_NATIVE_MESSAGE__ || data . __REPORT_REACT_DEVTOOLS_PORT__ ) ) {
@@ -53,9 +57,10 @@ const workerOnMessage = message => {
53
57
54
58
const onWindowMessage = e => {
55
59
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 } ) ;
57
62
}
58
- }
63
+ } ;
59
64
60
65
const createJSRuntime = ( ) => {
61
66
// This worker will run the application javascript code,
Original file line number Diff line number Diff line change 1
1
// This is the agent that is injected into the page that an Apollo Client app lives in
2
2
// 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' ;
6
6
7
7
// hook should have been injected before this executes.
8
8
let hook ;
9
9
let bridge ;
10
10
let connected ;
11
11
12
+ export const sendBridgeReady = ( ) => {
13
+ bridge . send ( 'ready' , hook . ApolloClient . version ) ;
14
+ } ;
15
+
12
16
const connect = ( ) => {
13
17
if ( connected ) return ;
14
18
connected = true ;
15
19
if ( Number ( hook . ApolloClient . version [ 0 ] ) !== 1 ) {
16
20
initLinkEvents ( hook , bridge ) ;
17
21
initBroadCastEvents ( hook , bridge ) ;
18
22
}
19
- bridge . log ( " backend ready." ) ;
20
- bridge . send ( "ready" , hook . ApolloClient . version ) ;
23
+ bridge . log ( ' backend ready.' ) ;
24
+ sendBridgeReady ( ) ;
21
25
checkVersions ( hook , bridge ) ;
22
26
} ;
23
27
24
- export const initBackend = ( b , h ) => {
28
+ export const initBackend = ( b , h , uuid ) => {
25
29
bridge = b ;
26
30
hook = h ;
27
- connect ( ) ;
31
+ connect ( uuid ) ;
28
32
} ;
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import * as RemoteDev from './remotedev';
18
18
import { getRequiredModules , ignoreRNDIntervalSpy } from './utils' ;
19
19
import { toggleNetworkInspect } from './networkInspect' ;
20
20
import Bridge from './apollo/bridge' ;
21
- import { initBackend } from './apollo/backend' ;
21
+ import { initBackend , sendBridgeReady } from './apollo/backend' ;
22
22
23
23
/* eslint-disable no-underscore-dangle */
24
24
self . __REMOTEDEV__ = RemoteDev ;
@@ -59,29 +59,31 @@ const setupRNDebugger = async message => {
59
59
clearInterval ( interval ) ;
60
60
61
61
const hook = {
62
- ApolloClient : self . __APOLLO_CLIENT__
62
+ ApolloClient : self . __APOLLO_CLIENT__ ,
63
63
} ;
64
64
65
65
const bridge = new Bridge ( {
66
66
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' ) {
70
69
return fn ( evt . data ) ;
71
70
}
72
71
} ) ;
73
72
} ,
74
73
send ( data ) {
75
74
postMessage ( {
76
75
...data ,
77
- source : 'apollo-devtools-backend'
76
+ source : 'apollo-devtools-backend' ,
78
77
} ) ;
79
78
} ,
80
79
} ) ;
81
80
81
+ bridge . on ( 'init' , ( ) => {
82
+ sendBridgeReady ( ) ;
83
+ } ) ;
84
+
82
85
initBackend ( bridge , hook ) ;
83
86
}
84
-
85
87
} , 1000 ) ;
86
88
} ;
87
89
You can’t perform that action at this time.
0 commit comments