Skip to content

Commit 2ad5bce

Browse files
committed
RDX: Update preload script loading
Electron has a new API for dealing with preload scripts now; use that instead of the previous API, which they are likely to remove. Signed-off-by: Mark Yen <mark.yen@suse.com>
1 parent b0369fb commit 2ad5bce

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

pkg/rancher-desktop/window/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,20 @@ function createView() {
211211
const webPreferences: Electron.WebPreferences = {
212212
nodeIntegration: false,
213213
contextIsolation: true,
214-
preload: path.join(paths.resources, 'preload.js'),
215214
sandbox: true,
216215
additionalArguments: [JSON.stringify(hostInfo)],
217216
};
218217

219218
if (currentExtension?.id) {
220219
webPreferences.partition = `persist:rdx-${ currentExtension.id }`;
221-
const webRequest = Electron.session.fromPartition(webPreferences.partition).webRequest;
220+
const session = Electron.session.fromPartition(webPreferences.partition);
221+
const { webRequest } = session;
222+
223+
session.registerPreloadScript({
224+
id: `rdx-preload-${ currentExtension.id }`,
225+
filePath: path.join(paths.resources, 'preload.js'),
226+
type: 'frame',
227+
});
222228

223229
webRequest.onBeforeSendHeaders((details, callback) => {
224230
const source = details.webContents?.getURL() ?? '';

0 commit comments

Comments
 (0)