MCPcopy
hub / github.com/wavetermdev/waveterm / createBuilderWindow

Function createBuilderWindow

emain/emain-builder.ts:35–121  ·  view source on GitHub ↗
(appId: string)

Source from the content-addressed store, hash-verified

33}
34
35export async function createBuilderWindow(appId: string): Promise<BuilderWindowType> {
36 const builderId = randomUUID();
37
38 const fullConfig = await RpcApi.GetFullConfigCommand(ElectronWshClient);
39 const clientData = await ClientService.GetClientData();
40 const clientId = clientData?.oid;
41 const windowId = randomUUID();
42
43 if (appId) {
44 const oref = `builder:${builderId}`;
45 await RpcApi.SetRTInfoCommand(ElectronWshClient, {
46 oref,
47 data: { "builder:appid": appId },
48 });
49 }
50
51 const winBounds = calculateWindowBounds(undefined, undefined, fullConfig.settings);
52
53 const builderWindow = new BrowserWindow({
54 x: winBounds.x,
55 y: winBounds.y,
56 width: winBounds.width,
57 height: winBounds.height,
58 minWidth: MinWindowWidth,
59 minHeight: MinWindowHeight,
60 titleBarStyle: unamePlatform === "darwin" ? "hiddenInset" : "default",
61 icon:
62 unamePlatform === "linux"
63 ? path.join(getElectronAppBasePath(), "public/logos/wave-logo-dark.png")
64 : undefined,
65 show: false,
66 backgroundColor: "#222222",
67 webPreferences: {
68 preload: path.join(getElectronAppBasePath(), "preload", "index.cjs"),
69 webviewTag: true,
70 },
71 });
72
73 if (isDevVite) {
74 await builderWindow.loadURL(`${process.env.ELECTRON_RENDERER_URL}/index.html`);
75 } else {
76 await builderWindow.loadFile(path.join(getElectronAppBasePath(), "frontend", "index.html"));
77 }
78
79 const initOpts: BuilderInitOpts = {
80 builderId,
81 clientId,
82 windowId,
83 };
84
85 const typedBuilderWindow = builderWindow as BuilderWindowType;
86 typedBuilderWindow.builderId = builderId;
87 typedBuilderWindow.builderAppId = appId;
88 typedBuilderWindow.savedInitOpts = initOpts;
89
90 typedBuilderWindow.on("focus", () => {
91 focusedBuilderWindow = typedBuilderWindow;
92 console.log("builder window focused", builderId);

Callers 1

openBuilderWindowFunction · 0.90

Calls 10

calculateWindowBoundsFunction · 0.90
getElectronAppBasePathFunction · 0.90
loadFileMethod · 0.80
onMethod · 0.80
emitMethod · 0.80
pushMethod · 0.80
GetFullConfigCommandMethod · 0.65
SetRTInfoCommandMethod · 0.65
DeleteBuilderCommandMethod · 0.65
GetClientDataMethod · 0.45

Tested by

no test coverage detected