1. /**
    
  2.  * In order to support reload-and-profile functionality, the renderer needs to be injected before any other scripts.
    
  3.  * Since it is a complex file (with imports) we can't just toString() it like we do with the hook itself,
    
  4.  * So this entry point (one of the web_accessible_resources) provides a way to eagerly inject it.
    
  5.  * The hook will look for the presence of a global __REACT_DEVTOOLS_ATTACH__ and attach an injected renderer early.
    
  6.  * The normal case (not a reload-and-profile) will not make use of this entry point though.
    
  7.  *
    
  8.  * @flow
    
  9.  */
    
  10. 
    
  11. import {attach} from 'react-devtools-shared/src/backend/renderer';
    
  12. import {SESSION_STORAGE_RELOAD_AND_PROFILE_KEY} from 'react-devtools-shared/src/constants';
    
  13. import {sessionStorageGetItem} from 'react-devtools-shared/src/storage';
    
  14. 
    
  15. if (
    
  16.   sessionStorageGetItem(SESSION_STORAGE_RELOAD_AND_PROFILE_KEY) === 'true' &&
    
  17.   !window.hasOwnProperty('__REACT_DEVTOOLS_ATTACH__')
    
  18. ) {
    
  19.   Object.defineProperty(
    
  20.     window,
    
  21.     '__REACT_DEVTOOLS_ATTACH__',
    
  22.     ({
    
  23.       enumerable: false,
    
  24.       // This property needs to be configurable to allow third-party integrations
    
  25.       // to attach their own renderer. Note that using third-party integrations
    
  26.       // is not officially supported. Use at your own risk.
    
  27.       configurable: true,
    
  28.       get() {
    
  29.         return attach;
    
  30.       },
    
  31.     }: Object),
    
  32.   );
    
  33. }