node-addon-api 7.1.0 → 8.0.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.
Files changed (2) hide show
  1. package/README.md +21 -249
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,266 +1,33 @@
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:
1
+ # **node-addon-api module**
5
2
 
6
- ```shell
7
- git branch -m master main
8
- git fetch origin
9
- git branch -u origin/main main
10
- ```
3
+ [![NPM](https://nodei.co/npm/node-addon-api.png?downloads=true&downloadRank=true)](https://nodei.co/npm/node-addon-api/) [![NPM](https://nodei.co/npm-dl/node-addon-api.png?months=6&height=1)](https://nodei.co/npm/node-addon-api/)
11
4
 
12
- # **node-addon-api module**
13
5
  This module contains **header-only C++ wrapper classes** which simplify
14
6
  the use of the C based [Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)
15
7
  provided by Node.js when using C++. It provides a C++ object model
16
8
  and exception handling semantics with low overhead.
17
9
 
18
- There are three options for implementing addons: Node-API, nan, or direct
19
- use of internal V8, libuv, and Node.js libraries. Unless there is a need for
20
- direct access to functionality that is not exposed by Node-API as outlined
21
- in [C/C++ addons](https://nodejs.org/dist/latest/docs/api/addons.html)
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.
25
-
26
- Node-API is an ABI stable C interface provided by Node.js for building native
27
- addons. It is independent of the underlying JavaScript runtime (e.g. V8 or ChakraCore)
28
- and is maintained as part of Node.js itself. It is intended to insulate
29
- native addons from changes in the underlying JavaScript engine and allow
30
- modules compiled for one version to run on later versions of Node.js without
31
- recompilation.
32
-
33
- The `node-addon-api` module, which is not part of Node.js, preserves the benefits
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
36
- using node-addon-api should run without having to be rebuilt with newer versions
37
- of Node.js.
38
-
39
- It is important to remember that *other* Node.js interfaces such as
40
- `libuv` (included in a project via `#include <uv.h>`) are not ABI-stable across
41
- Node.js major versions. Thus, an addon must use Node-API and/or `node-addon-api`
42
- exclusively and build against a version of Node.js that includes an
43
- implementation of Node-API (meaning an active LTS version of Node.js) in
44
- order to benefit from ABI stability across Node.js major versions. Node.js
45
- provides an [ABI stability guide][] containing a detailed explanation of ABI
46
- stability in general, and the Node-API ABI stability guarantee in particular.
47
-
48
- As new APIs are added to Node-API, node-addon-api must be updated to provide
49
- wrappers for those new APIs. For this reason, node-addon-api provides
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
52
- node-addon-api can be used together. For example, in order to be able
53
- to use an API for which the node-addon-api does not yet provide a wrapper.
10
+ - [API References](doc/README.md)
11
+ - [Badges](#badges)
12
+ - [Contributing](#contributing)
13
+ - [License](#license)
54
14
 
55
- APIs exposed by node-addon-api are generally used to create and
56
- manipulate JavaScript values. Concepts and operations generally map
57
- to ideas specified in the **ECMA262 Language Specification**.
15
+ ## API References
58
16
 
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
61
- and node-addon-api.
17
+ API references are available in the [doc](doc/README.md) directory.
62
18
 
63
- - **[Setup](#setup)**
64
- - **[API Documentation](#api)**
65
- - **[Examples](#examples)**
66
- - **[Tests](#tests)**
67
- - **[More resource and info about native Addons](#resources)**
68
- - **[Badges](#badges)**
69
- - **[Code of Conduct](CODE_OF_CONDUCT.md)**
70
- - **[Contributors](#contributors)**
71
- - **[License](#license)**
72
-
73
- ## **Current version: 7.1.0**
19
+ ## Current version: 8.0.0
74
20
 
75
21
  (See [CHANGELOG.md](CHANGELOG.md) for complete Changelog)
76
22
 
77
- [![NPM](https://nodei.co/npm/node-addon-api.png?downloads=true&downloadRank=true)](https://nodei.co/npm/node-addon-api/) [![NPM](https://nodei.co/npm-dl/node-addon-api.png?months=6&height=1)](https://nodei.co/npm/node-addon-api/)
78
-
79
- <a name="setup"></a>
80
-
81
23
  node-addon-api is based on [Node-API](https://nodejs.org/api/n-api.html) and supports using different Node-API versions.
82
24
  This allows addons built with it to run with Node.js versions which support the targeted Node-API version.
83
25
  **However** the node-addon-api support model is to support only the active LTS Node.js versions. This means that
84
26
  every year there will be a new major which drops support for the Node.js LTS version which has gone out of service.
85
27
 
86
- The oldest Node.js version supported by the current version of node-addon-api is Node.js 16.x.
87
-
88
- ## Setup
89
- - [Installation and usage](doc/setup.md)
90
- - [node-gyp](doc/node-gyp.md)
91
- - [cmake-js](doc/cmake-js.md)
92
- - [Conversion tool](doc/conversion-tool.md)
93
- - [Checker tool](doc/checker-tool.md)
94
- - [Generator](doc/generator.md)
95
- - [Prebuild tools](doc/prebuild_tools.md)
96
-
97
- <a name="api"></a>
98
-
99
- ### **API Documentation**
100
-
101
- The following is the documentation for node-addon-api.
102
-
103
- - [Full Class Hierarchy](doc/hierarchy.md)
104
- - [Addon Structure](doc/addon.md)
105
- - Data Types:
106
- - [Env](doc/env.md)
107
- - [CallbackInfo](doc/callbackinfo.md)
108
- - [Reference](doc/reference.md)
109
- - [Value](doc/value.md)
110
- - [Name](doc/name.md)
111
- - [Symbol](doc/symbol.md)
112
- - [String](doc/string.md)
113
- - [Number](doc/number.md)
114
- - [Date](doc/date.md)
115
- - [BigInt](doc/bigint.md)
116
- - [Boolean](doc/boolean.md)
117
- - [External](doc/external.md)
118
- - [Object](doc/object.md)
119
- - [Array](doc/array.md)
120
- - [ObjectReference](doc/object_reference.md)
121
- - [PropertyDescriptor](doc/property_descriptor.md)
122
- - [Function](doc/function.md)
123
- - [FunctionReference](doc/function_reference.md)
124
- - [ObjectWrap](doc/object_wrap.md)
125
- - [ClassPropertyDescriptor](doc/class_property_descriptor.md)
126
- - [Buffer](doc/buffer.md)
127
- - [ArrayBuffer](doc/array_buffer.md)
128
- - [TypedArray](doc/typed_array.md)
129
- - [TypedArrayOf](doc/typed_array_of.md)
130
- - [DataView](doc/dataview.md)
131
- - [Error Handling](doc/error_handling.md)
132
- - [Error](doc/error.md)
133
- - [TypeError](doc/type_error.md)
134
- - [RangeError](doc/range_error.md)
135
- - [SyntaxError](doc/syntax_error.md)
136
- - [Object Lifetime Management](doc/object_lifetime_management.md)
137
- - [HandleScope](doc/handle_scope.md)
138
- - [EscapableHandleScope](doc/escapable_handle_scope.md)
139
- - [Memory Management](doc/memory_management.md)
140
- - [Async Operations](doc/async_operations.md)
141
- - [AsyncWorker](doc/async_worker.md)
142
- - [AsyncContext](doc/async_context.md)
143
- - [AsyncWorker Variants](doc/async_worker_variants.md)
144
- - [Thread-safe Functions](doc/threadsafe.md)
145
- - [ThreadSafeFunction](doc/threadsafe_function.md)
146
- - [TypedThreadSafeFunction](doc/typed_threadsafe_function.md)
147
- - [Promises](doc/promises.md)
148
- - [Version management](doc/version_management.md)
149
-
150
- <a name="examples"></a>
151
-
152
- ### **Examples**
153
-
154
- Are you new to **node-addon-api**? Take a look at our **[examples](https://github.com/nodejs/node-addon-examples)**
155
-
156
- - **[Hello World](https://github.com/nodejs/node-addon-examples/tree/main/src/1-getting-started/1_hello_world)**
157
- - **[Pass arguments to a function](https://github.com/nodejs/node-addon-examples/tree/main/src/1-getting-started/2_function_arguments/node-addon-api)**
158
- - **[Callbacks](https://github.com/nodejs/node-addon-examples/tree/main/src/1-getting-started/3_callbacks/node-addon-api)**
159
- - **[Object factory](https://github.com/nodejs/node-addon-examples/tree/main/src/1-getting-started/4_object_factory/node-addon-api)**
160
- - **[Function factory](https://github.com/nodejs/node-addon-examples/tree/main/src/1-getting-started/5_function_factory/node-addon-api)**
161
- - **[Wrapping C++ Object](https://github.com/nodejs/node-addon-examples/tree/main/src/1-getting-started/6_object_wrap/node-addon-api)**
162
- - **[Factory of wrapped object](https://github.com/nodejs/node-addon-examples/tree/main/src/1-getting-started/7_factory_wrap/node-addon-api)**
163
- - **[Passing wrapped object around](https://github.com/nodejs/node-addon-examples/tree/main/src/2-js-to-native-conversion/8_passing_wrapped/node-addon-api)**
164
-
165
- <a name="tests"></a>
166
-
167
- ### **Tests**
168
-
169
- To run the **node-addon-api** tests do:
170
-
171
- ```
172
- npm install
173
- npm test
174
- ```
175
-
176
- To avoid testing the deprecated portions of the API run
177
- ```
178
- npm install
179
- npm test --disable-deprecated
180
- ```
181
-
182
- To run the tests targeting a specific version of Node-API run
183
- ```
184
- npm install
185
- export NAPI_VERSION=X
186
- npm test --NAPI_VERSION=X
187
- ```
188
-
189
- where X is the version of Node-API you want to target.
190
-
191
- To run a specific unit test, filter conditions are available
28
+ The oldest Node.js version supported by the current version of node-addon-api is Node.js 18.x.
192
29
 
193
- **Example:**
194
- compile and run only tests on objectwrap.cc and objectwrap.js
195
- ```
196
- npm run unit --filter=objectwrap
197
- ```
198
-
199
- Multiple unit tests cane be selected with wildcards
200
-
201
- **Example:**
202
- compile and run all test files ending with "reference" -> function_reference.cc, object_reference.cc, reference.cc
203
- ```
204
- npm run unit --filter=*reference
205
- ```
206
-
207
- Multiple filter conditions can be joined to broaden the test selection
208
-
209
- **Example:**
210
- compile and run all tests under folders threadsafe_function and typed_threadsafe_function and also the objectwrap.cc file
211
- npm run unit --filter='*function objectwrap'
212
-
213
- ### **Debug**
214
-
215
- To run the **node-addon-api** tests with `--debug` option:
216
-
217
- ```
218
- npm run-script dev
219
- ```
220
-
221
- If you want a faster build, you might use the following option:
222
-
223
- ```
224
- npm run-script dev:incremental
225
- ```
226
-
227
- Take a look and get inspired by our **[test suite](https://github.com/nodejs/node-addon-api/tree/HEAD/test)**
228
-
229
- ### **Benchmarks**
230
-
231
- You can run the available benchmarks using the following command:
232
-
233
- ```
234
- npm run-script benchmark
235
- ```
236
-
237
- See [benchmark/README.md](benchmark/README.md) for more details about running and adding benchmarks.
238
-
239
- <a name="resources"></a>
240
-
241
- ### **More resource and info about native Addons**
242
- - **[C++ Addons](https://nodejs.org/dist/latest/docs/api/addons.html)**
243
- - **[Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)**
244
- - **[Node-API - Next Generation Node API for Native Modules](https://youtu.be/-Oniup60Afs)**
245
- - **[How We Migrated Realm JavaScript From NAN to Node-API](https://developer.mongodb.com/article/realm-javascript-nan-to-n-api)**
246
-
247
- As node-addon-api's core mission is to expose the plain C Node-API as C++
248
- wrappers, tools that facilitate n-api/node-addon-api providing more
249
- convenient patterns for developing a Node.js add-on with n-api/node-addon-api
250
- can be published to NPM as standalone packages. It is also recommended to tag
251
- such packages with `node-addon-api` to provide more visibility to the community.
252
-
253
- Quick links to NPM searches: [keywords:node-addon-api](https://www.npmjs.com/search?q=keywords%3Anode-addon-api).
254
-
255
- <a name="other-bindings"></a>
256
-
257
- ### **Other bindings**
258
-
259
- - **[napi-rs](https://napi.rs)** - (`Rust`)
260
-
261
- <a name="badges"></a>
262
-
263
- ### **Badges**
30
+ ## Badges
264
31
 
265
32
  The use of badges is recommended to indicate the minimum version of Node-API
266
33
  required for the module. This helps to determine which Node.js major versions are
@@ -279,16 +46,15 @@ available:
279
46
  ![Node-API v9 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v9%20Badge.svg)
280
47
  ![Node-API Experimental Version Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20Experimental%20Version%20Badge.svg)
281
48
 
282
- ## **Contributing**
49
+ ## Contributing
283
50
 
284
51
  We love contributions from the community to **node-addon-api**!
285
52
  See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on our philosophy around extending this module.
286
53
 
287
- <a name="contributors"></a>
288
-
289
54
  ## Team members
290
55
 
291
56
  ### Active
57
+
292
58
  | Name | GitHub Link |
293
59
  | ------------------- | ----------------------------------------------------- |
294
60
  | Anna Henningsen | [addaleax](https://github.com/addaleax) |
@@ -299,7 +65,12 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on our philosophy around
299
65
  | Nicola Del Gobbo | [NickNaso](https://github.com/NickNaso) |
300
66
  | Vladimir Morozov | [vmoroz](https://github.com/vmoroz) |
301
67
 
68
+ <details>
69
+
70
+ <summary>Emeritus</summary>
71
+
302
72
  ### Emeritus
73
+
303
74
  | Name | GitHub Link |
304
75
  | ------------------- | ----------------------------------------------------- |
305
76
  | Arunesh Chandra | [aruneshchandra](https://github.com/aruneshchandra) |
@@ -311,9 +82,10 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on our philosophy around
311
82
  | Sampson Gao | [sampsongao](https://github.com/sampsongao) |
312
83
  | Taylor Woll | [boingoing](https://github.com/boingoing) |
313
84
 
314
- <a name="license"></a>
85
+ </details>
86
+
87
+ ## License
315
88
 
316
89
  Licensed under [MIT](./LICENSE.md)
317
90
 
318
- [ABI stability guide]: https://nodejs.org/en/docs/guides/abi-stability/
319
91
  [Node-API support matrix]: https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_n_api_version_matrix
package/package.json CHANGED
@@ -475,9 +475,9 @@
475
475
  "lint:fix": "node tools/clang-format --fix && node tools/eslint-format --fix"
476
476
  },
477
477
  "pre-commit": "lint",
478
- "version": "7.1.0",
478
+ "version": "8.0.0",
479
479
  "support": true,
480
480
  "engines": {
481
- "node": "^16 || ^18 || >= 20"
481
+ "node": "^18 || ^20 || >= 21"
482
482
  }
483
483
  }