@@ -319,57 +319,59 @@ export class ApolloClient<TCacheShape> implements DataProxy {
319
319
}
320
320
321
321
private connectToDevTools ( ) {
322
- if ( typeof window === "object" ) {
323
- type DevToolsConnector = {
324
- push ( client : ApolloClient < any > ) : void ;
325
- } ;
326
- const windowWithDevTools = window as Window & {
327
- [ devtoolsSymbol ] ?: DevToolsConnector ;
328
- __APOLLO_CLIENT__ ?: ApolloClient < any > ;
329
- } ;
330
- const devtoolsSymbol = Symbol . for ( "apollo.devtools" ) ;
331
- ( windowWithDevTools [ devtoolsSymbol ] =
332
- windowWithDevTools [ devtoolsSymbol ] || ( [ ] as DevToolsConnector ) ) . push (
333
- this
334
- ) ;
335
- windowWithDevTools . __APOLLO_CLIENT__ = this ;
322
+ if ( typeof window === "undefined" ) {
323
+ return ;
336
324
}
337
325
326
+ type DevToolsConnector = {
327
+ push ( client : ApolloClient < any > ) : void ;
328
+ } ;
329
+ const windowWithDevTools = window as Window & {
330
+ [ devtoolsSymbol ] ?: DevToolsConnector ;
331
+ __APOLLO_CLIENT__ ?: ApolloClient < any > ;
332
+ } ;
333
+ const devtoolsSymbol = Symbol . for ( "apollo.devtools" ) ;
334
+ ( windowWithDevTools [ devtoolsSymbol ] =
335
+ windowWithDevTools [ devtoolsSymbol ] || ( [ ] as DevToolsConnector ) ) . push (
336
+ this
337
+ ) ;
338
+ windowWithDevTools . __APOLLO_CLIENT__ = this ;
339
+
338
340
/**
339
341
* Suggest installing the devtools for developers who don't have them
340
342
*/
341
343
if ( ! hasSuggestedDevtools && __DEV__ ) {
342
344
hasSuggestedDevtools = true ;
343
- setTimeout ( ( ) => {
344
- if (
345
- typeof window !== "undefined" &&
346
- window . document &&
347
- window . top === window . self &&
348
- ! ( window as any ) . __APOLLO_DEVTOOLS_GLOBAL_HOOK__ &&
349
- / ^ ( h t t p s ? | f i l e ) : $ / . test ( window . location . protocol )
350
- ) {
351
- const nav = window . navigator ;
352
- const ua = nav && nav . userAgent ;
353
- let url : string | undefined ;
354
- if ( typeof ua === "string" ) {
355
- if ( ua . indexOf ( "Chrome/" ) > - 1 ) {
356
- url =
357
- "https://chrome.google.com/webstore/detail/" +
358
- "apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm" ;
359
- } else if ( ua . indexOf ( "Firefox/" ) > - 1 ) {
360
- url =
361
- "https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/" ;
345
+ if (
346
+ window . document &&
347
+ window . top === window . self &&
348
+ / ^ ( h t t p s ? | f i l e ) : $ / . test ( window . location . protocol )
349
+ ) {
350
+ setTimeout ( ( ) => {
351
+ if ( ! ( window as any ) . __APOLLO_DEVTOOLS_GLOBAL_HOOK__ ) {
352
+ const nav = window . navigator ;
353
+ const ua = nav && nav . userAgent ;
354
+ let url : string | undefined ;
355
+ if ( typeof ua === "string" ) {
356
+ if ( ua . indexOf ( "Chrome/" ) > - 1 ) {
357
+ url =
358
+ "https://chrome.google.com/webstore/detail/" +
359
+ "apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm" ;
360
+ } else if ( ua . indexOf ( "Firefox/" ) > - 1 ) {
361
+ url =
362
+ "https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/" ;
363
+ }
364
+ }
365
+ if ( url ) {
366
+ invariant . log (
367
+ "Download the Apollo DevTools for a better development " +
368
+ "experience: %s" ,
369
+ url
370
+ ) ;
362
371
}
363
372
}
364
- if ( url ) {
365
- invariant . log (
366
- "Download the Apollo DevTools for a better development " +
367
- "experience: %s" ,
368
- url
369
- ) ;
370
- }
371
- }
372
- } , 10000 ) ;
373
+ } , 10000 ) ;
374
+ }
373
375
}
374
376
}
375
377
0 commit comments