git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

scripts/web-probe/ime (1.2K)

 1 #!/usr/bin/env bash
 2 # web-probe/ime [<out-dir>] — input-method composition through the browser shell: the
 3 # reference app (src/main.rs) built for the page as `demo` builds it, and
 4 # ime.mjs's compositions in its text box, driven through Chromium's own IME path, in headless
 5 # Chromium with the clipboard permissions granted. Prints one line a check
 6 # and fails if any does. Needs what `run` needs.
 7 set -euo pipefail
 8 here=$(cd "$(dirname "$0")" && pwd)
 9 out=${1:+$(realpath -m "$1")}
10 fonts=${DEMO_FONTS_DIR:-/usr/share/fonts}
11 cd "$here/../.."
12 
13 cargo build --release --target wasm32-unknown-unknown --example demo_web
14 site=$(mktemp -d)
15 trap 'rm -rf "$site"' EXIT
16 wasm-bindgen --target web --no-typescript --out-dir "$site" \
17     target/wasm32-unknown-unknown/release/examples/demo_web.wasm
18 cp "$here/demo.html" "$site/demo.html"
19 ln -s "$fonts" "$site/fonts"
20 (cd "$fonts" && find . \( -type f -o -type l \) \( -iname '*.ttf' -o -iname '*.otf' -o -iname '*.ttc' -o -iname '*.otc' \) \
21     | sed 's|^\./||' | DEMO_FAMILIES="${DEMO_FAMILIES:-}" python3 -c 'import json,os,sys; print(json.dumps({"files": sys.stdin.read().split(), "families": os.environ["DEMO_FAMILIES"]}))') > "$site/fonts.json"
22 node "$here/ime.mjs" "$site" ${out:+"$out"}