Commit graph

2614 commits

Author SHA1 Message Date
翠 / green
0fa755d30a
feat(target): add support for powerpc64le-unknown-linux-gnu (#2023)
* refactor: remove unused ci.ts

* feat(target): add support for powerpc64le-unknown-linux-gnu
2024-04-09 11:27:48 +08:00
翠 / green
7ae562352a
feat(cli): add support for armv7-unknown-linux-muslebihf (#2019) 2024-04-08 21:04:57 +08:00
翠 / green
71a528535a
fix(napi): create_bigint_from_*128 returned incorrect word_count (#2024)
The value of `word_count` was inconsistent between the node side and rust side when calling `create_bigint_from_i128`/`create_bigint_from_u128`.
2024-04-08 10:43:23 +09:00
dependabot[bot]
c87944c7f4
chore(deps-dev): bump vite from 5.1.4 to 5.1.7 (#2025) 2024-04-05 08:57:45 +09:00
renovate[bot]
e4ad4767ef
fix(deps): update dependency emnapi to v1.1.1 (#2017)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-30 10:44:57 +00:00
LongYinan
f5b6854731
chore(release): publish
- @napi-rs/cli@3.0.0-alpha.45
2024-03-28 11:54:21 +08:00
LongYinan
77399ff130
fix(cli): wasi Node.js worker template (#2015) 2024-03-28 10:08:17 +08:00
LongYinan
f2e5094345
feat(napi-sys): support load Node-API symbols dynamically (#2014) 2024-03-27 14:35:16 +08:00
LongYinan
0550c56fcf
fix(napi): External should impl FromNapiRef rather than FromNapiValue (#2013)
- Close https://github.com/napi-rs/napi-rs/issues/1994
2024-03-25 15:11:11 +08:00
LongYinan
be610c9353
style: clippy fix (#2012) 2024-03-23 19:35:58 +08:00
Louis
15521fb90f
fix(napi): no panic when caller stops listening (#2010)
This fix is similar to the one in 5b5f616d81.

In both the then_callback & catch_callback, expect was being called in case
the send failed. This means that if we call a function that returns a promise
and the received gets closed (the calling thread stopped at the wrong time),
this will panic.

In such scenarios, it is fine not to panic. If the receiver doesn't care about
the output, we should just let it be.
2024-03-22 22:03:19 +08:00
LongYinan
35b9637151
chore(release): publish
- @napi-rs/cli@3.0.0-alpha.44
 - @napi-rs/wasm-runtime@0.1.2
2024-03-21 15:08:50 +08:00
LongYinan
6a29446dfb
chore(wasm-runtime): upgrade emnapi (#2008) 2024-03-21 14:41:05 +08:00
LongYinan
2a7c000275
Release independent packages
- napi@3.0.0-alpha.0
- napi-derive@3.0.0-alpha.0
2024-03-20 22:46:59 +08:00
renovate[bot]
e2b1a3e3d9
fix(deps): update dependency emnapi to v1.1.0 (#2006)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-20 22:30:58 +08:00
LongYinan
13651c5ff1
chore(napi): add Send and Sync to Reference (#2007) 2024-03-20 22:30:45 +08:00
LongYinan
4719caa643
feat(napi): support Return generic of ThreadsafeFunction (#1997)
* feat(napi): support to use tuple with either (#1993)

`Either` uses `ValidateNapiValue` + `TypeName` to validate and report error on value not being matched. So there's no way to remove these super traits from it. So I implemented these types to `Tuple` types.

* feat(napi): support `Return` generic of ThreadsafeFunction

* depracate JsFunction

* CalleeHandled tsfn should handle Result in callback

* Pass env to call_with_return_value callback

* Fix compile

* clippy fix

* Fix electron test

* Function args

---------

Co-authored-by: Hana <andywangsy@gmail.com>
2024-03-20 21:37:08 +08:00
Louis
693f0ac269
feat(napi): implement From<String> for Buffer (#2002) 2024-03-17 22:43:01 +08:00
dependabot[bot]
50623ca26b
chore(deps): bump follow-redirects from 1.15.5 to 1.15.6 (#2004)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.5 to 1.15.6.
<details>
<summary>Commits</summary>
<ul>
<li><a href="35a517c586"><code>35a517c</code></a> Release version 1.15.6 of the npm package.</li>
<li><a href="c4f847f851"><code>c4f847f</code></a> Drop Proxy-Authorization across hosts.</li>
<li><a href="8526b4a1b2"><code>8526b4a</code></a> Use GitHub for disclosure.</li>
<li>See full diff in <a href="https://github.com/follow-redirects/follow-redirects/compare/v1.15.5...v1.15.6">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=follow-redirects&package-manager=npm_and_yarn&previous-version=1.15.5&new-version=1.15.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/napi-rs/napi-rs/network/alerts).

</details>
2024-03-17 16:04:41 +08:00
Hana
97746b79a9
feat(napi): support to use tuple with either (#1993)
`Either` uses `ValidateNapiValue` + `TypeName` to validate and report error on value not being matched. So there's no way to remove these super traits from it. So I implemented these types to `Tuple` types.
2024-03-13 13:29:06 +08:00
Andrew Toth
6b1058a268
feat(napi-derive): add optional enum_string case conversion (#1995) 2024-03-11 20:10:00 +08:00
LongYinan
d962e34d3a
fix(napi): remove useless FromNapiValue bound check for ValidateNapiValue (#1999) 2024-03-10 21:22:46 +08:00
LongYinan
b03edafaff
ci: fix arm64 job (#1998) 2024-03-10 20:41:55 +08:00
renovate[bot]
368e210a8d
chore(deps): update yarn to v4.1.1 (#1989)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [yarn](https://togithub.com/yarnpkg/berry) ([source](https://togithub.com/yarnpkg/berry/tree/HEAD/packages/yarnpkg-cli)) | [`4.1.0` -> `4.1.1`](https://renovatebot.com/diffs/npm/yarn/4.1.0/4.1.1) | [![age](https://developer.mend.io/api/mc/badges/age/npm/yarn/4.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/yarn/4.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/yarn/4.1.0/4.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/yarn/4.1.0/4.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>yarnpkg/berry (yarn)</summary>

### [`v4.1.1`](52909a5e0d...6b7621f073)

[Compare Source](52909a5e0d...6b7621f073)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/napi-rs/napi-rs).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMjAuMiIsInVwZGF0ZWRJblZlciI6IjM3LjIyMC4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
2024-03-05 11:31:06 +08:00
LongYinan
a868c75ae8
ci: fix build in bun CI 2024-03-03 20:07:42 +08:00
renovate[bot]
b02c61783b
chore(deps): lock file maintenance (#1987)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-01 12:28:22 +08:00
LongYinan
4d5655accb
chore(release): publish
- @napi-rs/cli@3.0.0-alpha.43
2024-02-28 15:58:46 +08:00
LongYinan
19a13361d4
fix(cli): cleanup js binding template (#1984) 2024-02-28 15:51:16 +08:00
LongYinan
9abcb484ba
chore(release): publish
- @napi-rs/cli@3.0.0-alpha.42
2024-02-28 15:07:23 +08:00
LongYinan
e3e8a0fb39
Release independent packages
napi@2.16.0

napi-derive@2.16.0
2024-02-28 15:06:11 +08:00
LongYinan
aeb0b4766d
fix(napi): add back the typecheck logic that was accidentally removed in Object::get_named_property (#1982)
- Close https://github.com/napi-rs/napi-rs/issues/1641
2024-02-28 14:29:02 +08:00
Caleb Everett
95dd6ef485
refactor(cli): refactor js-binding to support easier bundling. (#1957)
* Refactor js-binding to support bundling single-package artifacts

The existsSync check breaks the bundlers I've tested (esbuild, webpack,
ncc), so you cannot bundle napi-rs packages that have all binarys in a
single package.

I've tested this change with both single package and multi package
libraries.

* Update snapshots

* Update CI

* Fix electron test

---------

Co-authored-by: Caleb ツ Everett <calebev@amazon.com>
Co-authored-by: LongYinan <lynweklm@gmail.com>
2024-02-26 15:46:07 +08:00
LongYinan
117e4ce153
fix(napi-derive): wrong dependency condition (#1980) 2024-02-25 15:25:42 +08:00
LongYinan
8ca1967bd8
feat(napi): impl BufferSlice and Uint8ClampedSlice (#1979) 2024-02-25 01:00:28 +08:00
LongYinan
f88a041fa3
feat(napi): impl chained Into for TypedArray types (#1978) 2024-02-25 00:58:27 +08:00
LongYinan
3e187151a6
fix(napi-derive): HashMap/IndexMap and slice generated types (#1977) 2024-02-25 00:56:30 +08:00
LongYinan
5af366b042
style(napi-derive): clippy fix (#1976) 2024-02-25 00:54:33 +08:00
LongYinan
71bbe0ef6f
fix(napi): remove useless create_reference in slice => TypedArray impl (#1975) 2024-02-25 00:52:30 +08:00
LongYinan
2fda360742
chore: fix renovate path and dedupe electron versions (#1974) 2024-02-25 00:50:22 +08:00
ebe97257a6
feat(napi-derive): add use_nullable attribute (#1971)
* feat(napi-derive): add use_nullable attribute

Co-authored-by: naskya <m@naskya.net>

* chore(napi-derive): update tests

Co-authored-by: naskya <m@naskya.net>

---------

Co-authored-by: naskya <m@naskya.net>
2024-02-24 21:49:54 +08:00
Louis
43415251b8
feat(napi): allow Reference as a class method param (#1966)
As of before this commit, there was a lock in the codegen preventing Reference
from being used as a function argument outside of a Reference<Self>.

This changes it, allowing Reference of any class to be added as a class method
argument anywhere. It has the same limitations as reference, as in it requires
the class to have been created with a factory or constructor. This change
implements FromNapiValue on Reference, which will unwrap the class and call the
existing from_value_ptr method. It also updated typegen so that we only emit
the reference type if we're in an impl block that doesn't match the Reference
we're getting. This ensures that typegen works as expected with the previous
behaviour.
2024-02-22 22:37:50 +08:00
LongYinan
17f509f96e
chore(release): publish
- @napi-rs/cli@3.0.0-alpha.41
2024-02-22 19:01:28 +08:00
LongYinan
33cf208758
Release independent packages
napi@2.15.4
2024-02-22 19:01:18 +08:00
Tom Barham
ebd5eef267
fix(napi): require static lifetime on add_finalizer callback (#1968)
Co-authored-by: LongYinan <lynweklm@gmail.com>
2024-02-22 18:40:04 +08:00
Louis
5b5f616d81
fix(napi): no hard fail on ThreadsafeFunction::call_async (#1970)
For many reasons, in an app we can end up in a scenario where the thread / task that initially called the ThreadsafeFunction gets interrupted. This means that the receiver would get collected, should a ThreadsafeFunction be awaited on the said thread. This will create an error when the ThreadsafeFunction's callback will be called, and call a napi_fatal_error.

This change makes it so that if the send errors, this error is hidden and thus prevents any hard failure. If a ThreadsafeFunction is called in such a case, its output won't be used, but we'll still run all the logic to ensure it ran properly.

Fixes https://github.com/napi-rs/napi-rs/issues/1665 - cc @Brooooooklyn
2024-02-22 17:34:10 +08:00
LongYinan
da99081ccf
fix(cli): allow more platform & arch fallback to wasm (#1969) 2024-02-22 16:42:33 +08:00
LongYinan
0306e3045a
fix(cli): fallback to wasm32 if platform is not support (#1967) 2024-02-21 23:48:29 +08:00
LongYinan
8855f18f50
Release independent packages
napi@2.15.3
2024-02-21 23:16:27 +08:00
dependabot[bot]
60d07338fd
chore(deps): bump ip from 1.1.8 to 1.1.9 (#1965)
Bumps [ip](https://github.com/indutny/node-ip) from 1.1.8 to 1.1.9.
<details>
<summary>Commits</summary>
<ul>
<li><a href="1ecbf2fd8c"><code>1ecbf2f</code></a> 1.1.9</li>
<li><a href="6a3ada9b47"><code>6a3ada9</code></a> lib: fixed CVE-2023-42282 and added unit test</li>
<li>See full diff in <a href="https://github.com/indutny/node-ip/compare/v1.1.8...v1.1.9">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=ip&package-manager=npm_and_yarn&previous-version=1.1.8&new-version=1.1.9)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/napi-rs/napi-rs/network/alerts).

</details>
2024-02-21 10:59:59 +08:00
Louis
9391196eef
fix(napi): prevent memory leak when Custom GC is used (#1963)
There is a piece of custom logic that has been added a while back to ensure
that Buffers can be sent across threads, and be dropped properly. This involves
a custom GC that runs on NodeJS's current thread (per my understanding). The
logic to drop the buffer on that custom GC differed from the one in the Drop
impl. This meant that everytime Node sent a buffer back to a napi-rs function,
the reference wouldn't be cleaned up properly, and it would leak (96 bytes per
Reference on an ARM MacOS machine).

This commit updates the logic in the custom GC so that it matches the one in
the Drop impl. This worked locally, and fixed any occurence of the leak I could
find.
2024-02-20 20:36:21 +08:00