node-addon-api 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +84 -0
- package/README.md +67 -47
- package/napi-inl.deprecated.h +8 -8
- package/napi-inl.h +118 -80
- package/napi.h +513 -424
- package/package.json +25 -5
- package/tools/clang-format.js +30 -10
- package/.clang-format +0 -111
- package/.editorconfig +0 -8
- package/.github/workflows/ci.yml +0 -55
- package/.github/workflows/linter.yml +0 -24
- package/.github/workflows/stale.yml +0 -18
- package/.travis.yml +0 -58
- package/CODE_OF_CONDUCT.md +0 -4
- package/CONTRIBUTING.md +0 -66
- package/appveyor.yml +0 -37
- package/benchmark/README.md +0 -47
- package/benchmark/binding.gyp +0 -25
- package/benchmark/function_args.cc +0 -217
- package/benchmark/function_args.js +0 -60
- package/benchmark/index.js +0 -34
- package/benchmark/property_descriptor.cc +0 -91
- package/benchmark/property_descriptor.js +0 -37
- package/doc/addon.md +0 -157
- package/doc/array.md +0 -81
- package/doc/array_buffer.md +0 -149
- package/doc/async_context.md +0 -86
- package/doc/async_operations.md +0 -31
- package/doc/async_worker.md +0 -427
- package/doc/async_worker_variants.md +0 -557
- package/doc/bigint.md +0 -97
- package/doc/boolean.md +0 -68
- package/doc/buffer.md +0 -144
- package/doc/callback_scope.md +0 -54
- package/doc/callbackinfo.md +0 -97
- package/doc/checker-tool.md +0 -32
- package/doc/class_property_descriptor.md +0 -117
- package/doc/cmake-js.md +0 -68
- package/doc/conversion-tool.md +0 -28
- package/doc/creating_a_release.md +0 -62
- package/doc/dataview.md +0 -248
- package/doc/date.md +0 -68
- package/doc/env.md +0 -132
- package/doc/error.md +0 -120
- package/doc/error_handling.md +0 -186
- package/doc/escapable_handle_scope.md +0 -82
- package/doc/external.md +0 -63
- package/doc/function.md +0 -402
- package/doc/function_reference.md +0 -238
- package/doc/generator.md +0 -13
- package/doc/handle_scope.md +0 -65
- package/doc/hierarchy.md +0 -91
- package/doc/instance_wrap.md +0 -408
- package/doc/memory_management.md +0 -27
- package/doc/name.md +0 -29
- package/doc/node-gyp.md +0 -82
- package/doc/number.md +0 -163
- package/doc/object.md +0 -279
- package/doc/object_lifetime_management.md +0 -83
- package/doc/object_reference.md +0 -117
- package/doc/object_wrap.md +0 -561
- package/doc/prebuild_tools.md +0 -16
- package/doc/promises.md +0 -79
- package/doc/property_descriptor.md +0 -286
- package/doc/range_error.md +0 -59
- package/doc/reference.md +0 -111
- package/doc/setup.md +0 -81
- package/doc/string.md +0 -93
- package/doc/symbol.md +0 -48
- package/doc/threadsafe.md +0 -121
- package/doc/threadsafe_function.md +0 -290
- package/doc/type_error.md +0 -59
- package/doc/typed_array.md +0 -78
- package/doc/typed_array_of.md +0 -137
- package/doc/typed_threadsafe_function.md +0 -307
- package/doc/value.md +0 -340
- package/doc/version_management.md +0 -43
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,89 @@
|
|
|
1
1
|
# node-addon-api Changelog
|
|
2
2
|
|
|
3
|
+
## 2021-05-17 Version 3.2.0, @NickNaso
|
|
4
|
+
|
|
5
|
+
### Notable changes:
|
|
6
|
+
|
|
7
|
+
#### API
|
|
8
|
+
|
|
9
|
+
- Remove unnecessary symbol exposure.
|
|
10
|
+
- Fixed leak in `Napi::ObjectWrap` instance for getter and setter method.
|
|
11
|
+
- Added `Napi::Object::Freeze` and `Napi::object::Seal` methods.
|
|
12
|
+
- `Napi::Reference` is now copyable.
|
|
13
|
+
|
|
14
|
+
#### Documentation
|
|
15
|
+
|
|
16
|
+
- Added docuemtnation for `Napi::Object::PropertyLValue`.
|
|
17
|
+
- Changed all N-API references to Node-API.
|
|
18
|
+
- Some minor corrections all over the documentation.
|
|
19
|
+
|
|
20
|
+
#### TEST
|
|
21
|
+
|
|
22
|
+
- Added tests relating to fetch property from Global Object.
|
|
23
|
+
- Added addtiona tests for `Napi::Object`.
|
|
24
|
+
- Added test for `Napi::Function` contructors.
|
|
25
|
+
- Fixed intermittent failure for `Napi::ThreadSafeFunction` test.
|
|
26
|
+
- Some minor corrections all over the test suite.
|
|
27
|
+
|
|
28
|
+
### TOOL
|
|
29
|
+
|
|
30
|
+
- Added Node.js v16.x to CI.
|
|
31
|
+
- Added CI configuration for Windows.
|
|
32
|
+
- Some fixex on linter command.
|
|
33
|
+
|
|
34
|
+
### Commits
|
|
35
|
+
|
|
36
|
+
* [[`52721312f6`](https://github.com/nodejs/node-addon-api/commit/52721312f6)] - **docs**: add napi-rs iin Other Bindings section (#999) (LongYinan)
|
|
37
|
+
* [[`78a6570a42`](https://github.com/nodejs/node-addon-api/commit/78a6570a42)] - **doc**: fix typo in code example (#997) (Tobias Nießen)
|
|
38
|
+
* [[`da3bd5778f`](https://github.com/nodejs/node-addon-api/commit/da3bd5778f)] - **test**: fix undoc assumptions about the timing of tsfn calls (legendecas) [#995](https://github.com/nodejs/node-addon-api/pull/995)
|
|
39
|
+
* [[`410cf6a81e`](https://github.com/nodejs/node-addon-api/commit/410cf6a81e)] - **src**: return bool on object freeze and seal (#991) (legendecas)
|
|
40
|
+
* [[`93f1898312`](https://github.com/nodejs/node-addon-api/commit/93f1898312)] - **src**: return bool on object set and define property (#977) (legendecas)
|
|
41
|
+
* [[`331c2ee274`](https://github.com/nodejs/node-addon-api/commit/331c2ee274)] - **build**: add Node.js v16.x to CI (#983) (legendecas)
|
|
42
|
+
* [[`b6f5eb15e6`](https://github.com/nodejs/node-addon-api/commit/b6f5eb15e6)] - **test**: run test suites with helpers (legendecas) [#976](https://github.com/nodejs/node-addon-api/pull/976)
|
|
43
|
+
* [[`fbcdf00ea0`](https://github.com/nodejs/node-addon-api/commit/fbcdf00ea0)] - **test**: rename misspelled parameters (Tobias Nießen) [#973](https://github.com/nodejs/node-addon-api/pull/973)
|
|
44
|
+
* [[`63a6c32e80`](https://github.com/nodejs/node-addon-api/commit/63a6c32e80)] - **test**: fix intermittent TSFN crashes (Kevin Eady) [#974](https://github.com/nodejs/node-addon-api/pull/974)
|
|
45
|
+
* [[`8f120b033f`](https://github.com/nodejs/node-addon-api/commit/8f120b033f)] - **fix**: key for wapping drawing's system condition (#970) (Kévin VOYER)
|
|
46
|
+
* [[`1c9d528d66`](https://github.com/nodejs/node-addon-api/commit/1c9d528d66)] - **doc**: correct struct definition (#969) (Darshan Sen)
|
|
47
|
+
* [[`5e64d1fa61`](https://github.com/nodejs/node-addon-api/commit/5e64d1fa61)] - Added badges for Node-API v7 and v8. (#954) (Nicola Del Gobbo)
|
|
48
|
+
* [[`6ce629b3fa`](https://github.com/nodejs/node-addon-api/commit/6ce629b3fa)] - **src**: add pull request template (#967) (Michael Dawson)
|
|
49
|
+
* [[`98126661af`](https://github.com/nodejs/node-addon-api/commit/98126661af)] - Update CONTRIBUTING.md (#966) (Michael Dawson)
|
|
50
|
+
* [[`77350eee98`](https://github.com/nodejs/node-addon-api/commit/77350eee98)] - **src**: added Freeze and Seal method to Object class. (NickNaso) [#955](https://github.com/nodejs/node-addon-api/pull/955)
|
|
51
|
+
* [[`bc5147cc4a`](https://github.com/nodejs/node-addon-api/commit/bc5147cc4a)] - Finished tests relating to fetch property from Global Object (JckXia)
|
|
52
|
+
* [[`0127813111`](https://github.com/nodejs/node-addon-api/commit/0127813111)] - **doc**: unambiguously mark deprecated signatures (Tobias Nießen) [#942](https://github.com/nodejs/node-addon-api/pull/942)
|
|
53
|
+
* [[`787e216105`](https://github.com/nodejs/node-addon-api/commit/787e216105)] - **doc**: rename N-API with Node-API (Darshan Sen) [#951](https://github.com/nodejs/node-addon-api/pull/951)
|
|
54
|
+
* [[`628023689a`](https://github.com/nodejs/node-addon-api/commit/628023689a)] - **src**: rename N-API with Node-API on comments (NickNaso) [#953](https://github.com/nodejs/node-addon-api/pull/953)
|
|
55
|
+
* [[`5c6391578f`](https://github.com/nodejs/node-addon-api/commit/5c6391578f)] - **build**: add CI configuration for Windows (NickNaso) [#948](https://github.com/nodejs/node-addon-api/pull/948)
|
|
56
|
+
* [[`8ef07251ec`](https://github.com/nodejs/node-addon-api/commit/8ef07251ec)] - **doc**: added some warnings for buffer and array buffer factory method. (#929) (Nicola Del Gobbo)
|
|
57
|
+
* [[`6490b1f730`](https://github.com/nodejs/node-addon-api/commit/6490b1f730)] - **doc**: sync Object::Set value arg with Value::From (#933) (Tobias Nießen)
|
|
58
|
+
* [[`7319a0d7a2`](https://github.com/nodejs/node-addon-api/commit/7319a0d7a2)] - Fix tab indent (#938) (Tobias Nießen)
|
|
59
|
+
* [[`1916cb937e`](https://github.com/nodejs/node-addon-api/commit/1916cb937e)] - **chore**: fixup linter commands (#940) (legendecas)
|
|
60
|
+
* [[`fc4585fa23`](https://github.com/nodejs/node-addon-api/commit/fc4585fa23)] - **test**: dd tests for Function constructors (JoseExposito) [#937](https://github.com/nodejs/node-addon-api/pull/937)
|
|
61
|
+
* [[`87b7aae469`](https://github.com/nodejs/node-addon-api/commit/87b7aae469)] - **doc**: warn about SuppressDestruct() (#926) (Anna Henningsen)
|
|
62
|
+
* [[`71494a49a3`](https://github.com/nodejs/node-addon-api/commit/71494a49a3)] - **src,doc**: refactor to replace typedefs with usings (Darshan Sen) [#910](https://github.com/nodejs/node-addon-api/pull/910)
|
|
63
|
+
* [[`298ff8d9d2`](https://github.com/nodejs/node-addon-api/commit/298ff8d9d2)] - **test**: add additional tests for Object (JoseExposito) [#923](https://github.com/nodejs/node-addon-api/pull/923)
|
|
64
|
+
* [[`8a1147b430`](https://github.com/nodejs/node-addon-api/commit/8a1147b430)] - **revert**: src: add additional tests for Function (Michael Dawson)
|
|
65
|
+
* [[`bb56ffaa6f`](https://github.com/nodejs/node-addon-api/commit/bb56ffaa6f)] - **doc**: fix documentation for object api (Nicola Del Gobbo) [#931](https://github.com/nodejs/node-addon-api/pull/931)
|
|
66
|
+
* [[`3b8bddab49`](https://github.com/nodejs/node-addon-api/commit/3b8bddab49)] - **src**: add additional tests for Function (José Expósito) [#928](https://github.com/nodejs/node-addon-api/pull/928)
|
|
67
|
+
* [[`74ab50c775`](https://github.com/nodejs/node-addon-api/commit/74ab50c775)] - **src**: allow references to be copyable in APIs (legendecas) [#915](https://github.com/nodejs/node-addon-api/pull/915)
|
|
68
|
+
* [[`929709d0fe`](https://github.com/nodejs/node-addon-api/commit/929709d0fe)] - **doc**: add propertylvalue.md (#925) (Gabriel Schulhof)
|
|
69
|
+
* [[`69d0d98be4`](https://github.com/nodejs/node-addon-api/commit/69d0d98be4)] - fixup (Anna Henningsen)
|
|
70
|
+
* [[`46e41d961b`](https://github.com/nodejs/node-addon-api/commit/46e41d961b)] - fixup (Anna Henningsen)
|
|
71
|
+
* [[`1af1642fb7`](https://github.com/nodejs/node-addon-api/commit/1af1642fb7)] - **doc**: warn about SuppressDestruct() (Anna Henningsen)
|
|
72
|
+
* [[`12c548b2ff`](https://github.com/nodejs/node-addon-api/commit/12c548b2ff)] - **tools**: fix error detection (#914) (Darshan Sen)
|
|
73
|
+
* [[`458d895d5b`](https://github.com/nodejs/node-addon-api/commit/458d895d5b)] - **packaging**: list files to be published to npm (Lovell Fuller) [#889](https://github.com/nodejs/node-addon-api/pull/889)
|
|
74
|
+
* [[`f7ed2490d4`](https://github.com/nodejs/node-addon-api/commit/f7ed2490d4)] - **test**: remove outdated V8 flag (Darshan Sen) [#895](https://github.com/nodejs/node-addon-api/pull/895)
|
|
75
|
+
* [[`a575a6ec60`](https://github.com/nodejs/node-addon-api/commit/a575a6ec60)] - **src**: fix leak in ObjectWrap instance set/getters (Kevin Eady) [#899](https://github.com/nodejs/node-addon-api/pull/899)
|
|
76
|
+
* [[`b6e844e0b0`](https://github.com/nodejs/node-addon-api/commit/b6e844e0b0)] - **doc**: fix spelling of "targeted" and "targeting" (#904) (Tobias Nießen)
|
|
77
|
+
* [[`4d856f6e91`](https://github.com/nodejs/node-addon-api/commit/4d856f6e91)] - **src**: remove unnecessary symbol exposure (Gabriel Schulhof) [#896](https://github.com/nodejs/node-addon-api/pull/896)
|
|
78
|
+
* [[`f35bb7d0d7`](https://github.com/nodejs/node-addon-api/commit/f35bb7d0d7)] - **doc**: Update GitHub URL references from 'master' to 'HEAD' (#898) (Jim Schlight)
|
|
79
|
+
* [[`286ae215d1`](https://github.com/nodejs/node-addon-api/commit/286ae215d1)] - Add warning about branch rename (Michael Dawson)
|
|
80
|
+
* [[`a4a7b28288`](https://github.com/nodejs/node-addon-api/commit/a4a7b28288)] - Update branch references from master to main (#886) (Jim Schlight)
|
|
81
|
+
* [[`a2ad0a107a`](https://github.com/nodejs/node-addon-api/commit/a2ad0a107a)] - **docs**: add NAN to N-API resource link (#880) (kidneysolo)
|
|
82
|
+
* [[`1c040eeb63`](https://github.com/nodejs/node-addon-api/commit/1c040eeb63)] - **test**: load testModules automatically (raisinten) [#876](https://github.com/nodejs/node-addon-api/pull/876)
|
|
83
|
+
* [[`bf478e4496`](https://github.com/nodejs/node-addon-api/commit/bf478e4496)] - **src**: use NAPI\_NOEXCEPT macro instead of noexcept (NickNaso) [#864](https://github.com/nodejs/node-addon-api/pull/864)
|
|
84
|
+
* [[`744705f2eb`](https://github.com/nodejs/node-addon-api/commit/744705f2eb)] - **test**: refactor remove repeated execution index.js (raisinten) [#839](https://github.com/nodejs/node-addon-api/pull/839)
|
|
85
|
+
* [[`db62e3c811`](https://github.com/nodejs/node-addon-api/commit/db62e3c811)] - Update team members (Michael Dawson)
|
|
86
|
+
|
|
3
87
|
## 2020-12-17 Version 3.1.0, @NickNaso
|
|
4
88
|
|
|
5
89
|
### Notable changes:
|
package/README.md
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
|
+
NOTE: The default branch has been renamed!
|
|
2
|
+
master is now named main
|
|
3
|
+
|
|
4
|
+
If you have a local clone, you can update it by running:
|
|
5
|
+
|
|
6
|
+
```shell
|
|
7
|
+
git branch -m master main
|
|
8
|
+
git fetch origin
|
|
9
|
+
git branch -u origin/main main
|
|
10
|
+
```
|
|
11
|
+
|
|
1
12
|
# **node-addon-api module**
|
|
2
13
|
This module contains **header-only C++ wrapper classes** which simplify
|
|
3
|
-
the use of the C based [
|
|
14
|
+
the use of the C based [Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)
|
|
4
15
|
provided by Node.js when using C++. It provides a C++ object model
|
|
5
16
|
and exception handling semantics with low overhead.
|
|
6
17
|
|
|
7
|
-
There are three options for implementing addons:
|
|
18
|
+
There are three options for implementing addons: Node-API, nan, or direct
|
|
8
19
|
use of internal V8, libuv and Node.js libraries. Unless there is a need for
|
|
9
|
-
direct access to functionality which is not exposed by
|
|
20
|
+
direct access to functionality which is not exposed by Node-API as outlined
|
|
10
21
|
in [C/C++ addons](https://nodejs.org/dist/latest/docs/api/addons.html)
|
|
11
|
-
in Node.js core, use
|
|
12
|
-
[C/C++ addons with
|
|
13
|
-
for more information on
|
|
22
|
+
in Node.js core, use Node-API. Refer to
|
|
23
|
+
[C/C++ addons with Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)
|
|
24
|
+
for more information on Node-API.
|
|
14
25
|
|
|
15
|
-
|
|
26
|
+
Node-API is an ABI stable C interface provided by Node.js for building native
|
|
16
27
|
addons. It is independent from the underlying JavaScript runtime (e.g. V8 or ChakraCore)
|
|
17
28
|
and is maintained as part of Node.js itself. It is intended to insulate
|
|
18
29
|
native addons from changes in the underlying JavaScript engine and allow
|
|
@@ -20,24 +31,24 @@ modules compiled for one version to run on later versions of Node.js without
|
|
|
20
31
|
recompilation.
|
|
21
32
|
|
|
22
33
|
The `node-addon-api` module, which is not part of Node.js, preserves the benefits
|
|
23
|
-
of the
|
|
24
|
-
provided by
|
|
34
|
+
of the Node-API as it consists only of inline code that depends only on the stable API
|
|
35
|
+
provided by Node-API. As such, modules built against one version of Node.js
|
|
25
36
|
using node-addon-api should run without having to be rebuilt with newer versions
|
|
26
37
|
of Node.js.
|
|
27
38
|
|
|
28
39
|
It is important to remember that *other* Node.js interfaces such as
|
|
29
40
|
`libuv` (included in a project via `#include <uv.h>`) are not ABI-stable across
|
|
30
|
-
Node.js major versions. Thus, an addon must use
|
|
41
|
+
Node.js major versions. Thus, an addon must use Node-API and/or `node-addon-api`
|
|
31
42
|
exclusively and build against a version of Node.js that includes an
|
|
32
|
-
implementation of
|
|
43
|
+
implementation of Node-API (meaning an active LTS version of Node.js) in
|
|
33
44
|
order to benefit from ABI stability across Node.js major versions. Node.js
|
|
34
45
|
provides an [ABI stability guide][] containing a detailed explanation of ABI
|
|
35
|
-
stability in general, and the
|
|
46
|
+
stability in general, and the Node-API ABI stability guarantee in particular.
|
|
36
47
|
|
|
37
|
-
As new APIs are added to
|
|
48
|
+
As new APIs are added to Node-API, node-addon-api must be updated to provide
|
|
38
49
|
wrappers for those new APIs. For this reason node-addon-api provides
|
|
39
|
-
methods that allow callers to obtain the underlying
|
|
40
|
-
direct calls to
|
|
50
|
+
methods that allow callers to obtain the underlying Node-API handles so
|
|
51
|
+
direct calls to Node-API and the use of the objects/methods provided by
|
|
41
52
|
node-addon-api can be used together. For example, in order to be able
|
|
42
53
|
to use an API for which the node-addon-api does not yet provide a wrapper.
|
|
43
54
|
|
|
@@ -45,8 +56,8 @@ APIs exposed by node-addon-api are generally used to create and
|
|
|
45
56
|
manipulate JavaScript values. Concepts and operations generally map
|
|
46
57
|
to ideas specified in the **ECMA262 Language Specification**.
|
|
47
58
|
|
|
48
|
-
The [
|
|
49
|
-
excellent orientation and tips for developers just getting started with
|
|
59
|
+
The [Node-API Resource](https://nodejs.github.io/node-addon-examples/) offers an
|
|
60
|
+
excellent orientation and tips for developers just getting started with Node-API
|
|
50
61
|
and node-addon-api.
|
|
51
62
|
|
|
52
63
|
- **[Setup](#setup)**
|
|
@@ -59,7 +70,7 @@ and node-addon-api.
|
|
|
59
70
|
- **[Contributors](#contributors)**
|
|
60
71
|
- **[License](#license)**
|
|
61
72
|
|
|
62
|
-
## **Current version: 3.
|
|
73
|
+
## **Current version: 3.2.0**
|
|
63
74
|
|
|
64
75
|
(See [CHANGELOG.md](CHANGELOG.md) for complete Changelog)
|
|
65
76
|
|
|
@@ -67,12 +78,12 @@ and node-addon-api.
|
|
|
67
78
|
|
|
68
79
|
<a name="setup"></a>
|
|
69
80
|
|
|
70
|
-
node-addon-api is based on [
|
|
71
|
-
This allows addons built with it to run with Node.js versions which support the targeted
|
|
81
|
+
node-addon-api is based on [Node-API](https://nodejs.org/api/n-api.html) and supports using different Node-API versions.
|
|
82
|
+
This allows addons built with it to run with Node.js versions which support the targeted Node-API version.
|
|
72
83
|
**However** the node-addon-api support model is to support only the active LTS Node.js versions. This means that
|
|
73
84
|
every year there will be a new major which drops support for the Node.js LTS version which has gone out of service.
|
|
74
85
|
|
|
75
|
-
The oldest Node.js version supported by the current version of node-addon-api is Node.js
|
|
86
|
+
The oldest Node.js version supported by the current version of node-addon-api is Node.js 12.x.
|
|
76
87
|
|
|
77
88
|
## Setup
|
|
78
89
|
- [Installation and usage](doc/setup.md)
|
|
@@ -141,14 +152,14 @@ The following is the documentation for node-addon-api.
|
|
|
141
152
|
|
|
142
153
|
Are you new to **node-addon-api**? Take a look at our **[examples](https://github.com/nodejs/node-addon-examples)**
|
|
143
154
|
|
|
144
|
-
- **[Hello World](https://github.com/nodejs/node-addon-examples/tree/
|
|
145
|
-
- **[Pass arguments to a function](https://github.com/nodejs/node-addon-examples/tree/
|
|
146
|
-
- **[Callbacks](https://github.com/nodejs/node-addon-examples/tree/
|
|
147
|
-
- **[Object factory](https://github.com/nodejs/node-addon-examples/tree/
|
|
148
|
-
- **[Function factory](https://github.com/nodejs/node-addon-examples/tree/
|
|
149
|
-
- **[Wrapping C++ Object](https://github.com/nodejs/node-addon-examples/tree/
|
|
150
|
-
- **[Factory of wrapped object](https://github.com/nodejs/node-addon-examples/tree/
|
|
151
|
-
- **[Passing wrapped object around](https://github.com/nodejs/node-addon-examples/tree/
|
|
155
|
+
- **[Hello World](https://github.com/nodejs/node-addon-examples/tree/HEAD/1_hello_world/node-addon-api)**
|
|
156
|
+
- **[Pass arguments to a function](https://github.com/nodejs/node-addon-examples/tree/HEAD/2_function_arguments/node-addon-api)**
|
|
157
|
+
- **[Callbacks](https://github.com/nodejs/node-addon-examples/tree/HEAD/3_callbacks/node-addon-api)**
|
|
158
|
+
- **[Object factory](https://github.com/nodejs/node-addon-examples/tree/HEAD/4_object_factory/node-addon-api)**
|
|
159
|
+
- **[Function factory](https://github.com/nodejs/node-addon-examples/tree/HEAD/5_function_factory/node-addon-api)**
|
|
160
|
+
- **[Wrapping C++ Object](https://github.com/nodejs/node-addon-examples/tree/HEAD/6_object_wrap/node-addon-api)**
|
|
161
|
+
- **[Factory of wrapped object](https://github.com/nodejs/node-addon-examples/tree/HEAD/7_factory_wrap/node-addon-api)**
|
|
162
|
+
- **[Passing wrapped object around](https://github.com/nodejs/node-addon-examples/tree/HEAD/8_passing_wrapped/node-addon-api)**
|
|
152
163
|
|
|
153
164
|
<a name="tests"></a>
|
|
154
165
|
|
|
@@ -167,14 +178,14 @@ npm install
|
|
|
167
178
|
npm test --disable-deprecated
|
|
168
179
|
```
|
|
169
180
|
|
|
170
|
-
To run the tests
|
|
181
|
+
To run the tests targeting a specific version of Node-API run
|
|
171
182
|
```
|
|
172
183
|
npm install
|
|
173
184
|
export NAPI_VERSION=X
|
|
174
185
|
npm test --NAPI_VERSION=X
|
|
175
186
|
```
|
|
176
187
|
|
|
177
|
-
where X is the version of
|
|
188
|
+
where X is the version of Node-API you want to target.
|
|
178
189
|
|
|
179
190
|
### **Debug**
|
|
180
191
|
|
|
@@ -190,7 +201,7 @@ If you want faster build, you might use the following option:
|
|
|
190
201
|
npm run-script dev:incremental
|
|
191
202
|
```
|
|
192
203
|
|
|
193
|
-
Take a look and get inspired by our **[test suite](https://github.com/nodejs/node-addon-api/tree/
|
|
204
|
+
Take a look and get inspired by our **[test suite](https://github.com/nodejs/node-addon-api/tree/HEAD/test)**
|
|
194
205
|
|
|
195
206
|
### **Benchmarks**
|
|
196
207
|
|
|
@@ -206,10 +217,11 @@ See [benchmark/README.md](benchmark/README.md) for more details about running an
|
|
|
206
217
|
|
|
207
218
|
### **More resource and info about native Addons**
|
|
208
219
|
- **[C++ Addons](https://nodejs.org/dist/latest/docs/api/addons.html)**
|
|
209
|
-
- **[
|
|
210
|
-
- **[
|
|
220
|
+
- **[Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)**
|
|
221
|
+
- **[Node-API - Next Generation Node API for Native Modules](https://youtu.be/-Oniup60Afs)**
|
|
222
|
+
- **[How We Migrated Realm JavaScript From NAN to Node-API](https://developer.mongodb.com/article/realm-javascript-nan-to-n-api)**
|
|
211
223
|
|
|
212
|
-
As node-addon-api's core mission is to expose the plain C
|
|
224
|
+
As node-addon-api's core mission is to expose the plain C Node-API as C++
|
|
213
225
|
wrappers, tools that facilitate n-api/node-addon-api providing more
|
|
214
226
|
convenient patterns on developing a Node.js add-ons with n-api/node-addon-api
|
|
215
227
|
can be published to NPM as standalone packages. It is also recommended to tag
|
|
@@ -217,23 +229,31 @@ such packages with `node-addon-api` to provide more visibility to the community.
|
|
|
217
229
|
|
|
218
230
|
Quick links to NPM searches: [keywords:node-addon-api](https://www.npmjs.com/search?q=keywords%3Anode-addon-api).
|
|
219
231
|
|
|
232
|
+
<a name="other-bindings"></a>
|
|
233
|
+
|
|
234
|
+
### **Other bindings**
|
|
235
|
+
|
|
236
|
+
- **[napi-rs](https://napi.rs)** - (`Rust`)
|
|
237
|
+
|
|
220
238
|
<a name="badges"></a>
|
|
221
239
|
|
|
222
240
|
### **Badges**
|
|
223
241
|
|
|
224
|
-
The use of badges is recommended to indicate the minimum version of
|
|
242
|
+
The use of badges is recommended to indicate the minimum version of Node-API
|
|
225
243
|
required for the module. This helps to determine which Node.js major versions are
|
|
226
|
-
supported. Addon maintainers can consult the [
|
|
227
|
-
which Node.js versions provide a given
|
|
244
|
+
supported. Addon maintainers can consult the [Node-API support matrix][] to determine
|
|
245
|
+
which Node.js versions provide a given Node-API version. The following badges are
|
|
228
246
|
available:
|
|
229
247
|
|
|
230
|
-

|
|
249
|
+

|
|
250
|
+

|
|
251
|
+

|
|
252
|
+

|
|
253
|
+

|
|
254
|
+

|
|
255
|
+

|
|
256
|
+

|
|
237
257
|
|
|
238
258
|
## **Contributing**
|
|
239
259
|
|
|
@@ -250,7 +270,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on our philosophy around
|
|
|
250
270
|
| Anna Henningsen | [addaleax](https://github.com/addaleax) |
|
|
251
271
|
| Chengzhong Wu | [legendecas](https://github.com/legendecas) |
|
|
252
272
|
| Gabriel Schulhof | [gabrielschulhof](https://github.com/gabrielschulhof) |
|
|
253
|
-
| Hitesh Kanwathirtha | [digitalinfinity](https://github.com/digitalinfinity) |
|
|
254
273
|
| Jim Schlight | [jschlight](https://github.com/jschlight) |
|
|
255
274
|
| Michael Dawson | [mhdawson](https://github.com/mhdawson) |
|
|
256
275
|
| Kevin Eady | [KevinEady](https://github.com/KevinEady)
|
|
@@ -262,6 +281,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on our philosophy around
|
|
|
262
281
|
| Arunesh Chandra | [aruneshchandra](https://github.com/aruneshchandra) |
|
|
263
282
|
| Benjamin Byholm | [kkoopa](https://github.com/kkoopa) |
|
|
264
283
|
| Jason Ginchereau | [jasongin](https://github.com/jasongin) |
|
|
284
|
+
| Hitesh Kanwathirtha | [digitalinfinity](https://github.com/digitalinfinity) |
|
|
265
285
|
| Sampson Gao | [sampsongao](https://github.com/sampsongao) |
|
|
266
286
|
| Taylor Woll | [boingoing](https://github.com/boingoing) |
|
|
267
287
|
|
|
@@ -270,4 +290,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on our philosophy around
|
|
|
270
290
|
Licensed under [MIT](./LICENSE.md)
|
|
271
291
|
|
|
272
292
|
[ABI stability guide]: https://nodejs.org/en/docs/guides/abi-stability/
|
|
273
|
-
[
|
|
293
|
+
[Node-API support matrix]: https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_n_api_version_matrix
|
package/napi-inl.deprecated.h
CHANGED
|
@@ -11,7 +11,7 @@ PropertyDescriptor::Accessor(const char* utf8name,
|
|
|
11
11
|
Getter getter,
|
|
12
12
|
napi_property_attributes attributes,
|
|
13
13
|
void* /*data*/) {
|
|
14
|
-
|
|
14
|
+
using CbData = details::CallbackData<Getter, Napi::Value>;
|
|
15
15
|
// TODO: Delete when the function is destroyed
|
|
16
16
|
auto callbackData = new CbData({ getter, nullptr });
|
|
17
17
|
|
|
@@ -40,7 +40,7 @@ inline PropertyDescriptor PropertyDescriptor::Accessor(napi_value name,
|
|
|
40
40
|
Getter getter,
|
|
41
41
|
napi_property_attributes attributes,
|
|
42
42
|
void* /*data*/) {
|
|
43
|
-
|
|
43
|
+
using CbData = details::CallbackData<Getter, Napi::Value>;
|
|
44
44
|
// TODO: Delete when the function is destroyed
|
|
45
45
|
auto callbackData = new CbData({ getter, nullptr });
|
|
46
46
|
|
|
@@ -71,7 +71,7 @@ inline PropertyDescriptor PropertyDescriptor::Accessor(const char* utf8name,
|
|
|
71
71
|
Setter setter,
|
|
72
72
|
napi_property_attributes attributes,
|
|
73
73
|
void* /*data*/) {
|
|
74
|
-
|
|
74
|
+
using CbData = details::AccessorCallbackData<Getter, Setter>;
|
|
75
75
|
// TODO: Delete when the function is destroyed
|
|
76
76
|
auto callbackData = new CbData({ getter, setter, nullptr });
|
|
77
77
|
|
|
@@ -102,7 +102,7 @@ inline PropertyDescriptor PropertyDescriptor::Accessor(napi_value name,
|
|
|
102
102
|
Setter setter,
|
|
103
103
|
napi_property_attributes attributes,
|
|
104
104
|
void* /*data*/) {
|
|
105
|
-
|
|
105
|
+
using CbData = details::AccessorCallbackData<Getter, Setter>;
|
|
106
106
|
// TODO: Delete when the function is destroyed
|
|
107
107
|
auto callbackData = new CbData({ getter, setter, nullptr });
|
|
108
108
|
|
|
@@ -133,8 +133,8 @@ inline PropertyDescriptor PropertyDescriptor::Function(const char* utf8name,
|
|
|
133
133
|
Callable cb,
|
|
134
134
|
napi_property_attributes attributes,
|
|
135
135
|
void* /*data*/) {
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
using ReturnType = decltype(cb(CallbackInfo(nullptr, nullptr)));
|
|
137
|
+
using CbData = details::CallbackData<Callable, ReturnType>;
|
|
138
138
|
// TODO: Delete when the function is destroyed
|
|
139
139
|
auto callbackData = new CbData({ cb, nullptr });
|
|
140
140
|
|
|
@@ -163,8 +163,8 @@ inline PropertyDescriptor PropertyDescriptor::Function(napi_value name,
|
|
|
163
163
|
Callable cb,
|
|
164
164
|
napi_property_attributes attributes,
|
|
165
165
|
void* /*data*/) {
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
using ReturnType = decltype(cb(CallbackInfo(nullptr, nullptr)));
|
|
167
|
+
using CbData = details::CallbackData<Callable, ReturnType>;
|
|
168
168
|
// TODO: Delete when the function is destroyed
|
|
169
169
|
auto callbackData = new CbData({ cb, nullptr });
|
|
170
170
|
|