(appId: string)
| 33 | } |
| 34 | |
| 35 | export 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); |
no test coverage detected