Commit graph

2287 commits

Author SHA1 Message Date
renovate[bot]
52c6969450
chore(deps): update yarn to v3.6.0 (#1614)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-02 01:38:45 +00:00
renovate[bot]
a851f42a0a
chore(deps): lock file maintenance (#1612)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-01 10:09:14 +08:00
renovate[bot]
de04804cc9
chore(deps): update dependency electron to v25 (#1610)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-01 10:08:45 +08:00
Levi Zim
dc6caf7d8e
docs(README): update platform support status (#1607)
Document riscv64 linux support status.
BTW add the missing node20 column.
2023-05-27 17:38:41 +08:00
LongYinan
17bd8718ee
Release independent packages
napi@2.13.1
2023-05-27 14:30:06 +08:00
LongYinan
5a2cd93708
fix(napi): missing ValidateNapiValue for JsObject (#1606) 2023-05-27 13:33:42 +08:00
LongYinan
433e5b13bf
Release independent packages
napi@2.13.0

napi-derive@2.13.0
2023-05-27 12:28:43 +08:00
LongYinan
e60b1a599b
fix(cli): add back override cargo by env (#1605) 2023-05-27 12:08:59 +08:00
LongYinan
c7d6ee6e4b
refactor(cli): --profile flag (#1604) 2023-05-27 12:00:43 +08:00
LongYinan
82c2113c24
fix(cli): revert back js-binding file (#1603) 2023-05-27 11:22:44 +08:00
Lucas Fernandes Nogueira
85836034ff
feat(cli): detect Cargo --profile argument (#1598) 2023-05-27 10:19:16 +08:00
LongYinan
c6258cf633
feat(napi): support chrono::NaiveDateTime (#1601) 2023-05-26 18:28:34 +08:00
LongYinan
ab83d88c57
Merge pull request #1599 from kxxt/feat/riscv64
feat(target): add support for riscv64gc-unknown-linux-gnu
2023-05-26 16:51:02 +08:00
kxxt
173553c037 ci: add riscv64gc-unknown-linux-gnu 2023-05-26 09:48:19 +08:00
kxxt
72fcd03d98 feat(target): riscv64gc-unknown-linux-gnu 2023-05-25 23:38:09 +08:00
renovate[bot]
4a0ca22706
chore(deps): update dependency electron to v24.4.0 (#1596)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-25 05:47:06 +00:00
LongYinan
e5163f7fc0
Release independent packages
napi@2.12.7
2023-05-20 10:56:29 +08:00
Jānis Gailis
d1fe0f0eb1
feat(napi): Bigint deserialization (#1592)
* Handle little endianness;
* Make sure get_<u/i>128 methods don't panic when words.len() < 2;
* Make sure BigInt deserialization takes into account word length and
  sign;

Signed-off-by: Janis Gailis <JanisGailis@users.noreply.github.com>
Co-authored-by: Janis Gailis <>
2023-05-19 17:27:29 +08:00
renovate[bot]
d6de0db49a
chore(deps): update dependency electron to v24.3.1 (#1593)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-18 10:15:58 +08:00
LongYinan
5bc098144c
chore(example): add callback return promise (#1590) 2023-05-16 11:05:37 +08:00
renovate[bot]
5a3d10013b
chore(deps): update dependency electron to v24.3.0 (#1587)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-12 19:37:59 +00:00
renovate[bot]
c2d70a2903
chore(deps): update dependency @rollup/plugin-commonjs to v25 (#1588) 2023-05-13 01:44:46 +08:00
Boshen
58600883dd
feat(cli): add --use-cross command for building with cross (#1584)
closes #1582
2023-05-09 09:30:30 +08:00
renovate[bot]
31ce5eb823
chore(deps): update dependency electron to v24.2.0 (#1580) 2023-05-04 09:27:17 +08:00
renovate[bot]
76659581b4
chore(deps): update yarn to v3.5.1 (#1579)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-02 08:46:08 +08:00
renovate[bot]
14d11e23d4
chore(deps): update dependency electron to v24.1.3 (#1578)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-27 09:37:33 +08:00
LongYinan
1f0edfa6f2
Release independent packages
napi-derive@2.12.5
2023-04-26 15:19:52 +08:00
LongYinan
d184d503d5
fix(napi-derive): increase initial ref count in async fn (#1577) 2023-04-26 15:18:00 +08:00
LongYinan
9a220bd1c2
Release independent packages
napi@2.12.6

napi-derive@2.12.4
2023-04-25 13:27:53 +08:00
Maël Nison
2f00e79873
chore(napi): adds support for Rc<T> / Arc<T> / Mutex<T> (#1573)
* Adds support for Rc/Arc/Mutex<T>

* Fixes codegen

* Fixes lint

* Fix clippy

---------

Co-authored-by: LongYinan <lynweklm@gmail.com>
2023-04-25 11:14:06 +08:00
liuyi
5a1f229dba
feat: clean napi-derive noop feature code path (#1571) 2023-04-18 10:15:29 +08:00
LongYinan
cd8888aa23
Release independent packages
napi@2.12.5
2023-04-17 00:00:06 +08:00
LongYinan
d9c191d270
test(napi): skip worker tests in slow Docker env (#1569) 2023-04-16 23:59:15 +08:00
LongYinan
d9ff0b4ddf
fix(napi): do nothing in deferred if thread is destroyed (#1568) 2023-04-15 18:58:53 +08:00
renovate[bot]
ad143df4e1
chore(deps): update dependency electron to v24.1.2 (#1562)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-15 15:37:17 +08:00
LongYinan
d14fdca242
fix(napi): thread safe issue while creating class instance (#1561) 2023-04-15 15:37:01 +08:00
renovate[bot]
77f53a8cc9
fix(deps): update rust crate libloading to 0.8 (#1563)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-15 06:40:31 +00:00
LongYinan
b60dbc5760
Release independent packages
napi@2.12.4
2023-04-11 11:44:32 +08:00
LongYinan
070230079d
fix(napi): noop feature 2023-04-11 11:44:10 +08:00
LongYinan
f4d9e09917
Release independent packages
napi@2.12.3

napi-derive@2.12.3
2023-04-11 11:21:48 +08:00
LongYinan
1d78f6c294
chore: upgrade npm dependencies (#1557) 2023-04-11 10:47:52 +08:00
gaoquanzero
7fdcd7a8ae
chore(napi): add noop feature in napi crate (#1546) 2023-04-10 18:47:34 +08:00
LongYinan
5624c82926
Merge pull request #1556 from napi-rs/fix-tsfn-callback-throw
fix(napi): re-throw error in ThreadsafeFunction callback if we could
2023-04-10 18:21:03 +08:00
LongYinan
66ef64bdc7
style(napi): use cast() instread as 2023-04-10 17:14:27 +08:00
LongYinan
752ffea1d9
fix(napi): revert Promise changes because of the flaky test 2023-04-10 17:14:26 +08:00
LongYinan
88773a7a8e
fix(napi): re-throw error in ThreadsafeFunction callback if we could 2023-04-10 17:02:13 +08:00
LongYinan
a57a59f735
ci: remove depracated action (#1555) 2023-04-08 23:37:28 +08:00
Alexey Orlenko
2d1e4144b3
fix: prevent crashing when napi_register_module_v1 is called twice (#1554)
* fix: prevent crashing when napi_register_module_v1 is called twice

Currently napi-rs addons can lead to the Node.js process aborting with
the following error when initialising the addon on Windows:

```
c:\ws\src\cleanup_queue-inl.h:32: Assertion `(insertion_info.second)
== (true)' failed.
```

This happens because `napi_add_env_cleanup_hook` must not be called
with the same arguments multiple times unless the previously scheduled
cleanup hook with the same arguments was already executed. However,
the cleanup hook added by `napi_register_module_v1` in napi-rs on
Windows was always created with `ptr::null_mut()` as an argument.

One case where this causes a problem is when using the addon from
multiple contexts (e.g. Node.js worker threads) at the same
time. However, Node.js doesn't provide any guarantees that the N-API
addon initialisation code will run only once even per thread and
context. In fact, it's totally valid to run `process.dlopen()`
multiple times from JavaScript land in Node.js, and this will lead to
the initialisation code being run multiple times as different
`exports` objects may need to be populated. This may happen in
numerous cases, e.g.:

- When it's not possible or not desirable to use `require()` and users
  must resort to using `process.dlopen()` (one use case is passing
  non-default flags to `dlopen(3)`, another is ES modules). Caching
  the results of `process.dlopen()` to avoid running it more than once
  may not always be possible reliably in all cases (for example,
  because of Jest sandbox).

- When the `require` cache is cleared.

- On Windows: `require("./addon.node")` and then
  `require(path.toNamespacedPath("./addon.node"))`.

Another issue is fixed inside `napi::tokio_runtime::drop_runtime`:
there's no need to call `napi_remove_env_cleanup_hook` (it's only
useful to cancel the hooks that haven't been executed yet). Null
pointer retrieved from `arg` was being passed as the `env` argument of
that function, so it didn't do anything and just returned
`napi_invalid_arg`.

This patch makes `napi_register_module_v1` use a counter as the
cleanup hook argument, so that the value is always different. An
alternative might have been to use a higher-level abstraction around
`sys::napi_env_cleanup_hook` that would take ownership of a boxed
closure, if there is something like this in the API already. Another
alternative could have been to heap-allocate a value so that we would
have a unique valid memory address.

The patch also contains a minor code cleanup related to
`RT_REFERENCE_COUNT` along the way: the counter is encapsulated inside
its module and `ensure_runtime` takes care of incrementing it, and
less strict memory ordering is now used as there's no need for
`SeqCst` here. If desired, it can be further optimised to
`Ordering::Release` and a separate acquire fence inside the if
statement in `drop_runtime`, as `AcqRel` for every decrement is also a
bit stricter than necessary (although simpler). These changes are not
necessary to fix the issue and can be extracted to a separate patch.

At first it was tempting to use the loaded value of
`RT_REFERENCE_COUNT` as the argument for the cleanup hook but it would
have been wrong: a simple counterexample is the following sequence:

1. init in the first context (queue: 0)
2. init in the second context (queue: 0, 1)
3. destroy the first context (queue: 1)
4. init in the third context (queue: 1, 1)

* test(napi): unload test was excluded unexpected

---------

Co-authored-by: LongYinan <lynweklm@gmail.com>
2023-04-08 23:08:48 +08:00
forehal
b5c3c05755
chore: publish
- @napi-rs/cli@3.0.0-alpha.3
2023-04-07 15:00:31 +08:00
forehal
7fcd68f14d
fix(cli): incorrect new project template content 2023-04-07 14:58:12 +08:00