* refactor(napi): reduce monomorphization load of `JsObject::{get, set}`
Outside of `std::panicking::try` and `tokio`, these functions were the highest-up in `cargo-llvm-lines`.
Moves most of the logic out into non-generic functions.
* refactor(napi): reduce monomorphization load of `JsDeferred::new`
* refactor(napi): reduce monomorphization load of `call_js_cb`
---------
Co-authored-by: LongYinan <lynweklm@gmail.com>
* Add test for #2083
* Add test for serde_byte with empty buffer
* Fix using serde_bytes with empty buffers
* skip wasi test
* fix test
* clippy fix
* avoid ub
* use safer impl
---------
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
Co-authored-by: LongYinan <lynweklm@gmail.com>
In Rust 1.78, when debug assertions are enabled, slice::from_raw_parts panics if the provided data is a null pointer. This is possible through JsArrayBufferValue::new() as well as through
JsArrayBuffer::into_value, when napi_get_arraybuffer_info returns a null pointer
due to a zero length buffer.
This was refactored in 4719caa64377f7d926c92a4c1051474ae79036c4. This codepath
was swapped, as the fatal exception must be the normal codepath when the callee
handled field is false. This fixes it by swapping this if statement, all the
other calls have been checked and seem fine.
This fix is similar to the one in 5b5f616d81.
In both the then_callback & catch_callback, expect was being called in case
the send failed. This means that if we call a function that returns a promise
and the received gets closed (the calling thread stopped at the wrong time),
this will panic.
In such scenarios, it is fine not to panic. If the receiver doesn't care about
the output, we should just let it be.
* feat(napi): support to use tuple with either (#1993)
`Either` uses `ValidateNapiValue` + `TypeName` to validate and report error on value not being matched. So there's no way to remove these super traits from it. So I implemented these types to `Tuple` types.
* feat(napi): support `Return` generic of ThreadsafeFunction
* depracate JsFunction
* CalleeHandled tsfn should handle Result in callback
* Pass env to call_with_return_value callback
* Fix compile
* clippy fix
* Fix electron test
* Function args
---------
Co-authored-by: Hana <andywangsy@gmail.com>
`Either` uses `ValidateNapiValue` + `TypeName` to validate and report error on value not being matched. So there's no way to remove these super traits from it. So I implemented these types to `Tuple` types.