Windows Notification Icons
Because calling it the system tray would be wrong.
Description
Provides fairly direct access to the Win32
Shell_NotifyIcon
API, which allows adding an icon to the notification area, and
support for the related windows APIs to load icons and use context
(e.g. right-click) menus.
Prebuilt as N-API (64-bit only for now, sorry), meaning you don't need Visual Studio or build tools installed on your development machine or CI server.
Note that this is using the Win32 desktop APIs, so you don't need to be running under the UWP (Windows Store) model, and thus has odd limitations like requiring an icon in the notification area to show a notification message, and not supporting notification actions (e.g. buttons).
Usage
The type definitions have fuller jsdoc descriptions, but as a basic overview:
; // Creates an empty (blank) icon in the notification area// that does nothing.// Unfortunately the Windows terminology I'm exposing here is// pretty confusing, they have "Notification icons" that have// icons and can show notifications that also have icons.const emptyIcon = ;// Remove it!emptyIcon; // Creates and adds an initialized icon, with a select callback.const appIcon = icon: Icon // Notify icons should use tooltip: "My icon from nodejs" { // `this` is `target` is `appIcon`. // `rightButton` is which mouse button it was selected with, // `mouseX and `mouseX` are the screen co-ordinates of the click. // If selected with the keyboard, these values will be simulated. if rightButton ; else // some default action, or just show the same menu. }; // Notifications should use the size `Icon.large`.// Icons can be loaded ahead of time to catch errors earlier,// and save a bit of time and memory.const notificationIcon = Icon;// You can also use some built-in icons, for example:const errorIcon = Icon; const toggleId = 1;const notificationId = 2;const submenuId = 3; const menu = id: toggleId text: "Toggle item" checked: true id: notificationId text: "Show notification" separator: true text: "Sub-menu" items: id: submenuId text: "Sub-menu item" ; { const id = menu; }