diff --git a/package/src/bun/core/BrowserWindow.ts b/package/src/bun/core/BrowserWindow.ts index b3ef6991..b78caa14 100644 --- a/package/src/bun/core/BrowserWindow.ts +++ b/package/src/bun/core/BrowserWindow.ts @@ -36,6 +36,8 @@ export type WindowOptionsType = { // Use for untrusted content (remote URLs) to prevent malicious sites from // accessing internal APIs, creating OOPIFs, or communicating with Bun sandbox: boolean; + /** Whether to show the window immediately on creation. Default: true */ + show?: boolean; }; const defaultOptions: WindowOptionsType = { @@ -54,6 +56,7 @@ const defaultOptions: WindowOptionsType = { transparent: false, navigationRules: null, sandbox: false, + show: true, }; export const BrowserWindowMap: { @@ -112,7 +115,7 @@ export class BrowserWindow { this.navigationRules = options.navigationRules || null; this.sandbox = options.sandbox ?? false; - this.init(options); + this.init({ ...options, show: options.show ?? defaultOptions.show }); } init({ @@ -120,6 +123,7 @@ export class BrowserWindow { styleMask, titleBarStyle, transparent, + show, }: Partial>) { this.ptr = ffi.request.createWindow({ id: this.id, @@ -162,6 +166,7 @@ export class BrowserWindow { }, titleBarStyle: titleBarStyle || "default", transparent: transparent ?? false, + show: show ?? true, }) as Pointer; BrowserWindowMap[this.id] = this; diff --git a/package/src/bun/proc/native.ts b/package/src/bun/proc/native.ts index dfeff8e4..76d06203 100644 --- a/package/src/bun/proc/native.ts +++ b/package/src/bun/proc/native.ts @@ -605,6 +605,7 @@ export const ffi = { }; titleBarStyle: string; transparent: boolean; + show?: boolean; }): FFIType.ptr => { const { id, @@ -667,7 +668,10 @@ export const ffi = { } native.symbols.setWindowTitle(windowPtr, toCString(title)); - native.symbols.showWindow(windowPtr); + + if (params.show !== false) { + native.symbols.showWindow(windowPtr); + } return windowPtr; },