MCPcopy Create free account
hub / github.com/jhen0409/react-native-debugger / createWindow

Function createWindow

electron/window.js:73–172  ·  view source on GitHub ↗
({ iconPath, isPortSettingRequired, port })

Source from the content-addressed store, hash-verified

71
72const minSize = 100
73export const createWindow = ({ iconPath, isPortSettingRequired, port }) => {
74 const { config, isConfigBroken, error } = readConfig()
75
76 if (isConfigBroken) {
77 dialog.showErrorBox(
78 'Root config error',
79 `Parse root config failed, please checkout \`${configFile}\`, the error trace:\n\n`
80 + `${error}\n\n`
81 + 'RNDebugger will load default config instead. '
82 + 'You can click `Debugger` -> `Open Config File` in application menu.',
83 )
84 }
85
86 const winBounds = store.get('winBounds') || {}
87 const increasePosition = BrowserWindow.getAllWindows().length * 10 || 0
88 const {
89 width, height, x = 0, y = 0,
90 } = winBounds
91 const win = new BrowserWindow({
92 ...winBounds,
93 width: width && width >= minSize ? width : 1024,
94 height: height && height >= minSize ? height : 750,
95 minWidth: minSize,
96 minHeight: minSize,
97 x: x + increasePosition,
98 y: y + increasePosition,
99 backgroundColor: '#272c37',
100 tabbingIdentifier: 'rndebugger',
101 webPreferences: {
102 contextIsolation: false,
103 nodeIntegration: true,
104 // experimentalFeatures: true,
105 // webSecurity: false,
106 // webviewTag: true, // Use this for new inspector in the future
107 },
108 ...config.windowBounds,
109 })
110 enable(win.webContents)
111
112 const isFirstWindow = BrowserWindow.getAllWindows().length === 1
113
114 const { timesJSLoadToRefreshDevTools = -1 } = config
115 win.debuggerConfig = {
116 port,
117 editor: config.editor,
118 fontFamily: config.fontFamily,
119 defaultReactDevToolsTheme: config.defaultReactDevToolsTheme,
120 defaultReactDevToolsPort: config.defaultReactDevToolsPort,
121 networkInspect: config.defaultNetworkInspect && 1,
122 isPortSettingRequired: isPortSettingRequired && 1,
123 timesJSLoadToRefreshDevTools,
124 }
125 win.loadURL(`file://${path.resolve(__dirname)}/app.html`)
126 let unregisterContextMenu
127 win.webContents.on('did-finish-load', () => {
128 win.webContents.zoomLevel = config.zoomLevel || store.get('zoomLevel', 0)
129 win.focus()
130 unregisterContextMenu = registerContextMenu(win)

Callers 4

findWindowFunction · 0.90
main.jsFile · 0.90
darwin.jsFile · 0.90
linux+win.jsFile · 0.90

Calls 10

readConfigFunction · 0.90
registerContextMenuFunction · 0.90
activeTabsFunction · 0.90
catchConsoleLogLinkFunction · 0.90
removeUnecessaryTabsFunction · 0.90
registerShortcutsFunction · 0.85
checkWindowInfoFunction · 0.85
executeJavaScriptFunction · 0.85

Tested by

no test coverage detected