Skip to content

napi-derive

napi-derive-v3.5.9

7/3/2026

Other

  • updated the following local packages: napi-derive-backend

napi-derive-backend-v5.1.1

7/3/2026

Other

  • (napi) share class accessor trampolines (#3364)
  • optimize object field raw property access (#3365)

napi-derive-v3.5.8

7/1/2026

Other

  • updated the following local packages: napi-derive-backend

napi-derive-backend-v5.1.0

7/1/2026

Added

  • (napi) implement To/FromNapiValue for OsString, OsStr, Path and PathBuf (#3339)

napi-derive-v3.5.7

6/24/2026

Other

  • updated the following local packages: napi-derive-backend

napi-derive-backend-v5.0.5

6/24/2026

Other

  • (napi-derive) outline #[napi(object)] field-error decoration (#3338)

napi-derive-v3.5.6

5/13/2026

Fixed

  • (napi) invalid TypeScript generic syntax for type aliases (#3289)
  • (deps) update rust crate ctor to v1 (#3276)
  • (deps) update rust crate ctor to 0.13.0 (#3275)
  • (deps) update rust crate ctor to 0.12.0 (#3271)

napi-derive-v3.5.5

4/29/2026

Fixed

  • (deps) update rust crate ctor to 0.11.0 (#3270)
  • (napi) Convert #[ctor] calls to declarative form to remove all features (#3257)

napi-derive-backend-v5.0.4

4/29/2026

Fixed

  • (napi-derive) only FnArgs unpacks tuple to variadic params (#3264)
  • (napi) Convert #[ctor] calls to declarative form to remove all features (#3257)

napi-derive-v3.5.4

4/15/2026

Fixed

  • (deps) update rust crate ctor to v0.10.0 (#3224)
  • (deps) disable ctor priority feature (#3209)
  • (deps) update rust crate ctor to v0.9.1 (#3204)

napi-derive-backend-v5.0.3

4/15/2026

Fixed

  • (napi) preserve generator class methods (#3231)

napi-derive-v3.5.3

3/28/2026

Fixed

  • (deps) update rust crate ctor to v0.8.0 (#3170)
  • (deps) update rust crate ctor to v0.7.0 (#3169)

napi-derive-v3.5.2

2/14/2026

Fixed

  • (deps) update rust crate convert_case to 0.11 (#3114)

napi-derive-backend-v5.0.2

2/14/2026

Fixed

  • (deps) update rust crate convert_case to 0.11 (#3114)
  • (napi-derive) escape * in comments (#3109)

napi-derive-v3.5.1

1/8/2026

Other

  • updated the following local packages: napi-derive-backend

napi-derive-backend-v5.0.1

1/8/2026

Fixed

  • (napi) memory leak in async fn (#3089)

napi-derive-v3.5.0

12/30/2025

Added

  • (napi-derive) add #[napi(async_iterator)] macro attribute (#3072)

napi-derive-backend-v5.0.0

12/30/2025

Added

  • (napi-derive) add #[napi(async_iterator)] macro attribute (#3072)

napi-derive-v3.4.1

12/19/2025

Other

  • clippy fix for Rust 1.92.0 (#3058)

napi-derive-backend-v4.0.1

12/19/2025

Fixed

  • (napi-derive) class setter param can't be optional (#3066)

napi-derive-v3.4.0

12/2/2025

Added

  • (napi-derive) add tracing feature for debug logging NAPI function calls (#3041)

Fixed

  • (deps) update rust crate convert_case to 0.10 (#3031)

napi-derive-backend-v4.0.0

12/2/2025

Added

  • (napi-derive) add tracing feature for debug logging NAPI function calls (#3041)
  • (napi) add node_api_create_object_with_properties support for enum creation (#2990)

Fixed

  • (napi-derive) add paren for function types (#3044)
  • (deps) update rust crate convert_case to 0.10 (#3031)

napi-derive-v3.3.3

11/10/2025

Fixed

  • (deps) update rust crate convert_case to 0.9 (#3001)

Other

  • (napi) fix tsdown config (#3010)

napi-derive-backend-v3.0.2

11/10/2025

Fixed

  • (deps) update rust crate convert_case to 0.9 (#3001)

Other

  • (napi) fix tsdown config (#3010)

napi-derive-v3.3.2

11/7/2025

Other

  • updated the following local packages: napi-derive-backend

napi-derive-v3.3.1

11/7/2025

Other

  • (napi) Promise and ThreadsafeFunction::call_async don't require tokio (#2998)

napi-derive-backend-v3.0.1

11/7/2025

Fixed

  • (napi-derive) TypedArray typegen (#3005)

napi-derive-v3.3.0

10/24/2025

Added

  • (napi-derive) add discriminant_case to allow changing case of discriminant (#2960)

Fixed

  • (deps) update rust crate ctor to v0.6.0 (#2951)

Other

  • (napi) bump rust-version (#2966)

napi-derive-backend-v3.0.0

10/24/2025

Added

  • (napi-derive) add discriminant_case to allow changing case of discriminant (#2960)

Fixed

  • (napi) stop ref error object in wasm targets (#2975)

Other

  • (napi) bump rust-version (#2966)
  • (napi-derive) make typegen easier to read (#2956)

napi-derive-v3.2.5

9/8/2025

Other

  • updated the following local packages: napi-derive-backend

napi-derive-backend-v2.2.0

9/8/2025

Added

  • (napi) support external JsStringLatin1 and JsStringUtf16 (#2898)

napi-derive-v3.2.4

8/16/2025

Other

  • updated the following local packages: napi-derive-backend

napi-derive-backend-v2.1.4

8/16/2025

Fixed

  • (napi-derive) codegen issue for &'env [u8] param (#2881)

Other

  • (napi) extends the Set types interoperability (#2875)

napi-derive-v3.2.3

8/13/2025

Fixed

  • (napi) link issue on cargo test --features noop (#2872)
  • (deps) update rust crate ctor to v0.5.0 (#2865)

napi-derive-backend-v2.1.3

8/13/2025

Fixed

  • (napi) link issue on cargo test --features noop (#2872)

napi-derive-v3.2.2

8/9/2025

Other

  • updated the following local packages: napi-derive-backend

napi-derive-backend-v2.1.2

8/9/2025

Fixed

  • (napi-derive) comments idents regression (#2857)

napi-derive-v3.2.1

8/8/2025

Other

  • updated the following local packages: napi-derive-backend

napi-derive-backend-v2.1.1

8/8/2025

Fixed

  • (napi) handle the return_if_invalid for Array param (#2846)

napi-derive-v3.2.0

8/7/2025

Added

  • (napi) add ScopeGenerator trait (#2831)
  • make generator an iterator (#2784)

napi-derive-backend-v2.1.0

8/7/2025

Added

  • make generator an iterator (#2784)

napi-derive-v3.1.2

7/30/2025

Other

  • updated the following local packages: napi-derive-backend

napi-derive-backend-v2.0.3

7/30/2025

Fixed

  • (napi-derive) generate types for threadsafe_function with WEAK=true correctly (#2813)

napi-derive-v3.1.1

7/22/2025

Other

  • updated the following local packages: napi-derive-backend

napi-derive-backend-v2.0.2

7/22/2025

Fixed

  • (napi-derive) lifetime codegen issue (#2794)

napi-derive-v3.1.0

7/21/2025

Added

  • (napi) provide ScopedTask to resolve JsValue with lifetime (#2786)

Other

  • pin release-plz action

napi-derive-backend-v2.0.1

7/21/2025

Other

  • pin release-plz action

napi-derive@3.0.0-beta.12

7/4/2025

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-beta.11...napi-derive@3.0.0-beta.12

napi-derive@3.0.0-beta.11

6/30/2025

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-beta.10...napi-derive@3.0.0-beta.11

napi-derive@3.0.0-beta.10

6/25/2025

What's Changed

New Contributors

Full Changelog: https://github.com/napi-rs/napi-rs/compare/@napi-rs/cli@3.0.0-alpha.91...napi-derive@3.0.0-beta.10

napi-derive@3.0.0-beta.9

6/24/2025 Version bump only

Full Changelog: https://github.com/napi-rs/napi-rs/compare/@napi-rs/cli@3.0.0-alpha.90...napi-derive@3.0.0-beta.9

napi-derive@3.0.0-beta.8

6/8/2025

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-beta.6...napi-derive@3.0.0-beta.8

napi-derive@3.0.0-beta.5

6/4/2025

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-beta.4...napi-derive@3.0.0-beta.5

napi-derive@3.0.0-beta.4

6/3/2025

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-beta.3...napi-derive@3.0.0-beta.4

napi-derive@3.0.0-beta.3

5/29/2025

What's Changed

Bump version only

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@3.0.0-beta.2...napi-derive@3.0.0-beta.3

napi-derive@3.0.0-beta.2

5/22/2025

What's Changed

Version bump only

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-beta.1...napi-derive@3.0.0-beta.2

napi-derive@3.0.0-beta.1

5/19/2025

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-beta.0...napi-derive@3.0.0-beta.1

napi-derive@3.0.0-beta.0

5/16/2025

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-build@2.1.6...napi-derive@3.0.0-beta.0

napi-derive@3.0.0-alpha.29

3/16/2025

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@3.0.0-alpha.31...napi-derive@3.0.0-alpha.29

napi-derive@3.0.0-alpha.26

2/11/2025

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/@napi-rs/cli@3.0.0-alpha.67...napi-derive@3.0.0-alpha.26

napi-derive@3.0.0-alpha.25

1/12/2025

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-alpha.24...napi-derive@3.0.0-alpha.25

napi-derive@3.0.0-alpha.24

1/12/2025

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@3.0.0-alpha.25...napi-derive@3.0.0-alpha.24

napi-derive@3.0.0-alpha.23

1/4/2025

What's Changed

New Contributors

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@3.0.0-alpha.23...napi-derive@3.0.0-alpha.23

napi-derive@2.16.13

12/3/2024

What Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@2.16.13...napi-derive@2.16.13

napi-derive@3.0.0-alpha.21

12/3/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@3.0.0-alpha.21...napi-derive@3.0.0-alpha.21

napi-derive@3.0.0-alpha.20

11/30/2024

What's Changed

New Contributors

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-alpha.19...napi-derive@3.0.0-alpha.20

napi-derive@3.0.0-alpha.19

11/13/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-alpha.18...napi-derive@3.0.0-alpha.19

napi-derive@3.0.0-alpha.18

11/7/2024

What's Changed

New Contributors

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-alpha.17...napi-derive@3.0.0-alpha.18

napi-derive@3.0.0-alpha.17

10/31/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-sys@3.0.0-alpha.0...napi-derive@3.0.0-alpha.17

napi-derive@3.0.0-alpha.16

10/28/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-alpha.15...napi-derive@3.0.0-alpha.16

napi-derive@3.0.0-alpha.15

10/21/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-alpha.14...napi-derive@3.0.0-alpha.15

napi-derive@3.0.0-alpha.14

10/13/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-alpha.13...napi-derive@3.0.0-alpha.14

napi-derive@3.0.0-alpha.13

10/2/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@3.0.0-alpha.12...napi-derive@3.0.0-alpha.13

napi-derive@3.0.0-alpha.12

9/23/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-alpha.11...napi-derive@3.0.0-alpha.12

napi-derive@3.0.0-alpha.11

9/21/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@3.0.0-alpha.11...napi-derive@3.0.0-alpha.11

napi-derive@3.0.0-alpha.10

9/20/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-alpha.9...napi-derive@3.0.0-alpha.10

napi-derive@3.0.0-alpha.9

9/19/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-alpha.8...napi-derive@3.0.0-alpha.9

napi-derive@2.16.12

9/12/2024

What Changed

  • fix(napi-derive): string enum validate logic #2213 @Brooooooklyn
  • fix(napi-derive): warning in empty enum codegen #2214 @Brooooooklyn
  • fix(napi,napi-derive): ffi lifetime and pointer sound issues #2216 @cathy-sjh
  • fix(napi-derive): replace self when function returns Result #2224 @CPunisher
  • perf(macro): constructor don't support asynchronous function #2239 @richerfu
  • fix(napi-derive): call flush on the BufWriter #2242 @richerfu

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.16.10...napi-derive@2.16.12

napi-derive@3.0.0-alpha.8

9/12/2024

What's Changed

New Contributors

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-alpha.7...napi-derive@3.0.0-alpha.8

napi-derive@2.16.11

8/10/2024

What Changed

  • fix(napi-derive): add more cases for typegen of function args by @CPunisher #2210

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.16.10...napi-derive@2.16.11

napi-derive@2.16.10

7/23/2024

What Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.16.9...napi-derive@2.16.10

napi-derive@3.0.0-alpha.7

7/23/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-alpha.6...napi-derive@3.0.0-alpha.7

napi-derive@2.16.9

7/16/2024

What's Changed

New Contributors

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.16.8...napi-derive@2.16.9

napi-derive@3.0.0-alpha.6

7/16/2024

What's Changed

New Contributors

Full Changelog: https://github.com/napi-rs/napi-rs/compare/@napi-rs/cli@3.0.0-alpha.59...napi-derive@3.0.0-alpha.6

napi-derive@2.16.8

7/1/2024

What changed

  • fix(napi-derive): missing declare keyword for function

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.16.7...napi-derive@2.16.8

napi-derive@3.0.0-alpha.3

7/1/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@3.0.0-alpha.2...napi-derive@3.0.0-alpha.3

napi-derive@2.16.4

5/6/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.16.3...napi-derive@2.16.4

napi-derive@2.16.3

4/18/2024

What Changed

  • fix(napi-derive): bail the unexpected factory directive by @Brooooooklyn #2051

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@2.16.4...napi-derive@2.16.3

napi-derive@2.16.2

4/10/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.16.1...napi-derive@2.16.2

napi-derive@2.16.1

3/26/2024

What's Changed

New Contributors

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.16.0...napi-derive@2.16.1

napi-derive@2.16.0

2/28/2024

What's Changed

New Contributors

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@2.15.4...napi-derive@2.16.0

napi-derive@2.15.1

2/8/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@2.15.1...napi-derive@2.15.1

napi-derive@2.15.0

1/26/2024

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.14.6...napi-derive@2.15.0

napi-derive@2.14.6

12/27/2023

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.14.5...napi-derive@2.14.6

napi-derive@2.14.5

12/27/2023

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/@napi-rs/cli@3.0.0-alpha.24...napi-derive@2.14.5

napi-derive@2.14.4

12/13/2023

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.14.3...napi-derive@2.14.4

napi-derive@2.14.3

12/11/2023

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/@napi-rs/cli@3.0.0-alpha.15...napi-derive@2.14.3

napi-derive@2.14.2

11/20/2023

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.14.1...napi-derive@2.14.2

napi-derive@2.14.1

11/8/2023

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-sys@2.3.0...napi-derive@2.14.1

napi-derive@2.14.0

11/7/2023

What's Changed

napi-derive@2.12.5

4/26/2023

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.12.4...napi-derive@2.12.5

napi-derive@2.12.4

4/25/2023

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@2.12.5...napi-derive@2.12.4

napi-derive@2.12.3

4/11/2023

Core features

rust
#[napi(string_enum)]
pub enum Status {
  Pristine,
  Loading,
  Ready,
}

⬇️⬇️⬇️⬇️⬇️

ts
export const enum Status {
  Pristine = 'Pristine',
  Loading = 'Loading',
  Ready = 'Ready'
}

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.12.2...napi-derive@2.12.3

napi-derive@2.12.2

3/22/2023

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.12.1...napi-derive@2.12.2

napi-derive@2.12.1

3/21/2023

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.12.0...napi-derive@2.12.1

napi-derive@2.12.0

3/21/2023

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@2.11.4...napi-derive@2.12.0

napi-derive@2.11.2

3/14/2023

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.11.1...napi-derive@2.11.2

napi-derive@2.11.1

2/18/2023

Changes

Full Changelog: https://github.com/napi-rs/napi-rs/compare/@napi-rs/cli@2.14.8...napi-derive@2.11.1

napi-derive@2.10.1

1/31/2023

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.10.0...napi-derive@2.10.1

napi-derive@2.10.0

1/24/2023

Highlights

ThreadsafeFunction as params and object fields

rust
#[napi]
pub fn accept_callback(callback: ThreadsafeFunction<u32>) {
  std::thread::spawn(move || {
    callback.call(200);
  });
}

⬇️⬇️⬇️⬇️⬇️

js
export function acceptCallback(callback: (err: Error | null, value: number) -> any)

Disable ToNapiValue for Object

With the object_to_js = false filed, the ThreadsafeFunction could be set as an Object field.

rust
#[napi(object, object_to_js = false)]
pub struct Options {
  pub enable_jsx: bool,
  pub on_data: ThreadsafeFunction<Vec<u8>>,
}

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/@napi-rs/cli@2.14.4...napi-derive@2.10.0

napi-derive@2.9.5

1/14/2023

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/@napi-rs/cli@2.14.3...napi-derive@2.9.5

napi-derive@2.9.4

1/13/2023

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@2.10.6...napi-derive@2.9.4

napi-derive@2.9.3

12/9/2022

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.9.2...napi-derive@2.9.3

napi-derive@2.9.1

9/8/2022

What's Changed

New Contributors

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@2.9.0...napi-derive@2.9.1

napi-derive@2.9.0

8/23/2022

What's Changed

New Contributors

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.8.0...napi-derive@2.9.0

napi-derive@2.8.0

8/17/2022

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.7.0...napi-derive@2.8.0

napi-derive@2.7.0

8/7/2022

What's Changed

napi-derive@2.6.0

7/6/2022

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.5.0...napi-derive@2.6.0

napi-derive@2.5.0

6/10/2022

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.4.1...napi-derive@2.5.0

napi-derive@2.3.3

4/27/2022

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.3.2...napi-derive@2.3.3

napi-derive@2.3.2

4/27/2022

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.3.1...napi-derive@2.3.2

napi-derive@2.3.1

4/25/2022

What's Changed

New Contributors

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@2.3.1...napi-derive@2.3.1

napi-derive@2.1.0

2/9/2022

What's Changed

New Contributors

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.8...napi-derive@2.1.0

napi-derive@2.0.8

1/18/2022

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.7...napi-derive@2.0.8

napi-derive@2.0.7

1/7/2022

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.6...napi-derive@2.0.7

napi-derive@2.0.6

1/6/2022

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.5...napi-derive@2.0.6

napi-derive@2.0.5

1/4/2022

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.4...napi-derive@2.0.5

napi-derive@2.0.4

12/24/2021

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.3...napi-derive@2.0.4

napi-derive@2.0.3

12/24/2021

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.2...napi-derive@2.0.3

napi-derive@2.0.2

12/23/2021

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.1...napi-derive@2.0.2

napi-derive@2.0.1

12/21/2021

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.0...napi-derive@2.0.1

napi-derive@2.0.0-beta.5

12/8/2021

Bugfix

napi-derive@2.0.0-beta.4

12/8/2021

Feature

This feature is useful for sharing code between Node.js native addon and wasm

napi-derive@2.0.0-beta.3

12/7/2021

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi@2.0.0-beta.3...napi-derive@2.0.0-beta.3

napi-derive@2.0.0-beta.2

12/6/2021

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.0-beta.1...napi-derive@2.0.0-beta.2

napi-derive@2.0.0-beta.1

12/2/2021

Bugfix

napi-derive@2.0.0-alpha.10

11/29/2021

Features

  • Output Rust doc comments in definitions as jsdoc comments #885 @timfish
rust
/// `constructor` option for `struct` requires all fields to be public,
/// otherwise tag impl fn as constructor
/// #[napi(constructor)]
#[napi]
pub struct Animal {
  #[napi(readonly)]
  /// Kind of animal
  pub kind: Kind,

  name: String,
}

#[napi]
impl Animal {
  /// This is the constructor
  #[napi(constructor)]
  pub fn new(kind: Kind, name: String) -> Self {
    Animal { kind, name }
  }

  /// This is a factory method
  #[napi(factory)]
  pub fn with_kind(kind: Kind) -> Self {
    Animal {
      kind,
      name: "Default".to_owned(),
    }
  }

  #[napi(getter)]
  pub fn get_name(&self) -> &str {
    self.name.as_str()
  }

  #[napi(setter)]
  pub fn set_name(&mut self, name: String) {
    self.name = name;
  }

  /// This is a
  /// multi-line comment
  /// with an emoji 🚀
  #[napi]
  pub fn whoami(&self) -> String {
    match self.kind {
      Kind::Dog => {
        format!("Dog: {}", self.name)
      }
      Kind::Cat => format!("Cat: {}", self.name),
      Kind::Duck => format!("Duck: {}", self.name),
    }
  }

  #[napi]
  /// This is static...
  pub fn get_dog_kind() -> Kind {
    Kind::Dog
  }
}

⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️

ts
/**
 * `constructor` option for `struct` requires all fields to be public,
 * otherwise tag impl fn as constructor
 * #[napi(constructor)]
 */
export class Animal {
  /** Kind of animal */
  readonly kind: Kind
  /** This is the constructor */
  constructor(kind: Kind, name: string)
  /** This is a factory method */
  static withKind(kind: Kind): Animal
  get name(): string
  set name(name: string)
  /**
   * This is a
   * multi-line comment
   * with an emoji 🚀
   */
  whoami(): string
  /** This is static... */
  static getDogKind(): Kind
}

napi-derive@2.0.0-alpha.9

11/26/2021

Features

  • Support rename function args and return type #884 @Brooooooklyn
rust
use napi::bindgen_prelude::*;
use napi_derive::napi;

#[napi(ts_args_type = "a: { foo: number }", ts_return_type = "string[]")]
fn ts_rename(a: Object) -> Result<Object> {
  a.get_property_names()
}

⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️

ts
export function tsRename(a: { foo: number }): string[]

napi-derive@2.0.0-alpha.6

11/16/2021

What's Changed

  • Generate TypeScript optional types from Rust Option
rust
#[napi]
fn map_option(val: Option<u32>) -> Option<u32> {
  val.map(|v| v + 1)
}
ts
export function mapOption(val?: number | undefined | null): number | undefined | null
rust
#[napi]
pub struct Context {
  data: String,
  pub maybe_need: Option<bool>,
}
ts
export class Context {
  maybeNeed?: boolean | undefined | null
}
rust
#[napi]
fn read_file<T: Fn(Result<()>, Option<String>) -> Result<()>>(callback: T) {
  match read_file_content() {
    Ok(s) => callback(Ok(()), Some(s)),
    Err(e) => callback(Err(e), None),
  }
  .unwrap();
}
ts
export function readFile(callback: (arg0: Error | undefined, arg1?: string | undefined | null) => void): void

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.0-alpha.5...napi-derive@2.0.0-alpha.6

napi-derive@2.0.0-alpha.5

11/16/2021

What's Changed

Full Changelog: https://github.com/napi-rs/napi-rs/compare/napi-derive@2.0.0-alpha.4...napi-derive@2.0.0-alpha.5

napi-derive@2.0.0-alpha.3

11/10/2021

Bugfix

napi-derive-backend@1.0.1

10/1/2021

Perf

  • ignore callback info while no arguments e69a763

napi-derive@1.1.0

4/1/2021

Feature