npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-mac-notifier

v1.2.0

Published

Create macOS system notifications from Node.js

Downloads

39

Readme

node-mac-notifier

A native Node module that lets you create macOS notifications from Node.js, without dishing out to a separate process. This is useful for desktop applications built with Electron (or something similar), as it adheres to the HTML5 Notification API.

Installation

npm install node-mac-notifier

Usage

Ensure that this module is called from a renderer process; it will have no effect in the main process. Works with Electron >=0.37.7.

const Notification = require('node-mac-notifier');
const notification = new Notification('Hello from node-mac-notifier', { body: 'It works!' });
notification.addEventListener('click', () => console.log('Got a click'));

In addition to the standard click event, these notifications also support a (non-standard) reply event. To enable the reply button, set canReply in the options argument. The user's response is included as a parameter on the event:

const notification = new Notification('Wow, replies!', { canReply: true });
notification.addEventListener('reply', ({ response }) => {
  console.log(`User entered: ${response}`);
});

API

new Notification(title, options)

title (string) (required)

The title of the notification.

options (Object)

Additional parameters to the notification.

  • options.id (string)

    A string identifying the notification. Maps to NSUserNotification.identifier. A notification with an id matching a previously delivered notification will not be shown. If not provided, defaults to a RFC4122 v4 string. Note that if you repeatedly create notifications with the same ID, only the first instance will be shown and future instances will not appear until that instance is closed.

  • options.body (string)

    The body text. Maps to NSUserNotification.informativeText.

  • options.subtitle (string)

    The subtitle text. Maps to NSUserNotification.subtitle.

  • options.icon (string)

    A URL with image content. Maps to NSUserNotification.contentImage. Should be an absolute URL.

  • options.soundName (string)

    The name of a sound file to play once the notification is delivered. Maps to NSUserNotification.soundName. Set to default to use NSUserNotificationDefaultSoundName, or leave undefined for a silent notification.

  • options.canReply (bool)

    If true, this notification will have a reply action button, and can emit the reply event. Maps to NSUserNotification.hasReplyButton.

  • options.bundleId (string)

    Set this to override the NSBundle.bundleIdentifier used for the notification. This is a brute force way for your notifications to take on the appropriate app icon.

close()

Dismisses the notification immediately.