Skip to content

Commit

Permalink
Release 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kjvalencik committed Dec 4, 2023
1 parent c281ffe commit 1a0e0d6
Show file tree
Hide file tree
Showing 14 changed files with 147 additions and 59 deletions.
2 changes: 2 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Neon owes its existence to the contributions of these fine people.
* [ComplexSpaces](https://github.com/complexspaces)
* [Nathaniel Daniel](https://github.com/adumbidiot)
* [John Darrington](https://github.com/DnOberon)
* [erics118](https://github.com/erics118)
* [Joey Ezechiëls](https://github.com/jjpe)
* [Ryan Fitzgerald](https://github.com/rf-)
* [Cory Forsyth](https://github.com/bantic)
Expand Down Expand Up @@ -74,4 +75,5 @@ Neon owes its existence to the contributions of these fine people.
* [Chi Wang](https://github.com/patr0nus)
* [wangcong](https://github.com/king6cong)
* [Amila Welihinda](https://github.com/amilajack)
* [xyloflake](https://github.com/xyloflake)
* [Felix Yan](https://github.com/felixonmars)
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ Neon!
See our [Neon fundamentals docs](https://neon-bindings.com/docs/intro) and
our [API docs](https://docs.rs/neon/latest/neon).

## Neon 0.10 Migration Guide
## Neon 1.0.0 Migration Guide

The latest version of Neon, 0.10, includes a few small breaking changes in order to clean up and improve the usability of our APIs.
The latest version of Neon, 1.0.0, includes several breaking changes in order to fix unsoundness, improve consistency, and add features.

**Read the new [migration guide](https://github.com/neon-bindings/neon/blob/main/doc/MIGRATION_GUIDE_0.10.md)** to learn how to port your
Neon projects to 0.10!
**Read the new [migration guide](doc/MIGRATION_GUIDE_1.0.0.md)** to learn how to port your
Neon projects to 1.0.0!

## Platform Support

Expand Down
23 changes: 23 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# Version 1.0.0

## Breaking Changes

* Remove the generic parameter from `JsFunction` (https://github.com/neon-bindings/neon/pull/989)
* `JsArray::new` takes a `usize` instead of a `u32` (https://github.com/neon-bindings/neon/pull/988)
* Made `Context::global` read a key and added `Context::global_object` (https://github.com/neon-bindings/neon/pull/987)
* Deprecated feature flags were removed

## Bug fixes

* Fix `unhandledRejection` with `JsPromise::to_future` (https://github.com/neon-bindings/neon/pull/1008)
* Typo in `cargo-cp-artifact` help (https://github.com/neon-bindings/neon/pull/998)
* Typo in README (https://github.com/neon-bindings/neon/pull/1012)

## Other

https://github.com/neon-bindings/neon/pull/1010

* Bumped dependency versions
* Changed to edition 2021
* Updated support matrix to Node 18, 20, and 21

# Version 1.0.0-alpha.4

Patch to enable new features flags in docs.rs.
Expand Down
2 changes: 1 addition & 1 deletion crates/neon-macros/Cargo.toml
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"
Expand Down
15 changes: 2 additions & 13 deletions crates/neon/Cargo.toml
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"
Expand All @@ -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 }
Expand Down Expand Up @@ -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"]

Expand Down
20 changes: 0 additions & 20 deletions crates/neon/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,6 @@ pub trait Context<'a>: ContextInternal<'a> {
}))
}

#[cfg_attr(
feature = "try-catch-api",
deprecated = "`try-catch-api` feature has no impact and may be removed"
)]
fn try_catch<T, F>(&mut self, f: F) -> Result<T, Handle<'a, JsValue>>
where
F: FnOnce(&mut Self) -> NeonResult<T>,
Expand Down Expand Up @@ -457,14 +453,6 @@ pub trait Context<'a>: ContextInternal<'a> {
}

#[cfg(feature = "napi-4")]
#[cfg_attr(
feature = "channel-api",
deprecated = "`channel-api` feature has no impact and may be removed"
)]
#[cfg_attr(
all(not(feature = "channel-api"), feature = "event-queue-api"),
deprecated = "`event-queue-api` feature has no impact and may be removed"
)]
#[cfg_attr(docsrs, doc(cfg(feature = "napi-4")))]
/// Returns an unbounded channel for scheduling events to be executed on the JavaScript thread.
///
Expand All @@ -480,10 +468,6 @@ pub trait Context<'a>: ContextInternal<'a> {
channel
}

#[cfg_attr(
feature = "promise-api",
deprecated = "`promise-api` feature has no impact and may be removed"
)]
/// Creates a [`Deferred`] and [`JsPromise`] pair. The [`Deferred`] handle can be
/// used to resolve or reject the [`JsPromise`].
///
Expand All @@ -502,10 +486,6 @@ pub trait Context<'a>: ContextInternal<'a> {
JsPromise::new(self)
}

#[cfg_attr(
feature = "task-api",
deprecated = "`task-api` feature has no impact and may be removed"
)]
/// Creates a [`TaskBuilder`] which can be used to schedule the `execute`
/// callback to asynchronously execute on the
/// [Node worker pool](https://nodejs.org/en/docs/guides/dont-block-the-event-loop/).
Expand Down
8 changes: 0 additions & 8 deletions crates/neon/src/event/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@ type Callback = Box<dyn FnOnce(Env) + Send + 'static>;
/// Ok(cx.undefined())
/// }
/// ```
#[cfg_attr(
feature = "channel-api",
deprecated = "`channel-api` feature has no impact and may be removed"
)]
#[cfg_attr(
all(not(feature = "channel-api"), feature = "event-queue-api"),
deprecated = "`event-queue-api` feature has no impact and may be removed"
)]
#[cfg_attr(docsrs, doc(cfg(feature = "napi-4")))]
pub struct Channel {
state: Arc<ChannelState>,
Expand Down
4 changes: 0 additions & 4 deletions crates/neon/src/event/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ use crate::{
types::{Deferred, JsPromise, Value},
};

#[cfg_attr(
feature = "task-api",
deprecated = "`task-api` feature has no impact and may be removed"
)]
/// Node asynchronous task builder
///
/// ```
Expand Down
4 changes: 0 additions & 4 deletions crates/neon/src/types_impl/promise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ const BOUNDARY: FailureBoundary = FailureBoundary {

#[derive(Debug)]
#[repr(transparent)]
#[cfg_attr(
feature = "promise-api",
deprecated = "`promise-api` feature has no impact and may be removed"
)]
/// The type of JavaScript
/// [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
/// objects.
Expand Down
110 changes: 110 additions & 0 deletions doc/MIGRATION_GUIDE_1.0.0.md
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`.
2 changes: 1 addition & 1 deletion pkgs/create-neon/data/versions.json
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"
}
2 changes: 1 addition & 1 deletion test/electron/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ license = "MIT/Apache-2.0"
crate-type = ["cdylib"]

[dependencies.neon]
version = "1.0.0-alpha.4"
version = "1.0.0"
path = "../../crates/neon"
2 changes: 1 addition & 1 deletion test/napi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ once_cell = "1.18.0"
tokio = { version = "1.34.0", features = ["rt-multi-thread"] }

[dependencies.neon]
version = "1.0.0-alpha.4"
version = "1.0.0"
path = "../../crates/neon"
features = ["futures", "napi-experimental", "external-buffers"]

0 comments on commit 1a0e0d6

Please sign in to comment.