MCPcopy Create free account
hub / github.com/Kong/insomnia / createPluginWindow

Function createPluginWindow

packages/insomnia/src/main/plugin-window.ts:177–215  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

175}
176
177export function createPluginWindow() {
178 if (pluginWindow && !pluginWindow.isDestroyed()) {
179 return;
180 }
181
182 ensureIpcListeners();
183
184 pluginWindow = new BrowserWindow({
185 show: false,
186 title: 'PluginWindow',
187 webPreferences: {
188 contextIsolation: false,
189 nodeIntegration: true,
190 preload: path.join(__dirname, 'entry.plugin-window-preload.min.js'),
191 backgroundThrottling: false,
192 devTools: process.env.NODE_ENV === 'development',
193 },
194 });
195
196 pluginWindow.on('closed', () => {
197 pluginWindow = null;
198 windowReady = false;
199 for (const [id, { reject }] of pendingRequests) {
200 pendingRequests.delete(id);
201 reject(new Error('[plugin-window] window closed'));
202 }
203 });
204
205 pluginWindow.webContents.on('render-process-gone', (_event, details) => {
206 bridgeMetrics.windowCrashes += 1;
207 console.log(`[plugin-bridge] window_crash reason=${details.reason} exit_code=${details.exitCode}`);
208 });
209
210 bridgeMetrics.windowStartups += 1;
211 bridgeMetrics.lastStartupAt = Date.now();
212 const pluginWindowPath = path.resolve(__dirname, 'plugin-window.html');
213 pluginWindow.loadFile(pluginWindowPath);
214 console.log(`[plugin-bridge] window_loading path=${pluginWindowPath} startups_total=${bridgeMetrics.windowStartups}`);
215}
216
217function waitForReady(timeoutMs = 10_000): Promise<void> {
218 if (windowReady) {

Callers 4

createWindowFunction · 0.90
invokeInPluginWindowFunction · 0.85

Calls 4

ensureIpcListenersFunction · 0.85
onMethod · 0.80
logMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected