From d9c53d728be02b01f0e2ff19845cd652068f9303 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Tue, 30 Nov 2021 18:43:34 +0800 Subject: [PATCH] feat(napi): support TypedArray input and output --- .cirrus.yml | 2 +- .github/workflows/test.yaml | 2 +- README.md | 82 +++--- cli/package.json | 2 +- crates/backend/src/codegen.rs | 1 - crates/backend/src/codegen/js_mod.rs | 9 - crates/backend/src/lib.rs | 1 - crates/backend/src/typegen.rs | 12 +- crates/backend/src/typegen/js_mod.rs | 13 - crates/napi/src/bindgen_runtime/js_values.rs | 2 + .../bindgen_runtime/js_values/arraybuffer.rs | 228 ++++++++++++++++ crates/napi/src/js_values/arraybuffer.rs | 55 ++-- examples/napi/__test__/typegen.spec.ts.md | 3 + examples/napi/__test__/typegen.spec.ts.snap | Bin 1789 -> 1831 bytes examples/napi/__test__/values.spec.ts | 18 ++ examples/napi/__test__/values.spec.ts.md | 1 + examples/napi/__test__/values.spec.ts.snap | Bin 574 -> 586 bytes examples/napi/index.d.ts | 3 + examples/napi/src/typed_array.rs | 17 ++ memory-testing/package.json | 2 +- package.json | 29 +- yarn.lock | 255 +++++++++--------- 22 files changed, 510 insertions(+), 227 deletions(-) delete mode 100644 crates/backend/src/codegen/js_mod.rs delete mode 100644 crates/backend/src/typegen/js_mod.rs create mode 100644 crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs diff --git a/.cirrus.yml b/.cirrus.yml index 1e119c62..1d4dc2dc 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -22,7 +22,7 @@ task: echo "~~~~ yarn --version ~~~~" yarn --version test_script: - - yarn install --ignore-platform --frozen-lockfile --registry https://registry.npmjs.org + - yarn install --ignore-platform --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org - yarn build - cargo test -p napi-sys --lib -- --nocapture - yarn build:test diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 112d6033..c7981919 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - node: ['12', '14', '16'] + node: ['12', '14', '16', '17'] os: [ubuntu-latest, macos-latest, windows-latest] name: stable - ${{ matrix.os }} - node@${{ matrix.node }} diff --git a/README.md b/README.md index d71651d4..d30994bc 100644 --- a/README.md +++ b/README.md @@ -55,20 +55,20 @@ _Main branch is now under napi@next developing. Checkout [v1 docs](https://napi. [![Windows arm64](https://github.com/napi-rs/napi-rs/actions/workflows/windows-arm.yml/badge.svg)](https://github.com/napi-rs/napi-rs/actions/workflows/windows-arm.yml) [![FreeBSD](https://api.cirrus-ci.com/github/napi-rs/napi-rs.svg)](https://cirrus-ci.com/github/napi-rs/napi-rs?branch=main) -| | node12 | node14 | node16 | -| --------------------- | ------ | ------ | ------ | -| Windows x64 | ✓ | ✓ | ✓ | -| Windows x86 | ✓ | ✓ | ✓ | -| Windows arm64 | ✓ | ✓ | ✓ | -| macOS x64 | ✓ | ✓ | ✓ | -| macOS aarch64 | ✓ | ✓ | ✓ | -| Linux x64 gnu | ✓ | ✓ | ✓ | -| Linux x64 musl | ✓ | ✓ | ✓ | -| Linux aarch64 gnu | ✓ | ✓ | ✓ | -| Linux aarch64 musl | ✓ | ✓ | ✓ | -| Linux arm gnueabihf | ✓ | ✓ | ✓ | -| Linux aarch64 android | ✓ | ✓ | ✓ | -| FreeBSD x64 | ✓ | ✓ | ✓ | +| | node12 | node14 | node16 | node17 | +| --------------------- | ------ | ------ | ------ | ------ | +| Windows x64 | ✓ | ✓ | ✓ | ✓ | +| Windows x86 | ✓ | ✓ | ✓ | ✓ | +| Windows arm64 | ✓ | ✓ | ✓ | ✓ | +| macOS x64 | ✓ | ✓ | ✓ | ✓ | +| macOS aarch64 | ✓ | ✓ | ✓ | ✓ | +| Linux x64 gnu | ✓ | ✓ | ✓ | ✓ | +| Linux x64 musl | ✓ | ✓ | ✓ | ✓ | +| Linux aarch64 gnu | ✓ | ✓ | ✓ | ✓ | +| Linux aarch64 musl | ✓ | ✓ | ✓ | ✓ | +| Linux arm gnueabihf | ✓ | ✓ | ✓ | ✓ | +| Linux aarch64 android | ✓ | ✓ | ✓ | ✓ | +| FreeBSD x64 | ✓ | ✓ | ✓ | ✓ | This library depends on Node-API and requires `Node@10.0.0` or later. @@ -221,30 +221,30 @@ yarn test ## Features table -| Rust Type | Node Type | [NAPI Version](https://nodejs.org/api/n-api.html#n_api_node_api_version_matrix) | Minimal Node version | Enable by `napi` feature | -| ----------------------- | ---------------------- | ------------------------------------------------------------------------------- | -------------------- | ------------------------ | -| u32 | Number | 1 | v8.0.0 | -| i32/i64 | Number | 1 | v8.0.0 | -| f64 | Number | 1 | v8.0.0 | -| bool | Boolean | 1 | v8.0.0 | -| String/&'a str | String | 1 | v8.0.0 | -| Latin1String | String | 1 | v8.0.0 | latin1 | -| UTF16String | String | 1 | v8.0.0 | -| Object | Object | 1 | v8.0.0 | -| serde_json::Map | Object | 1 | v8.0.0 | serde-json | -| serde_json::Value | any | 1 | v8.0.0 | serde-json | -| Array | Array | 1 | v8.0.0 | -| Vec | Array | 1 | v8.0.0 | -| Buffer | Buffer | 1 | v8.0.0 | -| External | External | 1 | v8.0.0 | | -| Null | null | 1 | v8.0.0 | -| Undefined/() | undefined | 1 | v8.0.0 | -| Result<()> | Error | 1 | v8.0.0 | -| T: Fn(...) -> Result | Function | 1 | v8.0.0 | -| Async/Future | Promise | 4 | v10.6.0 | async | -| AsyncTask | Promise | 1 | v8.5.0 | -| JsGlobal | global | 1 | v8.0.0 | -| JsSymbol | Symbol | 1 | v8.0.0 | -| (NOT YET) | ArrayBuffer/TypedArray | 1 | v8.0.0 | -| JsFunction | threadsafe function | 4 | v10.6.0 | napi4 | -| BigInt | BigInt | 6 | v10.7.0 | napi6 | +| Rust Type | Node Type | [NAPI Version](https://nodejs.org/api/n-api.html#n_api_node_api_version_matrix) | Minimal Node version | Enable by `napi` feature | +| ------------------------ | ------------------- | ------------------------------------------------------------------------------- | -------------------- | ------------------------ | +| u32 | Number | 1 | v8.0.0 | +| i32/i64 | Number | 1 | v8.0.0 | +| f64 | Number | 1 | v8.0.0 | +| bool | Boolean | 1 | v8.0.0 | +| String/&'a str | String | 1 | v8.0.0 | +| Latin1String | String | 1 | v8.0.0 | latin1 | +| UTF16String | String | 1 | v8.0.0 | +| Object | Object | 1 | v8.0.0 | +| serde_json::Map | Object | 1 | v8.0.0 | serde-json | +| serde_json::Value | any | 1 | v8.0.0 | serde-json | +| Array | Array | 1 | v8.0.0 | +| Vec | Array | 1 | v8.0.0 | +| Buffer | Buffer | 1 | v8.0.0 | +| External | External | 1 | v8.0.0 | | +| Null | null | 1 | v8.0.0 | +| Undefined/() | undefined | 1 | v8.0.0 | +| Result<()> | Error | 1 | v8.0.0 | +| T: Fn(...) -> Result | Function | 1 | v8.0.0 | +| Async/Future | Promise | 4 | v10.6.0 | async | +| AsyncTask | Promise | 1 | v8.5.0 | +| JsGlobal | global | 1 | v8.0.0 | +| JsSymbol | Symbol | 1 | v8.0.0 | +| Int8Array/Uint8Array ... | TypedArray | 1 | v8.0.0 | +| JsFunction | threadsafe function | 4 | v10.6.0 | napi4 | +| BigInt | BigInt | 6 | v10.7.0 | napi6 | diff --git a/cli/package.json b/cli/package.json index e38e9ea8..86f6c50e 100644 --- a/cli/package.json +++ b/cli/package.json @@ -36,7 +36,7 @@ "@types/inquirer": "^8.1.3", "@types/js-yaml": "^4.0.5", "@types/lodash-es": "^4.17.5", - "chalk": "^5.0.0", + "chalk": "4", "clipanion": "^3.1.0", "debug": "^4.3.3", "fdir": "^5.1.0", diff --git a/crates/backend/src/codegen.rs b/crates/backend/src/codegen.rs index a5d47c82..66c7f6ba 100644 --- a/crates/backend/src/codegen.rs +++ b/crates/backend/src/codegen.rs @@ -5,7 +5,6 @@ use crate::BindgenResult; mod r#const; mod r#enum; mod r#fn; -mod js_mod; mod r#struct; pub trait TryToTokens { diff --git a/crates/backend/src/codegen/js_mod.rs b/crates/backend/src/codegen/js_mod.rs deleted file mode 100644 index b215993d..00000000 --- a/crates/backend/src/codegen/js_mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -use proc_macro2::TokenStream; - -use crate::{NapiMod, TryToTokens}; - -impl TryToTokens for NapiMod { - fn try_to_tokens(&self, _tokens: &mut TokenStream) -> crate::BindgenResult<()> { - Ok(()) - } -} diff --git a/crates/backend/src/lib.rs b/crates/backend/src/lib.rs index 9e8c10c3..ad779c8d 100644 --- a/crates/backend/src/lib.rs +++ b/crates/backend/src/lib.rs @@ -53,5 +53,4 @@ napi_ast_impl! { (Impl, NapiImpl), (Enum, NapiEnum), (Const, NapiConst), - (Mod, NapiMod), } diff --git a/crates/backend/src/typegen.rs b/crates/backend/src/typegen.rs index 4c005fb1..2b86c926 100644 --- a/crates/backend/src/typegen.rs +++ b/crates/backend/src/typegen.rs @@ -1,7 +1,6 @@ mod r#const; mod r#enum; mod r#fn; -mod js_mod; pub(crate) mod r#struct; use std::collections::HashMap; @@ -121,6 +120,17 @@ static KNOWN_TYPES: Lazy> = Lazy::new(|| { ("Map", "Record"), ("HashMap", "Record<{}, {}>"), ("ArrayBuffer", "ArrayBuffer"), + ("Int8Array", "Int8Array"), + ("Uint8Array", "Uint8Array"), + ("Uint8ClampedArray", "Uint8ClampedArray"), + ("Int16Array", "Int16Array"), + ("Uint16Array", "Uint16Array"), + ("Int32Array", "Int32Array"), + ("Uint32Array", "Uint32Array"), + ("Float32Array", "Float32Array"), + ("Float64Array", "Float64Array"), + ("BigInt64Array", "BigInt64Array"), + ("BigUint64Array", "BigUint64Array"), ("DataView", "DataView"), ("Date", "Date"), ("JsBuffer", "Buffer"), diff --git a/crates/backend/src/typegen/js_mod.rs b/crates/backend/src/typegen/js_mod.rs deleted file mode 100644 index 01f7c8c5..00000000 --- a/crates/backend/src/typegen/js_mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -use crate::{NapiMod, ToTypeDef, TypeDef}; - -impl ToTypeDef for NapiMod { - fn to_type_def(&self) -> TypeDef { - TypeDef { - kind: "mod".to_owned(), - name: self.js_name.clone(), - def: "".to_owned(), - js_mod: None, - js_doc: "".to_owned(), - } - } -} diff --git a/crates/napi/src/bindgen_runtime/js_values.rs b/crates/napi/src/bindgen_runtime/js_values.rs index 8c6c0612..48210374 100644 --- a/crates/napi/src/bindgen_runtime/js_values.rs +++ b/crates/napi/src/bindgen_runtime/js_values.rs @@ -3,6 +3,7 @@ use std::ptr; use crate::{check_status, sys, Error, JsUnknown, NapiRaw, NapiValue, Result, Status, ValueType}; mod array; +mod arraybuffer; #[cfg(feature = "napi6")] mod bigint; mod boolean; @@ -23,6 +24,7 @@ mod symbol; mod task; pub use array::*; +pub use arraybuffer::*; #[cfg(feature = "napi6")] pub use bigint::*; pub use buffer::*; diff --git a/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs b/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs new file mode 100644 index 00000000..dc510e61 --- /dev/null +++ b/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs @@ -0,0 +1,228 @@ +use std::ffi::c_void; +use std::mem; +use std::ops::{Deref, DerefMut}; +use std::ptr; + +pub use crate::js_values::TypedArrayType; +use crate::{check_status, sys, Error, Result, Status}; + +use super::{FromNapiValue, ToNapiValue, TypeName}; + +macro_rules! impl_typed_array { + ($name:ident, $rust_type:ident, $typed_array_type:expr) => { + pub struct $name { + data: *mut $rust_type, + length: usize, + data_managed_type: DataManagedType, + byte_offset: usize, + finalizer_notify: Box, + } + + impl $name { + fn noop_finalize(_data: *mut $rust_type, _length: usize) {} + + pub fn new(mut data: Vec<$rust_type>) -> Self { + let ret = $name { + data: data.as_mut_ptr(), + length: data.len(), + data_managed_type: DataManagedType::Owned, + byte_offset: 0, + finalizer_notify: Box::new(Self::noop_finalize), + }; + mem::forget(data); + ret + } + + pub fn with_data_copied(data: D) -> Self + where + D: AsRef<[$rust_type]>, + { + let mut data_copied = data.as_ref().to_vec(); + let ret = $name { + data: data_copied.as_mut_ptr(), + length: data.as_ref().len(), + data_managed_type: DataManagedType::Owned, + finalizer_notify: Box::new(Self::noop_finalize), + byte_offset: 0, + }; + mem::forget(data_copied); + ret + } + + /// # Safety + /// + /// The caller will be notified when the data is deallocated by vm + pub unsafe fn with_external_data(data: *mut $rust_type, length: usize, notify: F) -> Self + where + F: 'static + FnOnce(*mut $rust_type, usize), + { + $name { + data, + length, + data_managed_type: DataManagedType::External, + finalizer_notify: Box::new(notify), + byte_offset: 0, + } + } + } + + impl Deref for $name { + type Target = [$rust_type]; + + fn deref(&self) -> &Self::Target { + unsafe { std::slice::from_raw_parts(self.data, self.length) } + } + } + + impl DerefMut for $name { + fn deref_mut(&mut self) -> &mut Self::Target { + unsafe { std::slice::from_raw_parts_mut(self.data, self.length) } + } + } + + impl AsRef<[$rust_type]> for $name { + fn as_ref(&self) -> &[$rust_type] { + unsafe { std::slice::from_raw_parts(self.data, self.length) } + .split_at(self.byte_offset) + .1 + } + } + + impl AsMut<[$rust_type]> for $name { + fn as_mut(&mut self) -> &mut [$rust_type] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.length) } + .split_at_mut(self.byte_offset) + .1 + } + } + + impl TypeName for $name { + fn type_name() -> &'static str { + "TypedArray" + } + + fn value_type() -> crate::ValueType { + crate::ValueType::Object + } + } + + impl FromNapiValue for $name { + unsafe fn from_napi_value( + env: napi_sys::napi_env, + napi_val: napi_sys::napi_value, + ) -> Result { + let mut typed_array_type = 0; + let mut length = 0; + let mut data = ptr::null_mut(); + let mut array_buffer = ptr::null_mut(); + let mut byte_offset = 0; + check_status!( + sys::napi_get_typedarray_info( + env, + napi_val, + &mut typed_array_type, + &mut length, + &mut data, + &mut array_buffer, + &mut byte_offset + ), + "Get TypedArray info failed" + )?; + if typed_array_type != $typed_array_type as i32 { + return Err(Error::new( + Status::InvalidArg, + format!("Expected $name, got {}", typed_array_type), + )); + } + Ok($name { + data: data as *mut $rust_type, + length, + byte_offset, + data_managed_type: DataManagedType::Vm, + finalizer_notify: Box::new(Self::noop_finalize), + }) + } + } + + impl ToNapiValue for $name { + unsafe fn to_napi_value(env: sys::napi_env, val: Self) -> Result { + let mut arraybuffer_value = ptr::null_mut(); + let ratio = mem::size_of::<$rust_type>() / mem::size_of::(); + let length = val.length * ratio; + let hint_ptr = Box::into_raw(Box::new(( + val.data_managed_type, + val.length, + val.finalizer_notify, + ))); + check_status!( + sys::napi_create_external_arraybuffer( + env, + val.data as *mut c_void, + length, + Some(finalizer::<$rust_type>), + hint_ptr as *mut c_void, + &mut arraybuffer_value + ), + "Create external arraybuffer failed" + )?; + let mut napi_val = ptr::null_mut(); + check_status!( + sys::napi_create_typedarray( + env, + $typed_array_type as i32, + val.length, + arraybuffer_value, + 0, + &mut napi_val, + ), + "Create TypedArray failed" + )?; + Ok(napi_val) + } + } + }; +} + +unsafe extern "C" fn finalizer( + _env: sys::napi_env, + finalize_data: *mut c_void, + finalize_hint: *mut c_void, +) { + let (data_managed_type, length, finalizer_notify) = + *Box::from_raw(finalize_hint as *mut (DataManagedType, usize, Box)); + match data_managed_type { + DataManagedType::Vm => { + // do nothing + } + DataManagedType::Owned => { + let length = length; + Vec::from_raw_parts(finalize_data as *mut T, length, length); + } + DataManagedType::External => { + (finalizer_notify)(finalize_data as *mut T, length); + } + } +} + +enum DataManagedType { + /// Vm managed data, passed in from JavaScript + Vm, + /// Rust owned data, which need to be deallocated in the finalizer + Owned, + /// External data, which need to be notice to the owner in finalizer + External, +} + +impl_typed_array!(Int8Array, i8, TypedArrayType::Int8); +impl_typed_array!(Uint8Array, u8, TypedArrayType::Uint8); +impl_typed_array!(Uint8ClampedArray, u8, TypedArrayType::Uint8Clamped); +impl_typed_array!(Int16Array, i16, TypedArrayType::Int16); +impl_typed_array!(Uint16Array, u16, TypedArrayType::Uint16); +impl_typed_array!(Int32Array, i32, TypedArrayType::Int32); +impl_typed_array!(Uint32Array, u32, TypedArrayType::Uint32); +impl_typed_array!(Float32Array, f32, TypedArrayType::Float32); +impl_typed_array!(Float64Array, f64, TypedArrayType::Float64); +#[cfg(feature = "napi6")] +impl_typed_array!(BigInt64Array, i64, TypedArrayType::BigInt64); +#[cfg(feature = "napi6")] +impl_typed_array!(BigUint64Array, u64, TypedArrayType::BigUint64); diff --git a/crates/napi/src/js_values/arraybuffer.rs b/crates/napi/src/js_values/arraybuffer.rs index 7e4ab9d5..76c654fd 100644 --- a/crates/napi/src/js_values/arraybuffer.rs +++ b/crates/napi/src/js_values/arraybuffer.rs @@ -39,8 +39,8 @@ impl TypeName for JsTypedArray { pub struct JsTypedArrayValue { pub arraybuffer: JsArrayBuffer, data: *mut c_void, - pub byte_offset: u64, - pub length: u64, + pub byte_offset: usize, + pub length: usize, pub typedarray_type: TypedArrayType, } @@ -234,19 +234,19 @@ impl JsTypedArray { /// ***Warning***: Use caution while using this API since the underlying data buffer is managed by the VM. pub fn into_value(self) -> Result { let mut typedarray_type = 0; - let mut len = 0u64; + let mut len = 0; let mut data = ptr::null_mut(); let mut arraybuffer_value = ptr::null_mut(); - let mut byte_offset = 0u64; + let mut byte_offset = 0; check_status!(unsafe { sys::napi_get_typedarray_info( self.0.env, self.0.value, &mut typedarray_type, - &mut len as *mut u64 as *mut _, + &mut len, &mut data, &mut arraybuffer_value, - &mut byte_offset as *mut u64 as *mut usize, + &mut byte_offset, ) })?; @@ -260,34 +260,51 @@ impl JsTypedArray { } } +impl JsTypedArrayValue { + #[inline] + fn is_valid_as_ref(&self, dest_type: TypedArrayType) { + if self.typedarray_type == TypedArrayType::Uint8Clamped && dest_type != TypedArrayType::Uint8 { + return; + } + if self.typedarray_type != dest_type { + panic!( + "invalid typedarray type: expected {:?}, got {:?}", + dest_type, self.typedarray_type + ); + } + } +} + macro_rules! impl_as_ref { - ($ref_type:ident) => { + ($ref_type:ident, $expect_type:expr) => { impl AsRef<[$ref_type]> for JsTypedArrayValue { fn as_ref(&self) -> &[$ref_type] { - unsafe { slice::from_raw_parts(self.data as *const $ref_type, self.length as usize) } + self.is_valid_as_ref($expect_type); + unsafe { slice::from_raw_parts(self.data as *const $ref_type, self.length) } } } impl AsMut<[$ref_type]> for JsTypedArrayValue { fn as_mut(&mut self) -> &mut [$ref_type] { - unsafe { slice::from_raw_parts_mut(self.data as *mut $ref_type, self.length as usize) } + self.is_valid_as_ref($expect_type); + unsafe { slice::from_raw_parts_mut(self.data as *mut $ref_type, self.length) } } } }; } -impl_as_ref!(u8); -impl_as_ref!(i8); -impl_as_ref!(u16); -impl_as_ref!(i16); -impl_as_ref!(u32); -impl_as_ref!(i32); -impl_as_ref!(f32); -impl_as_ref!(f64); +impl_as_ref!(u8, TypedArrayType::Uint8); +impl_as_ref!(i8, TypedArrayType::Int8); +impl_as_ref!(u16, TypedArrayType::Uint16); +impl_as_ref!(i16, TypedArrayType::Int16); +impl_as_ref!(u32, TypedArrayType::Uint32); +impl_as_ref!(i32, TypedArrayType::Int32); +impl_as_ref!(f32, TypedArrayType::Float32); +impl_as_ref!(f64, TypedArrayType::Float64); #[cfg(feature = "napi6")] -impl_as_ref!(i64); +impl_as_ref!(i64, TypedArrayType::BigInt64); #[cfg(feature = "napi6")] -impl_as_ref!(u64); +impl_as_ref!(u64, TypedArrayType::BigUint64); impl JsDataView { pub fn into_value(self) -> Result { diff --git a/examples/napi/__test__/typegen.spec.ts.md b/examples/napi/__test__/typegen.spec.ts.md index fe909b6d..a098885d 100644 --- a/examples/napi/__test__/typegen.spec.ts.md +++ b/examples/napi/__test__/typegen.spec.ts.md @@ -96,6 +96,9 @@ Generated by [AVA](https://avajs.dev). export function threadsafeFunctionThrowError(cb: (...args: any[]) => any): void␊ export function threadsafeFunctionFatalMode(cb: (...args: any[]) => any): void␊ export function getBuffer(): Buffer␊ + export function convertU32Array(input: Uint32Array): Array␊ + export function createExternalTypedArray(): Uint32Array␊ + export function mutateTypedArray(input: Float32Array): void␊ /**␊ * \`constructor\` option for \`struct\` requires all fields to be public,␊ * otherwise tag impl fn as constructor␊ diff --git a/examples/napi/__test__/typegen.spec.ts.snap b/examples/napi/__test__/typegen.spec.ts.snap index f8409d6b4631780212cb599d10d4d9025570c98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ec.ts b/examples/napi/__test__/values.spec.ts index 01c83b59..570fbd3c 100644 --- a/examples/napi/__test__/values.spec.ts +++ b/examples/napi/__test__/values.spec.ts @@ -56,6 +56,9 @@ import { xxh3, xxh64Alias, tsRename, + convertU32Array, + createExternalTypedArray, + mutateTypedArray, } from '../' test('export const', (t) => { @@ -213,6 +216,21 @@ test('buffer', (t) => { t.is(getBuffer().toString('utf-8'), 'Hello world') }) +test('convert typedarray to vec', (t) => { + const input = new Uint32Array([1, 2, 3, 4, 5]) + t.deepEqual(convertU32Array(input), Array.from(input)) +}) + +test('create external TypedArray', (t) => { + t.deepEqual(createExternalTypedArray(), new Uint32Array([1, 2, 3, 4, 5])) +}) + +test('mutate TypedArray', (t) => { + const input = new Float32Array([1, 2, 3, 4, 5]) + mutateTypedArray(input) + t.deepEqual(input, new Float32Array([2.0, 4.0, 6.0, 8.0, 10.0])) +}) + test('async', async (t) => { const bufPromise = readFileAsync(join(__dirname, '../package.json')) await t.notThrowsAsync(bufPromise) diff --git a/examples/napi/__test__/values.spec.ts.md b/examples/napi/__test__/values.spec.ts.md index b15aef2e..0def165f 100644 --- a/examples/napi/__test__/values.spec.ts.md +++ b/examples/napi/__test__/values.spec.ts.md @@ -23,6 +23,7 @@ Generated by [AVA](https://avajs.dev). 'ava', 'benny', 'c8', + 'chalk', 'cross-env', 'esbuild', 'eslint', diff --git a/examples/napi/__test__/values.spec.ts.snap b/examples/napi/__test__/values.spec.ts.snap index 5ba1eaf1f69603f1fa42b448e8a9f131a16486e4..f5678bc022b544b559a2a65cf3a125e83ea7edba 100644 GIT binary patch literal 586 zcmV-Q0=4}?RzVTy^94svnC800000000AR zlCf_SF%-t_TrWw}K$<3PX-jE}gqW;|1u+)!A0V-@I2Uud#<4B?E+PydA@L8e00RSK zB_;+2=86>wBs#INGNJCgHEHWd47I9LI@?JllNa=+&%sFc=OHA-v{6S zQZoO2SRo`JwZ%KF)0-dR`3X2%2!z}M9sxD3}#a z%c;Qd3Wm2zVJnQ}kT5S zsO5Q9(e34KWD}D@X_=_BpFddMG=9;*FLwU(h2ho-i_tZV27JmS-3RzV0%tgz#oeU00000000AR zlD}`$KorOC?B++)K$<2^DFvE}h2@kDA*S*VAS70ni*q;*=eyIL9W@NFF)|@BAa=Si zB4&hGky?p?nTZXtBEd`TcWEswePrwV{rc&>yEi0+P%=G!`{nuV&tD&Hzy9`P|Kv9% z%jd-!At7m;ebXjAcn9zIz$x$tIDpuFU=F+jJ^-h{FW_bX9uNUfftSEB@Co=11R)`} zfCoSfJOkbUAAu9#C-4^-Ko56;hrkTz(R!EG?pezhl;T&X(;>7)=#bDhBm&Z>A)&P{ z?H^h#Wo|}B=5eAJmkD=eh*C`LR8o;nQ>|t`7+|nh3C^5W7z#18R|zRS5zGpwHR z4a0*<*a{9Tz3cCyoGQ}laS}6QMV2M2p11r`U6`IFsnOO~ z>s70jscN;pA9k9%Cw|y%FH2#SKbnER$FrI) any): void export function threadsafeFunctionThrowError(cb: (...args: any[]) => any): void export function threadsafeFunctionFatalMode(cb: (...args: any[]) => any): void export function getBuffer(): Buffer +export function convertU32Array(input: Uint32Array): Array +export function createExternalTypedArray(): Uint32Array +export function mutateTypedArray(input: Float32Array): void /** * `constructor` option for `struct` requires all fields to be public, * otherwise tag impl fn as constructor diff --git a/examples/napi/src/typed_array.rs b/examples/napi/src/typed_array.rs index 8804c141..5d85194b 100644 --- a/examples/napi/src/typed_array.rs +++ b/examples/napi/src/typed_array.rs @@ -4,3 +4,20 @@ use napi::bindgen_prelude::*; fn get_buffer() -> Buffer { String::from("Hello world").as_bytes().into() } + +#[napi] +fn convert_u32_array(input: Uint32Array) -> Vec { + input.to_vec() +} + +#[napi] +fn create_external_typed_array() -> Uint32Array { + Uint32Array::new(vec![1, 2, 3, 4, 5]) +} + +#[napi] +fn mutate_typed_array(mut input: Float32Array) { + for item in input.as_mut() { + *item *= 2.0; + } +} diff --git a/memory-testing/package.json b/memory-testing/package.json index 20e804ac..3c4fe6bc 100644 --- a/memory-testing/package.json +++ b/memory-testing/package.json @@ -6,7 +6,7 @@ "build": "node ../cli/scripts/index.js build --release" }, "dependencies": { - "chalk": "^5.0.0", + "chalk": "4", "dockerode": "^3.3.1", "pretty-bytes": "^5.6.0", "table": "^6.7.3" diff --git a/package.json b/package.json index 6fa81caf..4a264373 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,11 @@ "version": "0.0.0", "description": "A minimal library for building compiled Node add-ons in Rust.", "private": "true", - "workspaces": ["cli", "triples", "memory-testing"], + "workspaces": [ + "cli", + "triples", + "memory-testing" + ], "repository": { "type": "git", "url": "git@github.com:Brooooooklyn/napi-rs.git" @@ -44,10 +48,18 @@ "arrowParens": "always" }, "lint-staged": { - "*.js": ["prettier --write"], - "*.@(yml|yaml)": ["prettier --parser yaml --write"], - "*.json": ["prettier --parser json --write"], - "*.md": ["prettier --parser markdown --write"] + "*.js": [ + "prettier --write" + ], + "*.@(yml|yaml)": [ + "prettier --parser yaml --write" + ], + "*.json": [ + "prettier --parser json --write" + ], + "*.md": [ + "prettier --parser markdown --write" + ] }, "husky": { "hooks": { @@ -62,15 +74,16 @@ "@rollup/plugin-replace": "^3.0.0", "@types/debug": "^4.1.7", "@types/lodash-es": "^4.17.5", - "@types/node": "^16.11.10", + "@types/node": "^16.11.11", "@types/sinon": "^10.0.6", "@typescript-eslint/eslint-plugin": "^5.5.0", "@typescript-eslint/parser": "^5.5.0", "ava": "^3.15.0", "benny": "^3.7.1", "c8": "^7.10.0", + "chalk": "4", "cross-env": "^7.0.3", - "esbuild": "^0.14.0", + "esbuild": "^0.14.1", "eslint": "^8.3.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-import": "^2.25.3", @@ -80,7 +93,7 @@ "lint-staged": "^12.1.2", "npm-run-all": "^4.1.5", "prettier": "^2.5.0", - "rollup": "^2.60.1", + "rollup": "^2.60.2", "shx": "^0.3.3", "sinon": "^12.0.1", "source-map-support": "^0.5.21", diff --git a/yarn.lock b/yarn.lock index 39bf58d5..53b8de3e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1204,10 +1204,10 @@ resolved "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz#31b7ca6407128a3d2bbc27fe2d21b345397f6197" integrity sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA== -"@types/node@*", "@types/node@^16.11.10": - version "16.11.10" - resolved "https://registry.npmjs.org/@types/node/-/node-16.11.10.tgz#2e3ad0a680d96367103d3e670d41c2fed3da61ae" - integrity sha512-3aRnHa1KlOEEhJ6+CvyHKK5vE9BcLGjtUpwvqYLRvYNQKMfabu3BwfJaA/SLW8dxe28LsNDjtHwePTuzn3gmOA== +"@types/node@*", "@types/node@^16.11.11": + version "16.11.11" + resolved "https://registry.npmjs.org/@types/node/-/node-16.11.11.tgz#6ea7342dfb379ea1210835bada87b3c512120234" + integrity sha512-KB0sixD67CeecHC33MYn+eYARkqTheIRNuu97y2XMjR7Wu3XibO1vaY6VBV6O/a89SPI81cEUIYT87UqUWlZNw== "@types/normalize-package-data@^2.4.0": version "2.4.1" @@ -1241,9 +1241,9 @@ "@types/node" "*" "@types/ssh2@*": - version "0.5.48" - resolved "https://registry.npmjs.org/@types/ssh2/-/ssh2-0.5.48.tgz#0d9e8654a76eaaf4cfeaeb88d74c4489cfcf7aea" - integrity sha512-cmQu0gp/6RtDXe1r2xXGgi0V0TeCdueDSRMEvBX8cTRT/sSREkUpgCYZLyh+iI8Ql+VNV8Az9toQoYa/IdgHbQ== + version "0.5.49" + resolved "https://registry.npmjs.org/@types/ssh2/-/ssh2-0.5.49.tgz#40014f780e3b7e6e667503df414fc884089c76e4" + integrity sha512-ffxhQhJqgTzrw8NxHTgkaDtAmAj2qxCyoves7ztpRgqvzbHcZTpTcm+ATWuuCbPQzxnnF4F3SGGTLGEWTZpwqA== dependencies: "@types/node" "*" "@types/ssh2-streams" "*" @@ -1880,6 +1880,14 @@ caseless@~0.12.0: resolved "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= +chalk@4, chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1: + version "4.1.2" + resolved "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + chalk@^2.0.0, chalk@^2.4.1: version "2.4.2" resolved "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" @@ -1889,19 +1897,6 @@ chalk@^2.0.0, chalk@^2.4.1: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1: - version "4.1.2" - resolved "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chalk@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/chalk/-/chalk-5.0.0.tgz#bd96c6bb8e02b96e08c0c3ee2a9d90e050c7b832" - integrity sha512-/duVOqst+luxCQRKEo4bNxinsOQtMP80ZYm7mMqzuh5PociNL0PvmHFvREJ9ueYL2TxlHjBcmLCdmocx9Vg+IQ== - chardet@^0.7.0: version "0.7.0" resolved "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" @@ -2693,113 +2688,113 @@ es-to-primitive@^1.2.1: is-date-object "^1.0.1" is-symbol "^1.0.2" -esbuild-android-arm64@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.14.0.tgz#fac7e9a207714a699283578e1c8106689e52fad9" - integrity sha512-X7BjFiRRNfxPNg1aT5zw4xK1vbvX2IvDPcEp4bv0CEXgR39UzuOMUsQoG92aZgj8JGs8jxQAZc8k9dVJ1WL2BA== +esbuild-android-arm64@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.14.1.tgz#470b99c1c4b49f33fd0a20ed153b15008173fd63" + integrity sha512-elQd3hTg93nU2GQ5PPCDAFe5+utxZX96RG8RixqIPxf8pzmyIzcpKG76L/9FabPf3LT1z+nLF1sajCU8eVRDyg== -esbuild-darwin-64@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.0.tgz#83bde8f68dd26ec4cbbbe4fd966eb1f4ce40a9d8" - integrity sha512-43vtt407jMp1kEXiaY0dEIGjOREax9F1+qMI0+F9tJyr06EHAofnbLL6cTmLgdPy/pMhltSvOJ8EddJrrOBgpQ== +esbuild-darwin-64@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.1.tgz#135f48f299f2ce3eb3ca1b1f3ec03d81108ab79e" + integrity sha512-PR3HZgbPRwsQbbOR1fJrfkt/Cs0JDyI3yzOKg2PPWk0H1AseZDBqPUY9b/0+BIjFwA5Jz/aAiq832hppsuJtNw== -esbuild-darwin-arm64@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.0.tgz#644efb31fb27e291465e24757b3194d36aa2eb7d" - integrity sha512-hMbT5YiBrFL763mnwR9BqNtq9XtJgJRxYs7Ad++KUd+ZhMoVE0Rs/YLe1oor9uBGhHLqQsZuJ2dUHjCsfT/iDg== +esbuild-darwin-arm64@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.1.tgz#7117a857bac99ece28ebba859a47dce47f565f9f" + integrity sha512-/fiSSOkOEa3co6yYtwgXouz8jZrG0qnXPEKiktFf2BQE8NON3ARTw43ZegaH+xMRFNgYBJEOOZIdzI3sIFEAxw== -esbuild-freebsd-64@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.0.tgz#c74755b5f8a8a9a2acf19d49236ac7c18c548f71" - integrity sha512-mx68HRYIZo6ZiHbWk5Md+mDJoDw779yWkJQAaBnXwOkGbDeA3JmPZjp6IPfy2P+n3emK9z6g4pKiebp1tQGVoQ== +esbuild-freebsd-64@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.1.tgz#2b7ca5ec572f2800b1ec88988affc4482c5ac4b7" + integrity sha512-ZJV+nfa8E8PdXnRc05PO3YMfgSj7Ko+kdHyGDE6OaNo1cO8ZyfacqLaWkY35shDDaeacklhD8ZR4qq5nbJKX1A== -esbuild-freebsd-arm64@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.0.tgz#b778a66b4fc6a0d0b91e2e2333620658724b45ef" - integrity sha512-iM8u+zTagh0WGn2FTTxi7DII/ycVzYyuf2Df6eP2ZX+vlx2FjaduhagRkpyhjfmEyhfJOrYSAR5R1biNPcA+VA== +esbuild-freebsd-arm64@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.1.tgz#63e8b77643ea8270d878cfab7dd9201a114f20fb" + integrity sha512-6N9zTD+SecJr2g9Ohl9C10WIk5FpQ+52bNamRy0sJoHwP31G5ObzKzq8jAtg1Jeggpu6P8auz3P/UL+3YioSwQ== -esbuild-linux-32@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.14.0.tgz#64bfaa635a8f4d6f2fea62cc8c2466f5a926b221" - integrity sha512-dWHotI2qlXWZyza7n85UubBj0asjpM7FTtQYDaRQKxoCJpCnSzq3aD55IJthiggZHXj2tAML9Bc5xjVLsBJR0w== +esbuild-linux-32@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.14.1.tgz#f00ae7f12d2abc0dc37e2a7e7c7c29764da87093" + integrity sha512-RtPgE6e7WefbAxRjVryisKFJ0nUwR2DMjwmYW/a1a0F1+Ge6FR+RqvgiY0DrM9TtxSUU0eryDXNF4n3UfxX3mg== -esbuild-linux-64@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.0.tgz#0e2714bd90cfc4afffcfee896d67763a03410d61" - integrity sha512-7buo31kp1/yKWPm9vU44FEUwkeIROrIgnCDV9KLMLSbOjGEHBZXYJ2L0p4ZnB7Z+m5YiW7F/AfJu0/1E87nOeQ== +esbuild-linux-64@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.1.tgz#2ee9dd76be1185abb1e967052e3b6ab16a1d3da4" + integrity sha512-JpxM0ar6Z+2v3vfFrxP7bFb8Wzb6gcGL9MxRqAJplDfGnee8HbfPge6svaazXeX9XJceeEqwxwWGB0qyCcxo7A== -esbuild-linux-arm64@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.0.tgz#008ddc7c37e9bfc0cc8902310a728f8b8bfdf002" - integrity sha512-9LBtCH2RkhDBwoAYksTtXljN6hlxxoL6a3ymNfXJG9JxFUQddOfhajXZdObFn/hgGkAFwx8dXqw+FnPm0FCzSg== +esbuild-linux-arm64@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.1.tgz#601e855b78e0636e120771296b43eb4f7d68a314" + integrity sha512-cFbeZf171bIf+PPLlQDBzagK85lCCxxVdMV1IVUA96Y3kvEgqcy2n9mha+QE1M/T+lIOPDsmLRgH1XqMFwLTSg== -esbuild-linux-arm@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.14.0.tgz#f8e3f91797eb291e7f8c1c867826e408804ece75" - integrity sha512-fgybXQwPRT4Io01+aD+yphcLOLRVGqbSdhvaDK3qBwqUvspFsq4QkI7PeeYpuQdBZWiRKLoi9v5r90l7JO/s+g== +esbuild-linux-arm@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.14.1.tgz#c0d364a20f12a653bdd2f41436788b99502dc287" + integrity sha512-eBRHexCijAYWzcvQLGHxyxIlYOkYhXvcb/O7HvzJfCAVWCnTx9TxxYJ3UppBC6dDFbAq4HwKhskvmesQdKMeBg== -esbuild-linux-mips64le@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.0.tgz#e2e3a2f3b4adf3ec64bcc43e21dd19105ff5ccab" - integrity sha512-Xz7soOqWeCWcLp15biPM08To+s0k1E/2q0pQZNQ+SY9S5H2vU4ujDXqKjxFc24G9CrOeUNEOXTkh+JldBGbTCA== +esbuild-linux-mips64le@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.1.tgz#a5f6e9c6e7950a3fad08bb3653bc3f5d71b4e249" + integrity sha512-UGb+sqHkL7wOQFLH0RoFhcRAlJNqbqs6GtJd1It5jJ2juOGqAkCv8V12aGDX9oRB6a+Om7cdHcH+6AMZ+qlaww== -esbuild-linux-ppc64le@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.0.tgz#8a13f6e5257e19b62e7c28762f3cc742d56f3e1c" - integrity sha512-fuBXTyUaZKxpmp43Nf0M1uI1OmZv/COcME9PG7NQ/EniwC680Xj5xQFhEBDVnvQQ+6xOnXdfPSojJq7gQxrORQ== +esbuild-linux-ppc64le@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.1.tgz#762cec24cf5afeee3f805a4679a3f5e29702173a" + integrity sha512-LIHGkGdy9wYlmkkoVHm6feWhkoi4VBXDiEVyNjXEhlzsBcP/CaRy+B8IJulzaU1ALLiGcsCQ2MC5UbFn/iTvmA== -esbuild-netbsd-64@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.0.tgz#e76051ea739efa5be7a5979f212882c8d9e1b7db" - integrity sha512-pQaECTKr/iCXtn1qjwih+cvoZzbZ+P3NwLQo4uo/IesklbPTR5eF4d85L1vPFVgff+itBMxbbB7aoRznSglN3A== +esbuild-netbsd-64@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.1.tgz#66ec7ac0b3eeb84f8c1ac27eecf16f59d93706a8" + integrity sha512-TWc1QIgtPwaK5nC1GT2ASTuy/CJhNKHN4h5PJRP1186VfI+k2uvXakS7bqO/M26F6jAMy8jDeCtilacqpwsvfA== -esbuild-openbsd-64@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.0.tgz#2d8c0689731605c68da816ac40095a1685c12e11" - integrity sha512-HiaqQX9HMb9u3eYvKZ86+m/paQwASJSIjXiRTFpFusypjtU2NJqWb/LiRvhfmwC6rb7YHwCSPx+juSM7M+20bA== +esbuild-openbsd-64@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.1.tgz#7515049bc7032ca2fb6811dc260f5ec9e1d9fe65" + integrity sha512-Z9/Zb77K+pK9s7mAsvwS56K8tCbLvNZ9UI4QVJSYqDgOmmDJOBT4owWnCqZ5cJI+2y4/F9KwCpFFTNUdPglPKA== -esbuild-sunos-64@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.0.tgz#62b2a27cdc8d0ac150d4d15857e764652960d2b6" - integrity sha512-TkMQOSiSU3fHLV3M+OKUgLZt5L7TpcBcMRvtFw1cTxAnX8eT+1qkWVLiDM8ow1C3P7PW3bkGY3LW8vOs8o/jBA== +esbuild-sunos-64@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.1.tgz#795f6bc7ce8c5177afb65f8d6c161a02f0c3e125" + integrity sha512-c4sF8146kNW8529wfkB6vO0ZqPgokyS2hORqKa4p/QKZdp+xrF2NPmvX5aN+Zt14oe6wVZuhYo6LGv7V4Gg04g== -esbuild-windows-32@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.14.0.tgz#364a1d1558b0a2351997c1aa7fd4408428eb78ab" - integrity sha512-0h7E50JHgyLd7TkqSIH0VzBhngWspxPHuq/crDAMnh4s4tW8zWCMLIz2c1HVwHfZsh7d5+C4/yBaQeJTHXGvIA== +esbuild-windows-32@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.14.1.tgz#ffffa6378733eeaa23ed5cfe539e2fbe1e635ef6" + integrity sha512-XP8yElaJtLGGjH7D72t5IWtP0jmc1Jqm4IjQARB17l0LTJO/n+N2X64rDWePJv6qimYxa5p2vTjkZc5v+YZTSQ== -esbuild-windows-64@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.0.tgz#e0db336f5c614f1b8dfacc0720cb0d30e118b36d" - integrity sha512-RxnovPOoQS5Id4mbdIUm96L0GIg+ZME4FthbErw1kZZabLi9eLp1gR3vSwkZXKbK8Z76uDkSW0EN74i1XWVpiQ== +esbuild-windows-64@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.1.tgz#46f3b4a90f937a8ad6456cd70478ebfc6771814f" + integrity sha512-fe+ShdyfiuGcCEdVKW//6MaM4MwikiWBWSBn8mebNAbjRqicH0injDOFVI7aUovAfrEt7+FGkf402s//hi0BVg== -esbuild-windows-arm64@0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.0.tgz#5ddc6134e766da3c7b62a9a463e91ad3127483b5" - integrity sha512-66KsVlT6lGDWgDKQsAlojxgUhZkkjVeosMVRdb913OwtcOjszceg6zFD748jzp9CUgAseHCNJqFmYOyBzneSEQ== +esbuild-windows-arm64@0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.1.tgz#c7067389d28139e6a18db1996178c3a3e07a22b3" + integrity sha512-wBVakhcIzQ3NZ33DFM6TjIObXPHaXOsqzvPwefXHvwBSC/N/e/g6fBeM7N/Moj3AmxLjKaB+vePvTGdxk6RPCg== -esbuild@^0.14.0: - version "0.14.0" - resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.14.0.tgz#9a3d21c9876b280e3b0186e36d372354ade51938" - integrity sha512-UOnSKRAyZondxdLrOXnI/mesUmU/GvDTcajCvxoIaObzMeQcn0HyoGtvbfATnazlx799ZqFSyIZGLXFszkjy3A== +esbuild@^0.14.1: + version "0.14.1" + resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.14.1.tgz#b834da3aa5858073205a6d4f948ffde0d650e4e3" + integrity sha512-J/LhUwELcmz0+CJfiaKzu7Rnj9ffWFLvMx+dKvdOfg+fQmoP6q9glla26LCm9BxpnPUjXChHeubLiMlKab/PYg== optionalDependencies: - esbuild-android-arm64 "0.14.0" - esbuild-darwin-64 "0.14.0" - esbuild-darwin-arm64 "0.14.0" - esbuild-freebsd-64 "0.14.0" - esbuild-freebsd-arm64 "0.14.0" - esbuild-linux-32 "0.14.0" - esbuild-linux-64 "0.14.0" - esbuild-linux-arm "0.14.0" - esbuild-linux-arm64 "0.14.0" - esbuild-linux-mips64le "0.14.0" - esbuild-linux-ppc64le "0.14.0" - esbuild-netbsd-64 "0.14.0" - esbuild-openbsd-64 "0.14.0" - esbuild-sunos-64 "0.14.0" - esbuild-windows-32 "0.14.0" - esbuild-windows-64 "0.14.0" - esbuild-windows-arm64 "0.14.0" + esbuild-android-arm64 "0.14.1" + esbuild-darwin-64 "0.14.1" + esbuild-darwin-arm64 "0.14.1" + esbuild-freebsd-64 "0.14.1" + esbuild-freebsd-arm64 "0.14.1" + esbuild-linux-32 "0.14.1" + esbuild-linux-64 "0.14.1" + esbuild-linux-arm "0.14.1" + esbuild-linux-arm64 "0.14.1" + esbuild-linux-mips64le "0.14.1" + esbuild-linux-ppc64le "0.14.1" + esbuild-netbsd-64 "0.14.1" + esbuild-openbsd-64 "0.14.1" + esbuild-sunos-64 "0.14.1" + esbuild-windows-32 "0.14.1" + esbuild-windows-64 "0.14.1" + esbuild-windows-arm64 "0.14.1" escalade@^3.1.1: version "3.1.1" @@ -4044,9 +4039,9 @@ istanbul-lib-report@^3.0.0: supports-color "^7.1.0" istanbul-reports@^3.0.2: - version "3.0.5" - resolved "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.0.5.tgz#a2580107e71279ea6d661ddede929ffc6d693384" - integrity sha512-5+19PlhnGabNWB7kOFnuxT8H3T/iIyQzIbQMxXsURmmvKg86P2sbkrGOT77VnHw0Qr0gc2XzRaRfMZYYbSQCJQ== + version "3.1.0" + resolved "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.0.tgz#57a32bff7ab4b315e401daa08fe2934e0c0b1ec2" + integrity sha512-rgeP8yMlXeH4mfd9K/sQXZv1lvcS7xo379zntcotPDdMwkcGYwMxGHGZYo0/+YW5B/nor2YGKz2BH5ume405ow== dependencies: html-escaper "^2.0.0" istanbul-lib-report "^3.0.0" @@ -4106,10 +4101,10 @@ json-schema-traverse@^1.0.0: resolved "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== -json-schema@0.2.3: - version "0.2.3" - resolved "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" - integrity sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM= +json-schema@0.4.0: + version "0.4.0" + resolved "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz#f7de4cf6efab838ebaeb3236474cbba5a1930ab5" + integrity sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA== json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" @@ -4152,13 +4147,13 @@ jsonparse@^1.2.0, jsonparse@^1.3.1: integrity sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA= jsprim@^1.2.2: - version "1.4.1" - resolved "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" - integrity sha1-MT5mvB5cwG5Di8G3SZwuXFastqI= + version "1.4.2" + resolved "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz#712c65533a15c878ba59e9ed5f0e26d5b77c5feb" + integrity sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw== dependencies: assert-plus "1.0.0" extsprintf "1.3.0" - json-schema "0.2.3" + json-schema "0.4.0" verror "1.10.0" just-extend@^4.0.2: @@ -5879,10 +5874,10 @@ rimraf@^3.0.0, rimraf@^3.0.2: dependencies: glob "^7.1.3" -rollup@^2.60.1: - version "2.60.1" - resolved "https://registry.npmjs.org/rollup/-/rollup-2.60.1.tgz#4b34cd247f09b421f10a3c9286eda2ecf9972079" - integrity sha512-akwfnpjY0rXEDSn1UTVfKXJhPsEBu+imi1gqBA1ZkHGydUnkV/fWCC90P7rDaLEW8KTwBcS1G3N4893Ndz+jwg== +rollup@^2.60.2: + version "2.60.2" + resolved "https://registry.npmjs.org/rollup/-/rollup-2.60.2.tgz#3f45ace36a9b10b4297181831ea0719922513463" + integrity sha512-1Bgjpq61sPjgoZzuiDSGvbI1tD91giZABgjCQBKM5aYLnzjq52GoDuWVwT/cm/MCxCMPU8gqQvkj8doQ5C8Oqw== optionalDependencies: fsevents "~2.3.2" @@ -6405,9 +6400,9 @@ supports-color@^7.1.0, supports-color@^7.2.0: has-flag "^4.0.0" supports-color@^9.0.2: - version "9.1.0" - resolved "https://registry.npmjs.org/supports-color/-/supports-color-9.1.0.tgz#558963681dafeff41ed68220488cbf438d29f351" - integrity sha512-lOCGOTmBSN54zKAoPWhHkjoqVQ0MqgzPE5iirtoSixhr0ZieR/6l7WZ32V53cvy9+1qghFnIk7k52p991lKd6g== + version "9.2.1" + resolved "https://registry.npmjs.org/supports-color/-/supports-color-9.2.1.tgz#599dc9d45acf74c6176e0d880bab1d7d718fe891" + integrity sha512-Obv7ycoCTG51N7y175StI9BlAXrmgZrFhZOb0/PyjHBher/NmsdBgbbQ1Inhq+gIhz6+7Gb+jWF2Vqi7Mf1xnQ== table@^6.7.3: version "6.7.3" @@ -6722,9 +6717,9 @@ typescript@^4.5.2: integrity sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw== uglify-js@^3.1.4: - version "3.14.3" - resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.3.tgz#c0f25dfea1e8e5323eccf59610be08b6043c15cf" - integrity sha512-mic3aOdiq01DuSVx0TseaEzMIVqebMZ0Z3vaeDhFEh9bsc24hV1TFvN74reA2vs08D0ZWfNjAcJ3UbVLaBss+g== + version "3.14.4" + resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.4.tgz#68756f17d1b90b9d289341736cb9a567d6882f90" + integrity sha512-AbiSR44J0GoCeV81+oxcy/jDOElO2Bx3d0MfQCUShq7JRXaM4KtQopZsq2vFv8bCq2yMaGrw1FgygUd03RyRDA== uid-number@0.0.6: version "0.0.6"