357 Commits

Author SHA1 Message Date
LongYinan
f705454029
feat(napi): introduce AsyncBlock to let user dispose resources after future done (#2338) 2024-10-31 09:24:30 +08:00
LongYinan
00a3c13b42
feat(napi): impl io::Read for Uint8Array (#2336) 2024-10-30 16:15:43 +08:00
LongYinan
79cbb9170e
fix!(sys): Node-API accpet NAPI_AUTO_LENGTH parameter type should be isize rather than usize (#2331) 2024-10-28 23:45:32 +08:00
LongYinan
f707f36c5a
feat(napi): implmenet Set (#2330) 2024-10-26 20:11:58 +08:00
LongYinan
aff84674b2
refactor!(napi): remove &str FromNapiValue (#2323) 2024-10-21 16:43:30 +08:00
lauren n. liberda
d685dedb76
docs: update n-api version matrix docs url (#2319)
it has changed back in node.js 16.0 docs
2024-10-21 12:49:08 +08:00
LongYinan
52c424a956
fix(napi): needless cast to CString before call napi_create_string_utf8 (#2321) 2024-10-21 12:48:43 +08:00
LongYinan
161758393f
fix(napi): TypedArray is not ArrayBuffer in Deno (#2314) 2024-10-17 16:36:21 +08:00
Richer
383b5d023c
fix(napi): before using from_raw_parts should check if data is null (#2311) 2024-10-15 16:47:34 +08:00
Richer
7ed5972a78
pref(napi): display the real info for TypedArray (#2310) 2024-10-15 15:36:34 +08:00
LongYinan
dc4bfb8ea3
refactor!(napi): pass self to Task::finally instread of &mut self (#2309) 2024-10-14 11:26:30 +08:00
LongYinan
72afae3736
refactor!(napi): Ref::unref accept &mut self instead of self (#2308) 2024-10-14 11:14:25 +08:00
Richer
16fc9cbe31
feat(napi): support arraybuffer for de (#2296)
* feat(napi): support arraybuffer for de

* use BufferSlice

* clippy fix

---------

Co-authored-by: LongYinan <lynweklm@gmail.com>
2024-10-14 00:24:45 +08:00
LongYinan
e0811d1644
fix(napi): data maybe null in custom_gc (#2304)
* fix(napi): data maybe null in custom_gc

Sometimes thread has not been disposed but the objects on it have been
recycled, we need to check if the data has been pointed to null before
unref it.

* disable v8 compile cache on CI
2024-10-13 23:33:39 +08:00
LongYinan
afd081d003
feat(napi,napi-derive): allow lifetime in Class (#2298) 2024-10-10 05:59:14 +02:00
LongYinan
724673225a
refactor!(napi): remove clone fn on ThreadsafeFunction (#2291) 2024-10-07 19:23:11 +02:00
LongYinan
eba0b52c59
chore(napi): env doesn't need to be mut (#2292) 2024-10-07 19:20:21 +02:00
LongYinan
69cd73d71c
refactor!(napi,napi-derive): add lifetime to ClassInstance (#2286) 2024-10-02 10:42:34 +02:00
LongYinan
a4a8d31a42
chore(napi): remove once_cell (#2271) 2024-09-23 16:57:14 +08:00
Richer
daf4a80bdb
feat(napi): mark create_buffer as deprecated & use BufferSlice to replace JsBuffer for ser (#2267) 2024-09-22 11:22:05 +08:00
LongYinan
fc4b6a632d
refactor(napi-derive): expand order (#2265) 2024-09-20 22:44:34 +08:00
LongYinan
91af2c5961
Release independent packages
- napi@3.0.0-alpha.10
- napi-derive@3.0.0-alpha.9
2024-09-19 22:30:36 +08:00
LongYinan
521ef58f59
refactor(napi): allow create BufferSlice from external data (#2263)
- also refactor the enum codegen, now we will not emit #[derive(Copy,
  Clone)] for the original enums.
- also refacotr the fn codegen, now #[napi] fn can accept env: &Env as
  argument, this is useful when the return type contains lifetime
2024-09-19 22:22:33 +08:00
Igor Matuszewski
cc21452f65
fix(napi): nullptr handling in TypedArrays (#2258)
* fix: Safely return empty slices if TypedArray buffer is null ptr

* fix: Only dispose of TypedArray if the data is not a nullptr

* test: Add a regression test for typed array null ptr deref
2024-09-19 13:38:19 +08:00
LongYinan
bf8f568788
refactor!(napi): Ref should not hold the value ptr (#2243)
It's unsafe
2024-09-12 23:25:09 +08:00
Cong-Cong Pan
c04327e27b
perf(napi): remove unnecessary checks for strings from napi_get_value_string_utf8 (#2247)
Co-authored-by: LongYinan <lynweklm@gmail.com>
2024-09-12 23:24:50 +08:00
LongYinan
b0bf4f00d0
fix(napi): windows function registration timing (#2248)
* fix(napi): windows function registration timing

* fix clippy issue

* upgrade zig version

* pin rust version on zig cross compile ci
2024-09-12 23:18:05 +08:00
Richer
8b6cc10d77
fix(napi): use error_ref should checkout it at first (#2235) 2024-08-31 14:31:53 +08:00
Richer
5934ecd2a9
feat(napi): mark JsArraybufferValue's value pub (#2226) 2024-08-23 22:25:52 +08:00
sjh
09a79edfb7
fix(napi,napi-derive): ffi lifetime and pointer sound issues (#2216)
* The ownership of the CString will be taken in map function

* for empty struct like `#[napi] struct A;`, the `value_ref` will be `0x1`, and it will be overwritten by the others instance of the same class
2024-08-18 18:21:13 +08:00
Louis
164ef2a9f3
chore: implement serde::Serialize for Either (#2209)
This adds an implementation of serde::Serialize for all the Either types.
Long term, we might want to use the either crate, but for now this makes this
implementation usable with serde.
2024-08-05 18:05:49 +08:00
LongYinan
282ce1c00a
fix(napi): allow ThreadsafeFunction in Either (#2204) 2024-08-03 13:22:09 +08:00
LongYinan
6acd3b94fb
chore: add fail reason to assert (#2192) 2024-07-18 14:19:50 +08:00
Hana
ba345be957
perf(napi): reduce allocation for ToNapiValue of &str (#2191) 2024-07-18 13:08:02 +08:00
LongYinan
54ec4897ea
fix(napi): PromiseRaw throw error logic (#2187) 2024-07-14 23:28:36 +08:00
Jade-fu
9e36daf559
fix(napi): reexport feature should be align (#2184) 2024-07-11 23:00:08 +08:00
LongYinan
a040416f9f
chore(napi): reduce Node-API call in AsyncTask (#2176) 2024-07-08 16:57:53 +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
bc9e931a4e
feat(napi): provide PromiseRaw for non-await scenario (#2168) 2024-07-06 19:09:16 +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
04bd89b9a4
chore(napi): exclude libuv api on wasm targets (#2156) 2024-06-24 23:36:05 +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