# @flowscripter/flowscripter-io-cli-hash-native 中文文档

规范地址：https://npmcn.com/package/%40flowscripter/flowscripter-io-cli-hash-native/

版本：2\.0\.9
npm 元数据更新时间：2026-11-12T08:06:05.404Z
中文译文更新时间：2026-11-15T01:04:57.572Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40flowscripter/flowscripter-io-cli-hash-native
原文对照：https://npmcn.com/package/%40flowscripter/flowscripter-io-cli-hash-native/?lang=original
项目主页：https://github.com/flowscripter/flowscripter-io-cli-hash-native#readme
源码仓库：https://github.com/flowscripter/flowscripter-io-cli-hash-native

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：30.5 kB，17 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：typescript ^7\.0\.2
- 首次发布：2026-08-27T05:23:18.871Z
- 最新版本发布：2026-11-12T08:06:04.970Z
- 近 30 天下载量：2354（2026-10-15 至 2026-11-13，npm 官方下载统计）
- 已发布版本数：30（近 12 个月 30 个）

## 中文简介

由粗口支撑的sha256散列为流写器-io-cli,通过 Bun FFI 曝光

## 安装

```sh
npm install @flowscripter/flowscripter-io-cli-hash-native
```

也可以使用：`pnpm add @flowscripter/flowscripter-io-cli-hash-native`、`yarn add @flowscripter/flowscripter-io-cli-hash-native`、`bun add @flowscripter/flowscripter-io-cli-hash-native`

## README

# 流写器- io- cli- hash- native

[![version](https://img.shields.io/github/v/release/flowscripter/flowscripter-io-cli-hash-native?sort=semver)](https://github.com/flowscripter/flowscripter-io-cli-hash-native/releases) [![build](https://img.shields.io/github/actions/workflow/status/flowscripter/flowscripter-io-cli-hash-native/release-bun-rust-library.yml)](https://github.com/flowscripter/flowscripter-io-cli-hash-native/actions/workflows/release-bun-rust-library.yml) [![docs](https://img.shields.io/badge/docs-API-blue)](https://flowscripter.github.io/flowscripter-io-cli-hash-native/index.html) [![rust doc](https://img.shields.io/docsrs/flowscripter_io_cli_hash_native)](https://docs.rs/flowscripter_io_cli_hash_native) [![license: MIT](https://img.shields.io/github/license/flowscripter/flowscripter-io-cli-hash-native)](https://github.com/flowscripter/flowscripter-io-cli-hash-native/blob/main/LICENSE)

> Rust-backed sha256 hashher for flowscripter-io-cli,通过 Bun FFI 曝光.

## Bun 模块使用

添加模块 :

`bun add @flowscripter/flowscripter-io-cli-hash-native`

使用模块 :

```typescript
import { initNativeLib, Sha256Hasher } from "@flowscripter/flowscripter-io-cli-hash-native";

await initNativeLib();

const hasher = new Sha256Hasher();
hasher.update(new TextEncoder().encode("hello"));
const digest = hasher.final();
```

## 发展

安装依赖性 :

`bun install`

构建(生产) `dist/` 对于Node.js和TypeScript消费者; Bun 直接使用原始来源:

`bun run build`

测试 :

`cargo test`

`cargo build --release && FLOWSCRIPTER_HASH_NATIVE_DEV_BUILD=1 bun test`

默认情况下, 本地库是从 `~/.flowscripter/lib` (如果缺少或与其校验和不符,则从释放中下载)。 设置 `FLOWSCRIPTER_HASH_NATIVE_DEV_BUILD=1` 让软件包更喜欢自己的 `target/release` 建起来.

格式 :

`cargo fmt && bunx oxfmt`

林特:

`bunx oxlint index.ts src/ tests/`

生成 HTML API 文档 :

`bunx typedoc index.ts`

## 文档

### 概览

`Sha256Hasher` 包装出土的 Rust `sha2` 三后执行 `extern "C"` 函数`hasher_init`, (中文(简体) ), `hasher_update`, (中文(简体) ), `hasher_final`通过 `bun:ffi`是因为 `dlopen`。 。 。 .

导入软件包没有副作用. `initNativeLib()` 必须在第一个 `Sha256Hasher` 创建:它解决、下载和验证本地库,然后装入一次.

每期发布一个 `<library file>.shasum` (SHA-256)每个本土图书馆的兄弟姐妹资产. 下载会写入一个临时文件, 对照该校验和进行核对, 然后再重新命名为 `~/.flowscripter/lib` 联合国 `.shasum`。已安装的图书馆将对照其 `.shasum` 在它被装载之前 `initNativeLib()` 如果核查失败, 则拒绝 .

`update()` 接受JS拥有的 `Uint8Array` 然后通过一个原始指针 直接进入同步的Rust呼叫 `bun:ffi`是因为 `ptr()` - 一旦字节在JS记忆中,就不再复制.

`updatePointer()` 接受一对已绘制的指针/长相配对——例如,一个出自本地来源且从未拥有JS自有副本的块——并直接传递给Rust呼叫,完全没有副本.

由此产生的32字节文摘被复制回联署材料 `final()`,无论散列了多少数据,其大小可忽略不计.

### API 密码

链接自动生成的 API 文件 :

[API 文档](https://flowscripter.github.io/flowscripter-io-cli-hash-native/index.html)

## 许可证

麻省理工学院

## 常见问题

### @flowscripter/flowscripter-io-cli-hash-native 是什么？

由粗口支撑的sha256散列为流写器-io-cli,通过 Bun FFI 曝光

### 如何安装 @flowscripter/flowscripter-io-cli-hash-native？

在项目目录运行 npm install @flowscripter/flowscripter-io-cli-hash-native，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：typescript（^7\.0\.2）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @flowscripter/flowscripter-io-cli-hash-native 支持 TypeScript 吗？

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

### @flowscripter/flowscripter-io-cli-hash-native 支持 ESM 还是 CommonJS？

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

### @flowscripter/flowscripter-io-cli-hash-native 可以商用吗？

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

### @flowscripter/flowscripter-io-cli-hash-native 的下载量有多少？

根据 npm 官方下载统计，@flowscripter/flowscripter-io-cli-hash-native 在 2026/10/15 – 2026/11/13 这 30 天内被下载 2,354 次，日均约 78 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @flowscripter/flowscripter-io-cli-hash-native 还在维护吗？

最新版本 2\.0\.9 发布于 2026/11/12（3 天前）；至今共发布 30 个版本，其中过去 12 个月发布了 30 个；首次发布于 2026/08/27。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

