Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
git apply --directory=fcitx5-rime patches/rime.log.patch
git apply --directory=fcitx5-rime patches/rime.js.patch
git apply --directory=fcitx5-skk patches/skk.patch
git apply --directory=fcitx5-zhuyin patches/zhuyin.patch
emcmake cmake -B build/js -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build/js
./scripts/install.sh js
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
git apply --directory=fcitx5-rime patches/rime.log.patch
git apply --directory=fcitx5-skk patches/skk.patch
git apply --directory=fcitx5-table-other patches/table-other.patch
git apply --directory=fcitx5-zhuyin patches/zhuyin.patch
cmake -B build/macos-${{ matrix.arch }} -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }}
cmake --build build/macos-${{ matrix.arch }}
./scripts/install.sh macos ${{ matrix.arch }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
shell: bash
run: |
cmake -B build/windows-${{ matrix.arch }} -G Ninja \
-DANTHY=OFF -DBAMBOO=OFF -DCHEWING=OFF -DCHINESE_ADDONS=OFF -DCSKK=OFF -DHANGUL=OFF -DJYUTPING=OFF -DKEYMAN=OFF -DKKC=OFF -DM17N=OFF -DMOZC=OFF -DRIME=OFF -DSKK=OFF -DTABLE_EXTRA=OFF \
-DANTHY=OFF -DBAMBOO=OFF -DCHEWING=OFF -DCHINESE_ADDONS=OFF -DCSKK=OFF -DHANGUL=OFF -DJYUTPING=OFF -DKEYMAN=OFF -DKKC=OFF -DM17N=OFF -DMOZC=OFF -DRIME=OFF -DSKK=OFF -DTABLE_EXTRA=OFF -DZHUYIN=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE='windows-cross/msys2.toolchain.cmake' \
-DARCH=${{ matrix.cmake_arch }}
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,6 @@
[submodule "windows-cross"]
path = windows-cross
url = https://github.com/fcitx-contrib/windows-cross
[submodule "fcitx5-zhuyin"]
path = fcitx5-zhuyin
url = https://github.com/fcitx/fcitx5-zhuyin
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ option(SKK "" ON)
option(TABLE_EXTRA "" ON)
option(THAI "" ON)
option(UNIKEY "" ON)
option(ZHUYIN "" ON)

list(PREPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
set(CMAKE_INSTALL_PREFIX /usr)
Expand Down Expand Up @@ -273,3 +274,9 @@ if (WIN32)
target_compile_definitions(unikey-lib PUBLIC -DUNIKEYHOOK)
endif()
endif()

# zhuyin
if (ZHUYIN)
add_subdirectory(fcitx5-zhuyin)
target_link_libraries(zhuyin "-L${PREBUILDER_LIB_DIR}" -lkyotocabinet -lz)
endif()
17 changes: 17 additions & 0 deletions docs/debug-js.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Uncaught RuntimeError: function signature mismatch

WASM 不允许函数指针的签名和实际函数的签名不一致。glib 巨量滥用这个 UB,因此出了很多问题。

将库开启调试,插件使用 `-DCMAKE_BUILD_TYPE=Debug`。

可能需要带 `--enable-features=WebAssemblyUnlimitedSyncCompilation` 启动 Chrome。

复现问题后,在 `call_indirect` 处断点。命中后在 Sources -> Scope -> Expression 展开 `stack`,序号最大的整数即为实际函数地址。

在 Module 展开 `tables`,`$env.__indirect_function_table` 找到实际函数。

# 产物包含绝对路径

`tar xf -C` 解包,`grep` 找到具体的 .o,`wasm2wat`。

在 wat 里找到 `(data $.L.str.x (i32.const y) "绝对路径")`,搜索 `(i32.const y)`,查看所在函数源码。
1 change: 1 addition & 0 deletions fcitx5-zhuyin
Submodule fcitx5-zhuyin added at 2f06f0
54 changes: 54 additions & 0 deletions patches/zhuyin.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8336d50..ca40c0d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,9 +37,7 @@ include("${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cma

add_subdirectory(po)
add_subdirectory(src)
-add_subdirectory(data)
enable_testing()
-add_subdirectory(test)

fcitx5_translate_desktop_file(org.fcitx.Fcitx5.Addon.Zhuyin.metainfo.xml.in
org.fcitx.Fcitx5.Addon.Zhuyin.metainfo.xml XML)
diff --git a/src/zhuyinengine.cpp b/src/zhuyinengine.cpp
index c886797..d0e220c 100644
--- a/src/zhuyinengine.cpp
+++ b/src/zhuyinengine.cpp
@@ -306,17 +306,17 @@ ZhuyinEngine::ZhuyinEngine(Instance *instance)
: instance_(instance), factory_([this](InputContext &ic) {
return new ZhuyinState(this, &ic);
}) {
- auto userDir =
- StandardPaths::global().userDirectory(StandardPathsType::PkgData) /
- "zhuyin";
+ const auto &sp = StandardPaths::global();
+ auto userDir = sp.userDirectory(StandardPathsType::PkgData) / "zhuyin";
if (!fs::makePath(userDir)) {
if (fs::isdir(userDir)) {
ZHUYIN_DEBUG() << "Failed to create user directory: " << userDir;
}
}
- context_.reset(zhuyin_init(
- StandardPaths::fcitxPath("pkgdatadir", "zhuyin").string().c_str(),
- userDir.string().c_str()));
+ std::string tablePath =
+ sp.locate(StandardPathsType::PkgData, "zhuyin/table.conf");
+ context_.reset(zhuyin_init(fcitx::fs::dirName(tablePath).c_str(),
+ userDir.string().c_str()));

instance->inputContextManager().registerProperty("zhuyinState", &factory_);
reloadConfig();
@@ -553,11 +553,6 @@ void ZhuyinEngine::reloadConfig() {

zhuyin_set_options(context_.get(), options);

- instance_->inputContextManager().foreach([this](InputContext *ic) {
- auto *state = ic->propertyFor(&factory_);
- state->reset();
- return true;
- });

zhuyin_load_phrase_library(context_.get(), USER_DICTIONARY);
}
4 changes: 4 additions & 0 deletions scripts/install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ macos=(
json
json-glib
keyman-core
kyotocabinet
leveldb
libchewing
libgee
libhangul
libkkc
libmozc
libpinyin
librime
libskk
libthai
Expand All @@ -40,12 +42,14 @@ js=(
json
json-glib
keyman-core
kyotocabinet
leveldb
libchewing
libgee
libhangul
libkkc
libmozc
libpinyin
librime
libskk
libthai
Expand Down
10 changes: 10 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ macos=(
table-other
thai
unikey
zhuyin
)

windows=(
Expand Down Expand Up @@ -48,6 +49,7 @@ js=(
skk
thai
unikey
zhuyin
)

. scripts/platform.sh "$@"
Expand Down Expand Up @@ -144,6 +146,13 @@ gunzip -fc $ROOT/cache/$skk_dict > $skk_share_dir/skk/SKK-JISYO.L
fi
fi

# zhuyin
if [[ $PLATFORM != "windows" ]]; then
zhuyin_data=zhuyin-data.tar.bz2
[[ -f $ROOT/cache/$zhuyin_data ]] || curl -LO --output-dir $ROOT/cache https://github.com/fcitx-contrib/zhuyin-data/releases/download/latest/$zhuyin_data
tar xf $ROOT/cache/$zhuyin_data -C $TARGET_DIR/zhuyin/usr
fi

if [[ $PLATFORM == "macos" || $PLATFORM == "windows" ]]; then
# split arch-specific files with data
for plugin in "${plugins[@]}"; do
Expand Down Expand Up @@ -208,6 +217,7 @@ package m17n
package mozc mozc
package rime rime
package skk skk
package zhuyin zhuyin
fi
package hallelujah hallelujah
package sayura sayura
Expand Down
18 changes: 18 additions & 0 deletions tests/test-zhuyin.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test } from '@playwright/test'
import { expectCandidate, expectText, init } from './util'

test('5j', async ({ page }) => {
await init(page, 'zhuyin', 'ㄅㄆㄇㄈ')

await page.keyboard.type('5j')
await expectText(page, 'ㄓㄨ')

await page.keyboard.press(' ')
await expectText(page, '朱')

await page.keyboard.press('ArrowDown')
await expectCandidate(page, '竹', 1)

await page.keyboard.press('4')
await expectText(page, '珠')
})