napi-derive
napi-derive@2.10.0
1/24/2023
Highlights
ThreadsafeFunction
as params and object fields
#[napi]
pub fn accept_callback(callback: ThreadsafeFunction<u32>) {
std::thread::spawn(move || {
callback.call(200);
});
}
⬇️⬇️⬇️⬇️⬇️
export function acceptCallback(callback: (err: Error | null, value: number) -> any)
Disable ToNapiValue
for Object
With the object_to_js = false
filed, the ThreadsafeFunction
could be set as an Object field.
#[napi(object, object_to_js = false)]
pub struct Options {
pub enable_jsx: bool,
pub on_data: ThreadsafeFunction<Vec<u8>>,
}
What's Changed
- feat(napi-derive): generate ThreadsafeFunction types by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1449
- feat(napi-derive): allow partial implement From/To Napivalue for Object by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1448
- chore(napi-derive): allow unsafe async &mut self by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1453
Full Changelog: https://github.com/napi-rs/napi-rs/compare/@napi-rs/cli@2.14.4...napi-derive@2.10.0
napi-derive@2.9.5
1/14/2023
What's Changed
- fix(napi-derive): fix union type generation for ts function notation by @h-a-n-a in https://github.com/napi-rs/napi-rs/pull/1439
Full Changelog: https://github.com/napi-rs/napi-rs/compare/@napi-rs/cli@2.14.3...napi-derive@2.9.5
napi-derive@2.9.4
1/13/2023
What's Changed
- fix(napi-derive): remove ts type on field attrs for feature
noop
by @h-a-n-a in https://github.com/napi-rs/napi-rs/pull/1436
Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@2.10.6...napi-derive@2.9.4
napi-derive@2.9.3
12/9/2022
What's Changed
- Better error message for
#[napi(catch_unwind)]
by @simonvandel in https://github.com/napi-rs/napi-rs/pull/1383
Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.9.2...napi-derive@2.9.3
napi-derive@2.9.1
9/8/2022
What's Changed
- fix(napi-derive): should not generate this types for Constructor/Getter/Setter by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1291
- pin minimum usable version of dependency syn by @mat-if in https://github.com/napi-rs/napi-rs/pull/1293
New Contributors
- @mat-if made their first contribution in https://github.com/napi-rs/napi-rs/pull/1293
Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@2.9.0...napi-derive@2.9.1
napi-derive@2.9.0
8/23/2022
What's Changed
- fix(napi-derive): fix macro expansion naming shadow by @JSerFeng in https://github.com/napi-rs/napi-rs/pull/1278
- feat(napi-derive): catch_unwind attribute by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1280
New Contributors
- @JSerFeng made their first contribution in https://github.com/napi-rs/napi-rs/pull/1278
Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.8.0...napi-derive@2.9.0
napi-derive@2.8.0
8/17/2022
What's Changed
- feat(napi-derive): implement instance_of for Class by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1272
- feat(napi-derive): support inject This
into raw function by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1273
Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.7.0...napi-derive@2.8.0
napi-derive@2.7.0
8/7/2022
What's Changed
- feat(napi-derive): support set property attribute in napi macro by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1257
- feat(napi-derive): Support
#[napi(strict)]
on&T
and&mut T
by @Hywan in https://github.com/napi-rs/napi-rs/pull/1238
napi-derive@2.6.0
7/6/2022
What's Changed
- feat(napi-derive): support return_if_invalid by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1219
- feat(napi-derive): allow injecting this in class method by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1221
Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.5.0...napi-derive@2.6.0
napi-derive@2.5.0
6/10/2022
What's Changed
- Add
rust-version
field toCargo.toml
s by @messense in https://github.com/napi-rs/napi-rs/pull/1190 - feat(napi-derive): add ts_arg_type attribute to override individual args on functions by @jose-acevedoflores in https://github.com/napi-rs/napi-rs/pull/1192
Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.4.1...napi-derive@2.5.0
napi-derive@2.3.3
4/27/2022
What's Changed
- fix(napi-derive): invalid TypeScript return type by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1155
Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.3.2...napi-derive@2.3.3
napi-derive@2.3.2
4/27/2022
What's Changed
- fix(napi-derive): should transform struct case on Impl by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1148
Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.3.1...napi-derive@2.3.2
napi-derive@2.3.1
4/25/2022
What's Changed
- Add build option to not include the header in dts file by @ceifa in https://github.com/napi-rs/napi-rs/pull/1140
- Simplify the optional values in generated declaration file by @ceifa in https://github.com/napi-rs/napi-rs/pull/1141
- Add u64 to BigInt conversion through From trait by @ceifa in https://github.com/napi-rs/napi-rs/pull/1143
New Contributors
- @ceifa made their first contribution in https://github.com/napi-rs/napi-rs/pull/1140
Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@2.3.1...napi-derive@2.3.1
napi-derive@2.1.0
2/9/2022
What's Changed
- feat(napi-derive): add
ts_type
attribute to override typescript type for fields in structs by @jose-acevedoflores in https://github.com/napi-rs/napi-rs/pull/1041 - fix(napi-derive): an
Option
in front of a required parameter is no … by @JoostK in https://github.com/napi-rs/napi-rs/pull/1043 - feat(napi-derive):
get_js_function
by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1048
New Contributors
- @JoostK made their first contribution in https://github.com/napi-rs/napi-rs/pull/1043
- @AlCalzone made their first contribution in https://github.com/napi-rs/napi-rs/pull/1052
Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.8...napi-derive@2.1.0
napi-derive@2.0.8
1/18/2022
What's Changed
- Correctly escape backslash in type definition doc comments by @timfish in https://github.com/napi-rs/napi-rs/pull/1034
Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.7...napi-derive@2.0.8
napi-derive@2.0.7
1/7/2022
What's Changed
- fix(napi-derive): BigInt in TypeScript should be bigint by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1015
Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.6...napi-derive@2.0.7
napi-derive@2.0.6
1/6/2022
What's Changed
- fix(napi-derive): should throw rather than panic if object mismatched by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1010
- fix(napi-derive): implement missing trait for JsClass reference by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1011
- chore(napi-derive): update convert_case by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1012
Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.5...napi-derive@2.0.6
napi-derive@2.0.5
1/4/2022
What's Changed
- Unraw rust identifiers before sending it to js. by @fluxxu in https://github.com/napi-rs/napi-rs/pull/987
Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.4...napi-derive@2.0.5