@tdh-keyboard/pinyin 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +65 -0
  2. package/package.json +4 -3
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # @tdh-keyboard/pinyin
2
+
3
+ `@tdh-keyboard/pinyin` 提供基于 RIME WASM 的拼音输入引擎实现,可直接接入 `@tdh-keyboard/vue` 和 `@tdh-keyboard/react`。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install @tdh-keyboard/pinyin
9
+ ```
10
+
11
+ ## 导出内容
12
+
13
+ - `RimePinyinEngine`:基于 RIME WASM 的拼音引擎实现
14
+ - `PinyinEngine`:通用拼音引擎接口类型
15
+ - `PinyinState`:拼音候选状态类型
16
+
17
+ ## 基本用法
18
+
19
+ ```ts
20
+ import { RimePinyinEngine } from '@tdh-keyboard/pinyin'
21
+
22
+ const engine = new RimePinyinEngine({
23
+ wasmDir: '/rime',
24
+ simplified: true,
25
+ })
26
+
27
+ await engine.initialize()
28
+
29
+ const state = await engine.processInput('nihao')
30
+ console.log(state?.candidates)
31
+
32
+ await engine.pickCandidate(0)
33
+ await engine.clearInput()
34
+ await engine.destroy()
35
+ ```
36
+
37
+ ## 与键盘组件配合使用
38
+
39
+ ```ts
40
+ import { registerPinyinEngine } from '@tdh-keyboard/vue'
41
+ import { RimePinyinEngine } from '@tdh-keyboard/pinyin'
42
+
43
+ registerPinyinEngine(new RimePinyinEngine({
44
+ wasmDir: '/rime',
45
+ }))
46
+ ```
47
+
48
+ ## 资源文件部署
49
+
50
+ 发布时需要同时提供 `data/` 目录中的 RIME 资源文件,并保证 `wasmDir` 指向这些静态资源所在目录。
51
+
52
+ 默认会加载以下文件:
53
+
54
+ - `rime-api.wasm`
55
+ - `default.yaml`
56
+ - `luna_pinyin.schema.yaml`
57
+ - `luna_pinyin.table.bin`
58
+ - `luna_pinyin.prism.bin`
59
+ - `luna_pinyin.reverse.bin`
60
+
61
+ ## 选项说明
62
+
63
+ - `wasmDir`:`rime-api.js`、`rime-api.wasm` 和数据文件的访问路径前缀
64
+ - `dataFiles`:自定义需要预加载的数据文件列表
65
+ - `simplified`:是否默认启用简体中文输出,默认 `true`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tdh-keyboard/pinyin",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "中文虚拟键盘组件库拼音输入引擎",
5
5
  "author": "tdh",
6
6
  "license": "Apache 2.0",
@@ -23,10 +23,11 @@
23
23
  "types": "dist/index.d.ts",
24
24
  "files": [
25
25
  "data",
26
- "dist"
26
+ "dist",
27
+ "README.md"
27
28
  ],
28
29
  "dependencies": {
29
- "@tdh-keyboard/core": "1.0.0"
30
+ "@tdh-keyboard/core": "1.0.1"
30
31
  },
31
32
  "devDependencies": {
32
33
  "tsdown": "^0.21.2",