@gajae-code/natives

中文文档
0.21.0发布于 2026/11/16MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 9268

Native Rust bindings for grep, clipboard, image processing, syntax highlighting, PTY, and shell operations via N-API

原始使用文档
文档目录4 节
  1. What's Inside
  2. Usage
  3. Building
  4. Architecture

@gajae-code/natives

Native Rust functionality via N-API.

What's Inside

  • Grep: Regex-based search powered by ripgrep's engine with native file walking and matching
  • Find: Glob-based file/directory discovery with gitignore support (pure TypeScript via globPaths)
  • SIXEL: Terminal image encoding for SIXEL-capable terminals (decode, resize, encode in one pass)

General-purpose image processing (decode/resize/encode for files and buffers) lives in Bun.Image on the JS side; this crate only ships the SIXEL encoder because no built-in equivalent exists for that terminal protocol.

Usage

import { grep, find, encodeSixel } from "@gajae-code/natives";

// Grep for a pattern
const results = await grep({
    pattern: "TODO",
    path: "/path/to/project",
    glob: "*.ts",
    context: 2,
});

// Find files
const files = await find({
    pattern: "*.rs",
    path: "/path/to/project",
    fileType: "file",
});

// SIXEL encode for a terminal cell box (px)
const sequence = encodeSixel(pngBytes, widthPx, heightPx);

Building

# Build native addon from workspace root (requires Rust)
bun run build

# Type check
bun run check

Architecture

crates/pi-natives/       # Rust source (workspace member)
  src/lib.rs             # N-API exports
  src/sixel.rs           # SIXEL terminal-image encoding
  Cargo.toml             # Rust dependencies
native/                  # Stable JS/types loader files
  index.js               # Loads the host addon
  index.d.ts             # Generated public API types
packages/natives-*/      # Optional per-platform prebuilt addon packages
  native/pi_natives.<platform>-<arch>-modern.node   # x64 modern ISA (AVX2)
  native/pi_natives.<platform>-<arch>-baseline.node # x64 baseline ISA
  native/pi_natives.<platform>-<arch>.node          # non-x64 build artifact

版本与发布记录

@gajae-code/natives 共发布 160 个版本,首次发布于 2026/05/28;过去 12 个月发布了 160 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.21.0latest2026/11/16今天
0.20.1-nightly.20261108030927.43711868338.gb4127889c4a8nightly2026/11/15今天
0.20.1-nightly.20261108030927.43590872198.gb4127889c4a82026/11/141 天前
0.20.1-nightly.20261108030927.43424588966.gb4127889c4a82026/11/132 天前
0.20.1-nightly.20261108030927.43222623203.gb4127889c4a82026/11/123 天前
0.20.1-nightly.20261108030927.43016219422.gb4127889c4a82026/11/114 天前

关于 @gajae-code/natives 的常见问题

@gajae-code/natives 是什么?

Native Rust bindings for grep, clipboard, image processing, syntax highlighting, PTY, and shell operations via N-API

如何安装 @gajae-code/natives?

在项目目录运行 npm install @gajae-code/natives,或使用 pnpm add / yarn add / bun add。

@gajae-code/natives 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gajae-code/natives 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@gajae-code/natives 可以商用吗?

@gajae-code/natives 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gajae-code/natives 的下载量有多少?

根据 npm 官方下载统计,@gajae-code/natives 在 2026/10/16 – 2026/11/14 这 30 天内被下载 9,268 次,日均约 309 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gajae-code/natives 还在维护吗?

最新版本 0.21.0 发布于 2026/11/16(今天);至今共发布 160 个版本,其中过去 12 个月发布了 160 个;首次发布于 2026/05/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。