Skip to content

Commit d65706a

Browse files
JiaLiPassionatscott
authored andcommitted
feat(zone.js): update electron patch to support electron/remote 14 (#45073)
Close #43346 From electron 14, the `CallbacksRegistry` is moved to `@electron/remote` package, so all `remote` call between `main` process and `renderer` process is not being patched since the new version of electron released. Also `CallbacksRegistry` is not exported outside, so this commit make a `hack` patch to load `CallbacksRegistry` from `@electron/remote/dist/src/renderer/callbacks-registry` for patching. PR Close #45073
1 parent 4fa5307 commit d65706a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/zone.js/lib/extra/electron.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,17 @@ Zone.__load_patch('electron', (global: any, Zone: ZoneType, api: _ZonePrivate) =
1111
return delegate && delegate.apply(self, api.bindArguments(args, source));
1212
});
1313
}
14-
const {desktopCapturer, shell, CallbacksRegistry, ipcRenderer} = require('electron');
14+
let {desktopCapturer, shell, CallbacksRegistry, ipcRenderer} = require('electron');
15+
if (!CallbacksRegistry) {
16+
try {
17+
// Try to load CallbacksRegistry class from @electron/remote src
18+
// since from electron 14+, the CallbacksRegistry is moved to @electron/remote
19+
// pacakge and not exported to outside, so this is a hack to patch CallbacksRegistry.
20+
CallbacksRegistry =
21+
require('@electron/remote/dist/src/renderer/callbacks-registry').CallbacksRegistry;
22+
} catch (err) {
23+
}
24+
}
1525
// patch api in renderer process directly
1626
// desktopCapturer
1727
if (desktopCapturer) {

0 commit comments

Comments
 (0)