Commit graph

22 commits

Author SHA1 Message Date
LongYinan
0550c56fcf
fix(napi): External should impl FromNapiRef rather than FromNapiValue (#2013)
- Close https://github.com/napi-rs/napi-rs/issues/1994
2024-03-25 15:11:11 +08:00
LongYinan
4719caa643
feat(napi): support Return generic of ThreadsafeFunction (#1997)
* 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>
2024-03-20 21:37:08 +08:00
Janrupf
ac3626a023
fix(napi): Fix buffer corruption and soundness issues (#1923)
* fix(napi): Fix buffer corruption and soundness issues

* test: fix tests to conform to buffer API
2024-01-29 18:32:28 +08:00
LongYinan
05b4be4d80
style: clippy fix (#1711) 2023-08-30 16:41:13 +08:00
Victor Teo
aee742f185
feat(napi): property getter and setter with closure (#1526)
* getter with closure with segment fault

* fix getter closure pointer

* add setter

* Cleanup API

* Add test for `create_function_from_closure`

* Fix compile error

* Fix flaky test title

---------

Co-authored-by: LongYinan <lynweklm@gmail.com>
2023-03-21 11:22:07 +08:00
LongYinan
e9de5681be
fix(napi): also apply electron external data fallback to lowlevel APIs (#1458)
* fix(napi): also apply electron external data fallback to lowlevel APIs

* chore: allow uninlined_format_args in tests
2023-01-28 21:31:57 +08:00
LongYinan
dc3a4c9f25
feat(napi): refactor ThreadsafeFunction to allow get return value of it (#1427) 2023-01-11 18:54:45 +08:00
LongYinan
6e4b16fe5d
style: clippy fix 2022-12-16 20:19:39 +08:00
nihohit
1cf32631bf
fix(napi): typed arrays ref shouldn't use offset. (#1376)
Notice from the n-api docs that the data returned from
`napi_get_typedarray_info` is already adjusted by the byte offset.
https://nodejs.org/api/n-api.html#napi_get_typedarray_info

This means that when `as_ref`/`as_mut` apply the byte offset, the
offset is in practice applied twice.
This wasn't caught in tests because no test tried to modify a typed
array with a byte offset, and the test didn't us the typed array
structs, only `JsTypedArray`. If you want, I can modify the rest of the
functions in examples/napi-compt-mode/src/arraybuffers.rs
and the matching tests, to test all typed arrays.

IMO the `byte_offset` field can be removed entirely from the struct,
but I wanted to submit a minimal PR.
2022-11-30 20:54:13 +08:00
Devon Govett
5541d650a9
feat(napi): add threadsafe deferred values (#1306) 2022-10-03 13:00:48 +08:00
Devon Govett
5ba70b0e1a
fix(napi): improve error propagation (#1303) 2022-09-14 17:03:11 +08:00
Ben Noordhuis
f301581445 feat(napi): make Error::from_reason() generic 2022-05-01 17:00:24 +02:00
Niklas Mischkulnig
0bdb722097
test(napi): add test for multiple empty buffers 2022-04-23 12:27:47 +02:00
LongYinan
89893cdca3
style: apply clippy suggestion 2022-02-06 10:49:16 +08:00
LongYinan
49a0139f81
style: clippy fix 2021-12-03 16:49:25 +08:00
LongYinan
4aa56a148c
fix(napi): missing coerce_to_bool on JsValue 2021-11-21 23:10:29 +08:00
LongYinan
3386bb9867
feat(napi): support JsGlobal in Env 2021-11-15 22:41:01 +08:00
LongYinan
30031f09ed
feat(napi): create ThreadsafeFunction from JsFunction 2021-11-12 17:22:57 +08:00
LongYinan
0424a08c06
feat(napi): BigInt codegen support 2021-11-11 16:18:25 +08:00
LongYinan
e0671fe071
feat(napi): implement Env::throw to throw any JsValue 2021-11-06 23:33:58 +08:00
LongYinan
e74fe2fb94
feat(napi): implement AsyncTask with AbortSignal support 2021-11-06 13:51:54 +08:00
forehalo
2467b7139b
Introduce #[napi] procedural macro to automation development boilerplate (#696)
* napi procedural macro for basic rust/JavaScript types
* introduce the `compat-mode` for `napi` and `napi-derive` crates for backward compatible
* remove #[inline] and let compiler to decide the inline behavior
* cli now can produce the `.d.ts` file for native binding
* many tests and example for the new procedural macro

Co-authored-by: LongYinan <lynweklm@gmail.com>
2021-09-23 01:29:09 +08:00