@f5-sales-demo/pi-natives (英语)
通过 N-API 的原始 Rust 功能 .
里面的东西
- Grep 读取: 基于 Regex 的搜索由 riggrep 的引擎提供动力, 并配对本地文件
- 查找: 基于 gitignore 支持的基于 glob 的文件/目录发现(纯类型脚本通过
globPaths(中文(简体) ) - 图像: 通过光子-rs(大小调整,格式转换)通过N-API曝光的图像处理
使用量
import { grep, find } from "@f5-sales-demo/pi-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",
});
// Image processing
const pngBytes = await new Bun.Image(bytes).resize(800, 600).png().bytes();
大楼
# Build native addon from workspace root (requires Rust)
bun run build
# Type check
bun run check
建筑
crates/pi-natives/ # Rust source (workspace member)
src/lib.rs # N-API exports
src/image.rs # SIXEL image decoding and encoding
Cargo.toml # Rust dependencies
native/ # Native addon binaries
pi_natives.<platform>-<arch>-modern.node # x64 modern ISA (AVX2)
pi_natives.<platform>-<arch>-baseline.node # x64 baseline ISA
pi_natives.<platform>-<arch>.node # non-x64 build artifact
src/ # TypeScript wrappers
native.ts # Native addon loader
index.ts # Public API