420 Commits

Author SHA1 Message Date
LongYinan
d96bd288de
fix!(napi): upgrade to ctor 0.3.6 (#2472) 2025-02-20 12:22:29 +08:00
LongYinan
0ce8fab19c
chore(napi): merge thread cleanup (#2469) 2025-02-16 16:55:16 +08:00
LongYinan
8d8ccdfc77
refactor!(napi): TypedArray API surfaces (#2462) 2025-02-11 13:35:43 +08:00
lghuahua
8ea8e9ebfc
feat(napi-derive): impl #[napi(array)] (#2459) 2025-02-11 13:35:27 +08:00
lghuahua
cc4d8bfa84
fix(napi-derive): enable tuple fields to support js_name attribute (#2439)
Co-authored-by: LongYinan <lynweklm@gmail.com>
2025-01-22 12:10:26 +08:00
renovate[bot]
98e16fad8b
chore(deps): update dependency @oxc-node/core to ^0.0.19 (#2438)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-20 04:23:42 +00:00
renovate[bot]
1b24837445
chore(deps): update dependency @oxc-node/core to ^0.0.18 (#2434)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-20 02:57:22 +00:00
renovate[bot]
8ce7f77e5d
chore(deps): update dependency electron to v34 (#2428)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-20 09:48:41 +08:00
renovate[bot]
63b8ace192
chore(deps): update dependency vite-plugin-node-polyfills to ^0.23.0 (#2431)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-19 07:33:06 +00:00
renovate[bot]
e8d48e14d4
chore(deps): update vitest monorepo to v3 (#2429)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-17 15:19:49 +08:00
renovate[bot]
f03807e465
chore(deps): update dependency @oxc-node/core to ^0.0.17 (#2427)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-13 04:59:26 +00:00
LongYinan
ea05ad3845
fix(napi-derive): hide the lifetime recursively in codegen (#2426) 2025-01-12 22:36:14 +08:00
LongYinan
24e6bd38f3
chore: remove ts-node in examples/napi test (#2425) 2025-01-12 19:22:37 +08:00
LongYinan
05572bf1d4
feat(napi): allow create ReadableStream from polyfill (#2424) 2025-01-12 15:32:12 +08:00
LongYinan
73d5c1d803
fix(napi): add back Buffer/TypedArray custom gc on wasi (#2421) 2025-01-12 11:45:50 +08:00
LongYinan
98cb7671d3
feat(napi): impl ReadableStream and AsyncGenerator (#2418)
* feat(napi): impl ReadableStream and AsyncGenerator

* clippy fix

* Into<Vec<u8>> trait

* Skip node18 stream test due to Node.js bug

* Cleanup

* Also skip wasi test

* Merge test

* Skip wasi

* Useless expect-error
2025-01-03 17:09:42 +08:00
lghuahua
31cd07c8c2
feat(napi-derive): support type on #[napi] (#2416)
Co-authored-by: LongYinan <lynweklm@gmail.com>
2025-01-02 17:15:07 +08:00
richerfu
5f7415c1fe
fix(napi): Function call with empty tuple should generate empty arguments (#2407)
Co-authored-by: LongYinan <lynweklm@gmail.com>
2025-01-02 17:10:53 +08:00
Stanisław Czech
b4b74d6f1f
refactor!(napi): arguments tuple behavior (#2401)
* Implement FromNapiValue trait as macro

Code behavior should remain the same, with much less copy-pasting of the same code.
Additionally, this commit adds a unit tests for test for FromNapiValue
for tuple trait which appears to be currently missing.

* Simplify macro arr_get

Rewrite the macro to reduce the size of expanded code of the macro
(from 4088 to 2429 lines). Although this is a minor change,
this may help reduce the size of compiled library.

* Refactor typegen Type::Path

Removes the need for keeping mutable variable, as its only assigned once.

* [API BREAKING] Update api for calling functions.

This commit introduces new type FnArgs,
that is created with the goal of distinguishing between
calling JS function from rust with tuple as argument
and calling with multiple arguments.

Currently there is no possibility to add ToNapiValue value,
as tuple is used to call callback functions with more than one
argument from rust.

With this change, callbacks with multiple arguments,
should be called, with converting tuple of argument
into FnArgs struct, either by calling into() on such
tuple, or by creating FnArgs struct directly.

* Add support for FnArgs when generating TS types

Updated the macro for generating typescript types,
to correctly handle FnArgs struct. This is now treated
as passthrough type and generates the output from the
type inside of FnArgs struct.

* Implement ToNapiValue trait for tuple

With the changes to callback calling API, it's now possible
to safely add this change. This change allows to pass tuple
from rust code to JS to match the existing FromNapiValue trait
currently existing in the library.
2025-01-02 16:58:58 +08:00
LongYinan
8fffa49282
fix(napi): resuse threads worker on Node.js (#2399) 2024-12-18 23:48:30 +08:00
underfin
533635619e
fix(napi): delete error reference with raw Error (#2388)
* fix: delete error reference at drop

* fix: ci

* fix: ci

* fix: ci

* fix: ci

* fix: avoid using drop
2024-12-09 19:17:16 +08:00
renovate[bot]
77fe9757fc
chore(deps): lock file maintenance (#2380)
* chore(deps): lock file maintenance

* Fix typecheck

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: LongYinan <lynweklm@gmail.com>
2024-12-03 15:28:37 +08:00
Hiroshi Ogawa
61543c0f45
fix(napi): handle nul byte in object key (#2385)
* fix: fix to_napi_value

* test: add test

* fix: fix from_napi_value

* fix: fix object.get/set

* test: test plain object

* test: snapshot
2024-12-03 14:17:18 +08:00
翠 / green
6a4ce688c4
fix(napi-derive): generate correct types for HashMap with RandomState argument (#2384)
* fix(napi-derive): generate correct types for HashMap with RandomState argument

* chore: update snapshot
2024-12-02 22:37:00 +08:00
LongYinan
4c7a3d3264
chore: Rust 1.83.0 clippy fix (#2378) 2024-11-30 10:49:01 +08:00
翠 / green
521aefe420
feat(napi-derive): implement #[napi(transparent)] (#2376) 2024-11-30 10:28:40 +08:00
renovate[bot]
7815851b1e
chore(deps): update dependency vite to v6 (#2372)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-27 14:24:47 +08:00
frankwang
8b474f929d
feat(napi-derive): allow ts_type in napi fn attrs (#2362)
* feat: allow ts_type in fn attrs

* chore: add override fn type example
2024-11-22 15:44:16 +08:00
Stanisław Czech
272334c69f
fix(napi): update logic for handling signed integers (#2356)
* Fix from functions for BigInt

Allow proper parsing of negative integers in those functions.

Fixes the pannic when calling:
BigInt::from(i128::MIN);

* Fix get_i128 and get_i64 for BigInt

Update the getter logic to take sign into account.

for get_i128 and get_u128 make lossless value consistent with the documentation
(documentation described different behavior then the code logic)

* Extend tests for BigInt types

Add more test cases for negative i64 and i128 to test the created changes

* Simplify the to napiValue logic for 128 bit types

Update the logic to handle negative values properly

Refactor to_napi_value and create_bigint_from_*128 to use the same logic
instead of copping mostly the same code 4 times

* Fix specification for deserialize object test

For unknown reason the binary specification was holding different value than spec file
2024-11-18 23:12:11 +08:00
LongYinan
0db0e1aabb
feat(sys): add experimental apis (#2358) 2024-11-18 23:10:41 +08:00
Richer
48b3b238de
feat(napi): allow us to create nest function from closure (#2360) 2024-11-18 21:28:47 +08:00
Richer
c1b07a82c1
fix(backend): fix type when function as object field (#2359) 2024-11-18 14:39:49 +08:00
LongYinan
49ed2ddf71
fix(napi-derive): object lifetime compile issue (#2351) 2024-11-11 20:19:41 +08:00
LongYinan
f705454029
feat(napi): introduce AsyncBlock to let user dispose resources after future done (#2338) 2024-10-31 09:24:30 +08:00
LongYinan
c91456d84a
feat(napi): support return *const c_char to JavaScript directly (#2332) 2024-10-28 23:48:33 +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
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
renovate[bot]
24c000e4d5
chore(deps): update dependency electron to v33 (#2312)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-15 14:53:52 +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
af68b685f5
chore: set DISABLE_V8_COMPILE_CACHE in docker test (#2307) 2024-10-14 00:14:09 +08:00
LongYinan
4496ffd220
chore: refresh npm dependencies (#2303) 2024-10-13 23:50:57 +08:00
Richer
7881069894
test: fix some test case (#2301) 2024-10-13 13:33:47 +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
69cd73d71c
refactor!(napi,napi-derive): add lifetime to ClassInstance (#2286) 2024-10-02 10:42:34 +02:00