Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion package/src/bun/core/BrowserWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export type WindowOptionsType<T = undefined> = {
// 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 = {
Expand All @@ -54,6 +56,7 @@ const defaultOptions: WindowOptionsType = {
transparent: false,
navigationRules: null,
sandbox: false,
show: true,
};

export const BrowserWindowMap: {
Expand Down Expand Up @@ -112,14 +115,15 @@ export class BrowserWindow<T extends RPCWithTransport = RPCWithTransport> {
this.navigationRules = options.navigationRules || null;
this.sandbox = options.sandbox ?? false;

this.init(options);
this.init({ ...options, show: options.show ?? defaultOptions.show });
}

init({
rpc,
styleMask,
titleBarStyle,
transparent,
show,
}: Partial<WindowOptionsType<T>>) {
this.ptr = ffi.request.createWindow({
id: this.id,
Expand Down Expand Up @@ -162,6 +166,7 @@ export class BrowserWindow<T extends RPCWithTransport = RPCWithTransport> {
},
titleBarStyle: titleBarStyle || "default",
transparent: transparent ?? false,
show: show ?? true,
}) as Pointer;

BrowserWindowMap[this.id] = this;
Expand Down
6 changes: 5 additions & 1 deletion package/src/bun/proc/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ export const ffi = {
};
titleBarStyle: string;
transparent: boolean;
show?: boolean;
}): FFIType.ptr => {
const {
id,
Expand Down Expand Up @@ -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;
},
Expand Down