From c6d5241b98ef7509ac94c46cd8eae9e759ab0bcb Mon Sep 17 00:00:00 2001 From: meehl <12648828+meehl@users.noreply.github.com> Date: Fri, 18 Sep 2026 09:58:10 +0200 Subject: [PATCH] Expose `luautf8` module through runtime This removes the runtime dependency on the external `luautf8` C library. --- Cargo.lock | 45 ++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/pob.rs | 3 +++ src/pob/subscript.rs | 3 +++ 4 files changed, 52 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 594e057..0d32a28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1401,6 +1401,28 @@ dependencies = [ "windows-registry", ] +[[package]] +name = "icu_casemap" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2edfd120d8445de853cf53a1abec916f638f933a70a6f4bf8f7e2d7b7f884e9" +dependencies = [ + "icu_casemap_data", + "icu_collections", + "icu_locale_core", + "icu_properties", + "icu_provider", + "potential_utf", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_casemap_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "059fcda0fc8d33effc6633a8cf0d8a3c17caf7d7c91918fba9918744f501e4e8" + [[package]] name = "icu_collections" version = "2.3.0" @@ -1409,6 +1431,7 @@ checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513" dependencies = [ "displaydoc", "potential_utf", + "serde", "utf8_iter", "yoke", "zerofrom", @@ -1877,6 +1900,18 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" +[[package]] +name = "luautf8-rs" +version = "0.1.0" +source = "git+https://github.com/meehl/luautf8-rs.git?rev=dc74b734e5285108068cf2ffb674c1dc840073c1#dc74b734e5285108068cf2ffb674c1dc840073c1" +dependencies = [ + "icu_casemap", + "icu_properties", + "mlua", + "unicode-normalization", + "unicode-segmentation", +] + [[package]] name = "lz4_flex" version = "0.13.1" @@ -3351,6 +3386,7 @@ dependencies = [ "glob", "image", "log", + "luautf8-rs", "mlua", "nohash-hasher", "num-traits", @@ -3980,6 +4016,15 @@ version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" +[[package]] +name = "unicode-normalization" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.13.3" diff --git a/Cargo.toml b/Cargo.toml index e6f5f71..280c379 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ flate2 = "1.1.2" glob = "0.3.3" image = { version = "0.25.8", default-features = false, features = ["rayon", "jpeg", "png", "webp"] } log = "0.4" +luautf8-rs = { git = "https://github.com/meehl/luautf8-rs.git", rev = "dc74b734e5285108068cf2ffb674c1dc840073c1", features = ["luajit"] } mlua = { version = "0.12.0", features = ["luajit", "anyhow"] } nohash-hasher = "0.2.0" num-traits = "0.2.19" diff --git a/src/pob.rs b/src/pob.rs index efc36c1..9ca46b1 100644 --- a/src/pob.rs +++ b/src/pob.rs @@ -124,6 +124,9 @@ impl PathOfBuilding { // register API functions api::register_globals(&lua)?; + // register Rust port of `luautf8` as module + lua.register_module("lua-utf8", luautf8::create_module(&lua)?)?; + Ok(lua) } diff --git a/src/pob/subscript.rs b/src/pob/subscript.rs index ab0e24c..892ffd5 100644 --- a/src/pob/subscript.rs +++ b/src/pob/subscript.rs @@ -136,6 +136,9 @@ impl Subscript { let lua = unsafe { Lua::unsafe_new() }; append_lua_package_dir(&lua, &script_dir.join("lua"))?; + // register Rust port of `luautf8` as module + lua.register_module("lua-utf8", luautf8::create_module(&lua)?)?; + // register a proxy for each allowed blocking call. // forwards the call to the main thread and blocks on `reply_rx` until the main thread // sends back the return values