-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c281ffe
commit 1a0e0d6
Showing
14 changed files
with
147 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "neon-macros" | ||
version = "1.0.0-alpha.4" | ||
version = "1.0.0" | ||
authors = ["Dave Herman <[email protected]>"] | ||
description = "Procedural macros supporting Neon" | ||
repository = "https://github.com/neon-bindings/neon" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "neon" | ||
version = "1.0.0-alpha.4" | ||
version = "1.0.0" | ||
authors = ["Dave Herman <[email protected]>"] | ||
description = "A safe abstraction layer for Node.js." | ||
readme = "../../README.md" | ||
|
@@ -27,7 +27,7 @@ libloading = "0.8.1" | |
semver = "1.0.20" | ||
smallvec = "1.11.2" | ||
once_cell = "1.18.0" | ||
neon-macros = { version = "=1.0.0-alpha.4", path = "../neon-macros" } | ||
neon-macros = { version = "=1.0.0", path = "../neon-macros" } | ||
aquamarine = { version = "0.3.2", optional = true } | ||
easy-cast = { version = "0.5.2", optional = true } | ||
doc-comment = { version = "0.3.3", optional = true } | ||
|
@@ -75,17 +75,6 @@ napi-8 = ["napi-7", "getrandom"] | |
napi-latest = ["napi-8"] | ||
napi-experimental = ["napi-8"] | ||
|
||
# DEPRECATED: These perform no action and will be removed in 1.0 | ||
try-catch-api = [] | ||
channel-api = [] | ||
event-queue-api = [] | ||
promise-api = [] | ||
task-api = [] | ||
|
||
# Feature flag to include procedural macros | ||
# DEPRECATED: This is always enabled and should be removed. | ||
proc-macros = [] | ||
|
||
# Enables the optional dependencies that are only used for generating the API docs. | ||
doc-dependencies = ["doc-comment", "aquamarine", "easy-cast"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Neon 1.0.0 Migration Guide | ||
|
||
> **Note:** This migration guide assumes a project is using Neon 0.10 without Node-API backend. If using an older version or the legacy backend, see the [previous migration guide](MIGRATION_GUIDE_0.10.md). | ||
The Neon 1.0 has stabilized and brings a more consistent and ergonomic API. There are a few (minor) breaking changes and this guide will help walk through them! | ||
|
||
## Removed Traits | ||
|
||
A few traits have been removed because they were either redundant or only used for features that no longer exist. | ||
|
||
### `Managed` | ||
|
||
The `Managed` trait marked values that were _managed_ by the JavaScript VM. It was redundant with the `Value` trait. Trait bounds referencing `Managed` may be either removed or replaced with `Value`. | ||
|
||
#### Before | ||
|
||
```rust | ||
fn example<V>(h: Handle<V>) | ||
where | ||
V: Managed, | ||
{ | ||
} | ||
``` | ||
|
||
#### After | ||
|
||
```rust | ||
fn example<V>(h: Handle<V>) | ||
where | ||
V: Value, | ||
{ | ||
} | ||
``` | ||
|
||
### `CallContext`, `This`, and `T` in `JsFunction<T>` | ||
|
||
The `This` trait marked values for `cx.this()` in `JsFunction`. However, it was not type checked and could result in a panic at runtime. Instead, `cx.this()` always returns a `JsValue`. Since, `JsFunction`'s `T` parameter had a default, in many cases no changes are necessary. In some cases, the `T` parameter will need to be removed and a `downcast` added. | ||
|
||
#### Before | ||
|
||
```rust | ||
// `CallContext<JsObject>` is equivalent to `FunctionContext` | ||
fn example(mut cx: CallContext<JsObject>) -> JsResult<JsUndefined> { | ||
let a = cx.this().get::<JsValue, _, _>(&mut cx, "a")?; | ||
|
||
Ok(cx.undefined()) | ||
} | ||
``` | ||
|
||
#### After | ||
|
||
```rust | ||
fn example(mut cx: FunctionContext) -> JsResult<JsUndefined> { | ||
let a = cx.this::<JsObject>()?.get::<JsValue, _, _>(&mut cx, "a")?; | ||
|
||
Ok(cx.undefined()) | ||
} | ||
``` | ||
|
||
### `JsResultExt` | ||
|
||
The `JsResultExt` trait provided a `.or_throw(&mut cx)` to allow converting a Rust error into a JavaScript exception. However, it required `T: Value`. It has been replaced with a more generic `ResultExt` trait. Most usages only require replacing `JsResultExt` with `ResultExt`. In some cases, an additional `T: Value` bound will need to be added or removed. | ||
|
||
#### Before | ||
|
||
```rust | ||
use neon::result::JsResultExt; | ||
``` | ||
|
||
#### After | ||
|
||
```rust | ||
use neon::result::ResultExt; | ||
``` | ||
|
||
## `usize` indexes and lengths | ||
|
||
Neon inconsistently used `u32`, `usize`, and sometimes even `i32` for indexes and lengths. For consistency with Rust, `usize` is used everywhere. Update explicit types to use `usize` and remove type casting. Implicit types do not need to be updated. | ||
|
||
#### Before | ||
|
||
```rust | ||
fn example(mut cx: FunctionContext) -> JsResult<JsUndefined> { | ||
let arr = cx.empty_array(); | ||
let msg = cx.string("Hello!"); | ||
|
||
arr.set(&mut cx, 0u32, msg)?; | ||
|
||
Ok(cx.undefined()) | ||
} | ||
``` | ||
|
||
#### After | ||
|
||
```rust | ||
fn example(mut cx: FunctionContext) -> JsResult<JsUndefined> { | ||
let arr = cx.empty_array(); | ||
let msg = cx.string("Hello!"); | ||
|
||
arr.set(&mut cx, 0usize, msg)?; | ||
|
||
Ok(cx.undefined()) | ||
} | ||
``` | ||
|
||
## Feature Flags | ||
|
||
Neon `0.10` made extensive use of feature flags for features that had not been stabilized (e.g., `try-catch-api`, `channel-api`). All features have been stabilized and the feature flags removed. Resolve by removing these features from the project's `Cargo.toml`. | ||
|
||
Two feature flags are still exist: `napi-N` for the Node-API version and `futures` for compatibility between Rust `Future` and JavaScript `Promise`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"neon": "0.10", | ||
"neon": "1.0.0", | ||
"napi": "8", | ||
"cargo-cp-artifact": "0.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters