mirror of
https://github.com/napi-rs/napi-rs.git
synced 2025-12-08 19:56:07 +00:00
* Implement FromNapiValue trait as macro Code behavior should remain the same, with much less copy-pasting of the same code. Additionally, this commit adds a unit tests for test for FromNapiValue for tuple trait which appears to be currently missing. * Simplify macro arr_get Rewrite the macro to reduce the size of expanded code of the macro (from 4088 to 2429 lines). Although this is a minor change, this may help reduce the size of compiled library. * Refactor typegen Type::Path Removes the need for keeping mutable variable, as its only assigned once. * [API BREAKING] Update api for calling functions. This commit introduces new type FnArgs, that is created with the goal of distinguishing between calling JS function from rust with tuple as argument and calling with multiple arguments. Currently there is no possibility to add ToNapiValue value, as tuple is used to call callback functions with more than one argument from rust. With this change, callbacks with multiple arguments, should be called, with converting tuple of argument into FnArgs struct, either by calling into() on such tuple, or by creating FnArgs struct directly. * Add support for FnArgs when generating TS types Updated the macro for generating typescript types, to correctly handle FnArgs struct. This is now treated as passthrough type and generates the output from the type inside of FnArgs struct. * Implement ToNapiValue trait for tuple With the changes to callback calling API, it's now possible to safely add this change. This change allows to pass tuple from rust code to JS to match the existing FromNapiValue trait currently existing in the library.
napi-derive-backend
Take care the ast parsing from napi-derive and generate "bridge" runtime code for both nodejs and rust.