Files
react-native/packages/debugger-shell/src/electron/preload.js
T
Tim Yung e8e51ac1fb RN: Flowify Remaining Files (#51822)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51822

Adds `flow` to the remaining files without it, in React Native.

After this, every `*.{flow,js}` file in React Native will have either `flow` or `noflow`.

Changelog:
[Internal]

Reviewed By: NickGerleman

Differential Revision: D75980238

fbshipit-source-id: 84cd88e4eb0b0b1dc69df247de79a75c2119bf96
2025-06-04 19:33:54 -07:00

46 lines
1.4 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
// $FlowFixMe[prop-missing]
const {contextBridge, ipcRenderer} = require('electron');
contextBridge.executeInMainWorld({
func: ipcDevTools => {
let didDecorateInspectorFrontendHostInstance = false;
// reactNativeDecorateInspectorFrontendHostInstance was introduced in
// https://github.com/facebook/react-native-devtools-frontend/pull/168
// $FlowIgnore[prop-missing]
globalThis.reactNativeDecorateInspectorFrontendHostInstance = (
InspectorFrontendHostInstance: $FlowFixMe,
) => {
didDecorateInspectorFrontendHostInstance = true;
InspectorFrontendHostInstance.bringToFront = () => {
ipcDevTools.bringToFront();
};
};
document.addEventListener('DOMContentLoaded', () => {
if (!didDecorateInspectorFrontendHostInstance) {
console.error(
'reactNativeDecorateInspectorFrontendHostInstance was not called at startup. ' +
'This version of the DevTools frontend may not be compatible with @react-native/debugger-shell.',
);
}
});
},
args: [
{
bringToFront() {
ipcRenderer.send('bringToFront');
},
},
],
});