MCPcopy
hub / github.com/vercel/hyper / newWindow

Function newWindow

app/ui/window.ts:21–338  ·  view source on GitHub ↗
(
  options_: BrowserWindowConstructorOptions,
  cfg: configOptions,
  fn?: (win: BrowserWindow) => void
)

Source from the content-addressed store, hash-verified

19import {getWorkingDirectoryFromPID} from 'native-process-working-directory';
20
21export function newWindow(
22 options_: BrowserWindowConstructorOptions,
23 cfg: configOptions,
24 fn?: (win: BrowserWindow) => void
25): BrowserWindow {
26 const classOpts = Object.assign({uid: uuidv4()});
27 app.plugins.decorateWindowClass(classOpts);
28
29 const winOpts: BrowserWindowConstructorOptions = {
30 minWidth: 370,
31 minHeight: 190,
32 backgroundColor: toElectronBackgroundColor(cfg.backgroundColor || '#000'),
33 titleBarStyle: 'hiddenInset',
34 title: 'Hyper.app',
35 // we want to go frameless on Windows and Linux
36 frame: process.platform === 'darwin',
37 transparent: process.platform === 'darwin',
38 icon,
39 show: Boolean(process.env.HYPER_DEBUG || process.env.HYPERTERM_DEBUG || isDev),
40 acceptFirstMouse: true,
41 webPreferences: {
42 nodeIntegration: true,
43 navigateOnDragDrop: true,
44 contextIsolation: false
45 },
46 ...options_
47 };
48 const window = new BrowserWindow(app.plugins.getDecoratedBrowserOptions(winOpts));
49
50 // Enable remote module on this window
51 remoteEnable(window.webContents);
52
53 window.uid = classOpts.uid;
54
55 app.plugins.onWindowClass(window);
56 window.uid = classOpts.uid;
57
58 const rpc = createRPC(window);
59 const sessions = new Map<string, Session>();
60
61 const updateBackgroundColor = () => {
62 const cfg_ = app.plugins.getDecoratedConfig();
63 window.setBackgroundColor(toElectronBackgroundColor(cfg_.backgroundColor || '#000'));
64 };
65
66 // set working directory
67 let argPath = process.argv[1];
68 if (argPath && process.platform === 'win32') {
69 if (/[a-zA-Z]:"/.test(argPath)) {
70 argPath = argPath.replace('"', sep);
71 }
72 argPath = normalize(argPath + sep);
73 }
74 let workingDirectory = homeDirectory;
75 if (argPath && isAbsolute(argPath)) {
76 workingDirectory = argPath;
77 } else if (cfg.workingDirectory && isAbsolute(cfg.workingDirectory)) {
78 workingDirectory = cfg.workingDirectory;

Callers 1

createWindowFunction · 0.90

Calls 15

unsetRendererTypeFunction · 0.90
setRendererTypeFunction · 0.90
execCommandFunction · 0.90
updateBackgroundColorFunction · 0.85
fetchNotificationsFunction · 0.85
createSessionFunction · 0.85
deleteSessionsFunction · 0.85
updateFocusTimeFunction · 0.85
testMethod · 0.80
onMethod · 0.80
setMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected