| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | * |
| 7 | * @flow |
| 8 | */ |
| 9 | |
| 10 | import {register} from './DevToolsCdtMcp.js'; |
| 11 | |
| 12 | // Side effect: install the facade (before React) and register the React tool |
| 13 | // group for chrome-devtools-mcp. Import this module before React. |
| 14 | if ( |
| 15 | typeof window !== 'undefined' && |
| 16 | typeof window.addEventListener === 'function' && |
| 17 | typeof window.removeEventListener === 'function' |
| 18 | ) { |
| 19 | register(); |
| 20 | } else { |
| 21 | // eslint-disable-next-line react-internal/prod-error-codes |
| 22 | throw new Error( |
| 23 | 'react-devtools-cdt-mcp/register must be imported in a browser-like ' + |
| 24 | 'environment before React initializes. Use the root entry point for ' + |
| 25 | 'side-effect-free access to register().', |
| 26 | ); |
| 27 | } |
| 28 | |
| 29 | export * from './DevToolsCdtMcp.js'; |