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

librime-wasm

v0.1.0

Published

Rime Input Method Engine - WebAssembly port with complete TypeScript bindings

Readme

librime-wasm

License: MIT TypeScript

Rime 输入法引擎的 WebAssembly 移植版本,提供完整的 TypeScript API。

作者: Kail

🎯 主要特性

  • 完整的 Rime API - 所有 librime 核心功能
  • 类型安全 - 完整的 TypeScript 类型定义
  • 跨平台 - 同时支持 Node.js 和浏览器环境
  • 高性能 - 基于 WebAssembly,接近原生性能
  • 易用性 - 简洁的 JavaScript/TypeScript API

使用场景

  • ✅ Web 输入法开发
  • ✅ 跨平台输入法应用
  • ✅ 自动化配置测试
  • ✅ 输入法研究和教学

特性

  • 完整的 Rime API 支持 - 所有公开的 RimeApi 函数
  • 类型安全 - 完整的 TypeScript 类型定义
  • 跨平台 - 同时支持 Node.js 和浏览器环境
  • 高性能 - 基于 WebAssembly,接近原生性能
  • 易用性 - 简洁的 JavaScript/TypeScript API
  • CI/CD 友好 - 适合自动化测试和验证
  • 零依赖 - 纯 WebAssembly,无需系统级依赖

安装

npm install librime-wasm

快速开始

Node.js 环境

import { RimeEngine } from 'librime-wasm';

// 创建引擎
const engine = new RimeEngine({
  sharedDataDir: '/rime/share',
  userDataDir: '/rime/user'
});

// 初始化
await engine.initialize();

// 创建会话
const session = engine.createSession('luna_pinyin');

// 输入拼音
session.setInput('zhongguo');

// 获取候选词
const candidates = session.getCandidates(10);
console.log(candidates);
// [{ text: '中国', comment: '' }, { text: '种果', comment: '' }, ...]

// 清理
engine.shutdown();

浏览器环境

import { RimeEngine } from 'librime-wasm/browser';

const engine = new RimeEngine({
  sharedDataDir: '/rime/share',
  userDataDir: '/rime/user',
  dataBaseUrl: 'https://cdn.example.com/rime-data'
});

await engine.initialize();

// 使用方式与 Node.js 相同
const session = engine.createSession('luna_pinyin');
session.setInput('nihao');
const candidates = session.getCandidates();

API 文档

RimeEngine

主引擎类,管理 Rime 的生命周期和会话。

constructor(config: RimeConfig)

创建引擎实例。

interface RimeConfig {
  sharedDataDir: string;   // 共享数据目录
  userDataDir: string;     // 用户数据目录
  appName?: string;        // 应用名称
  logLevel?: LogLevel;     // 日志级别
}

async initialize(): Promise

初始化引擎。

createSession(schemaId?: string): number

创建新会话,返回会话 ID。

getSession(sessionId: number): RimeSession

获取指定会话。

destroySession(sessionId: number): void

销毁会话。

async shutdown(): Promise

关闭引擎。

RimeSession

会话类,处理输入和候选词查询。

setInput(input: string): boolean

设置输入字符串。

getCandidates(topN?: number): Candidate[]

获取候选词列表。

interface Candidate {
  text: string;
  comment: string;
}

getContext(): RimeContext

获取完整上下文信息。

selectSchema(schemaId: string): boolean

切换输入方案。

开发

# 安装依赖
npm install

# 构建
npm run build

# 测试
npm test

# 监听模式
npm run build:ts:watch

CI/CD 验证

本库特别适合在 CI/CD 系统中验证 Rime 配置文件:

快速验证

# 验证特定文件
node scripts/validate-rime.js schemas/your_schema.yaml

# 验证多个文件
node scripts/validate-rime.js schemas/*.yaml

# 在 package.json 中
npm run validate:rime

GitHub Actions 集成

- name: 验证 Rime 配置
  run: |
    npm ci
    npm run build:ts
    node scripts/validate-rime.js schemas/**/*.yaml

详细用法请查看 CI/CD 验证指南

已知限制

  1. Lua 插件:当前不支持 Lua 扩展(Emscripten 限制)
  2. 词典大小:大型词典占用较多内存,建议按需加载
  3. 首次加载:WASM 文件约 5MB,首次加载需要时间

许可证

MIT - 详见 LICENSE 文件

致谢

本项目基于以下优秀的开源项目:

原 librime 项目采用 BSD-3-Clause 许可证,本项目在移植和重写后采用 MIT 许可证。

相关项目