Skip to content

Commit

Permalink
Merge pull request rancher-sandbox#8122 from mook-as/bump/electron-34
Browse files Browse the repository at this point in the history
Electron: Bump to Electron 34
  • Loading branch information
jandubois authored Jan 22, 2025
2 parents 60bc2de + 1638707 commit e61181d
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 106 deletions.
6 changes: 1 addition & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ updates:
# we ignore everything higher than 11.
dependency-name: "@nuxtjs/eslint-config-typescript"
versions: [">11"]
- # Electron major bumps are too complicated; we need to do those manually.
dependency-name: "electron"
update-types: ["version-update:semver-major"]
- # node-fetch 3+ requires ECMAScript modules, but Electron doesn't
# support that. See https://github.com/electron/electron/issues/21457
- # node-fetch 3+ requires ECMAScript modules; we still have issues with them.
dependency-name: "node-fetch"
versions: [">2"]
- # This needs to be done in lockstep with node-fetch.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"cross-env": "7.0.3",
"css-loader": "7.1.2",
"ejs": "3.1.10",
"electron": "30.5.1",
"electron": "34.0.0",
"electron-builder": "25.1.8",
"eslint": "8.57.1",
"eslint-plugin-deprecation": "3.0.0",
Expand Down
22 changes: 20 additions & 2 deletions pkg/rancher-desktop/main/extensions/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ export class ExtensionManagerImpl implements ExtensionManager {
this.setMainHandler('extensions/vm/http-fetch', async(event, config) => {
const extensionId = this.getExtensionIdFromEvent(event);

if (!extensionId) {
return; // Sender frame has gone away, no need to fetch anymore.
}
if (extensionId === EXTENSION_APP) {
throw new Error('HTTP fetch from main app not implemented yet');
}
Expand Down Expand Up @@ -426,8 +429,14 @@ export class ExtensionManagerImpl implements ExtensionManager {
/**
* Given an IpcMainEvent, return the extension ID associated with it.
*/
protected getExtensionIdFromEvent(event: IpcMainEvent | IpcMainInvokeEvent): string {
const origin = new URL(event.senderFrame.origin);
protected getExtensionIdFromEvent(event: IpcMainEvent | IpcMainInvokeEvent): string | undefined {
const { senderFrame } = event;

if (!senderFrame) {
return;
}

const origin = new URL(senderFrame.origin);

return origin.protocol === 'app:' ? EXTENSION_APP : Buffer.from(origin.hostname, 'hex').toString();
}
Expand All @@ -436,6 +445,9 @@ export class ExtensionManagerImpl implements ExtensionManager {
protected async spawnHost(event: IpcMainEvent | IpcMainInvokeEvent, options: SpawnOptions): Promise<ReadableChildProcess> {
const extensionId = this.getExtensionIdFromEvent(event);

if (!extensionId) {
throw new Error(`spawning process from a closed window`);
}
if (extensionId === EXTENSION_APP) {
throw new Error(`spawning a process from the main application is not implemented yet: ${ options.command.join(' ') }`);
}
Expand Down Expand Up @@ -467,6 +479,9 @@ export class ExtensionManagerImpl implements ExtensionManager {
protected async spawnDockerCli(event: IpcMainEvent | IpcMainInvokeEvent, options: SpawnOptions): Promise<ReadableChildProcess> {
const extensionId = this.getExtensionIdFromEvent(event);

if (!extensionId) {
throw new Error(`Spawning docker client from closed sender frame`);
}
if (extensionId !== EXTENSION_APP) {
const extension = await this.getExtension(extensionId) as ExtensionImpl;

Expand All @@ -486,6 +501,9 @@ export class ExtensionManagerImpl implements ExtensionManager {
protected async spawnContainer(event: IpcMainEvent | IpcMainInvokeEvent, options: SpawnOptions): Promise<ReadableChildProcess> {
const extensionId = this.getExtensionIdFromEvent(event);

if (!extensionId) {
throw new Error(`Spawning docker client from closed sender frame`);
}
if (extensionId === EXTENSION_APP) {
throw new Error(`Spawning a container command is not implemented for the main app: ${ options.command.join(' ') }`);
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/rancher-desktop/main/mainmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ function getPreferencesMenuItem(): MenuItemConstructorOptions[] {
* @param focusedWindow The window that has focus
* @param zoomLevelAdjustment The desired increment to adjust the zoom level by
*/
function adjustZoomLevel(focusedWindow: Electron.BrowserWindow | undefined, zoomLevelAdjustment: number) {
if (!focusedWindow) {
function adjustZoomLevel(focusedWindow: Electron.BaseWindow | undefined, zoomLevelAdjustment: number) {
if (!focusedWindow || !(focusedWindow instanceof Electron.BrowserWindow)) {
return;
}

Expand Down
Loading

0 comments on commit e61181d

Please sign in to comment.