Skip to content

Commit

Permalink
allow use github repo rime conf
Browse files Browse the repository at this point in the history
  • Loading branch information
jdxin0 committed Oct 21, 2024
1 parent 9b349ac commit 854fa91
Show file tree
Hide file tree
Showing 7 changed files with 5,541 additions and 4,150 deletions.
12 changes: 7 additions & 5 deletions background/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RimeCandidateIterator, RimeEngine, RimeSession } from "./engine";
import { parse, stringify } from 'yaml'
import type { RimeCandidate } from "~shared-types";
import EventEmitter from "events";
import { ConstructionOutlined } from "@mui/icons-material";

const kShiftMask = 1 << 0;
const kControlMask = 1 << 2;
Expand Down Expand Up @@ -185,14 +186,15 @@ export class InputController extends EventEmitter {
}
}
try {
console.log("Loading RIME engine...");
console.log(">>>Loading RIME engine...");
const configObj = await chrome.storage.sync.get(["settings"]);
if (!configObj.settings) {
throw Error("Could not find RIME settings, refusing to launch.");
}
this.activeSettings = configObj.settings as ImeSettings;
console.log("Settings: ", JSON.stringify(this.activeSettings));
console.log(">>>Settings: ", JSON.stringify(this.activeSettings));
await this.loadMutex.runExclusive(async () => {
console.log("this.loadMutex.runExclusive");
let asciiMode = false;
if (this.engine) {
if (this.session) {
Expand All @@ -206,7 +208,7 @@ export class InputController extends EventEmitter {
}

await new Promise(r => setTimeout(r, 10));

console.log("loadRimeConfig");
const config = await this.loadRimeConfig(this.activeSettings);
const fs = await getFs();
const dirs = ['/root/build', '/root/shared', '/root/user', '/root/shared/opencc'];
Expand All @@ -225,13 +227,13 @@ export class InputController extends EventEmitter {
await fs.writeWholeFile("/root/build/default.yaml", new TextEncoder().encode(stringify(
{ ascii_composer: { good_old_caps_lock: true, switch_key: { Caps_Lock: "clear", Shift_L: "commit_code" } } }
)));

console.log("new RimeEngine()");
const engine = new RimeEngine();
await engine.initialize(this.printErr.bind(this), fs);
if (maintenance) {
await engine.rebuildPrism(this.activeSettings.schema, config);
}

console.log("engine.createSession");
const session = await engine.createSession(this.activeSettings.schema, config);
await this.flushInputCacheToSession(session);
this.engine = engine;
Expand Down
2 changes: 1 addition & 1 deletion build-rel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ rsync -r inputview $BUILD_DIR
google-chrome --pack-extension=$BUILD_DIR --pack-extension-key=fydeos-rime-extention.pem
mkdir -p ../rel/
chmod 644 $BUILD_DIR.crx
sudo mv $BUILD_DIR.crx ../rel/rime.crx
mv $BUILD_DIR.crx ../rel/rime.crx
9 changes: 9 additions & 0 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
"error_downloading_schema": {
"message": "Error while downloading schema: "
},
"error_form": {
"message": "github repo url or schema_id error"
},
"error_fetch_schema_list": {
"message": "Error while fetching schema list:"
},
Expand All @@ -82,9 +85,15 @@
"open_source": {
"message": "View on GitHub"
},
"add_schema": {
"message": "Add"
},
"update_schema": {
"message": "Update"
},
"remove_schema": {
"message": "Remove"
},
"cannot_edit_this_file": {
"message": "Please choose a text file"
},
Expand Down
9 changes: 9 additions & 0 deletions locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
"error_downloading_schema": {
"message": "下载方案时发生错误:"
},
"error_form": {
"message": "github repo url 和 schema id 错误"
},
"error_fetch_schema_list": {
"message": "获取方案列表时发生错误:"
},
Expand All @@ -82,9 +85,15 @@
"open_source": {
"message": "源代码"
},
"add_schema": {
"message": "添加"
},
"update_schema": {
"message": "更新"
},
"remove_schema": {
"message": "移除"
},
"cannot_edit_this_file": {
"message": "请选择一个文本文件"
},
Expand Down
Loading

0 comments on commit 854fa91

Please sign in to comment.