572 Commits

Author SHA1 Message Date
LongYinan
6ecc4503b5
Release independent packages
- napi@3.0.0-alpha.29
- napi-derive@3.0.0-alpha.27
2025-02-21 12:58:32 +08:00
LongYinan
d96bd288de
fix!(napi): upgrade to ctor 0.3.6 (#2472) 2025-02-20 12:22:29 +08:00
LongYinan
384dcac588
chore(napi): remove thread_local! in REFERENCE_MAP (#2470) 2025-02-16 18:08:04 +08:00
LongYinan
0ce8fab19c
chore(napi): merge thread cleanup (#2469) 2025-02-16 16:55:16 +08:00
LongYinan
b1f8966fa7
Release independent packages
- napi@3.0.0-alpha.28
- napi@3.0.0-alpha.26
2025-02-11 22:36:00 +08:00
renovate[bot]
9e3f809c2e
fix(deps): update rust crate ctor to 0.3 (#2463)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-11 11:42:45 +00:00
LongYinan
13f4969ee2
chore: remove debug print 2025-02-11 18:12:50 +08:00
LongYinan
8d8ccdfc77
refactor!(napi): TypedArray API surfaces (#2462) 2025-02-11 13:35:43 +08:00
Zack Radisic
2d8e19d7c6
chore(napi): expose functions which turn raw pointer into External (#2449)
* Expose functions which turn raw pointer into External

* Add safety documentation
2025-02-03 13:03:29 +08:00
LongYinan
1868b0a214
chore: clippy fix (#2433) 2025-01-20 10:45:44 +08:00
LongYinan
55846053f7
Release independent packages
- napi@3.0.0-alpha.27
- napi-derive@3.0.0-alpha.24
2025-01-12 20:40:29 +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
8ebc851fce
Release independent packages
napi@3.0.0-alpha.26

napi-derive@3.0.0-alpha.26
2025-01-04 20:07:20 +08:00
LongYinan
35ebf8f7d4
fix(napi): remove feature flag on Object::new 2025-01-04 20:06:40 +08:00
LongYinan
a24993b773
Release independent packages
- napi@3.0.0-alpha.25
- napi@3.0.0-alpha.23
2025-01-04 15:23:37 +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
LongYinan
aad71cdb00
docs: update badge and matrix 2025-01-02 17:52:39 +08:00
richerfu
a7c41f33ec
feat(napi): add get and try_get for FunctionCallContext (#2409)
Co-authored-by: LongYinan <lynweklm@gmail.com>
2025-01-02 17:14:53 +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
LongYinan
480f8cecd9
style(napi): code format 2025-01-02 16:59:36 +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
Cong-Cong Pan
24da4e6ffb
perf(napi): JsStringUtf8 take & into_owned & as_str fn (#2404) 2024-12-20 12:58:41 +08:00
ganthern
b1400e3263
docs: update MSRV in README.md (#2402) 2024-12-19 22:21:28 +08:00
LongYinan
8027aa0602
Release independent packages
- napi@3.0.0-alpha.24
- napi-derive@3.0.0-alpha.22
- napi-sys@3.0.0-alpha.1
- napi-build@2.1.4
2024-12-18 23:52:09 +08:00
LongYinan
8fffa49282
fix(napi): resuse threads worker on Node.js (#2399) 2024-12-18 23:48:30 +08:00
LongYinan
7c532640d5
Release independent packages
- napi@3.0.0-alpha.23
2024-12-10 11:31:57 +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
LongYinan
dd07a04ca6
Release independent packages
- napi@3.0.0-alpha.22
- napi-derive@3.0.0-alpha.21
2024-12-03 21:59:14 +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
LongYinan
7886d24d12
Release independent packages
- napi@3.0.0-alpha.21
- napi-derive@3.0.0-alpha.20
2024-11-30 10:52:22 +08:00
LongYinan
4c7a3d3264
chore: Rust 1.83.0 clippy fix (#2378) 2024-11-30 10:49:01 +08:00
翠 / green
e42287618b
feat(napi): implement ValidateNapiValue for HashSet with any hasher (#2377) 2024-11-30 10:28:54 +08:00
翠 / green
f116eaf5e5
feat(napi): implement ValidateNapiValue for HashMap with any hasher (#2374) 2024-11-29 05:19:28 -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
LongYinan
209386f5c1
Release independent packages
- napi@3.0.0-alpha.20
2024-11-07 14:03:46 +08:00
LongYinan
726f888241
fix(napi): memory leak in PromiseRaw callbacks (#2348) 2024-11-07 13:19:15 +08:00
LongYinan
cf2305517d
chore(napi): deprecate Env::create_reference (#2347) 2024-11-07 13:05:01 +08:00
LongYinan
ae8eab3ef8
chore(napi): remove Read from Uint8Array (#2346) 2024-11-07 13:04:47 +08:00
LongYinan
59dce18ab4
Release independent packages
- napi@3.0.0-alpha.19
2024-10-31 11:06:23 +08:00
LongYinan
fd23549009
Release independent packages
- napi@3.0.0-alpha.18
- napi-derive@3.0.0-alpha.17
2024-10-31 10:50:01 +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
00a3c13b42
feat(napi): impl io::Read for Uint8Array (#2336) 2024-10-30 16:15:43 +08:00
LongYinan
6a690e1c53
Release independent packages
- napi@3.0.0-alpha.17
- napi@3.0.0-alpha.16
- napi-sys@3.0.0-alpha.0
2024-10-28 23:50:45 +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
953f2e3553
Release independent packages
- napi@3.0.0-alpha.16
- napi@3.0.0-alpha.15
2024-10-21 16:46:26 +08:00
LongYinan
aff84674b2
refactor!(napi): remove &str FromNapiValue (#2323) 2024-10-21 16:43:30 +08:00