@zh-keyboard/pinyin 1.0.0

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.
Binary file
@@ -0,0 +1,72 @@
1
+ import { PinyinEngine, PinyinEngine as PinyinEngine$1 } from "@zh-keyboard/core";
2
+
3
+ //#region src/types.d.ts
4
+ interface RimeCandidate {
5
+ text: string;
6
+ comment: string;
7
+ }
8
+ interface RimeState {
9
+ /** 已提交(最终)文本;若无提交则为 null。 */
10
+ committed: string | null;
11
+ /** 选区前的预编辑文本。 */
12
+ preeditHead: string;
13
+ /** 当前被选中的预编辑部分。 */
14
+ preeditBody: string;
15
+ /** 选区后的预编辑文本。 */
16
+ preeditTail: string;
17
+ /** 预编辑中的光标位置。 */
18
+ cursorPos: number;
19
+ /** 当前页的候选项列表。 */
20
+ candidates: RimeCandidate[];
21
+ /** 当前页码(从 0 开始)。 */
22
+ pageNo: number;
23
+ /** 是否为候选的最后一页。 */
24
+ isLastPage: boolean;
25
+ /** 高亮候选的索引。 */
26
+ highlightedIndex: number;
27
+ /** 候选选择键的标签数组。 */
28
+ selectLabels: string[];
29
+ }
30
+ interface RimeWasmOptions {
31
+ /**
32
+ * rime-api.js、rime-api.wasm 以及所有数据文件(YAML 配置 + 二进制词典)的 URL 或路径前缀。
33
+ * 默认为当前目录。
34
+ */
35
+ wasmDir?: string;
36
+ /**
37
+ * 启动时要获取并加载的数据文件名列表。
38
+ * 文件会从 `wasmDir` 获取并在引擎初始化前写入虚拟文件系统的 `/rime/build/`。
39
+ * 默认为 luna_pinyin 的 schema、词典文件以及配置 YAML。
40
+ */
41
+ dataFiles?: string[];
42
+ } //#endregion
43
+ //#region src/index.d.ts
44
+ type PinyinState = RimeState;
45
+ interface RimePinyinEngineOptions extends RimeWasmOptions {
46
+ /**
47
+ * 是否默认使用简体中文
48
+ * @default true
49
+ */
50
+ simplified?: boolean;
51
+ }
52
+ /**
53
+ * 创建基于 RIME WASM 的拼音引擎,实现 PinyinEngine 通用接口。
54
+ * 内部处理分页逻辑,processInput 返回所有页的候选词集合。
55
+ */
56
+ declare class RimePinyinEngine implements PinyinEngine$1 {
57
+ private options;
58
+ private engine;
59
+ private prevRimeInput;
60
+ private initPromise;
61
+ constructor(options?: RimePinyinEngineOptions);
62
+ private getEngine;
63
+ initialize(): Promise<void>;
64
+ processInput(fullPinyin: string): Promise<RimeState | null>;
65
+ pickCandidate(index: number): Promise<RimeState>;
66
+ clearInput(): Promise<void>;
67
+ setSimplified(simplified: boolean): Promise<void>;
68
+ destroy(): Promise<void>;
69
+ }
70
+ //#endregion
71
+ export { PinyinEngine, PinyinState, RimePinyinEngine, RimePinyinEngineOptions };
72
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1,72 @@
1
+ import { PinyinEngine, PinyinEngine as PinyinEngine$1 } from "@zh-keyboard/core";
2
+
3
+ //#region src/types.d.ts
4
+ interface RimeCandidate {
5
+ text: string;
6
+ comment: string;
7
+ }
8
+ interface RimeState {
9
+ /** 已提交(最终)文本;若无提交则为 null。 */
10
+ committed: string | null;
11
+ /** 选区前的预编辑文本。 */
12
+ preeditHead: string;
13
+ /** 当前被选中的预编辑部分。 */
14
+ preeditBody: string;
15
+ /** 选区后的预编辑文本。 */
16
+ preeditTail: string;
17
+ /** 预编辑中的光标位置。 */
18
+ cursorPos: number;
19
+ /** 当前页的候选项列表。 */
20
+ candidates: RimeCandidate[];
21
+ /** 当前页码(从 0 开始)。 */
22
+ pageNo: number;
23
+ /** 是否为候选的最后一页。 */
24
+ isLastPage: boolean;
25
+ /** 高亮候选的索引。 */
26
+ highlightedIndex: number;
27
+ /** 候选选择键的标签数组。 */
28
+ selectLabels: string[];
29
+ }
30
+ interface RimeWasmOptions {
31
+ /**
32
+ * rime-api.js、rime-api.wasm 以及所有数据文件(YAML 配置 + 二进制词典)的 URL 或路径前缀。
33
+ * 默认为当前目录。
34
+ */
35
+ wasmDir?: string;
36
+ /**
37
+ * 启动时要获取并加载的数据文件名列表。
38
+ * 文件会从 `wasmDir` 获取并在引擎初始化前写入虚拟文件系统的 `/rime/build/`。
39
+ * 默认为 luna_pinyin 的 schema、词典文件以及配置 YAML。
40
+ */
41
+ dataFiles?: string[];
42
+ } //#endregion
43
+ //#region src/index.d.ts
44
+ type PinyinState = RimeState;
45
+ interface RimePinyinEngineOptions extends RimeWasmOptions {
46
+ /**
47
+ * 是否默认使用简体中文
48
+ * @default true
49
+ */
50
+ simplified?: boolean;
51
+ }
52
+ /**
53
+ * 创建基于 RIME WASM 的拼音引擎,实现 PinyinEngine 通用接口。
54
+ * 内部处理分页逻辑,processInput 返回所有页的候选词集合。
55
+ */
56
+ declare class RimePinyinEngine implements PinyinEngine$1 {
57
+ private options;
58
+ private engine;
59
+ private prevRimeInput;
60
+ private initPromise;
61
+ constructor(options?: RimePinyinEngineOptions);
62
+ private getEngine;
63
+ initialize(): Promise<void>;
64
+ processInput(fullPinyin: string): Promise<RimeState | null>;
65
+ pickCandidate(index: number): Promise<RimeState>;
66
+ clearInput(): Promise<void>;
67
+ setSimplified(simplified: boolean): Promise<void>;
68
+ destroy(): Promise<void>;
69
+ }
70
+ //#endregion
71
+ export { PinyinEngine, PinyinState, RimePinyinEngine, RimePinyinEngineOptions };
72
+ //# sourceMappingURL=index.d.ts.map