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

@bindrs/rfd

v2.2.2

Published

πŸ“‚ Lets you open native file picker and message boxes in JavaScript!

Downloads

12

Readme

Rusty File Dialogs for JavaScript

πŸ“‚ Lets you open native file picker and message boxes in JavaScript!

πŸ‘¨β€πŸ’» Uses your OS' native API
πŸ– Piggy-backs on the Rusty File Dialogs project
πŸ“‚ Lets you open file picker dialogs
πŸ”” Utility alert boxes too!

Installation

npm Yarn pnpm

You can install this package using npm, pnpm, Yarn, or your favorite npm-compatible package manager!

npm install @bindrs/rfd

If you're using Deno, you can use the new npm: specifiers to import this package straight from the npm registry. It's not possible to use an npm CDN because this package uses a .node compiled binary.

import {} from "npm:@bindrs/rfd";

πŸ›‘ This package doesn't work in the browser. It's meant to be used with Node.js, Deno, or Bun which all support .node native addons.

| | Node.js v16 | Node.js v18 | Node.js v20 | | ---------------- | ----------- | ----------- | ----------- | | Windows x64 | βœ… | βœ… | βœ… | | Windows x32 | ❌ | ❌ | ❌ | | Windows arm64 | ❌ | ❌ | ❌ | | macOS x64 | βœ… | βœ… | βœ… | | macOS arm64 | ❌ | ❌ | ❌ | | Linux x64 gnu | βœ… | βœ… | βœ… | | Linux x64 musl | ❌ | ❌ | ❌ | | Linux arm gnu | ❌ | ❌ | ❌ | | Linux arm64 gnu | ❌ | ❌ | ❌ | | Linux arm64 musl | ❌ | ❌ | ❌ | | Android arm64 | ❌ | ❌ | ❌ | | Android armv7 | ❌ | ❌ | ❌ | | FreeBSD x64 | ❌ | ❌ | ❌ |

Want to add support for your favorite platform? Open a PR! ❀️

Usage

Node.js Deno Bun

import { homedir } from "node:os";
import { AsyncFileDialog } from "@bindrs/rfd";

const fileHandle = await new AsyncFileDialog()
  .addFilter("Images", ["png", "jpg", "jpeg"])
  .addFilter("All Files", ["*"])
  .setTitle("Pick an image")
  .setDirectory(homedir())
  .pickFile();
const path = fileHandle.path();
console.log(`You chose to open ${path}!`);
//=> You chose to open /home/jcbhmr/cool.png!

You can also open message boxes:

import { AsyncMessageDialog } from "@bindrs/rfd";

const answer = await new AsyncMessageDialog()
  .setTitle("Hello!")
  .setDescription("Click OK if you're feeling good 😊")
  .show();
if (answer) {
  console.log("You clicked OK!");
  //=> You clicked OK!
}

πŸ“š Check out the TypeDoc website for more extensive API documentation. You can also refer to the original rfd crate documentation if you want to learn more about the features and limitations inherited from the Rust API.

Development

Rust Node.js

This project uses NAPI-RS to bridge the gap between Rust and JavaScript. Other options like Neon also work, but this seemed the simplest. To get started, you'll need the Rust toolchain installed in addition to the usual Node.js stuff. You'll also need the GTK-3 or other platform-specific libraries installed for your desktop GUI.

To quickly get setup on Ubuntu, you can run the below commands. If you're on Windows, you don't need any extra GUI libraries; those are already all included with the Windows native toolkits!

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
sudo apt install libgtk-3-dev

We use a testing REPL instead of more concrete tests. This is because any concrete test we write won't work in CI because there's no GUI in GitHub Actions! 😭 It's better to just tinker around with it in a REPL.

npm run test:repl