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-win-toast-notifier

v0.1.17

Published

node wrapper around windows cli tool https://github.com/ci-mon/win-toast-notifier

Downloads

7

Readme

Win-Toast-Notifier Node.js Wrapper

Node.js wrapper for win-toast-notifier. Allows to interact with user via windows toast notifications.

Complex.jpg

See examples in notifier.test.ts

Install

npm i node-win-toast-notifier

Application id

In order to send desktop notifications application should have registered ID. More details: https://learn.microsoft.com/en-us/windows/win32/shell/appids

Usage in electron

Simple.jpg

import {registerOnSquirrelStartup} from "node-win-toast-notifier";
import {build} from "./../package.json"

// register appid during electron squirrel startup
if (require("electron-squirrel-startup")) {
  (async () => {
    await registerOnSquirrelStartup('com.squirrel.my-app', 'my app', options.icons.green.big_png_win);
    app.quit();
  })();
}

app.on("ready", async () => {
  const notifier = await createNotifier({
    application_id: 'com.squirrel.my-app'
  });
  
  const notification = await notifier.notify({
    body: 'Hello',
    audio: {src: NotificationSounds.SMS},
    actions: [
      {
        actionType: 'input',
        type: 'selection',
        id: 'selectOptions',
        defaultInput: 'option1',
        selection: [
          {
            id: 'option1',
            content: 'Option 1'
          },
          {
            id: 'option2',
            content: 'Option 2'
          }
        ]
      },
      {
        actionType: 'action',
        content: 'Button 1',
        arguments: 'button1Pressed'
      }
    ]
  });
  notification.onChange(statusMessage => {
    if (statusMessage.type == StatusMessageType.Activated){
      if (statusMessage.info?.arguments === 'button1Pressed'){
        console.log(`You pressed button 1`)
      }
    }
  });
});

Sending raw xml notification

You can validate xml content via app https://www.microsoft.com/store/productid/9NBLGGH5XSL1

var notificationXML = `
<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text >Hello</text>
        </binding>
    </visual>
</toast>`;
const notification = await notifier.notifyRaw(notificationXML);

How to copy binary during vite build

vite.main.config.ts

export default defineConfig(async ({command, mode}) => {

  let viteConfig: ResolvedConfig = null, notifierCopied: boolean;
  return {
    plugins: [
      {
        name: 'copy-notifier',
        configResolved(config) {
          viteConfig = config;
        },
        async writeBundle(){
          if (!notifierCopied) {
            notifierCopied = true;
            let source = path.resolve(__dirname, `./node_modules/node-win-toast-notifier/bin/win-toast-notifier.exe`);
            let dest = path.resolve(viteConfig.build.outDir, '../bin');
            fs.mkdirSync(dest);
            fs.copyFileSync(source, path.resolve(dest, "win-toast-notifier.exe"));
            console.info('cimon-desktop-notifier.exe copied!')
          }
          return Promise.resolve(null);
        }
      } as Plugin
    ],
  }
});