diff --git a/lib/Cargo.lock b/lib/Cargo.lock index 42e5db3c9..37b2254f6 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -411,12 +411,14 @@ dependencies = [ "log", "once_cell", "paste", + "regex", "serde", + "textwrap", "thiserror", "tokio", "toml", "uniffi", - "uniffi_bindgen", + "uniffi_bindgen 0.3.1+v0.25.0", "uniffi_build", "uniffi_macros", ] @@ -648,7 +650,8 @@ dependencies = [ "thiserror", "tokio", "uniffi", - "uniffi_bindgen", + "uniffi_bindgen 0.25.3", + "uniffi_bindgen 0.3.1+v0.25.0", "uniffi_bindgen_kotlin_multiplatform", ] @@ -2172,10 +2175,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] -name = "oneshot-uniffi" -version = "0.1.6" +name = "oneshot" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c548d5c78976f6955d72d0ced18c48ca07030f7a1d4024529fedd7c1c01b29c" +checksum = "e296cf87e61c9cfc1a61c3c63a0f7f286ed4554e0e22be84e8a38e1d264a2a29" [[package]] name = "opaque-debug" @@ -2657,9 +2660,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -2669,9 +2672,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -2686,9 +2689,9 @@ checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "remove_dir_all" @@ -3300,6 +3303,12 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "smawk" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" + [[package]] name = "socket2" version = "0.5.7" @@ -3477,6 +3486,11 @@ name = "textwrap" version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" +dependencies = [ + "smawk", + "unicode-linebreak", + "unicode-width", +] [[package]] name = "thiserror" @@ -3816,6 +3830,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + [[package]] name = "unicode-normalization" version = "0.1.22" @@ -3826,20 +3846,49 @@ dependencies = [ ] [[package]] -name = "uniffi" -version = "0.25.3" +name = "unicode-width" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21345172d31092fd48c47fd56c53d4ae9e41c4b1f559fb8c38c1ab1685fd919f" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" + +[[package]] +name = "uniffi" +version = "0.3.1+v0.25.0" +source = "git+https://github.com/NordSecurity/uniffi-rs.git?tag=v0.3.1+v0.25.0#1a5dc527165589456c3d7233107917e065192b03" dependencies = [ "anyhow", "camino", "clap 4.5.17", - "uniffi_bindgen", + "uniffi_bindgen 0.3.1+v0.25.0", "uniffi_build", "uniffi_core", "uniffi_macros", ] +[[package]] +name = "uniffi_bindgen" +version = "0.3.1+v0.25.0" +source = "git+https://github.com/NordSecurity/uniffi-rs.git?tag=v0.3.1+v0.25.0#1a5dc527165589456c3d7233107917e065192b03" +dependencies = [ + "anyhow", + "askama", + "camino", + "cargo_metadata", + "clap 4.5.17", + "fs-err", + "glob", + "goblin", + "heck 0.4.1", + "once_cell", + "paste", + "serde", + "textwrap", + "toml", + "uniffi_meta 0.3.1+v0.25.0", + "uniffi_testing 0.3.1+v0.25.0", + "uniffi_udl 0.3.1+v0.25.0", +] + [[package]] name = "uniffi_bindgen" version = "0.25.3" @@ -3850,7 +3899,6 @@ dependencies = [ "askama", "camino", "cargo_metadata", - "clap 4.5.17", "fs-err", "glob", "goblin", @@ -3859,9 +3907,9 @@ dependencies = [ "paste", "serde", "toml", - "uniffi_meta", - "uniffi_testing", - "uniffi_udl", + "uniffi_meta 0.25.3", + "uniffi_testing 0.25.3", + "uniffi_udl 0.25.3", ] [[package]] @@ -3878,18 +3926,26 @@ dependencies = [ "paste", "serde", "toml", - "uniffi_bindgen", + "uniffi_bindgen 0.25.3", ] [[package]] name = "uniffi_build" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "001964dd3682d600084b3aaf75acf9c3426699bc27b65e96bb32d175a31c74e9" +version = "0.3.1+v0.25.0" +source = "git+https://github.com/NordSecurity/uniffi-rs.git?tag=v0.3.1+v0.25.0#1a5dc527165589456c3d7233107917e065192b03" dependencies = [ "anyhow", "camino", - "uniffi_bindgen", + "uniffi_bindgen 0.3.1+v0.25.0", +] + +[[package]] +name = "uniffi_checksum_derive" +version = "0.3.1+v0.25.0" +source = "git+https://github.com/NordSecurity/uniffi-rs.git?tag=v0.3.1+v0.25.0#1a5dc527165589456c3d7233107917e065192b03" +dependencies = [ + "quote", + "syn 2.0.77", ] [[package]] @@ -3904,25 +3960,23 @@ dependencies = [ [[package]] name = "uniffi_core" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6121a127a3af1665cd90d12dd2b3683c2643c5103281d0fed5838324ca1fad5b" +version = "0.25.0" +source = "git+https://github.com/NordSecurity/uniffi-rs.git?tag=v0.3.1+v0.25.0#1a5dc527165589456c3d7233107917e065192b03" dependencies = [ "anyhow", "bytes", "camino", "log", "once_cell", - "oneshot-uniffi", + "oneshot", "paste", "static_assertions", ] [[package]] name = "uniffi_macros" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11cf7a58f101fcedafa5b77ea037999b88748607f0ef3a33eaa0efc5392e92e4" +version = "0.3.1+v0.25.0" +source = "git+https://github.com/NordSecurity/uniffi-rs.git?tag=v0.3.1+v0.25.0#1a5dc527165589456c3d7233107917e065192b03" dependencies = [ "bincode", "camino", @@ -3934,7 +3988,18 @@ dependencies = [ "syn 2.0.77", "toml", "uniffi_build", - "uniffi_meta", + "uniffi_meta 0.3.1+v0.25.0", +] + +[[package]] +name = "uniffi_meta" +version = "0.3.1+v0.25.0" +source = "git+https://github.com/NordSecurity/uniffi-rs.git?tag=v0.3.1+v0.25.0#1a5dc527165589456c3d7233107917e065192b03" +dependencies = [ + "anyhow", + "bytes", + "siphasher", + "uniffi_checksum_derive 0.3.1+v0.25.0", ] [[package]] @@ -3946,7 +4011,19 @@ dependencies = [ "anyhow", "bytes", "siphasher", - "uniffi_checksum_derive", + "uniffi_checksum_derive 0.25.3", +] + +[[package]] +name = "uniffi_testing" +version = "0.3.1+v0.25.0" +source = "git+https://github.com/NordSecurity/uniffi-rs.git?tag=v0.3.1+v0.25.0#1a5dc527165589456c3d7233107917e065192b03" +dependencies = [ + "anyhow", + "camino", + "cargo_metadata", + "fs-err", + "once_cell", ] [[package]] @@ -3962,6 +4039,17 @@ dependencies = [ "once_cell", ] +[[package]] +name = "uniffi_udl" +version = "0.3.1+v0.25.0" +source = "git+https://github.com/NordSecurity/uniffi-rs.git?tag=v0.3.1+v0.25.0#1a5dc527165589456c3d7233107917e065192b03" +dependencies = [ + "anyhow", + "uniffi_meta 0.3.1+v0.25.0", + "uniffi_testing 0.3.1+v0.25.0", + "weedle2 4.0.0 (git+https://github.com/NordSecurity/uniffi-rs.git?tag=v0.3.1+v0.25.0)", +] + [[package]] name = "uniffi_udl" version = "0.25.3" @@ -3969,9 +4057,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "889edb7109c6078abe0e53e9b4070cf74a6b3468d141bdf5ef1bd4d1dc24a1c3" dependencies = [ "anyhow", - "uniffi_meta", - "uniffi_testing", - "weedle2", + "uniffi_meta 0.25.3", + "uniffi_testing 0.25.3", + "weedle2 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4215,6 +4303,14 @@ dependencies = [ "nom", ] +[[package]] +name = "weedle2" +version = "4.0.0" +source = "git+https://github.com/NordSecurity/uniffi-rs.git?tag=v0.3.1+v0.25.0#1a5dc527165589456c3d7233107917e065192b03" +dependencies = [ + "nom", +] + [[package]] name = "which" version = "4.4.2" diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 9ef470383..c5c53cc80 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -36,8 +36,10 @@ log = "0.4.20" once_cell = "1.19" thiserror = "1.0" # Version must match that used by uniffi-bindgen-go -uniffi = "0.25.0" -uniffi_macros = "0.25.0" +uniffi = { git = "https://github.com/NordSecurity/uniffi-rs.git", tag = "v0.3.1+v0.25.0" } +uniffi_bindgen = { git = "https://github.com/NordSecurity/uniffi-rs.git", tag = "v0.3.1+v0.25.0" } +uniffi_build = { git = "https://github.com/NordSecurity/uniffi-rs.git", tag = "v0.3.1+v0.25.0" } +uniffi_macros = { git = "https://github.com/NordSecurity/uniffi-rs.git", tag = "v0.3.1+v0.25.0" } [patch.crates-io] # https://github.com/BlockstreamResearch/rust-secp256k1-zkp/pull/48/commits diff --git a/lib/bindings/Cargo.toml b/lib/bindings/Cargo.toml index 0f713421d..ad297a5d1 100644 --- a/lib/bindings/Cargo.toml +++ b/lib/bindings/Cargo.toml @@ -17,7 +17,8 @@ breez-sdk-liquid = { path = "../core" } log = { workspace = true } uniffi = { workspace = true, features = [ "bindgen-tests", "cli" ] } # Bindgen used by KMP, version has to match the one supported by KMP -uniffi_bindgen = "0.25.2" +uniffi_bindgen = { workspace = true } +uniffi_bindgen_kmp = { version = "0.25.2", package = "uniffi_bindgen" } uniffi_bindgen_kotlin_multiplatform = { git = "https://gitlab.com/trixnity/uniffi-kotlin-multiplatform-bindings", rev = "e8e3a88df5b657787c1198425c16008232b26548" } camino = "1.1.1" thiserror = { workspace = true } diff --git a/lib/bindings/langs/react-native/Cargo.toml b/lib/bindings/langs/react-native/Cargo.toml index 5c6fe2d3a..941b1caf3 100644 --- a/lib/bindings/langs/react-native/Cargo.toml +++ b/lib/bindings/langs/react-native/Cargo.toml @@ -9,9 +9,9 @@ edition = "2021" anyhow = { version = "1.0.57", features = ["backtrace"] } thiserror = "1.0" tokio = { version = "1", features = ["full"] } -uniffi = { version = "0.25.2", features = ["bindgen-tests", "cli"] } -uniffi_bindgen = "0.25.2" -uniffi_macros = "0.25.2" +uniffi = { workspace = true, features = ["bindgen-tests", "cli"] } +uniffi_bindgen = { workspace = true } +uniffi_macros = { workspace = true } camino = "1.1.1" log = { workspace = true } serde = "*" @@ -21,8 +21,10 @@ clap = { version = "3.2.22", features = ["derive"] } heck = "0.4" paste = "1.0" once_cell = { workspace = true } +textwrap = "0.16" +regex = "1.11.0" [build-dependencies] -uniffi_build = { version = "0.25.2" } -uniffi_bindgen = "0.25.2" +uniffi_build = { workspace = true } +uniffi_bindgen = { workspace = true } anyhow = { version = "1.0.57", features = ["backtrace"] } diff --git a/lib/bindings/langs/react-native/src/gen_typescript/mod.rs b/lib/bindings/langs/react-native/src/gen_typescript/mod.rs index b02d2f1f8..dbdf51f5d 100644 --- a/lib/bindings/langs/react-native/src/gen_typescript/mod.rs +++ b/lib/bindings/langs/react-native/src/gen_typescript/mod.rs @@ -134,6 +134,8 @@ impl TypescriptCodeOracle { } pub mod filters { + use regex::{Captures, Regex}; + use super::*; fn oracle() -> &'static TypescriptCodeOracle { @@ -211,4 +213,82 @@ pub mod filters { pub fn ignored_function(nm: &str) -> Result { Ok(IGNORED_FUNCTIONS.contains(nm)) } + + pub fn docstring( + docstring: &str, + tabs: &i32, + ci: &ComponentInterface, + ) -> Result { + let docstring = replace_types(docstring, ci)?; + let docstring = replace_variables(&docstring)?; + let docstring = textwrap::indent(&textwrap::dedent(&docstring), " * "); + + let tabs = usize::try_from(*tabs).unwrap_or_default(); + let wrapped_docstring = format!("/**\n{docstring}\n */"); + Ok(textwrap::indent(&wrapped_docstring, &"\t".repeat(tabs))) + } + + fn replace_types(docstring: &str, ci: &ComponentInterface) -> Result { + let re = Regex::new(r"\[([a-zA-Z0-9_:]+)\]").unwrap(); + let replacement = |caps: &Captures| -> Result { + let split: Vec<&str> = caps[1].split("::").collect(); + if let Some(enum_def) = ci.get_enum_definition(&split[0]) { + let name = type_name(enum_def)?; + if split.len() == 2 { + let v_name = enum_variant(&split[1])?; + return Ok(format!("{{@link {}.{}}}", name, v_name)); + } + return Ok(format!("{{@link {}}}", name)); + } else if let Some(fn_def) = ci.get_function_definition(&split[0]) { + let name = fn_name(fn_def.name())?; + return Ok(format!("{{@link {}}}", name)); + } else if let Some(obj_def) = ci.get_object_definition(&split[0]) { + let mut name = type_name(obj_def)?; + if split.len() == 2 { + name = fn_name(&split[1])?; + } + return Ok(format!("{{@link {}}}", name)); + } else if let Some(rec_def) = ci.get_record_definition(&split[0]) { + let name = type_name(rec_def)?; + if split.len() == 2 { + let v_name = var_name(&split[1])?; + return Ok(format!("{{@link {}.{}}}", name, v_name)); + } + return Ok(format!("{{@link {}}}", name)); + } else if let Some(cb_def) = ci.get_callback_interface_definition(&split[0]) { + let name = type_name(cb_def)?; + return Ok(format!("{{@link {}}}", name)); + } + Ok(caps[0].to_string()) + }; + replace_all(&re, docstring, replacement) + } + + fn replace_variables(docstring: &str) -> Result { + let re = Regex::new(r"`(\w+)`").unwrap(); + let replacement = |caps: &Captures| -> Result { + if let Ok(name) = var_name(&caps[1]) { + return Ok(format!("`{}`", name)); + } + Ok(caps[0].to_string()) + }; + replace_all(&re, docstring, replacement) + } + + fn replace_all( + re: &Regex, + haystack: &str, + replacement: impl Fn(&Captures) -> Result, + ) -> Result { + let mut new = String::new(); + let mut last_match = 0; + for caps in re.captures_iter(haystack) { + let m = caps.get(0).unwrap(); + new.push_str(&haystack[last_match..m.start()]); + new.push_str(&replacement(&caps)?); + last_match = m.end(); + } + new.push_str(&haystack[last_match..]); + Ok(new) + } } diff --git a/lib/bindings/langs/react-native/src/gen_typescript/templates/EnumTemplate.ts b/lib/bindings/langs/react-native/src/gen_typescript/templates/EnumTemplate.ts index bc1e084eb..08544cf45 100644 --- a/lib/bindings/langs/react-native/src/gen_typescript/templates/EnumTemplate.ts +++ b/lib/bindings/langs/react-native/src/gen_typescript/templates/EnumTemplate.ts @@ -1,23 +1,23 @@ {%- if !ci.is_name_used_as_error(name) -%} {%- let e = ci.get_enum_definition(name).unwrap() %} {%- if e.is_flat() %} - +{% call ts::docstring(e, 0, ci) %} export enum {{ type_name }} { - {% for variant in e.variants() -%} - {{ variant.name()|enum_variant }} = "{{ variant.name()|var_name }}"{% if !loop.last %}, - {% endif %} + {%- for variant in e.variants() -%} + {%- call ts::docstring(variant, 1, ci) %} + {{ variant.name()|enum_variant }} = "{{ variant.name()|var_name }}"{% if !loop.last %},{% endif %} {%- endfor %} } {%- else %} export enum {{ type_name }}Variant { - {% for variant in e.variants() -%} - {{ variant.name()|enum_variant }} = "{{ variant.name()|var_name }}"{% if !loop.last %}, - {% endif %} + {%- for variant in e.variants() -%} + {%- call ts::docstring(variant, 1, ci) %} + {{ variant.name()|enum_variant }} = "{{ variant.name()|var_name }}"{% if !loop.last %},{% endif %} {%- endfor %} } - +{% call ts::docstring(e, 0, ci) %} export type {{ type_name }} = {% for variant in e.variants() -%}{ type: {{ type_name }}Variant.{{ variant.name()|enum_variant }}{% if variant.has_fields() %}, {%- call ts::field_list_decl(variant) -%}{% endif %} diff --git a/lib/bindings/langs/react-native/src/gen_typescript/templates/Helpers.ts b/lib/bindings/langs/react-native/src/gen_typescript/templates/Helpers.ts index c9262aa4a..25b335c18 100644 --- a/lib/bindings/langs/react-native/src/gen_typescript/templates/Helpers.ts +++ b/lib/bindings/langs/react-native/src/gen_typescript/templates/Helpers.ts @@ -1,20 +1,22 @@ +{%- call ts::docstring(ci.get_callback_interface_definition("EventListener").unwrap(), 0, ci) %} export type EventListener = (e: SdkEvent) => void - +{% call ts::docstring(ci.get_callback_interface_definition("Logger").unwrap(), 0, ci) %} export type Logger = (logEntry: LogEntry) => void - +{% call ts::docstring(ci.get_function_definition("connect").unwrap(), 0, ci) %} export const connect = async (req: ConnectRequest): Promise => { const response = await BreezSDKLiquid.connect(req) return response } - +{%- let obj = ci.get_object_definition("BindingLiquidSdk").unwrap() %} +{% call ts::docstring(obj.get_method("add_event_listener"), 0, ci) %} export const addEventListener = async (listener: EventListener): Promise => { const response = await BreezSDKLiquid.addEventListener() BreezSDKLiquidEmitter.addListener(`event-${response}`, listener) return response } - +{% call ts::docstring(ci.get_function_definition("set_logger").unwrap(), 0, ci) %} export const setLogger = async (logger: Logger): Promise => { const subscription = BreezSDKLiquidEmitter.addListener("breezSdkLiquidLog", logger) diff --git a/lib/bindings/langs/react-native/src/gen_typescript/templates/Objects.ts b/lib/bindings/langs/react-native/src/gen_typescript/templates/Objects.ts index 4cf23a111..c3b39f934 100644 --- a/lib/bindings/langs/react-native/src/gen_typescript/templates/Objects.ts +++ b/lib/bindings/langs/react-native/src/gen_typescript/templates/Objects.ts @@ -3,6 +3,7 @@ {%- match type_ %} {%- when Type::Object { name, module_path, imp } %} {% let obj = ci.get_object_definition(name).unwrap() %} +{%- call ts::docstring(obj, 0, ci) %} {%- for func in obj.methods() -%} {%- if func.name()|ignored_function == false -%} {%- include "TopLevelFunctionTemplate.ts" %} diff --git a/lib/bindings/langs/react-native/src/gen_typescript/templates/RecordTemplate.ts b/lib/bindings/langs/react-native/src/gen_typescript/templates/RecordTemplate.ts index 24e297a29..a67abea1a 100644 --- a/lib/bindings/langs/react-native/src/gen_typescript/templates/RecordTemplate.ts +++ b/lib/bindings/langs/react-native/src/gen_typescript/templates/RecordTemplate.ts @@ -1,5 +1,6 @@ {%- let rec = ci.get_record_definition(name).unwrap() %} +{%- call ts::docstring(rec, 0, ci) %} export type {{ type_name }} = { {%- call ts::field_list_decl(rec) %} } diff --git a/lib/bindings/langs/react-native/src/gen_typescript/templates/TopLevelFunctionTemplate.ts b/lib/bindings/langs/react-native/src/gen_typescript/templates/TopLevelFunctionTemplate.ts index a8191e87b..432eb0f78 100644 --- a/lib/bindings/langs/react-native/src/gen_typescript/templates/TopLevelFunctionTemplate.ts +++ b/lib/bindings/langs/react-native/src/gen_typescript/templates/TopLevelFunctionTemplate.ts @@ -1,3 +1,4 @@ +{%- call ts::docstring(func, 0, ci) %} {%- match func.return_type() -%} {%- when Some with (return_type) %} export const {{ func.name()|fn_name }} = async ({%- call ts::arg_list_decl(func) -%}): Promise<{{ return_type|return_type_name }}> => { diff --git a/lib/bindings/langs/react-native/src/gen_typescript/templates/Types.ts b/lib/bindings/langs/react-native/src/gen_typescript/templates/Types.ts index df4f877e1..390617931 100644 --- a/lib/bindings/langs/react-native/src/gen_typescript/templates/Types.ts +++ b/lib/bindings/langs/react-native/src/gen_typescript/templates/Types.ts @@ -2,7 +2,7 @@ {%- let type_name = type_|type_name %} {%- match type_ %} {%- when Type::Record { name, module_path } %} -{%- include "RecordTemplate.ts" %} +{% include "RecordTemplate.ts" %} {%- when Type::Enum { name, module_path } %} {%- include "EnumTemplate.ts" %} {%- else %} diff --git a/lib/bindings/langs/react-native/src/gen_typescript/templates/macros.ts b/lib/bindings/langs/react-native/src/gen_typescript/templates/macros.ts index 77042cf5d..8fb221067 100644 --- a/lib/bindings/langs/react-native/src/gen_typescript/templates/macros.ts +++ b/lib/bindings/langs/react-native/src/gen_typescript/templates/macros.ts @@ -14,6 +14,7 @@ {%- macro field_list_decl(rec) %} {%- for f in rec.fields() %} + {%- call docstring(f, 1, ci) %} {%- match f.as_type() %} {%- when Type::Optional { inner_type } %} {%- let unboxed = inner_type.as_ref() %} @@ -30,3 +31,11 @@ {%- if !loop.last %}, {% endif -%} {%- endfor %} {%- endmacro %} + +{%- macro docstring(defn, indent_tabs, ci) %} +{%- match defn.docstring() %} +{%- when Some(docstring) %} +{{ docstring|docstring(indent_tabs, ci) }} +{%- else -%} +{%- endmatch %} +{%- endmacro %} \ No newline at end of file diff --git a/lib/bindings/uniffi-bindgen.rs b/lib/bindings/uniffi-bindgen.rs index 9172dd706..af616d6cc 100644 --- a/lib/bindings/uniffi-bindgen.rs +++ b/lib/bindings/uniffi-bindgen.rs @@ -7,7 +7,7 @@ fn main() { let udl_file = "./src/breez_sdk_liquid.udl"; let out_dir = Utf8Path::new("ffi/kmp"); let config = Utf8Path::new("uniffi.toml"); - uniffi_bindgen::generate_external_bindings( + uniffi_bindgen_kmp::generate_external_bindings( KotlinBindingGenerator {}, udl_file, Some(config),