Commit graph

543 commits

Author SHA1 Message Date
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 4719caa643. 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
7999475f76
Release independent packages
napi-build@2.1.3
2024-04-13 18:55:53 +08:00
LongYinan
16f0d49284
chore: increase wasi memory limits (#2035) 2024-04-13 18:35:08 +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
LongYinan
e274cf7ae6
feat(napi-derive): enhance the error messages in object validator (#2034) 2024-04-10 16:52:23 +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
Andrew Toth
6b1058a268
feat(napi-derive): add optional enum_string case conversion (#1995) 2024-03-11 20:10:00 +08:00
LongYinan
d962e34d3a
fix(napi): remove useless FromNapiValue bound check for ValidateNapiValue (#1999) 2024-03-10 21:22:46 +08:00
LongYinan
e3e8a0fb39
Release independent packages
napi@2.16.0

napi-derive@2.16.0
2024-02-28 15:06:11 +08:00
LongYinan
aeb0b4766d
fix(napi): add back the typecheck logic that was accidentally removed in Object::get_named_property (#1982)
- Close https://github.com/napi-rs/napi-rs/issues/1641
2024-02-28 14:29:02 +08:00
LongYinan
117e4ce153
fix(napi-derive): wrong dependency condition (#1980) 2024-02-25 15:25:42 +08:00
LongYinan
8ca1967bd8
feat(napi): impl BufferSlice and Uint8ClampedSlice (#1979) 2024-02-25 01:00:28 +08:00
LongYinan
f88a041fa3
feat(napi): impl chained Into for TypedArray types (#1978) 2024-02-25 00:58:27 +08:00
LongYinan
3e187151a6
fix(napi-derive): HashMap/IndexMap and slice generated types (#1977) 2024-02-25 00:56:30 +08:00
LongYinan
5af366b042
style(napi-derive): clippy fix (#1976) 2024-02-25 00:54:33 +08:00
LongYinan
71bbe0ef6f
fix(napi): remove useless create_reference in slice => TypedArray impl (#1975) 2024-02-25 00:52:30 +08:00
ebe97257a6
feat(napi-derive): add use_nullable attribute (#1971)
* feat(napi-derive): add use_nullable attribute

Co-authored-by: naskya <m@naskya.net>

* chore(napi-derive): update tests

Co-authored-by: naskya <m@naskya.net>

---------

Co-authored-by: naskya <m@naskya.net>
2024-02-24 21:49:54 +08:00
Louis
43415251b8
feat(napi): allow Reference as a class method param (#1966)
As of before this commit, there was a lock in the codegen preventing Reference
from being used as a function argument outside of a Reference<Self>.

This changes it, allowing Reference of any class to be added as a class method
argument anywhere. It has the same limitations as reference, as in it requires
the class to have been created with a factory or constructor. This change
implements FromNapiValue on Reference, which will unwrap the class and call the
existing from_value_ptr method. It also updated typegen so that we only emit
the reference type if we're in an impl block that doesn't match the Reference
we're getting. This ensures that typegen works as expected with the previous
behaviour.
2024-02-22 22:37:50 +08:00
LongYinan
33cf208758
Release independent packages
napi@2.15.4
2024-02-22 19:01:18 +08:00
Tom Barham
ebd5eef267
fix(napi): require static lifetime on add_finalizer callback (#1968)
Co-authored-by: LongYinan <lynweklm@gmail.com>
2024-02-22 18:40:04 +08:00
Louis
5b5f616d81
fix(napi): no hard fail on ThreadsafeFunction::call_async (#1970)
For many reasons, in an app we can end up in a scenario where the thread / task that initially called the ThreadsafeFunction gets interrupted. This means that the receiver would get collected, should a ThreadsafeFunction be awaited on the said thread. This will create an error when the ThreadsafeFunction's callback will be called, and call a napi_fatal_error.

This change makes it so that if the send errors, this error is hidden and thus prevents any hard failure. If a ThreadsafeFunction is called in such a case, its output won't be used, but we'll still run all the logic to ensure it ran properly.

Fixes https://github.com/napi-rs/napi-rs/issues/1665 - cc @Brooooooklyn
2024-02-22 17:34:10 +08:00
LongYinan
8855f18f50
Release independent packages
napi@2.15.3
2024-02-21 23:16:27 +08:00
Louis
9391196eef
fix(napi): prevent memory leak when Custom GC is used (#1963)
There is a piece of custom logic that has been added a while back to ensure
that Buffers can be sent across threads, and be dropped properly. This involves
a custom GC that runs on NodeJS's current thread (per my understanding). The
logic to drop the buffer on that custom GC differed from the one in the Drop
impl. This meant that everytime Node sent a buffer back to a napi-rs function,
the reference wouldn't be cleaned up properly, and it would leak (96 bytes per
Reference on an ARM MacOS machine).

This commit updates the logic in the custom GC so that it matches the one in
the Drop impl. This worked locally, and fixed any occurence of the leak I could
find.
2024-02-20 20:36:21 +08:00
Louis
90e3a349db
fix: remove outdated rustdoc about tokio channels (#1961)
This seems to be a relic of when napi-rs used channels to send data to the
tokio runtime. This removes the outdated doc, as this could be misleading if
one wants to understand what those channels are about.
2024-02-20 16:36:29 +08:00
LongYinan
9e44fd635b
fix(napi-derive): napi-derive-backend version 2024-02-20 15:17:43 +08:00
LongYinan
95af8065c0
Release independent packages
napi-build@2.1.2
2024-02-19 19:10:16 +08:00
LongYinan
ad35076d07
fix(cli,build): build params (#1960) 2024-02-19 18:09:34 +08:00
LongYinan
f7376f1e97
Release independent packages
napi-build@2.1.1
2024-02-18 22:05:20 +08:00
LongYinan
08b1f689bf
feat(cli,build): support setjmp.h (#1958) 2024-02-18 21:45:19 +08:00
LongYinan
97039b2f08
Release independent packages
- napi@2.15.2
- napi-derive@2.15.2
2024-02-17 22:58:31 +08:00
LongYinan
c49309fdc2
fix(napi): memory leak while using Reference (#1954)
- Close https://github.com/napi-rs/napi-rs/issues/1952
2024-02-17 22:14:27 +08:00
LongYinan
20e0983288
style: apply clippy fix (#1953) 2024-02-17 14:12:24 +08:00
LongYinan
5ac153388f
feat(napi): accept slice as TypedArray (#1951) 2024-02-15 23:40:45 +08:00
LongYinan
d7dc4dc5a2
feat(napi): extends the Map types interoperability (#1950) 2024-02-15 15:43:21 +08:00
LongYinan
b6adf8ae5c
Release independent packages
napi-derive@2.15.1
2024-02-08 20:41:49 +08:00