mirror of
https://github.com/Melorise/TamaASR.git
synced 2026-11-07 14:39:32 +00:00
feat: 实现 Linux Fcitx5 实时输入链路
加入 Unix Socket v2 协议、会话状态机、动态快捷键、完整 preedit 更新、结束提交以及断线重连和安全取消。 AI-assisted-by: Codex AI-model: gpt-5.6-sol AI-reasoning-effort: medium Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { JsonLineDecoder, defaultSocketPath } from '../src/main/fcitx-bridge';
|
||||
|
||||
test('Socket 路径只使用当前用户运行时目录', () => {
|
||||
assert.equal(defaultSocketPath({ XDG_RUNTIME_DIR: '/run/user/1000' }), '/run/user/1000/meloasr/fcitx5.sock');
|
||||
assert.throws(() => defaultSocketPath({}), /XDG_RUNTIME_DIR/);
|
||||
});
|
||||
|
||||
test('JSONL 解码器支持拆包、粘包与无效 JSON', () => {
|
||||
const messages: unknown[] = [];
|
||||
const errors: Error[] = [];
|
||||
const decoder = new JsonLineDecoder((message) => messages.push(message), (error) => errors.push(error));
|
||||
decoder.push('{"type":"hel');
|
||||
decoder.push('lo","protocol":2}\n{"type":"request-start"}\nnot-json\n');
|
||||
assert.deepEqual(messages, [{ type: 'hello', protocol: 2 }, { type: 'request-start' }]);
|
||||
assert.equal(errors.length, 1);
|
||||
});
|
||||
Reference in New Issue
Block a user