Commit graph

2470 commits

Author SHA1 Message Date
Bo
e47c13f177
fix(napi): check if the tokio runtime exists when registering the module
And recreate it if it does not exist.

In windows, electron renderer process will crash if:
1. Import some NAPI module that enable `tokio-rt` flag in renderer process.
2. Reload the page.
3. Call a function imported from that NAPI module.

Because the tokio runtime will be dropped when reloading the page, and won't create again, but currently we assume that the runtime must exist in tokio-based `within_runtime_if_available`.
This will cause some panic like this:

```
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', napi-rs\crates\napi\src\tokio_runtime.rs:72:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: Renderer process crashed: crashed, exitCode: -529697949
    at EventEmitter.<anonymous> (napi-rs\examples\napi\electron.js:33:9)
    at EventEmitter.emit (node:events:525:35)
```
2023-03-28 12:03:00 +08:00
LongYinan
a956d51a9a
Release independent packages
napi@2.12.1
2023-03-23 15:35:25 +08:00
Gabriel Francisco
3983be23f5
fix(napi): big numbers losing precision on serde_json::Value (#1538)
* fix(napi): big numbers losing precision on serde_json::Value

* fix(napi): add feature flags for bigint on number conversion

* chore(napi): change MAX_SAFE_INT to constant and convert big numbers to string when bigint is not available

* chore(napi): change how the check for safe integer range is made
2023-03-23 13:34:34 +08:00
LongYinan
2e865cad29
Release independent packages
napi-derive@2.12.2
2023-03-22 18:03:28 +08:00
LongYinan
b896b90795
chore: publish
- @napi-rs/cli@2.15.2
2023-03-22 18:02:55 +08:00
LongYinan
5398b16238
fix(cli,napi-derive): backward compatible with older cli with #1531 (#1536) 2023-03-22 17:35:55 +08:00
LongYinan
2f4d9d4447
Release independent packages
napi-derive@2.12.1
2023-03-21 18:50:44 +08:00
LongYinan
8a086b67d6
chore: publish
- @napi-rs/cli@2.15.1
2023-03-21 18:49:47 +08:00
LongYinan
0f0837f5ca
fix(cli): dts pipe (#1532) 2023-03-21 18:47:43 +08:00
LongYinan
3d48d4464b
fix(cli,napi-derive): re-export types from shared crate (#1531)
* fix(cli,napi-derive): re-export types from shared crate

* chore: publish

 - @napi-rs/cli@2.15.1-alpha.0

* Clippy fix

* Fix memory testing
2023-03-21 18:12:52 +08:00
LongYinan
3b831f42f5
Release independent packages
napi@2.12.0

napi-derive@2.12.0
2023-03-21 13:39:58 +08:00
LongYinan
0d951cb3d9
chore: publish
- @napi-rs/cli@2.15.0
2023-03-21 13:38:58 +08:00
Victor Teo
aee742f185
feat(napi): property getter and setter with closure (#1526)
* getter with closure with segment fault

* fix getter closure pointer

* add setter

* Cleanup API

* Add test for `create_function_from_closure`

* Fix compile error

* Fix flaky test title

---------

Co-authored-by: LongYinan <lynweklm@gmail.com>
2023-03-21 11:22:07 +08:00
LongYinan
550ef7c3cc
feat: export registers in wasm32 target (#1529) 2023-03-20 18:42:27 +08:00
LongYinan
5605bdf7fc
fix(napi): ThreadsafeFunctionHandle never being dropped (#1530) 2023-03-20 18:01:09 +08:00
Francesco Benedetto
c8bd8924e2
fix(cli): export non const enums when generating typedefs (#1527)
* fix(cli): export non const enums when generating typedefs

* Make --const-enum as a build flag

---------

Co-authored-by: LongYinan <lynweklm@gmail.com>
2023-03-20 14:19:18 +08:00
LongYinan
d255a0a575
chore: decrease timeout in tsfn test 2023-03-20 11:59:53 +08:00
Bo
a6e1ff471c
fix(napi): use weak arc for passing thread_finalize_data (#1525)
* fix(napi): use weak arc for passing thread_finalize_data

* fix: try to fix test of tsfn_return_promise_timeout
2023-03-20 11:56:54 +08:00
LongYinan
347e81b3cc
chore(napi): upgrade bitflags to v2 (#1518) 2023-03-16 11:23:03 +08:00
LongYinan
73db80311a
Release independent packages
napi@2.11.4
2023-03-14 21:41:01 +08:00
HotQ
0af728a601
fix(napi): prevent access to tsfn-raw after tsfn finalized(#1514) (#1515) 2023-03-14 21:31:52 +08:00
LongYinan
c1072462a5
Release independent packages
napi@2.11.3

napi-derive@2.11.2
2023-03-14 15:37:34 +08:00
Alberto Pose
ffc4980d52
fix(napi): panic when Promise callbacks trigger after Promise is dropped (#1469) (#1516)
Co-authored-by: Alberto Pose <albepose@amazon.com>
2023-03-14 15:32:17 +08:00
LongYinan
894f082429
build: fix alpine zig image 2023-03-12 19:23:25 +08:00
LongYinan
1ff67418c7
build: fix alpine zig image 2023-03-12 18:56:08 +08:00
LongYinan
f2d3804506
ci: cancel-in-progress duplicated job 2023-03-12 18:31:13 +08:00
LongYinan
ef26f6a56e
build: libc++-dev still need to be installed 2023-03-12 18:27:12 +08:00
LongYinan
60dea3d6d0
chore: ci components upgrade (#1512) 2023-03-12 18:24:48 +08:00
LongYinan
0904dc5d43
build: fix Docker build context 2023-03-12 17:50:38 +08:00
LongYinan
1867c9f476
build: add libc++ in aarch64-linux-gnu Docker (#1511) 2023-03-12 17:25:53 +08:00
LongYinan
7e2ab566d4
build: upgrade toolchain in Docker 2023-03-12 16:13:32 +08:00
LongYinan
96959e6425
chore(napi): remove thread_local from dependenies (#1506) 2023-03-05 19:49:52 +08:00
LongYinan
3bd3c9cc08
test(napi): tests for custom gc in worker_threads (#1505) 2023-03-05 16:51:06 +08:00
Markus
86cfbca33e
feat(napi): expose uv_run (#1499)
Signed-off-by: MarkusJx <28785953+MarkusJx@users.noreply.github.com>
2023-02-27 17:31:03 +08:00
Hana
fc101d0d6b
fix(napi): display should be implemented on error generics (#1497) 2023-02-24 19:46:39 +08:00
LongYinan
4fc7cb12f4
chore: add opencollective link 2023-02-22 13:06:49 +08:00
LongYinan
25cc07b476
Release independent packages
napi@2.11.2

napi-derive@2.11.1
2023-02-18 11:35:57 +08:00
LongYinan
11286b8a67
chore: publish
- @napi-rs/cli@2.14.8
2023-02-17 01:07:55 +08:00
liuyi
7281f533bd
fix(cli): always generate typedef file even native code never changes (#1489) 2023-02-16 22:24:40 +08:00
Hana
853f52ed1f
fix(napi): error should be send sync conditionally (#1487) 2023-02-14 18:58:04 +08:00
LongYinan
ec9349bb3b
Release independent packages
napi@2.11.1
2023-02-09 23:22:29 +08:00
LongYinan
8e3eb6204b
fix(napi): support custom status in Error (#1486) 2023-02-09 23:18:57 +08:00
LongYinan
8e5ed4c7a0
Release independent packages
napi@2.11.0

napi-derive@2.11.0
2023-02-08 22:33:55 +08:00
Hana
90cc0a6abe
feat(napi): convert ToNapiValue tuple to variadic tsfn (#1475)
* refactor: convert ToNapiValue tuple to variadic tsfn

* chore: resolve conflicts

* fix: typo

* chore: use into instead of to

* chore: syntax compat
2023-02-08 22:30:43 +08:00
m1212e
a7dcf2a838
fix(napi): convert u64 to u32 in serialization (#1478)
https://github.com/napi-rs/napi-rs/issues/1470
serde_json::Value parses positive integers to u64 types by default. When converting serde_json::Value to a js value, those numbers are converted to BigInts, even if they are within the bounds of the number primitive. The added checks converts an u64 to an u32 if possible to prevent this behavior.

Co-authored-by: m1212e <->
2023-02-08 22:25:03 +08:00
LongYinan
80ec3dd2d9
Release independent packages
napi@2.10.17
2023-02-08 17:34:08 +08:00
LongYinan
c34ccc9131
fix(napi): impl Send Sync to External 2023-02-08 17:33:27 +08:00
LongYinan
efacce7f66
chore: publish
- @napi-rs/cli@2.14.7
2023-02-08 17:03:21 +08:00
Sean Larkin
cb529d21cf
fix(cli): JS bindgen file now respects destDir (#1481) 2023-02-08 14:14:55 +08:00
LongYinan
f24c9e6e83
Release independent packages
napi@2.10.16
2023-02-07 16:17:04 +08:00