No description
Find a file
renovate[bot] 1d93461dcd
chore(deps): update dependency electron to v29 (#1962)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [electron](https://togithub.com/electron/electron) | [`^28.2.0` -> `^29.0.0`](https://renovatebot.com/diffs/npm/electron/28.2.1/29.0.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/electron/29.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/electron/29.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/electron/28.2.1/29.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/electron/28.2.1/29.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>electron/electron (electron)</summary>

### [`v29.0.0`](https://togithub.com/electron/electron/releases/tag/v29.0.0): electron v29.0.0

[Compare Source](https://togithub.com/electron/electron/compare/v28.2.3...v29.0.0)

### Release Notes for v29.0.0

#### Stack Upgrades

-   Chromium `122.0.6261.39`
    -   [New in 122](https://developer.chrome.com/blog/new-in-chrome-122/)
    -   [New in 121](https://developer.chrome.com/blog/new-in-chrome-121/)
-   Node `20.9.0`
    -   [Node 20.9.0 blog post](https://nodejs.org/en/blog/release/v20.9.0/)
-   V8 `12.2`

#### Breaking Changes

-   Functions called over the `contextBridge` are now called with the expected receiver (`this`). [#&#8203;39978](https://togithub.com/electron/electron/pull/39978) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/40262), [28](https://togithub.com/electron/electron/pull/40263))</span>
-   The `gpu-process-crashed` event on `app` has been deprecated. [#&#8203;40169](https://togithub.com/electron/electron/pull/40169) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/40195))</span>
-   The deprecated `gpu-process-crashed` event on `app` has been removed. [#&#8203;40255](https://togithub.com/electron/electron/pull/40255)
-   The deprecated `renderer-process-crashed` event on `app` and `crashed` event on `WebContents` and `<webview>` have been removed. [#&#8203;40115](https://togithub.com/electron/electron/pull/40115)

#### Features

##### Additions

-   Added `WebContentsView` and `BaseWindow`, replacing the now-deprecated `BrowserView` APIs. [#&#8203;40759](https://togithub.com/electron/electron/pull/40759)
-   Added `keyboardLock` to `ses.setPermissionRequestHandler(handler)`. [#&#8203;40369](https://togithub.com/electron/electron/pull/40369) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/40458), [27](https://togithub.com/electron/electron/pull/40459), [28](https://togithub.com/electron/electron/pull/40460))</span>
-   Added an option in `protocol.registerSchemesAsPrivileged` to allow V8 code cache in custom schemes. [#&#8203;40544](https://togithub.com/electron/electron/pull/40544) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/40708), [28](https://togithub.com/electron/electron/pull/40709))</span>
-   Added net module to utility process. [#&#8203;40890](https://togithub.com/electron/electron/pull/40890) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/40968), [28](https://togithub.com/electron/electron/pull/40967))</span>
-   Added new [Electron Fuse](https://www.electronjs.org/docs/latest/tutorial/fuses) that opts the `file://` protocol into more secure and restrictive behaviour that matches Chromium. [#&#8203;40372](https://togithub.com/electron/electron/pull/40372)
-   Added new `webUtils.getPathForFile` method to replace `File.path` augmentation. [#&#8203;38776](https://togithub.com/electron/electron/pull/38776)
-   Added support for configuring `use_remote_checksums` via `.npmrc`. [#&#8203;40253](https://togithub.com/electron/electron/pull/40253)
-   Migrated `app.{set|get}LoginItemSettings(settings)` to use Apple's new recommended underlying framework on macOS. [#&#8203;37244](https://togithub.com/electron/electron/pull/37244)
-   This PR adds several properties to the `display` object including `detected`, `maximumCursorSize`, and `nativeOrigin`. [#&#8203;40497](https://togithub.com/electron/electron/pull/40497) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/40554))</span>

##### Removed/Deprecated

-   Removed extraneous dlls from Windows zip files. [#&#8203;41129](https://togithub.com/electron/electron/pull/41129) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/41128))</span>

#### Fixes

-   Added support for `ThumbnailCapturerMac` and `ScreenCaptureKitStreamPickerSonoma` chromium feature flags to bypass deprecated API warning on macOS 14.4. [#&#8203;41329](https://togithub.com/electron/electron/pull/41329)
-   Fixed Electron 29.0.0-beta.3 regression that could pop up context menus in the wrong location. [#&#8203;41296](https://togithub.com/electron/electron/pull/41296)
-   Fixed an issue where `import.meta.url` did not work in the renderer process with `contextIsolation` enabled. [#&#8203;41265](https://togithub.com/electron/electron/pull/41265)
-   Fixed an issue where `original-fs` methods were not properly corrected for patched imports. [#&#8203;41238](https://togithub.com/electron/electron/pull/41238)
-   Fixed an issue where draggable regions didn't work across platforms. [#&#8203;41112](https://togithub.com/electron/electron/pull/41112)
-   Fixed crash in MessagePort::close. [#&#8203;41237](https://togithub.com/electron/electron/pull/41237)
-   Fixed the `GrantFileProtocolExtraPrivileges` not correctly preventing `fetch()` calls to `file://` URLs. [#&#8203;40864](https://togithub.com/electron/electron/pull/40864)

##### Also in earlier versions...

-   Apply module search paths restriction on worker and child process. [#&#8203;41138](https://togithub.com/electron/electron/pull/41138) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/41139), [28](https://togithub.com/electron/electron/pull/41137))</span>
-   Backported fix for AVX related crashes on certain linux machines. [#&#8203;40536](https://togithub.com/electron/electron/pull/40536) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/40540), [27](https://togithub.com/electron/electron/pull/40541), [28](https://togithub.com/electron/electron/pull/40542))</span>
-   CSS style `-webkit-app-region: drag;` has no effect in full screen mode. [#&#8203;41332](https://togithub.com/electron/electron/pull/41332) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/41331), [28](https://togithub.com/electron/electron/pull/41330))</span>
-   Fixed "will-navigate" not being emitted when pressing links in `chrome:` pages. [#&#8203;40390](https://togithub.com/electron/electron/pull/40390) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/40524), [28](https://togithub.com/electron/electron/pull/40525))</span>
-   Fixed `session.fromPartition()` key lookup bug. [#&#8203;41084](https://togithub.com/electron/electron/pull/41084) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/41083))</span>
-   Fixed a crash resultant from trying to listen to power-related events before the `ready` event was emitted on Linux. [#&#8203;40925](https://togithub.com/electron/electron/pull/40925) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/40922), [27](https://togithub.com/electron/electron/pull/40923), [28](https://togithub.com/electron/electron/pull/40924))</span>
-   Fixed a crash that started occurring sporadically with some types of macOS window close. [#&#8203;41299](https://togithub.com/electron/electron/pull/41299) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/41298))</span>
-   Fixed a partition alloc ref count check for higher MacOS versions. [#&#8203;40766](https://togithub.com/electron/electron/pull/40766) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/40765))</span>
-   Fixed a potential `async_hooks` crash when listening for the `restore` event on Windows after minimizing a maximized BrowserWindow. [#&#8203;41146](https://togithub.com/electron/electron/pull/41146) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/41144), [28](https://togithub.com/electron/electron/pull/41145))</span>
-   Fixed a potential crash when calling `dialog.showMessageBoxSync`. [#&#8203;41043](https://togithub.com/electron/electron/pull/41043) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/41041), [28](https://togithub.com/electron/electron/pull/41042))</span>
-   Fixed a potential issue with `async_hook` corruption in some error contexts. [#&#8203;40574](https://togithub.com/electron/electron/pull/40574) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/40592), [27](https://togithub.com/electron/electron/pull/40593), [28](https://togithub.com/electron/electron/pull/40594))</span>
-   Fixed a unexpectedly thrown error in some unsupported chrome extensions. [#&#8203;40500](https://togithub.com/electron/electron/pull/40500) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/40512), [27](https://togithub.com/electron/electron/pull/40513), [28](https://togithub.com/electron/electron/pull/40514))</span>
-   Fixed an error changing file format in `dialog.showOpenDialog` on macOS. [#&#8203;40308](https://togithub.com/electron/electron/pull/40308) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/40347), [28](https://togithub.com/electron/electron/pull/40346))</span>
-   Fixed an issue where Request objects did not correctly copy headers into fetches. [#&#8203;41019](https://togithub.com/electron/electron/pull/41019) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/41103))</span>
-   Fixed an issue where WebViews could sometimes crash on unload. [#&#8203;40400](https://togithub.com/electron/electron/pull/40400) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/40443), [27](https://togithub.com/electron/electron/pull/40444), [28](https://togithub.com/electron/electron/pull/40445))</span>
-   Fixed an issue where Windows Toast notifications weren't properly dismissed from the Action Center on `notification.close()` if they'd previously been dismissed. [#&#8203;40197](https://togithub.com/electron/electron/pull/40197) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/40242), [27](https://togithub.com/electron/electron/pull/40244), [28](https://togithub.com/electron/electron/pull/40243))</span>
-   Fixed an issue where `MessagePorts` were not being correctly garbage collected when not referenced. [#&#8203;40189](https://togithub.com/electron/electron/pull/40189) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/40201))</span>
-   Fixed an issue where `inAppPurchase.getProducts` and `inAppPurchase.purchasedProduct` did not resolve as expected. [#&#8203;40957](https://togithub.com/electron/electron/pull/40957) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/40955), [28](https://togithub.com/electron/electron/pull/40956))</span>
-   Fixed an issue where `navigator.keyboard.lock()` did not work per [latest expected behavior](https://developer.chrome.com/blog/better-full-screen-mode). [#&#8203;40365](https://togithub.com/electron/electron/pull/40365) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/40387), [27](https://togithub.com/electron/electron/pull/40388), [28](https://togithub.com/electron/electron/pull/40389))</span>
-   Fixed an issue where `select-usb-device` did not respect the `filter` option in `navigator.usb.requestDevice()`. [#&#8203;41197](https://togithub.com/electron/electron/pull/41197) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/41196), [28](https://togithub.com/electron/electron/pull/41198))</span>
-   Fixed an issue where `webContents.printToPDF` could fail when certain combinations of `margins` and `pageSize` values are passed. [#&#8203;41266](https://togithub.com/electron/electron/pull/41266) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/41267))</span>
-   Fixed an issue where crashes in `node::Environment` destruction potentially wouldn't be propagated to the ` 
    Service ` exit handler. [#&#8203;41301](https://togithub.com/electron/electron/pull/41301) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/41300), [28](https://togithub.com/electron/electron/pull/41302))</span>
-   Fixed an issue where devtools could not be re-opened. [#&#8203;40666](https://togithub.com/electron/electron/pull/40666) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/40679))</span>
-   Fixed an issue where font requests were incorrectly being sent to dev tools multiple times per resource. [#&#8203;40681](https://togithub.com/electron/electron/pull/40681) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/40715), [28](https://togithub.com/electron/electron/pull/40688))</span>
-   Fixed an issue where fully occluded windows would return an empty image from `webContents.capturePage()` on Windows and Linux. [#&#8203;39730](https://togithub.com/electron/electron/pull/39730) <span style="font-size:small;">(Also in [25](https://togithub.com/electron/electron/pull/40186), [26](https://togithub.com/electron/electron/pull/40187), [27](https://togithub.com/electron/electron/pull/40188), [28](https://togithub.com/electron/electron/pull/40185))</span>
-   Fixed an issue where non-modal windows with vibrancy could have incorrectly rounded corners on Sonoma. [#&#8203;41037](https://togithub.com/electron/electron/pull/41037) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/41035), [28](https://togithub.com/electron/electron/pull/41036))</span>
-   Fixed an issue where the `printBackground` option in `webContents.printToPDF` did not work as expected. [#&#8203;41180](https://togithub.com/electron/electron/pull/41180) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/41179))</span>
-   Fixed an issue where zoom level settings did not persist per-session for webviews. [#&#8203;40650](https://togithub.com/electron/electron/pull/40650) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/41269), [28](https://togithub.com/electron/electron/pull/41268))</span>
-   Fixed an issue with webContents interaction with fullscreen and WCO on macOS. [#&#8203;40179](https://togithub.com/electron/electron/pull/40179) <span style="font-size:small;">(Also in [25](https://togithub.com/electron/electron/pull/40220), [26](https://togithub.com/electron/electron/pull/40218), [27](https://togithub.com/electron/electron/pull/40217), [28](https://togithub.com/electron/electron/pull/40219))</span>
-   Fixed app incorrectly activating panel windows on macOS Sonoma. [#&#8203;40307](https://togithub.com/electron/electron/pull/40307) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/40465))</span>
-   Fixed child window opening in non-active macOS apps. [#&#8203;40546](https://togithub.com/electron/electron/pull/40546) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/40657), [27](https://togithub.com/electron/electron/pull/40658), [28](https://togithub.com/electron/electron/pull/40659))</span>
-   Fixed default protocol handler behavior on Windows. [#&#8203;40908](https://togithub.com/electron/electron/pull/40908) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/40909))</span>
-   Fixed file paths passed to `shell.showItemInFolder` not being escaped in Linux. [#&#8203;40527](https://togithub.com/electron/electron/pull/40527) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/40560), [27](https://togithub.com/electron/electron/pull/40561), [28](https://togithub.com/electron/electron/pull/40562))</span>
-   Fixed forked child process not able to send IPC message under some cases on macOS. [#&#8203;41102](https://togithub.com/electron/electron/pull/41102) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/41099), [27](https://togithub.com/electron/electron/pull/41100), [28](https://togithub.com/electron/electron/pull/41101))</span>
-   Fixed incorrect title bar shown on frameless transparent windows. [#&#8203;40862](https://togithub.com/electron/electron/pull/40862) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/40868), [28](https://togithub.com/electron/electron/pull/40867))</span>
-   Fixed loading nested ESM dependencies in `node_modules`
    -   Correctly support the `throwIfNoEntry` option in `fs.statSync`/`fs.lstatSync` in asar files. [#&#8203;40221](https://togithub.com/electron/electron/pull/40221) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/40224))</span>
-   Fixed macOS bug that causes window maximize button to be disabled in full-screen mode. [#&#8203;41029](https://togithub.com/electron/electron/pull/41029) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/41027), [28](https://togithub.com/electron/electron/pull/41028))</span>
-   Fixed on-screen-keyboard not hiding for webviews under some cases. [#&#8203;41149](https://togithub.com/electron/electron/pull/41149) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/41151), [28](https://togithub.com/electron/electron/pull/41150))</span>
-   Fixed problem with bounds of maximized window when  toggle BrowserWindow.setResizable function. [#&#8203;40503](https://togithub.com/electron/electron/pull/40503) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/40580), [27](https://togithub.com/electron/electron/pull/40581), [28](https://togithub.com/electron/electron/pull/40582))</span>
-   Fixed resizing performance issue on macOS. [#&#8203;40577](https://togithub.com/electron/electron/pull/40577) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/40584), [27](https://togithub.com/electron/electron/pull/40585), [28](https://togithub.com/electron/electron/pull/40586))</span>
-   Fixed some redundant permission dialogs while screen sharing on Wayland. [#&#8203;40098](https://togithub.com/electron/electron/pull/40098) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/40191), [27](https://togithub.com/electron/electron/pull/40193), [28](https://togithub.com/electron/electron/pull/40192))</span>
-   Fixed the enabled/disabled behavior of the maximize/fullscreen button of macOS windows. [#&#8203;40897](https://togithub.com/electron/electron/pull/40897) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/40895), [28](https://togithub.com/electron/electron/pull/40896))</span>
-   Prevent node mode to be used as script runner by other apps on macOS. [#&#8203;40579](https://togithub.com/electron/electron/pull/40579) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/40738), [27](https://togithub.com/electron/electron/pull/40737), [28](https://togithub.com/electron/electron/pull/40710))</span>
-   Unset all Node envs in node process when parent is a foreign process. [#&#8203;40881](https://togithub.com/electron/electron/pull/40881) <span style="font-size:small;">(Also in [26](https://togithub.com/electron/electron/pull/40882), [27](https://togithub.com/electron/electron/pull/40879), [28](https://togithub.com/electron/electron/pull/40880))</span>
-   Use `activateIgnoringOtherApps` for focusing non-panels on macOS. [#&#8203;40570](https://togithub.com/electron/electron/pull/40570) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/40621))</span>

#### Other Changes

-   Re-enabled partition alloc on Mac. [#&#8203;33981](https://togithub.com/electron/electron/pull/33981) <span style="font-size:small;">(Also in [28](https://togithub.com/electron/electron/pull/40230))</span>
-   Reverted new WebContentsView and BaseWindow APIs. [#&#8203;41060](https://togithub.com/electron/electron/pull/41060)
-   Security: backported fix for chromium:1517354. [#&#8203;40969](https://togithub.com/electron/electron/pull/40969)

#### Notices

##### End of Support for 26.x.y

Electron 26.x.y has reached end-of-support as per the project's [support policy](https://www.electronjs.org/docs/latest/tutorial/electron-timelines#version-support-policy). Developers and applications are encouraged to upgrade to a newer version of Electron.

### [`v28.2.3`](https://togithub.com/electron/electron/releases/tag/v28.2.3): electron v28.2.3

[Compare Source](https://togithub.com/electron/electron/compare/v28.2.2...v28.2.3)

### Release Notes for v28.2.3

#### Fixes

-   Fixed a crash that started occurring sporadically with some types of macOS window close. [#&#8203;41298](https://togithub.com/electron/electron/pull/41298) <span style="font-size:small;">(Also in [29](https://togithub.com/electron/electron/pull/41299))</span>
-   Fixed an issue where `webContents.printToPDF` could fail when certain combinations of `margins` and `pageSize` values are passed. [#&#8203;41267](https://togithub.com/electron/electron/pull/41267) <span style="font-size:small;">(Also in [29](https://togithub.com/electron/electron/pull/41266))</span>
-   Fixed an issue where crashes in `node::Environment` destruction potentially wouldn't be propagated to the `NodeService` exit handler. [#&#8203;41302](https://togithub.com/electron/electron/pull/41302) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/41300), [29](https://togithub.com/electron/electron/pull/41301))</span>
-   Fixed an issue where zoom level settings did not persist per-session for webviews. [#&#8203;41268](https://togithub.com/electron/electron/pull/41268) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/41269))</span>

#### Other Changes

-   Updated Chromium to 120.0.6099.283. [#&#8203;41262](https://togithub.com/electron/electron/pull/41262)

### [`v28.2.2`](https://togithub.com/electron/electron/releases/tag/v28.2.2): electron v28.2.2

[Compare Source](https://togithub.com/electron/electron/compare/v28.2.1...v28.2.2)

### Release Notes for v28.2.2

#### Fixes

-   Fixed an issue where `select-usb-device` did not respect the `filter` option in `navigator.usb.requestDevice()`. [#&#8203;41198](https://togithub.com/electron/electron/pull/41198) <span style="font-size:small;">(Also in [27](https://togithub.com/electron/electron/pull/41196), [29](https://togithub.com/electron/electron/pull/41197))</span>

#### Other Changes

-   Security: backported fix for [`1511567`](https://togithub.com/electron/electron/commit/1511567).
    -   Security: backported fix for [`1514777`](https://togithub.com/electron/electron/commit/1514777).
    -   Security: backported fix for [`1511085`](https://togithub.com/electron/electron/commit/1511085).
    -   Security: backported fix for [`1519980`](https://togithub.com/electron/electron/commit/1519980). [#&#8203;41178](https://togithub.com/electron/electron/pull/41178)
-   Updated Chromium to 120.0.6099.276. [#&#8203;41195](https://togithub.com/electron/electron/pull/41195)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/napi-rs/napi-rs).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMDAuMCIsInVwZGF0ZWRJblZlciI6IjM3LjIwMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
2024-02-20 15:57:17 +08:00
.cargo fix(napi): compile error for wasm32-unknown-unknown target 2023-11-20 17:10:58 +08:00
.github ci: upgrade toolchain in Docker (#1956) 2024-02-18 13:42:10 +08:00
.husky fix(napi-derive): JsArrayBuffer generated type 2024-01-26 14:32:24 +08:00
.yarn chore(deps): update yarn to v4.1.0 (#1931) 2024-01-31 22:19:33 +08:00
bench feat(cli): brand new cli tool with both cli and programmatical usage (#1492) 2023-04-06 11:04:53 +08:00
cli chore(release): publish 2024-02-19 19:10:51 +08:00
crates fix(napi-derive): napi-derive-backend version 2024-02-20 15:17:43 +08:00
examples style: apply clippy fix (#1953) 2024-02-17 14:12:24 +08:00
images docs: add next.js into README 2021-07-30 13:14:54 +08:00
memory-testing chore: upgrade all dependencies (#1933) 2024-02-01 12:14:56 +08:00
triples chore: upgrade all dependencies (#1933) 2024-02-01 12:14:56 +08:00
wasm-runtime chore: upgrade all dependencies (#1933) 2024-02-01 12:14:56 +08:00
.cirrus.yml feat: add wasm runtime package (#1904) 2024-01-16 23:28:40 +08:00
.dockerignore feat(napi): support musl linux 2020-06-11 16:20:37 +08:00
.editorconfig init 2018-04-28 16:26:38 +08:00
.eslintignore feat(cli): support generate browser compatible codes (#1891) 2024-01-08 21:02:46 +08:00
.eslintrc.yml feat: add wasm runtime package (#1904) 2024-01-16 23:28:40 +08:00
.gitattributes chore: upgrade to yarn3 2022-01-24 17:25:40 +08:00
.gitignore chore: add .idea folder to ignore (#1801) 2023-11-13 10:07:50 +08:00
.npmignore feat: support linux aarch64 2020-10-15 09:12:43 +08:00
.prettierignore chore: upgrade emnapi dependencies (#1817) 2023-11-19 15:13:06 +08:00
.yarnrc.yml chore(deps): update yarn to v4.1.0 (#1931) 2024-01-31 22:19:33 +08:00
alpine-zig.Dockerfile build: upgrade toolchain in Docker (#1810) 2023-11-14 09:58:58 +08:00
alpine.Dockerfile build: update Node.js version in alpine.Dockerfile 2023-03-31 14:19:05 +08:00
Cargo.toml refactor(cli): --profile flag (#1604) 2023-05-27 12:00:43 +08:00
CODE_OF_CONDUCT.md doc: add email to CODE_OF_CONDUCT 2020-05-20 18:49:36 +08:00
debian-aarch64.Dockerfile ci: upgrade toolchain in Docker (#1956) 2024-02-18 13:42:10 +08:00
debian-zig.Dockerfile build: upgrade toolchain in Docker (#1810) 2023-11-14 09:58:58 +08:00
debian.Dockerfile ci: upgrade toolchain in Docker (#1956) 2024-02-18 13:42:10 +08:00
lerna.json ci: add release npm cli 2023-07-18 11:06:45 +08:00
LICENSE docs: update license 2021-01-25 14:12:44 +08:00
package.json chore(deps): update dependency electron to v29 (#1962) 2024-02-20 15:57:17 +08:00
README.md chore: drop node 17, add node 18 2022-04-27 13:17:39 +08:00
renovate.json chore: upgrade all dependencies (#1933) 2024-02-01 12:14:56 +08:00
rustfmt.toml feat(cli): refactor cli build 2021-11-19 18:22:40 +08:00
tsconfig.json fix: prevent crashing when napi_register_module_v1 is called twice (#1554) 2023-04-08 23:08:48 +08:00
tsconfig.root-lint.json feat: add wasm runtime package (#1904) 2024-01-16 23:28:40 +08:00
yarn.lock chore(deps): update dependency electron to v29 (#1962) 2024-02-20 15:57:17 +08:00

napi-rs

This project was initialized from xray

A framework for building compiled Node.js add-ons in Rust via Node-API. Website: https://napi.rs

chat Stake to support us

Platform Support

Test & Release FreeBSD Address Sanitizer Memory Leak Detect

MSRV

Rust 1.65.0

node12 node14 node16 node18 node20
Windows x64
Windows x86
Windows arm64
macOS x64
macOS aarch64
Linux x64 gnu
Linux x64 musl
Linux aarch64 gnu
Linux aarch64 musl
Linux arm gnueabihf
Linux riscv64 gnu N/A N/A
Linux aarch64 android
Linux armv7 android
FreeBSD x64

This library depends on Node-API and requires Node@10.0.0 or later.

We already have some packages written by napi-rs: node-rs

One nice feature is that this crate allows you to build add-ons purely with the Rust/JavaScript toolchain and without involving node-gyp.

Taste

You can start from package-template to play with napi-rs

Define JavaScript functions

/// import the preludes
use napi::bindgen_prelude::*;
use napi_derive::napi;

/// module registration is done by the runtime, no need to explicitly do it now.
#[napi]
fn fibonacci(n: u32) -> u32 {
  match n {
    1 | 2 => 1,
    _ => fibonacci(n - 1) + fibonacci(n - 2),
  }
}

/// use `Fn`, `FnMut` or `FnOnce` traits to defined JavaScript callbacks
/// the return type of callbacks can only be `Result`.
#[napi]
fn get_cwd<T: Fn(String) -> Result<()>>(callback: T) {
  callback(env::current_dir().unwrap().to_string_lossy().to_string()).unwrap();
}

/// or, define the callback signature in where clause
#[napi]
fn test_callback<T>(callback: T)
where T: Fn(String) -> Result<()>
{}

/// async fn, require `async` feature enabled.
/// [dependencies]
/// napi = {version="2", features=["async"]}
#[napi]
async fn read_file_async(path: String) -> Result<Buffer> {
  tokio::fs::read(path)
    .map(|r| match r {
      Ok(content) => Ok(content.into()),
      Err(e) => Err(Error::new(
        Status::GenericFailure,
        format!("failed to read file, {}", e),
      )),
    })
    .await
}

more examples at examples

Building

This repository is a Cargo crate. Any napi-based add-on should contain Cargo.toml to make it a Cargo crate.

In your Cargo.toml you need to set the crate-type to "cdylib" so that cargo builds a C-style shared library that can be dynamically loaded by the Node executable. You'll also need to add this crate as a dependency.

[package]
name = "awesome"

[lib]
crate-type = ["cdylib"]

[dependencies]
napi = "2"
napi-derive = "2"

[build-dependencies]
napi-build = "1"

And create build.rs in your own project:

// build.rs
extern crate napi_build;

fn main() {
  napi_build::setup();
}

So far, the napi build script has only been tested on macOS Linux Windows x64 MSVC and FreeBSD.

Install the @napi-rs/cli to help you build your Rust codes and copy Dynamic lib file to .node file in case you can require it in your program.

{
  "package": "awesome-package",
  "devDependencies": {
    "@napi-rs/cli": "^1.0.0"
  },
  "napi": {
    "name": "jarvis" // <----------- Config the name of native addon, or the napi command will use the name of `Cargo.toml` for the binary file name.
  },
  "scripts": {
    "build": "napi build --release",
    "build:debug": "napi build"
  }
}

Then you can require your native binding:

require('./jarvis.node')

The module_name would be your package name in your Cargo.toml.

xxx => ./xxx.node

xxx-yyy => ./xxx_yyy.node

You can also copy Dynamic lib file to an appointed location:

napi build [--release] ./dll
napi build [--release] ./artifacts

There are documents which contains more details about the @napi-rs/cli usage.

Testing

Because libraries that depend on this crate must be loaded into a Node executable in order to resolve symbols, all tests are written in JavaScript in the test_module subdirectory.

To run tests:

yarn build:test
yarn test

Features table

Rust Type Node Type NAPI Version Minimal Node version Enable by napi feature
u32 Number 1 v8.0.0
i32/i64 Number 1 v8.0.0
f64 Number 1 v8.0.0
bool Boolean 1 v8.0.0
String/&'a str String 1 v8.0.0
Latin1String String 1 v8.0.0 latin1
UTF16String String 1 v8.0.0
Object Object 1 v8.0.0
serde_json::Map Object 1 v8.0.0 serde-json
serde_json::Value any 1 v8.0.0 serde-json
Array Array 1 v8.0.0
Vec Array 1 v8.0.0
Buffer Buffer 1 v8.0.0
External External 1 v8.0.0
Null null 1 v8.0.0
Undefined/() undefined 1 v8.0.0
Result<()> Error 1 v8.0.0
T: Fn(...) -> Result Function 1 v8.0.0
Async/Future Promise 4 v10.6.0 async
AsyncTask Promise 1 v8.5.0
JsGlobal global 1 v8.0.0
JsSymbol Symbol 1 v8.0.0
Int8Array/Uint8Array ... TypedArray 1 v8.0.0
JsFunction threadsafe function 4 v10.6.0 napi4
BigInt BigInt 6 v10.7.0 napi6