432 Commits

Author SHA1 Message Date
LongYinan
a040416f9f
chore(napi): reduce Node-API call in AsyncTask (#2176) 2024-07-08 16:57:53 +08:00
LongYinan
70a5fce68d
Release independent packages
- napi@3.0.0-alpha.6
2024-07-07 20:55:20 +08:00
LongYinan
3a511bacee
fix(napi): Promise callbacks should require static lifetime (#2172) 2024-07-07 20:42:17 +08:00
LongYinan
27030c8dae
refactor(napi): simplify Promise implementation (#2171) 2024-07-07 14:59:03 +08:00
LongYinan
807b987a20
fix(napi): PromiseRaw does not require napi4 and tokio_rt 2024-07-06 23:59:26 +08:00
LongYinan
eb09a6f7f5
Release independent packages
- napi@3.0.0-alpha.5
- napi-derive@3.0.0-alpha.4
2024-07-06 23:48:30 +08:00
LongYinan
bc9e931a4e
feat(napi): provide PromiseRaw for non-await scenario (#2168) 2024-07-06 19:09:16 +08:00
LongYinan
a4cd94ea30
Release independent packages
- napi@3.0.0-alpha.4
2024-07-06 14:34:06 +08:00
LongYinan
aef57fb196
feat(napi): impl from_string for Uint8Array (#2167) 2024-07-06 14:32:09 +08:00
Jade-fu
2265ca3e1a
fix(napi): asynchronous functions can return any errors (#2165)
* feat(napi): asynchronous functions can return any errors as long as they implement the Into<Error> trait.

* chore: use impl Into<Error>
2024-07-04 14:47:32 +08:00
LongYinan
657fbfb113
Release independent packages
- napi@3.0.0-alpha.3
- napi-derive@3.0.0-alpha.2
2024-06-27 20:46:29 +08:00
Gentle
7c4072b237
let docs.rs generate all documentation (#2160)
without this, all-features = true has no effect

Co-authored-by: Gentle <ramon.klass@gmail.com>
2024-06-27 20:40:34 +08:00
LongYinan
04bd89b9a4
chore(napi): exclude libuv api on wasm targets (#2156) 2024-06-24 23:36:05 +08:00
LongYinan
a7d85b0549
chore(napi): remove stale tokio feature (#2155) 2024-06-24 17:41:58 +08:00
Dennis Duda
bd5b86e13b
chore(napi): reduce monomorphization load of various functions (#2143)
* 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>
2024-06-18 22:41:49 +08:00
LongYinan
ea623903d8
chore: clippy fix (#2144) 2024-06-18 13:20:43 +08:00
Özgür Akkurt
14d88997d7
chore(napi): print anyhow error in debug mode to show trace (#2140) 2024-06-17 11:45:10 +08:00
Ranger
19e3488efc
fix(napi): JsString should respect \0 character to align with String (#2138)
* fix(napi): JsString should respect \0 character to align with String

* chore(test): update snapshot
2024-06-12 15:20:27 +08:00
Kreijstal
ac47a92424
feat(build): add windows gnu target (#2026)
* squash  attempt number 2

* Add clang64

this adds clang64 compiler to the test suite

---------

Co-authored-by: LongYinan <lynweklm@gmail.com>
2024-06-09 00:54:59 +08:00
Gentle
2f21ba1872
chore(napi): make Ser and De public #2131
also adds helper functions needed to work with Ser and De

Co-authored-by: Gentle <ramon.klass@gmail.com>
2024-06-07 16:19:55 +08:00
Ranger
a3b01870a3
feat(napi): support External for compact mode and add JsExternal as deprecated (#2125) 2024-05-26 14:43:33 +08:00
Ranger
879008c4b6
feat(napi): implement ToNapiValue for Ref as required by TSFN (#2122) 2024-05-23 09:50:03 +08:00
Ranger
c52d2042a2
feat(napi): Function build_thfn support calledhandled mode (#2114)
* feat(napi): Function build_thfn support calledhandled mode

* test(example): add calleehandle example
2024-05-18 20:20:12 +08:00
LongYinan
1e781a589c
chore(napi): remove depracated get_js_function (#2101) 2024-05-09 15:13:44 +08:00
Niklas Mischkulnig
f3d665d5b1
fix(napi): panic when deserializing empty buffer with Rust 1.78 (#2094)
* 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>
2024-05-07 17:57:15 +08:00
LongYinan
4572ede9f5
refactor(napi): split T and CallJsBackArgs generic type (#2091) 2024-05-06 18:25:40 +08:00
Ranger
e9123e2c43
fix(napi): make sure env without exception pending before throw error (#2092) 2024-05-06 18:11:53 +08:00
LongYinan
3fc19fb2a3
style: fix clippy errors (#2090)
* style: fix clippy errors

* ci: rename wasip1 target name
2024-05-06 13:53:49 +08:00
Simon Hausmann
67ee2d085f
fix(napi): panic in JsArrayBufferValue as_ref/as_mut with Rust 1.78 (#2083)
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.
2024-05-06 11:56:58 +08:00
naskya
68b5f2c587
feat(napi): support chrono datetime with timezones (#2074)
* feat(napi): implement From/ToNapiValue for chrono::DateTime<Local> and chrono::DateTime<FixedOffset> (#1902)

* chore(napi): update tests

Co-authored-by: sup39 <dev@sup39.dev>

---------

Co-authored-by: sup39 <dev@sup39.dev>
2024-04-30 22:51:40 +08:00
LongYinan
8f5d7e5274
fix(napi): handle panic in async block (#2050)
- Close https://github.com/napi-rs/napi-rs/issues/2047
2024-04-17 23:34:47 +08:00
LongYinan
dacfeac1f5
Release independent packages
napi@3.0.0-alpha.2
2024-04-15 23:59:37 +08:00
LongYinan
e3a403b441
feat(napi): allow user defined tokio runtime (#2040) 2024-04-15 23:58:28 +08:00
Louis
19dbadefba
fix(ThreadsafeFunction): ensure CalleeHandled works as expected (#2039)
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.
2024-04-15 23:19:15 +08:00
翠 / green
923b82aee9
feat(napi): allow &External to be created from napi value (#2037) 2024-04-15 17:54:10 +08:00
LongYinan
63c8ab3f20
Release independent packages
napi@3.0.0-alpha.1
napi-derive@3.0.0-alpha.1
napi-sys@2.4.0
2024-04-10 17:03:00 +08:00
Ranger
e86e3add2b
fix(napi): napi_adjust_external_memory should be hidden with wasm target (#2031) 2024-04-10 14:57:04 +08:00
翠 / green
a394984f5d
docs: update platform support in README (#2029)
Co-authored-by: LongYinan <lynweklm@gmail.com>
2024-04-09 18:29:04 +08:00
翠 / green
2e0f983ccf
feat(target): add support for s390x-unknown-linux-gnu (#2028)
* feat(target): add support for s390x-unknown-linux-gnu

* chore: rerun CI
2024-04-09 14:16:09 +08:00
翠 / green
71a528535a
fix(napi): create_bigint_from_*128 returned incorrect word_count (#2024)
The value of `word_count` was inconsistent between the node side and rust side when calling `create_bigint_from_i128`/`create_bigint_from_u128`.
2024-04-08 10:43:23 +09:00
LongYinan
f2e5094345
feat(napi-sys): support load Node-API symbols dynamically (#2014) 2024-03-27 14:35:16 +08:00
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
be610c9353
style: clippy fix (#2012) 2024-03-23 19:35:58 +08:00
Louis
15521fb90f
fix(napi): no panic when caller stops listening (#2010)
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.
2024-03-22 22:03:19 +08:00
LongYinan
2a7c000275
Release independent packages
- napi@3.0.0-alpha.0
- napi-derive@3.0.0-alpha.0
2024-03-20 22:46:59 +08:00
LongYinan
13651c5ff1
chore(napi): add Send and Sync to Reference (#2007) 2024-03-20 22:30:45 +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
Louis
693f0ac269
feat(napi): implement From<String> for Buffer (#2002) 2024-03-17 22:43:01 +08:00
Hana
97746b79a9
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.
2024-03-13 13:29:06 +08:00
LongYinan
d962e34d3a
fix(napi): remove useless FromNapiValue bound check for ValidateNapiValue (#1999) 2024-03-10 21:22:46 +08:00