Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

native-progress-bar

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

native-progress-bar

This module allows your Electron app to display native dialogs with progress bars in them on Windows and macOS.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

native-progress-bar

This module allows your Electron app to display native dialogs with progress bars in them on Windows and macOS. It has no dependencies other than binding and creates a ~85KB Node addon.

To see various examples for progress bars, check out test/src/progress-bars.js.

Screenshots

Default Style Progress Bar

HUD Style Progress Bar

Utility Style Progress Bar

Application required (macOS)

On macOS, the module only works in Node.js environments that run within a proper application (like Electron). It therefore does not run in simple Node.js scripts that you might execute with node myscript.js.

API

import { ProgressBar } from "native-progress-bar"

let progressBar, interval;

// All arguments are optional
progressBar = new ProgressBar({
  // Window title
  title: "Running disk operation",
  // Message, shown above the progress bar
  message: "Running format C:",
  // Initial progress value
  progress: 0,
  // Can be "hud", "utility", or "default". Only of effect on macOS.
  style: "hud"
  // Zero or more buttons
  buttons: [{
    label: "Cancel",
    click: (progressBar) => {
      console.log("Cancel button clicked");
      progressBar.close();
    }
  }],
  // A function called when the dialog is closed. Useful to cleanup intervals.
  onClose: () => {
    clearInterval(interval);
  },
});

interval = setInterval(() => {
  if (progressBar.progress >= 100) {
    clearInterval(interval);

    // You can dynamically change buttons
    progressBar.buttons = [{
      label: "Done",
      click: (progressBar) => {
        console.log("Done button clicked");
        progressBar.close();
      }
    }]

    return
  }

  progressBar.progress += 1;
}, 200);

What about Linux?

I didn't need Linux but I'd welcome PRs implementing it there.

Keywords

FAQs

Package last updated on 05 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc