Native dialog, port of Rust rfd.
Based on rfd@0.14.1.
deno:
deno add @miyauci/rfd
node:
npx jsr add @miyauci/rfd
The load
function must be called first. By default, it downloads and caches
remote binaries.
import { FileDialog, load } from "@miyauci/rfd/$RUNTIME";
await load();
const dialog = new FileDialog();
const path = dialog.pickFile();
In addition, see supported runtime.
MessageDialog
corresponds to
rfd::MessageDialog。
import {
load,
MessageButtons,
MessageDialog,
MessageLevel,
} from "@miyauci/rfd/$RUNTIME";
await load();
const dialog = new MessageDialog();
const result = dialog.setLevel(MessageLevel.Error).setButtons(
MessageButtons.OkCancel,
)
.show();
If you want to use a local binary, specify its path.
import { load } from "@miyauci/rfd/$RUNTIME";
await load("/path/to/bin");
Deno FFI requires explicit resource release. To prevent resource leaks, use
using
or call [Symbol.dispose]
. See
ECMAScript Explicit Resource Management.
import { FileDialog, load } from "@miyauci/rfd/deno";
await load();
using dialog = new FileDialog();
The following flags are required for execution:
--unstable-ffi
The following permissions must be allowed:
Permission | Value |
---|---|
--allow-env |
|
--allow-read |
${DENO_DIR}/plug |
--allow-ffi |
path to binary cache |
This is usually used for debugging, etc.
Currently supported targets are as follows.
The following platforms are supported:
Platform | Rust Target |
---|---|
64-bit macOS (10.12+, Sierra+) | x86_64-apple-darwin |
ARM64 macOS (11.0+, Big Sur+) | aarch64-apple-darwin |
64-bit MSVC (Windows 10+, Windows Server 2016+) | x86_64-pc-windows-msvc |
ARM64 Windows MSVC | aarch64-pc-windows-msvc |
64-bit Linux (kernel 3.2+, glibc 2.17+) | x86_64-unknown-linux-gnu |
ARM64 Linux (kernel 4.1, glibc 2.17+) | aarch64-unknown-linux-gnu |
The following runtime are supported:
Runtime | Import Specifier |
---|---|
Deno | @miyauci/rfd/deno |
Node.js | @miyauci/rfd/node |
The following modules are supported:
rfd | Supported |
---|---|
FileDialog | ✅ |
MessageDialog | ✅ |
AsyncFileDialog | - |
AsyncMessageDialog | - |
FileHandle | - |
See jsr doc for all APIs.
See CONTRIBUTING.md
MIT © 2024 Tomoki Miyauchi