Skip to content
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ vitest.config.*.timestamp*
.history

build
out
out
pnpm-lock.yaml
Copy link
Copy Markdown
Contributor

@Bram-Zijp Bram-Zijp Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed the notification of this pull request and haven't looked at it in a while. The pnpm-lock.yaml should not be gitignored. By committing this, the package versions remain stable unless you manually bump them. This also adds security as it contains the module package hashes. When hackers push to an pre-existing version, this hash will prevent it from getting automatically installed as the hash would be changed.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@ app.whenReady().then(() => {
setupWindowRouter({
preload: join(__dirname, '../preload/index.js'),
mainWindow,
setupWindowHooks: (browserWindow) => {
setupWindowHooks: (browserWindow, context) => {
browserWindow.webContents.setWindowOpenHandler((details) => {
shell.openExternal(details.url);
return { action: 'deny' };
});

console.log(context); // To get the window config and id
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind this change but I would be interested in knowing the use-case for the context here.


if (process.env['ELECTRON_RENDERER_URL']) {
browserWindow.loadURL(process.env['ELECTRON_RENDERER_URL']);
} else {
Expand Down
12 changes: 10 additions & 2 deletions src/main/setupWindowRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ type Windows = Record<
}
>;

export type WindowHooksContext = {
id?: string;
windowConfig?: PublicWindowConfig;
};

export function setupWindowRouter({
preload,
mainWindow,
Expand All @@ -26,7 +31,7 @@ export function setupWindowRouter({
preload: string;
mainWindow: BrowserWindow;
windows?: Windows;
setupWindowHooks?: (browserWindow: BrowserWindow) => unknown;
setupWindowHooks?: (browserWindow: BrowserWindow, context?: WindowHooksContext) => unknown;
}) {
const windowMap = new Map<string, BrowserWindow>();
const windowConfigsFromRenderer = new Map<string, PublicWindowConfig>();
Expand Down Expand Up @@ -59,7 +64,10 @@ export function setupWindowRouter({
...constructorOptions?.webPreferences,
},
});
setupWindowHooks?.(newWindow);
setupWindowHooks?.(newWindow, {
id: arg.id,
windowConfig: windowConfigFromArg,
});
windowConfig?.extraWindowHooks?.(newWindow);
newWindow.on('ready-to-show', () => {
newWindow.webContents.send(
Expand Down