604 Commits

Author SHA1 Message Date
CPunisher
c459f0acf6
feat: support structured enum with discriminated unions (#2222)
* Structured enum

* Type indent

* Add test example

* Remove trailing commas

* discriminant

* discriminant conflict

* more test

* typo
2024-08-22 14:59:50 +08:00
CPunisher
e02ec1e87c
Replace self for Result<T> (#2224) 2024-08-22 14:59:00 +08:00
LongYinan
8df3f0f596
docs: remove dev protocal badge 2024-08-22 10:45:32 +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
LongYinan
2e5bf773e3
fix(napi-derive): warning in empty enum codegen (#2214) 2024-08-10 22:30:50 +08:00
LongYinan
d84fc42832
fix(napi-derive): string enum validate logic (#2213) 2024-08-10 21:27:17 +08:00
CPunisher
a154612019
fix(napi-derive): add more cases for typegen of function args (#2210)
* Handle more arg pat

* Update testcase

* Revert
2024-08-08 11:07:21 +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
Cong-Cong Pan
327998d0ac
fix(napi-derive): error for missing impl FromNapiValue since object_from_js = false (#2197) 2024-07-25 12:18:13 +08:00
LongYinan
22dba74813
Release independent packages
- napi-derive@3.0.0-alpha.7
2024-07-23 22:07:15 +08:00
Louis
f88b90f71e
fix(napi-derive): call flush on the BufWriter (#2195)
This is mandated by the Rust doc of the BufWriter. We've also seen bugs where
the data doesn't seem to be flushed properly, and thus the CLI fails to parse
JSONs emitted by napi-derive. This might be it, or not, but flushing shouldn't
hurt.
2024-07-23 21:08:13 +08:00
LongYinan
b884f62f7b
Release independent packages
- napi@3.0.0-alpha.8
2024-07-18 14:26:43 +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
0f7c40354f
Release independent packages
- napi-derive@3.0.0-alpha.6
2024-07-16 13:06:00 +08:00
Cong-Cong Pan
782d6ac5f8
fix(napi-derive): napi getter macros (#2188)
* fix: napi getter macros

* chore: cargo fmt
2024-07-16 12:48:38 +08:00
LongYinan
2fccedbaba
Release independent packages
- napi@3.0.0-alpha.7
2024-07-14 23:29:08 +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
8891c43ef7
Release independent packages
- napi-derive@3.0.0-alpha.5
2024-07-07 21:03:40 +08:00
LongYinan
38d041569a
fix(napi-derive): PromiseRaw typegen 2024-07-07 21:03:14 +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
16386638c2
fix(napi-derive): Result type in async fn (#2169) 2024-07-06 23:46:24 +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
1228e918e9
Release independent packages
- napi-derive@3.0.0-alpha.3
2024-07-01 13:28:46 +08:00
Jade-fu
c2bda9a900
fix(napi-derive): class constructor and factory should support custom error status (#2161) 2024-06-30 16:12:00 +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
magic-akari
734d74bd02
fix(typegen): add missing declare keyword (#2117) 2024-05-19 16:53:23 +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
Louis
c223954dc6
chore(napi): allow value attribute on enum variants (#2115)
This allows us to customize the enum value for string_enum. So far, only the case attribute was allowing us to customize the value of those variants, this is a next step in allowing the value to be different from the actual name.

This has a new test, and snapshots have been updated accordingly.

@Brooooooklyn - could we include that in napi v2 and tag after it?
2024-05-17 11:22:33 +08:00