new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

Electron · all subjects

native apis

11 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

app.runningUnderRosettaTranslation removed, use runningUnderARM64Translation

The `app.runningUnderRosettaTranslation` property has been removed. Use `app.runningUnderARM64Translation` instead.

systemPreferences color scheme events removed, use nativeTheme.updated

The following `systemPreferences` events have been removed: `inverted-color-scheme-changed` and `high-contrast-color-scheme-changed`. Use the new `updated` event on the `nativeTheme` module instead: `nativeTheme.on('updated', () => { ... })`.

systemPreferences appearance methods removed, use nativeTheme

The following `systemPreferences` methods and properties have been removed: `systemPreferences.getAppLevelAppearance()`, `systemPreferences.setAppLevelAppearance()`, and `systemPreferences.appLevelAppearance`. Use the `nativeTheme` module instead: `nativeTheme.shouldUseDarkColors` and `nativeTheme.themeSource`.

systemPreferences.getColor alternate-selected-control-text removed

The `alternate-selected-control-text` value for `systemPreferences.getColor` has been removed. Use `selected-content-background` instead.

desktopCapturer.getSources moved to main process only

The `desktopCapturer.getSources` API is now only available in the main process, not in the renderer. This change improves the default security of Electron apps. In the main process, use `ipcMain.handle` to expose it via IPC to the renderer.

desktopCapturer.getSources example with IPC

Example of exposing desktopCapturer.getSources via IPC: In main process: `ipcMain.handle('DESKTOP_CAPTURER_GET_SOURCES', (event, opts) => desktopCapturer.getSources(opts))`. In renderer process: `const desktopCapturer = { getSources: (opts) => ipcRenderer.invoke('DESKTOP_CAPTURER_GET_SOURCES', opts) }`.

shell.moveItemToTrash removed, use shell.trashItem

The deprecated synchronous `shell.moveItemToTrash()` API has been removed. Use the asynchronous `shell.trashItem(path).then(/* ... */)` instead.

systemPreferences dark mode methods removed, use nativeTheme

The following `systemPreferences` methods have been removed: `isDarkMode()`, `isInvertedColorScheme()`, `isHighContrastColorScheme()`. Use the corresponding `nativeTheme` properties instead: `shouldUseDarkColors`, `shouldUseInvertedColorScheme`, `shouldUseHighContrastColors`.

shell.openItem replaced with shell.openPath

The `shell.openItem()` API has been replaced with an asynchronous `shell.openPath()` API.

powerMonitor.querySystemIdleState replaced with getSystemIdleState

The `powerMonitor.querySystemIdleState(threshold, callback)` API has been replaced with synchronous `powerMonitor.getSystemIdleState(threshold)` that returns the idle state directly.

powerMonitor.querySystemIdleTime replaced with getSystemIdleTime

The `powerMonitor.querySystemIdleTime(callback)` API has been replaced with synchronous `powerMonitor.getSystemIdleTime()` that returns the idle time directly.

Give your agent this brain