refactor!(napi): arguments tuple behavior#2401
Merged
Brooooooklyn merged 6 commits intonapi-rs:mainfrom Jan 2, 2025
Merged
Conversation
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.
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.
Removes the need for keeping mutable variable, as its only assigned once.
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.
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.
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.
github-merge-queue bot
pushed a commit
to rolldown/rolldown
that referenced
this pull request
Feb 3, 2025
<!-- Thank you for contributing! --> ### Description 1. the modification because napi-rs/napi-rs#2401 <!-- Please insert your description here and provide especially info about the "what" this PR is solving -->
github-merge-queue bot
pushed a commit
to rolldown/rolldown
that referenced
this pull request
Feb 3, 2025
<!-- Thank you for contributing! --> ### Description 1. the modification because napi-rs/napi-rs#2401 <!-- Please insert your description here and provide especially info about the "what" this PR is solving -->
IWANABETHATGUY
added a commit
to rolldown/rolldown
that referenced
this pull request
Feb 3, 2025
<!-- Thank you for contributing! --> ### Description 1. the modification because napi-rs/napi-rs#2401 <!-- Please insert your description here and provide especially info about the "what" this PR is solving -->
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces the following changes:
More details is in specific commit description.