A framework for building compiled Node.js add-ons in Rust via Node-API
OTHER License
Bot releases are hidden (Show)
Published by Brooooooklyn over 1 year ago
Published by Brooooooklyn over 1 year ago
Error::new
API enhancementError::new
now support passing status: AsRef<str>
and message: ToString
pub enum CustomError {
NapiError(Error<Status>),
Panic,
}
impl AsRef<str> for CustomError {
fn as_ref(&self) -> &str {
match self {
CustomError::Panic => "Panic",
CustomError::NapiError(e) => e.status.as_ref(),
}
}
}
#[napi]
pub fn custom_status_code() -> Result<(), CustomError> {
Err(Error::new(CustomError::Panic, "don't panic"))
}
test('custom status code in Error', (t) => {
t.throws(() => customStatusCode(), {
code: 'Panic',
})
})
Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]@2.11.1
Published by Brooooooklyn over 1 year ago
ThreadsafeFunction
#[napi]
pub fn accept_threadsafe_function_tuple_args(func: ThreadsafeFunction<(u32, bool, String)>) {
thread::spawn(move || {
func.call(
Ok((1, false, "NAPI-RS".into())),
ThreadsafeFunctionCallMode::NonBlocking,
);
});
}
⬇️⬇️⬇️⬇️⬇️⬇️⬇️
export function acceptThreadsafeFunctionTupleArgs(func: (err: Error | null, arg0: number, arg1: boolean, arg2: string) => any): void
ToNapiValue
tuple to variadic tsfn by @h-a-n-a #1475Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]@2.11.0
Published by Brooooooklyn over 1 year ago
Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]@2.10.17
Published by Brooooooklyn over 1 year ago
Published by Brooooooklyn over 1 year ago
Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]@2.10.16
Published by Brooooooklyn over 1 year ago
Full Changelog: https://github.com/napi-rs/napi-rs/compare/@napi-rs/[email protected]@2.10.15
Published by Brooooooklyn over 1 year ago
Note: Version bump only for package @napi-rs/cli
Published by Brooooooklyn over 1 year ago
Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]@2.10.1
Published by Brooooooklyn over 1 year ago
Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]@2.10.14
Published by Brooooooklyn over 1 year ago
Published by Brooooooklyn over 1 year ago
Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]@2.10.13
Published by Brooooooklyn over 1 year ago
Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]@2.10.12
Published by Brooooooklyn over 1 year ago
Electron disallowed the create_external_xxx
API since electron@21
: https://www.electronjs.org/blog/v8-memory-cage
NAPI-RS will fallback to use create_buffer_copy
if napi_create_external_buffer
return the napi_no_external_buffers_allowed
status.
Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]@2.10.11
Published by Brooooooklyn over 1 year ago
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)
ToNapiValue
for ObjectWith 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>>,
}
Full Changelog: https://github.com/napi-rs/napi-rs/compare/@napi-rs/[email protected]@2.10.0
Published by Brooooooklyn over 1 year ago
EitherN<Promise<..>>
by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1452
Full Changelog: https://github.com/napi-rs/napi-rs/compare/@napi-rs/[email protected]@2.10.10
Published by Brooooooklyn over 1 year ago
Published by Brooooooklyn over 1 year ago
Electron disallowed the create_external_xxx
API since electron@21
: https://www.electronjs.org/blog/v8-memory-cage
NAPI-RS will fallback to use create_buffer_copy
if napi_create_external_buffer
return the napi_no_external_buffers_allowed
status.
Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]@2.10.9
Published by Brooooooklyn over 1 year ago
napi_no_external_buffers_allowed
to Status
by @Brooooooklyn in https://github.com/napi-rs/napi-rs/pull/1445
Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]@2.2.3
Published by Brooooooklyn almost 2 years ago
Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]@2.10.8