Files
react/packages/react-devtools/app.js
Jan Kassens 64fe791be8 Flow upgrade to 0.146
This upgrade made more expressions invalidate refinements. In some
places this lead to a large number of suppressions that I automatically
suppressed and should be followed up on when the code is touched.
I think most of them might require either manual annotations or moving
a value into a const to allow refinement.

ghstack-source-id: a45b40abf0
Pull Request resolved: https://github.com/facebook/react/pull/25410
2022-10-04 11:01:50 -04:00

66 lines
1.9 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
const {app, BrowserWindow} = require('electron'); // Module to create native browser window.
const {join} = require('path');
const os = require('os');
const argv = require('minimist')(process.argv.slice(2));
const projectRoots = argv._;
let mainWindow = null;
app.on('window-all-closed', function() {
app.quit();
});
app.on('ready', function() {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 600,
icon: join(__dirname, 'icons/icon128.png'),
frame: false,
//titleBarStyle: 'customButtonsOnHover',
webPreferences: {
nodeIntegration: true,
nodeIntegrationInWorker: true,
},
});
// set dock icon for macos
if (os.platform() === 'darwin') {
app.dock.setIcon(join(__dirname, 'icons/icon128.png'));
}
// https://stackoverflow.com/questions/32402327/
// $FlowFixMe[incompatible-use] found when upgrading Flow
mainWindow.webContents.on('new-window', function(event, url) {
event.preventDefault();
require('electron').shell.openExternal(url);
});
// and load the index.html of the app.
// $FlowFixMe[incompatible-use] found when upgrading Flow
mainWindow.loadURL('file://' + __dirname + '/app.html'); // eslint-disable-line no-path-concat
// $FlowFixMe[incompatible-use] found when upgrading Flow
mainWindow.webContents.executeJavaScript(
// We use this so that RN can keep relative JSX __source filenames
// but "click to open in editor" still works. js1 passes project roots
// as the argument to DevTools.
'window.devtools.setProjectRoots(' + JSON.stringify(projectRoots) + ')',
);
// Emitted when the window is closed.
// $FlowFixMe[incompatible-use] found when upgrading Flow
mainWindow.on('closed', function() {
mainWindow = null;
});
});