Commit graph

2533 commits

Author SHA1 Message Date
LongYinan
44f536d47a
chore(deps): lock file maintenance (#1935)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Update | Change |
|---|---|
| lockFileMaintenance | All locks refreshed |

🔧 This Pull Request updates lock files to use the latest dependency versions.

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on the first day of the month" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

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

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- 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:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNTMuMiIsInVwZGF0ZWRJblZlciI6IjM3LjE1My4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
2024-02-01 16:07:45 +08:00
renovate[bot]
5e12280a26
chore(deps): lock file maintenance 2024-02-01 07:38:30 +00:00
LongYinan
9cca0c4a9e
ci: use m1 macos (#1938) 2024-02-01 15:37:37 +08:00
LongYinan
0177f59a8a
ci: use m1 macos 2024-02-01 07:00:32 +00:00
LongYinan
199893a309
chore(cli): upgrade peer dependencies (#1937) 2024-02-01 15:00:15 +08:00
LongYinan
0007e3aaf6
chore: upgrade all dependencies (#1933) 2024-02-01 12:14:56 +08:00
renovate[bot]
556732d4c4
chore(deps): update yarn to v4.1.0 (#1931)
[![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.0.2` -> `4.1.0`](https://renovatebot.com/diffs/npm/yarn/4.0.2/4.1.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/yarn/4.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/yarn/4.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/yarn/4.0.2/4.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/yarn/4.0.2/4.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

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

### [`v4.1.0`](https://togithub.com/yarnpkg/berry/blob/HEAD/CHANGELOG.md#410)

[Compare Source](a64075561a...52909a5e0d)

-   Tweaks `-,--verbose` in `yarn workspaces foreach`; `-v` will now only print the prefixes, `-vv` will be necessary to also print the timings.

-   Adds a new `--json` option to `yarn run` when called without script name

-   Fixes `node-modules` linker `link:` dependencies mistreatment as inner workspaces, when they point to a parent folder of a workspace

-   Fixes spurious "No candidates found" errors

-   Fixes missing executable permissions when using `nodeLinker: pnpm`

-   Fixes packages being incorrectly flagged as optional

-   Fixes cache key corruptions due to uncontrolled git merges

-   Fixes `yarn version apply --all --dry-run` making unexpected changes

-   Fixes `yarn npm login` when the remote registry is Verdaccio

</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:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNTMuMiIsInVwZGF0ZWRJblZlciI6IjM3LjE1My4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
2024-01-31 22:19:33 +08:00
renovate[bot]
27367cf015
chore(deps): update dependency npm-run-all2 to v6 (#1927)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-31 21:21:14 +08:00
renovate[bot]
53adce9212
chore(deps): replace dependency npm-run-all with npm-run-all2 ^5.0.0 (#1926)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [npm-run-all](https://togithub.com/mysticatea/npm-run-all) | devDependencies | replacement | [`^4.1.5` -> `^5.0.0`](https://renovatebot.com/diffs/npm/npm-run-all/4.1.5/) |

This is a special PR that replaces `npm-run-all` with the community suggested minimal stable replacement version.

---

### Configuration

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

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **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:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNTMuMiIsInVwZGF0ZWRJblZlciI6IjM3LjE1My4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
2024-01-29 19:07:40 +08:00
Janrupf
ac3626a023
fix(napi): Fix buffer corruption and soundness issues (#1923)
* fix(napi): Fix buffer corruption and soundness issues

* test: fix tests to conform to buffer API
2024-01-29 18:32:28 +08:00
renovate[bot]
949883bc99
chore(deps): update dependency esbuild to ^0.20.0 (#1925)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-27 22:45:01 +00:00
LongYinan
a6aaa94e7d
Release independent packages
- napi@2.15.0
- napi-derive@2.15.0
2024-01-26 14:32:24 +08:00
LongYinan
f625328868
fix(napi): move JsValuesTupleIntoVec trait to function.rs 2024-01-26 14:32:24 +08:00
LongYinan
f69771e2d4
fix(napi-derive): JsArrayBuffer generated type 2024-01-26 14:32:24 +08:00
LongYinan
b9ba7c9d68
fix(napi): memory issue while creating external buffer on electron 2024-01-26 14:32:24 +08:00
LongYinan
aff95d0271
chore(napi): remove napi_val on Ref because it is unused 2024-01-26 03:29:52 +00:00
LongYinan
4ba481c49d
chore(napi): delete unwrap_from_ref API because it was never work (#1915)
This is a garbage API because it simply does not work correctly, and presumably nobody uses it.
2024-01-26 11:29:34 +08:00
LongYinan
12503a8061
chore(napi): delete unwrap_from_ref API because it was never work 2024-01-26 02:58:53 +00:00
LongYinan
baf0db2f19
feat(napi): new Function/FunctionRef API (#1913)
This is the experimental feature that provides a all new design `Function` API in NAPI-RS.
The main motivation to design a new `Function` instead of improving the old `JsFunction` is there are some fundamental problems in the old `JsFunction` API.
1. The old `JsFunction` doesn't contains a lifetime, which means you can send it to a outlive scope and call it later, which would cause a `napi_invalid_arg` error in the underlying `napi_call_function` API. This design issue also happens in the `JsObject`/`JsBuffer` and all other non-primitive types APIs.
2. It's not possible to generate correct TypeScript type definitions for the old `JsFunction` API.
3. The arguments of the old `JsFunction` API must be the same type, which is makes it really unfriendly to use.

Expect that, we also have a high level and modern Function exists in the `NAPI-RS` which is the Generic type style `Fn(Args) -> Return`.
This API is pretty nice to use, and more importantly, it's sound.
But there are some limitations to use it, like create a reference to it to outlive the scope of the JavaScript function under the hood. And you can't use it create a `ThreadsafeFunction`.
So there is the new design `Function` API, there are some core features:
1. It's a generic typed API, which means you can get more accurate Rust type information and generate correct TypeScript type definitions.
2. It's sound, which means you can't send it to a outlive scope and call it later, if you want do that, you must create a reference to it or create a `ThreadsafeFunction`.
3. It's friendly to use, you can use different types of arguments and return types, and it can covert the Rust tuple type to JavaScript arguments automatically.
Here is some examples to show how to use it:
```rust
use napi::bindgen_prelude::*;
use napi_derive::napi;

#[napi]
pub fn callback_javascript_callback(add_one: Function<u32, u32>) -> Result<u32> {
  add_one.call(100)
}
```
⬇️⬇️⬇️
```typescript
export function callbackJavascriptCallback(add_one: (arg0: number) => number): number;
```
⬇️⬇️⬇️
```javascript
callbackJavascriptCallback((arg0) => arg0 + 1);
// 101
```
If you define a tuple as the `Function` arguments, it will be converted to JavaScript arguments automatically.
```rust
use napi::bindgen_prelude::*;
use napi_derive::napi;

#[napi]
pub fn callback_javascript_callback(add: Function<(u32, u32), u32>) -> Result<u32> {
  add.call((100, 200))
}
```
⬇️⬇️⬇️
```typescript
export function callbackJavascriptCallback(add: (arg0: number, arg1: number) => number): number;
```
⬇️⬇️⬇️
```javascript
callbackJavascriptCallback((arg0, arg1) => arg0 + arg1);
// 300
```
If you are trying to send it into a outlive scope, you will get a compile error.
For example, if you are trying to send a callback to `git2-rs` `RemoteCallbacks::credentials` API:
```rust
use napi::bindgen_prelude::*;
use napi_derive::napi;

#[napi]
pub fn build_credential(on_credential: Function<(String, Option<String>, CredentialType), ClassInstance<Cred>>) -> Result<()> {
 let mut callbacks = git2::RemoteCallbacks::new();
 callbacks.credentials(move |url, username_from_url, allowed_types| {
   on_credential.call((url.to_string(), username_from_url.map(|s| s.to_string()), allowed_types.into()))
    .map(...)
    .map_error(...)
 });
}
```
You will get a compile error:
```text
error[E0597]: `on_credential` does not live long enough
```
To fix this issue, you can create a reference to it:
```rust
use napi::bindgen_prelude::*;
use napi_derive::napi;
#[napi]
pub fn build_credential(env: Env. on_credential: Function<(String, Option<String>, CredentialType), ClassInstance<Cred>>) -> Result<()> {
  let mut callbacks = git2::RemoteCallbacks::new();
  let on_credential_ref = on_credential.create_ref()?;
  callbacks.credentials(move |url, username_from_url, allowed_types| {
    let on_credential = on_credential_ref.borrow_back(&env)?;
    on_credential.call((url.to_string(), username_from_url.map(|s| s.to_string()), allowed_types.into()))
    .map(...)
    .map_error(...)
  });
}
```
2024-01-26 10:58:30 +08:00
LongYinan
fecd0d8049
Update crates/napi/src/bindgen_runtime/js_values/function.rs 2024-01-26 02:27:46 +00:00
LongYinan
5be7ab0f6b
feat(napi): new Function/FunctionRef API 2024-01-26 02:27:46 +00:00
LongYinan
134707ef1d
fix(napi): callback in execute_tokio_future does not need to be Send (#1917)
The resolver does not need to be `Send` or `Sync`, because it's assumed to be called from the same thread that the JavaScript thread is running on.
2024-01-26 10:27:17 +08:00
renovate[bot]
80f37eeb6a
chore(deps): update dependency husky to v9 (#1914)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-25 16:06:58 +08:00
LongYinan
69d2a75384
Release independent packages
- napi@2.14.4
2024-01-24 17:20:46 +08:00
LongYinan
e332270698
fix(napi): future in block_on do not need to be send 2024-01-24 17:20:31 +08:00
LongYinan
3cbae4e8c1
Release independent packages
- napi@2.14.3
2024-01-24 17:16:41 +08:00
LongYinan
38568c2693
chore(napi): expose spawn_blocking on tokio runtime (#1912) 2024-01-24 17:15:36 +08:00
LongYinan
b4345d1375
fix(napi): block_on type (#1911) 2024-01-24 17:13:42 +08:00
咲奈Sakina
57bcee590b
fix(wasm-runtime): wasm compatible with core-js (#1909) 2024-01-20 15:24:16 +08:00
dependabot[bot]
e595f99266
chore(deps-dev): bump vite from 5.0.11 to 5.0.12 (#1910) 2024-01-20 09:00:53 +08:00
renovate[bot]
84701ef879
chore(deps): update actions/cache action to v4 (#1908)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [actions/cache](https://togithub.com/actions/cache) | action | major | `v3` -> `v4` |

---

### Release Notes

<details>
<summary>actions/cache (actions/cache)</summary>

### [`v4`](https://togithub.com/actions/cache/compare/v3...v4)

[Compare Source](https://togithub.com/actions/cache/compare/v3...v4)

</details>

---

### Configuration

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

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **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:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMzUuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEzNS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
2024-01-18 10:35:59 +08:00
LongYinan
5b9f86fea0
chore(release): publish
- @napi-rs/cli@3.0.0-alpha.36
 - @napi-rs/wasm-runtime@0.1.1
2024-01-17 00:59:12 +08:00
LongYinan
44dc39f1f0
fix(cli,wasm-runtime): dependencies (#1905) 2024-01-17 00:57:29 +08:00
LongYinan
a439e2c3e6
chore(release): publish
- @napi-rs/cli@3.0.0-alpha.35
 - @napi-rs/wasm-runtime@0.1.0
2024-01-16 23:58:23 +08:00
LongYinan
120accd965
feat: add wasm runtime package (#1904) 2024-01-16 23:28:40 +08:00
Milton Moura
ddeaf30f14
feat(cli): Add support for s390x linux arch in js bindings template (#1901)
Signed-off-by: Milton Moura <miltonmoura@gmail.com>
2024-01-16 11:18:05 +08:00
LongYinan
78de67e08f
chore: bump memfs-browser (#1900) 2024-01-16 11:10:55 +08:00
LongYinan
c2b6c18031
chore(release): publish
- @napi-rs/cli@3.0.0-alpha.34
2024-01-10 13:29:47 +08:00
LongYinan
fc3d5cbcff
fix(cli): add browser entry (#1899) 2024-01-10 11:18:13 +08:00
LongYinan
0a70d6ffd7
chore(release): publish
- @napi-rs/cli@3.0.0-alpha.33
2024-01-09 01:06:03 +08:00
LongYinan
1676930728
fix(cli): artifacts wasi worker name (#1895) 2024-01-09 01:05:19 +08:00
LongYinan
a6934ab041
chore: fix generated .d.ts file 2024-01-09 00:58:41 +08:00
LongYinan
2de358aaa6
chore(release): publish
- @napi-rs/cli@3.0.0-alpha.32
2024-01-09 00:36:01 +08:00
LongYinan
9b8dab6b63
fix(cli): missing files in created wasi package (#1894) 2024-01-09 00:34:59 +08:00
LongYinan
ffbaba3a9b
chore(release): publish
- @napi-rs/cli@3.0.0-alpha.31
2024-01-08 21:05:45 +08:00
LongYinan
7d3b53d41d
feat(cli): support generate browser compatible codes (#1891) 2024-01-08 21:02:46 +08:00
renovate[bot]
ecde07f8c1
fix(deps): update dependency @tybys/wasm-util to v0.8.1 (#1892)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-07 19:17:45 +00:00
renovate[bot]
19df3c1ea2
chore(deps): update dependency c8 to v9 (#1889)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [c8](https://togithub.com/bcoe/c8) | [`^8.0.1` -> `^9.0.0`](https://renovatebot.com/diffs/npm/c8/8.0.1/9.0.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/c8/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/c8/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/c8/8.0.1/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/c8/8.0.1/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>bcoe/c8 (c8)</summary>

### [`v9.0.0`](https://togithub.com/bcoe/c8/blob/HEAD/CHANGELOG.md#900-2024-01-03)

[Compare Source](https://togithub.com/bcoe/c8/compare/v8.0.1...v9.0.0)

##### ⚠ BREAKING CHANGES

-   **build:** minimum Node.js version is now 14.14.0

##### Features

-   **build:** minimum Node.js version is now 14.14.0 ([2cdc86b](2cdc86bd0a))
-   **deps:** update foreground-child to promise API ([#&#8203;512](https://togithub.com/bcoe/c8/issues/512)) ([b46b640](b46b640127))
-   **deps:** use Node.js built in rm ([2cdc86b](2cdc86bd0a))

</details>

---

### Configuration

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

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **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:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEwMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
2024-01-04 11:49:50 +08:00
LongYinan
1392954c32
chore(release): publish
- @napi-rs/cli@3.0.0-alpha.30
2024-01-03 19:31:17 +08:00
LongYinan
3889d8ad17
fix(cli): upload to github releases issue (#1888) 2024-01-03 19:29:33 +08:00