From 4d43a6270aa681d0a107c7bef631aaa07d089648 Mon Sep 17 00:00:00 2001 From: marc-signal Date: Fri, 15 May 2026 14:16:26 -0400 Subject: [PATCH] Use linkme, not macro expansion, for Native.ts generation --- .github/workflows/build_and_test.yml | 2 +- .github/workflows/npm.yml | 2 +- Cargo.lock | 31 + Cargo.toml | 3 + README.md | 2 +- acknowledgments/acknowledgments.html | 7 +- justfile | 2 +- node/package.json | 4 +- node/ts/Native.ts | 3425 +++++++++-------- rust/bridge/README.md | 4 +- rust/bridge/node/Cargo.toml | 8 +- rust/bridge/node/bin/gen_ts_decl.py | 358 -- rust/bridge/node/native_ts/Cargo.toml | 19 + .../node/{bin => native_ts/src}/Native.ts.in | 54 +- rust/bridge/node/native_ts/src/main.rs | 51 + rust/bridge/node/src/lib.rs | 165 +- rust/bridge/node/src/logging.rs | 3 +- rust/bridge/shared/Cargo.toml | 1 + rust/bridge/shared/macros/src/lib.rs | 7 +- rust/bridge/shared/macros/src/node.rs | 190 +- rust/bridge/shared/macros/src/util.rs | 14 + rust/bridge/shared/testing/Cargo.toml | 1 + rust/bridge/shared/testing/src/types.rs | 42 + rust/bridge/shared/types/Cargo.toml | 1 + rust/bridge/shared/types/src/lib.rs | 3 + rust/bridge/shared/types/src/metadata.rs | 108 + .../shared/types/src/net/remote_config.rs | 1 - rust/bridge/shared/types/src/node/convert.rs | 305 +- .../shared/types/src/support/serialized.rs | 3 + rust/bridge/shared/types/src/zkgroup.rs | 8 +- 30 files changed, 2584 insertions(+), 2240 deletions(-) delete mode 100755 rust/bridge/node/bin/gen_ts_decl.py create mode 100644 rust/bridge/node/native_ts/Cargo.toml rename rust/bridge/node/{bin => native_ts/src}/Native.ts.in (72%) create mode 100644 rust/bridge/node/native_ts/src/main.rs create mode 100644 rust/bridge/shared/types/src/metadata.rs diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 4f8c1bf55..b17222c86 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -589,7 +589,7 @@ jobs: node-version-file: '.nvmrc' - name: Verify that the Node bindings are up to date - run: rust/bridge/node/bin/gen_ts_decl.py --verify + run: cargo run -p libsignal-node-native_ts -- --verify if: startsWith(matrix.os, 'ubuntu-') - run: npm ci diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index 2f0bca139..0c6aa98ad 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -154,7 +154,7 @@ jobs: - run: sudo apt-get install -U protobuf-compiler - name: Verify that the Node bindings are up to date - run: rust/bridge/node/bin/gen_ts_decl.py --verify + run: cargo run -p libsignal-node-native_ts -- --verify publish: name: Publish diff --git a/Cargo.lock b/Cargo.lock index 687ea179a..ccf3ef2ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2992,6 +2992,7 @@ dependencies = [ "libsignal-bridge", "libsignal-bridge-macros", "libsignal-bridge-testing", + "libsignal-bridge-types", "libsignal-protocol", "linkme", "log", @@ -3005,6 +3006,19 @@ dependencies = [ "uuid", ] +[[package]] +name = "libsignal-node-native_ts" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "libsignal-bridge", + "libsignal-bridge-testing", + "libsignal-bridge-types", + "libsignal-node", + "minijinja", +] + [[package]] name = "libsignal-protocol" version = "0.1.0" @@ -3206,6 +3220,12 @@ dependencies = [ "libc", ] +[[package]] +name = "memo-map" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d1115007560874e373613744c6fba374c17688327a71c1476d1a5954cc857b" + [[package]] name = "mime" version = "0.3.17" @@ -3291,6 +3311,17 @@ dependencies = [ "tracing", ] +[[package]] +name = "minijinja" +version = "2.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805bfd7352166bae857ee569628b52bcd85a1cecf7810861ebceb1686b72b75d" +dependencies = [ + "indexmap 2.13.0", + "memo-map", + "serde", +] + [[package]] name = "minimal-lexical" version = "0.2.1" diff --git a/Cargo.toml b/Cargo.toml index 40e1c6f69..7cce2ca65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ members = [ "rust/bridge/jni/impl", "rust/bridge/jni/testing", "rust/bridge/node", + "rust/bridge/node/native_ts", ] default-members = [ "rust/crypto", @@ -67,6 +68,7 @@ libsignal-message-backup = { path = "rust/message-backup" } libsignal-net = { path = "rust/net" } libsignal-net-chat = { path = "rust/net/chat" } libsignal-net-grpc = { path = "rust/net/grpc" } +libsignal-node = { path = "rust/bridge/node" } libsignal-protocol = { path = "rust/protocol" } libsignal-svrb = { path = "rust/svrb" } poksho = { path = "rust/poksho" } @@ -160,6 +162,7 @@ mediasan-common = "0.5.3" minidump = { version = "0.22.1", default-features = false } minidump-processor = { version = "0.22.1", default-features = false } minidump-unwind = { version = "0.22.1", default-features = false } +minijinja = "2.19.0" mp4san = "0.5.3" neon = { version = "1.1.0", default-features = false } nonzero_ext = "0.3.0" diff --git a/README.md b/README.md index f86bd128a..65c07f5db 100644 --- a/README.md +++ b/README.md @@ -214,7 +214,7 @@ $ npm run test When testing changes locally, you can use `npm run build` to do an incremental rebuild of the Rust library. Alternately, `npm run build-with-debug-level-logs` will rebuild without filtering out debug- and verbose-level logs. -When exposing new APIs to Node, you will need to run `rust/bridge/node/bin/gen_ts_decl.py` in +When exposing new APIs to Node, you will need to run `just generate-node` in addition to rebuilding. [nvm]: https://github.com/nvm-sh/nvm diff --git a/acknowledgments/acknowledgments.html b/acknowledgments/acknowledgments.html index 4ac84bca5..680a6a2ac 100644 --- a/acknowledgments/acknowledgments.html +++ b/acknowledgments/acknowledgments.html @@ -47,8 +47,8 @@

Overview of licenses: