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 🙏

© 2026 – Pkg Stats / Ryan Hefner

jsh_rime

v2.0.2

Published

中文拼音输入引擎 — 基于 RIME WASM,无 UI 依赖

Readme

jsh_rime

中文拼音输入引擎,基于 RIME 编译为 WebAssembly 在浏览器中运行,无 UI 依赖。

安装

npm install jsh_rime

使用

import { createPinyinInput } from 'jsh_rime'

// 1. 创建引擎(自动初始化)
const py = await createPinyinInput({
  wasmDir: '/rime', // WASM 和词典文件的 URL 路径前缀
})

// 2. 输入拼音
const state = await py.input('nihao')
// state.candidates = [{ text: '你好', comment: '' }, ...]

// 3. 选择候选词
const result = await py.select(0)
// result.committed = '你好'

// 4. 用完销毁
await py.destroy()

部署数据文件

引擎在浏览器运行时需要加载 WASM 和词典文件。这些文件位于 node_modules/jsh_rime/data/ 目录下,需要复制到你的静态资源目录中(如 public/rime/),并将 wasmDir 设置为该路径。

# 例如,将数据文件复制到 public/rime/
cp -r node_modules/jsh_rime/data/* public/rime/

然后配置 wasmDir: '/rime'。

API

createPinyinInput(options?)

创建并初始化拼音引擎,返回 Promise<PinyinInput>。

| 选项 | 类型 | 默认值 | 说明 | |---|---|---|---| | wasmDir | string | '.' | WASM 及数据文件的 URL 路径前缀 | | simplified | boolean | true | 是否默认使用简体中文 | | dataFiles | string[] | 见源码 | 需要加载的词典文件名列表 |

PinyinInput

| 方法 | 说明 | |---|---| | input(pinyin: string) | 输入拼音串,返回 PinyinState \| null | | select(index: number) | 选择第 index 个候选词,返回 PinyinState | | clear() | 清除当前输入状态 | | setSimplified(simplified: boolean) | 切换简体 / 繁体 | | destroy() | 销毁引擎,释放 WASM 资源 |

PinyinState

| 字段 | 类型 | 说明 | |---|---|---| | committed | string \| null | 已提交的文本 | | preeditHead | string | 预编辑区 — 光标前 | | preeditBody | string | 预编辑区 — 当前选中 | | preeditTail | string | 预编辑区 — 光标后 | | candidates | Candidate[] | 当前页候选词 | | pageNo | number | 当前页码 | | isLastPage | boolean | 是否最后一页 | | highlightedIndex | number | 高亮候选索引 | | selectLabels | string[] | 候选快捷键标签 |

RimePinyinEngine

完整引擎类,用法同上,但需要手动 initialize()。

import { RimePinyinEngine } from 'jsh_rime'
const engine = new RimePinyinEngine({ wasmDir: '/rime' })
await engine.initialize()

License

Apache-2.0