koffi 2.7.2 → 2.7.3

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 (65) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/koffi/darwin_arm64/koffi.node +0 -0
  3. package/build/koffi/darwin_x64/koffi.node +0 -0
  4. package/build/koffi/freebsd_arm64/koffi.node +0 -0
  5. package/build/koffi/freebsd_ia32/koffi.node +0 -0
  6. package/build/koffi/freebsd_x64/koffi.node +0 -0
  7. package/build/koffi/linux_arm32hf/koffi.node +0 -0
  8. package/build/koffi/linux_arm64/koffi.node +0 -0
  9. package/build/koffi/linux_ia32/koffi.node +0 -0
  10. package/build/koffi/linux_riscv64hf64/koffi.node +0 -0
  11. package/build/koffi/linux_x64/koffi.node +0 -0
  12. package/build/koffi/openbsd_ia32/koffi.node +0 -0
  13. package/build/koffi/openbsd_x64/koffi.node +0 -0
  14. package/build/koffi/win32_arm64/koffi.node +0 -0
  15. package/build/koffi/win32_ia32/koffi.node +0 -0
  16. package/build/koffi/win32_x64/koffi.node +0 -0
  17. package/doc/misc.md +1 -1
  18. package/index.js +2 -2
  19. package/indirect.js +2 -2
  20. package/package.json +2 -2
  21. package/src/koffi/src/call.cc +1 -1
  22. package/src/koffi/src/util.cc +7 -13
  23. package/src/koffi/src/util.hh +9 -1
  24. package/vendor/node-addon-api/CHANGELOG.md +76 -0
  25. package/vendor/node-addon-api/LICENSE.md +2 -6
  26. package/vendor/node-addon-api/README.md +10 -9
  27. package/vendor/node-addon-api/benchmark/binding.gyp +4 -4
  28. package/vendor/node-addon-api/common.gypi +1 -2
  29. package/vendor/node-addon-api/doc/array.md +1 -1
  30. package/vendor/node-addon-api/doc/async_worker_variants.md +16 -16
  31. package/vendor/node-addon-api/doc/cmake-js.md +1 -1
  32. package/vendor/node-addon-api/doc/env.md +11 -0
  33. package/vendor/node-addon-api/doc/hierarchy.md +2 -0
  34. package/vendor/node-addon-api/doc/setup.md +53 -71
  35. package/vendor/node-addon-api/doc/syntax_error.md +66 -0
  36. package/vendor/node-addon-api/doc/value.md +2 -0
  37. package/vendor/node-addon-api/index.js +2 -1
  38. package/vendor/node-addon-api/napi-inl.h +68 -65
  39. package/vendor/node-addon-api/napi.h +15 -5
  40. package/vendor/node-addon-api/node_addon_api.gyp +32 -0
  41. package/vendor/node-addon-api/package.json +14 -3
  42. package/vendor/node-addon-api/test/addon.cc +7 -1
  43. package/vendor/node-addon-api/test/addon.js +5 -9
  44. package/vendor/node-addon-api/test/addon_data.cc +3 -3
  45. package/vendor/node-addon-api/test/addon_data.js +16 -38
  46. package/vendor/node-addon-api/test/bigint.cc +0 -1
  47. package/vendor/node-addon-api/test/binding.cc +12 -1
  48. package/vendor/node-addon-api/test/binding.gyp +10 -8
  49. package/vendor/node-addon-api/test/child_processes/addon.js +11 -0
  50. package/vendor/node-addon-api/test/child_processes/addon_data.js +24 -0
  51. package/vendor/node-addon-api/test/child_processes/objectwrap_function.js +22 -0
  52. package/vendor/node-addon-api/test/child_processes/threadsafe_function_exception.js +33 -0
  53. package/vendor/node-addon-api/test/child_processes/typed_threadsafe_function_exception.js +19 -0
  54. package/vendor/node-addon-api/test/common/index.js +57 -3
  55. package/vendor/node-addon-api/test/env_misc.cc +25 -0
  56. package/vendor/node-addon-api/test/env_misc.js +12 -0
  57. package/vendor/node-addon-api/test/error.cc +47 -0
  58. package/vendor/node-addon-api/test/error.js +16 -0
  59. package/vendor/node-addon-api/test/index.js +5 -0
  60. package/vendor/node-addon-api/test/objectwrap_function.cc +10 -12
  61. package/vendor/node-addon-api/test/objectwrap_function.js +4 -20
  62. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_exception.cc +50 -0
  63. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_exception.js +20 -0
  64. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_exception.cc +39 -0
  65. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_exception.js +13 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  ### Koffi 2.7
6
6
 
7
+ #### Koffi 2.7.3 (2024-01-26)
8
+
9
+ - Support decoding NULL terminated arrays
10
+
7
11
  #### Koffi 2.7.2 (2024-01-15)
8
12
 
9
13
  - Add missing TypeScript declaration for `koffi.free()`
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/doc/misc.md CHANGED
@@ -69,7 +69,7 @@ You can alias a type with `koffi.alias(name, type)`. Aliased types are completel
69
69
  For synchronous/normal calls, Koffi uses two preallocated memory blocks:
70
70
 
71
71
  - One to construct the C stack and assign registers, subsequently used by the platform-specific assembly code (1 MiB by default)
72
- - One to allocate strings and big objects/structs (2 MiB by default)
72
+ - One to allocate strings and objects/structs (2 MiB by default)
73
73
 
74
74
  Unless very big strings or objects (at least more than one page of memory) are used, Koffi does not directly allocate any extra memory during calls or callbacks. However, please note that the JS engine (V8) might.
75
75
 
package/index.js CHANGED
@@ -378,8 +378,8 @@ var require_package = __commonJS({
378
378
  "build/dist/src/koffi/package.json"(exports2, module2) {
379
379
  module2.exports = {
380
380
  name: "koffi",
381
- version: "2.7.2",
382
- stable: "2.7.2",
381
+ version: "2.7.3",
382
+ stable: "2.7.3",
383
383
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
384
384
  keywords: [
385
385
  "foreign",
package/indirect.js CHANGED
@@ -378,8 +378,8 @@ var require_package = __commonJS({
378
378
  "build/dist/src/koffi/package.json"(exports2, module2) {
379
379
  module2.exports = {
380
380
  name: "koffi",
381
- version: "2.7.2",
382
- stable: "2.7.2",
381
+ version: "2.7.3",
382
+ stable: "2.7.3",
383
383
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
384
384
  keywords: [
385
385
  "foreign",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "2.7.2",
4
- "stable": "2.7.2",
3
+ "version": "2.7.3",
4
+ "stable": "2.7.3",
5
5
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
6
6
  "keywords": [
7
7
  "foreign",
@@ -1269,7 +1269,7 @@ void CallData::PopOutArguments()
1269
1269
  RG_ASSERT(array.IsArray());
1270
1270
  RG_ASSERT(array.Length() == 1);
1271
1271
 
1272
- Size len = WideStringLength((const char16_t *)out.ptr, out.max_len);
1272
+ Size len = NullTerminatedLength((const char16_t *)out.ptr, out.max_len);
1273
1273
  Napi::String str = Napi::String::New(env, (const char16_t *)out.ptr, len);
1274
1274
 
1275
1275
  array.Set(0u, str);
@@ -779,17 +779,6 @@ void DecodeObject(Napi::Object obj, const uint8_t *origin, const TypeInfo *type)
779
779
  }
780
780
  }
781
781
 
782
- Size WideStringLength(const char16_t *str16, Size max)
783
- {
784
- Size len = 0;
785
-
786
- while (len < max && str16[len]) {
787
- len++;
788
- }
789
-
790
- return len;
791
- }
792
-
793
782
  Napi::Value DecodeArray(Napi::Env env, const uint8_t *origin, const TypeInfo *type)
794
783
  {
795
784
  InstanceData *instance = env.GetInstanceData<InstanceData>();
@@ -873,7 +862,7 @@ Napi::Value DecodeArray(Napi::Env env, const uint8_t *origin, const TypeInfo *ty
873
862
  case PrimitiveKind::Int16: {
874
863
  if (type->hint == ArrayHint::String) {
875
864
  const char16_t *ptr = (const char16_t *)origin;
876
- Size count = WideStringLength(ptr, len);
865
+ Size count = NullTerminatedLength(ptr, len);
877
866
 
878
867
  Napi::String str = Napi::String::New(env, ptr, count);
879
868
  return str;
@@ -1186,7 +1175,12 @@ Napi::Value Decode(Napi::Env env, const uint8_t *ptr, const TypeInfo *type, cons
1186
1175
  } break;
1187
1176
  case PrimitiveKind::Int16:
1188
1177
  case PrimitiveKind::UInt16: {
1189
- Size count = WideStringLength((const char16_t *)ptr, RG_SIZE_MAX);
1178
+ Size count = NullTerminatedLength((const char16_t *)ptr, RG_SIZE_MAX);
1179
+ type = MakeArrayType(instance, type, count);
1180
+ } break;
1181
+
1182
+ case PrimitiveKind::Pointer: {
1183
+ Size count = NullTerminatedLength((const void **)ptr, RG_SIZE_MAX);
1190
1184
  type = MakeArrayType(instance, type, count);
1191
1185
  } break;
1192
1186
 
@@ -156,7 +156,15 @@ T GetNumber(Napi::Value value)
156
156
  RG_UNREACHABLE();
157
157
  }
158
158
 
159
- Size WideStringLength(const char16_t *str16, Size max);
159
+ template <typename T>
160
+ Size NullTerminatedLength(const T *ptr, Size max)
161
+ {
162
+ Size len = 0;
163
+ while (len < max && ptr[len]) {
164
+ len++;
165
+ }
166
+ return len;
167
+ }
160
168
 
161
169
  Napi::Object DecodeObject(Napi::Env env, const uint8_t *origin, const TypeInfo *type);
162
170
  void DecodeObject(Napi::Object obj, const uint8_t *origin, const TypeInfo *type);
@@ -1,5 +1,81 @@
1
1
  # node-addon-api Changelog
2
2
 
3
+ ## 2024-01-18 Version 7.1.0, @legendecas
4
+
5
+ ### Notable changes
6
+
7
+ #### API
8
+
9
+ - Add Env::GetModuleFileName
10
+ - Add SyntaxError
11
+ - Allow NAPI\_VERSION env var and templatize AttachData callback
12
+ - Add common gyp dependency targets.
13
+
14
+ ### Commits
15
+
16
+ * \[[`864fed488c`](https://github.com/nodejs/node-addon-api/commit/864fed488c)] - build(deps): bump github/codeql-action from 3.22.12 to 3.23.0 (dependabot\[bot]) [#1428](https://github.com/nodejs/node-addon-api/pull/1428)
17
+ * \[[`81a8d43130`](https://github.com/nodejs/node-addon-api/commit/81a8d43130)] - build(deps): bump actions/dependency-review-action from 3.1.4 to 3.1.5 (dependabot\[bot]) [#1427](https://github.com/nodejs/node-addon-api/pull/1427)
18
+ * \[[`e20088941b`](https://github.com/nodejs/node-addon-api/commit/e20088941b)] - build(deps): bump github/codeql-action from 3.22.11 to 3.22.12 (dependabot\[bot]) [#1426](https://github.com/nodejs/node-addon-api/pull/1426)
19
+ * \[[`76c7b12e4e`](https://github.com/nodejs/node-addon-api/commit/76c7b12e4e)] - build(deps): bump actions/setup-node from 4.0.0 to 4.0.1 (dependabot\[bot]) [#1425](https://github.com/nodejs/node-addon-api/pull/1425)
20
+ * \[[`cd58edde1d`](https://github.com/nodejs/node-addon-api/commit/cd58edde1d)] - build(deps): bump actions/upload-artifact from 3.1.3 to 4.0.0 (dependabot\[bot]) [#1424](https://github.com/nodejs/node-addon-api/pull/1424)
21
+ * \[[`0fd1b9e0e1`](https://github.com/nodejs/node-addon-api/commit/0fd1b9e0e1)] - build(deps): bump github/codeql-action from 2.22.8 to 3.22.11 (dependabot\[bot]) [#1423](https://github.com/nodejs/node-addon-api/pull/1423)
22
+ * \[[`c181b19d68`](https://github.com/nodejs/node-addon-api/commit/c181b19d68)] - build(deps): bump actions/stale from 8.0.0 to 9.0.0 (dependabot\[bot]) [#1418](https://github.com/nodejs/node-addon-api/pull/1418)
23
+ * \[[`6fa67791a1`](https://github.com/nodejs/node-addon-api/commit/6fa67791a1)] - build(deps): bump actions/setup-python from 4.7.1 to 5.0.0 (dependabot\[bot]) [#1417](https://github.com/nodejs/node-addon-api/pull/1417)
24
+ * \[[`1fff346fa6`](https://github.com/nodejs/node-addon-api/commit/1fff346fa6)] - build(deps): bump actions/dependency-review-action from 3.1.3 to 3.1.4 (dependabot\[bot]) [#1415](https://github.com/nodejs/node-addon-api/pull/1415)
25
+ * \[[`ecb9690fe5`](https://github.com/nodejs/node-addon-api/commit/ecb9690fe5)] - build(deps): bump github/codeql-action from 2.22.7 to 2.22.8 (dependabot\[bot]) [#1414](https://github.com/nodejs/node-addon-api/pull/1414)
26
+ * \[[`969547b871`](https://github.com/nodejs/node-addon-api/commit/969547b871)] - build(deps): bump github/codeql-action from 2.22.5 to 2.22.7 (dependabot\[bot]) [#1413](https://github.com/nodejs/node-addon-api/pull/1413)
27
+ * \[[`183d1522a9`](https://github.com/nodejs/node-addon-api/commit/183d1522a9)] - build(deps): bump step-security/harden-runner from 2.6.0 to 2.6.1 (dependabot\[bot]) [#1412](https://github.com/nodejs/node-addon-api/pull/1412)
28
+ * \[[`25f977724a`](https://github.com/nodejs/node-addon-api/commit/25f977724a)] - build(deps): bump actions/dependency-review-action from 3.1.0 to 3.1.3 (dependabot\[bot]) [#1410](https://github.com/nodejs/node-addon-api/pull/1410)
29
+ * \[[`f6d125a407`](https://github.com/nodejs/node-addon-api/commit/f6d125a407)] - build(deps): bump actions/setup-python from 4.7.0 to 4.7.1 (dependabot\[bot]) [#1406](https://github.com/nodejs/node-addon-api/pull/1406)
30
+ * \[[`ce78a39ec7`](https://github.com/nodejs/node-addon-api/commit/ce78a39ec7)] - build(deps): bump github/codeql-action from 2.22.4 to 2.22.5 (dependabot\[bot]) [#1400](https://github.com/nodejs/node-addon-api/pull/1400)
31
+ * \[[`dc211ebb48`](https://github.com/nodejs/node-addon-api/commit/dc211ebb48)] - build(deps): bump actions/setup-node from 3.8.1 to 4.0.0 (dependabot\[bot]) [#1398](https://github.com/nodejs/node-addon-api/pull/1398)
32
+ * \[[`cab559e3bd`](https://github.com/nodejs/node-addon-api/commit/cab559e3bd)] - build(deps): bump ossf/scorecard-action from 2.3.0 to 2.3.1 (dependabot\[bot]) [#1397](https://github.com/nodejs/node-addon-api/pull/1397)
33
+ * \[[`f71ff5582d`](https://github.com/nodejs/node-addon-api/commit/f71ff5582d)] - build(deps): bump github/codeql-action from 2.22.3 to 2.22.4 (dependabot\[bot]) [#1396](https://github.com/nodejs/node-addon-api/pull/1396)
34
+ * \[[`21c1d08680`](https://github.com/nodejs/node-addon-api/commit/21c1d08680)] - build(deps): bump actions/checkout from 4.1.0 to 4.1.1 (dependabot\[bot]) [#1394](https://github.com/nodejs/node-addon-api/pull/1394)
35
+ * \[[`e4eec0939c`](https://github.com/nodejs/node-addon-api/commit/e4eec0939c)] - build(deps): bump github/codeql-action from 2.21.9 to 2.22.3 (dependabot\[bot]) [#1393](https://github.com/nodejs/node-addon-api/pull/1393)
36
+ * \[[`94f3459474`](https://github.com/nodejs/node-addon-api/commit/94f3459474)] - build(deps): bump ossf/scorecard-action from 2.2.0 to 2.3.0 (dependabot\[bot]) [#1388](https://github.com/nodejs/node-addon-api/pull/1388)
37
+ * \[[`90a741ef10`](https://github.com/nodejs/node-addon-api/commit/90a741ef10)] - build(deps): bump step-security/harden-runner from 2.5.1 to 2.6.0 (dependabot\[bot]) [#1386](https://github.com/nodejs/node-addon-api/pull/1386)
38
+ * \[[`7e1aa06132`](https://github.com/nodejs/node-addon-api/commit/7e1aa06132)] - Update LICENSE.md (Michael Dawson) [#1385](https://github.com/nodejs/node-addon-api/pull/1385)
39
+ * \[[`0a0612362e`](https://github.com/nodejs/node-addon-api/commit/0a0612362e)] - build(deps): bump github/codeql-action from 2.21.7 to 2.21.9 (dependabot\[bot]) [#1384](https://github.com/nodejs/node-addon-api/pull/1384)
40
+ * \[[`47bd430da2`](https://github.com/nodejs/node-addon-api/commit/47bd430da2)] - build(deps): bump actions/checkout from 4.0.0 to 4.1.0 (dependabot\[bot]) [#1383](https://github.com/nodejs/node-addon-api/pull/1383)
41
+ * \[[`b3f7f73cb9`](https://github.com/nodejs/node-addon-api/commit/b3f7f73cb9)] - build(deps): bump actions/dependency-review-action from 3.0.8 to 3.1.0 (dependabot\[bot]) [#1377](https://github.com/nodejs/node-addon-api/pull/1377)
42
+ * \[[`12c1655387`](https://github.com/nodejs/node-addon-api/commit/12c1655387)] - build(deps): bump github/codeql-action from 2.21.6 to 2.21.7 (dependabot\[bot]) [#1380](https://github.com/nodejs/node-addon-api/pull/1380)
43
+ * \[[`6abed318e4`](https://github.com/nodejs/node-addon-api/commit/6abed318e4)] - build(deps): bump github/codeql-action from 2.21.5 to 2.21.6 (dependabot\[bot]) [#1378](https://github.com/nodejs/node-addon-api/pull/1378)
44
+ * \[[`89eda59930`](https://github.com/nodejs/node-addon-api/commit/89eda59930)] - build(deps): bump actions/upload-artifact from 3.1.2 to 3.1.3 (dependabot\[bot]) [#1376](https://github.com/nodejs/node-addon-api/pull/1376)
45
+ * \[[`90870dbffa`](https://github.com/nodejs/node-addon-api/commit/90870dbffa)] - build(deps): bump actions/checkout from 3.6.0 to 4.0.0 (dependabot\[bot]) [#1375](https://github.com/nodejs/node-addon-api/pull/1375)
46
+ * \[[`b860793eff`](https://github.com/nodejs/node-addon-api/commit/b860793eff)] - build(deps): bump github/codeql-action from 2.21.2 to 2.21.5 (dependabot\[bot]) [#1372](https://github.com/nodejs/node-addon-api/pull/1372)
47
+ * \[[`f9b9974b4a`](https://github.com/nodejs/node-addon-api/commit/f9b9974b4a)] - build(deps): bump actions/checkout from 3.5.3 to 3.6.0 (dependabot\[bot]) [#1371](https://github.com/nodejs/node-addon-api/pull/1371)
48
+ * \[[`9596e3de2d`](https://github.com/nodejs/node-addon-api/commit/9596e3de2d)] - build(deps): bump actions/setup-node from 3.7.0 to 3.8.1 (dependabot\[bot]) [#1370](https://github.com/nodejs/node-addon-api/pull/1370)
49
+ * \[[`e969210747`](https://github.com/nodejs/node-addon-api/commit/e969210747)] - build(deps): bump actions/dependency-review-action from 3.0.6 to 3.0.8 (dependabot\[bot]) [#1368](https://github.com/nodejs/node-addon-api/pull/1368)
50
+ * \[[`13ef96a5a9`](https://github.com/nodejs/node-addon-api/commit/13ef96a5a9)] - build(deps): bump step-security/harden-runner from 2.5.0 to 2.5.1 (dependabot\[bot]) [#1364](https://github.com/nodejs/node-addon-api/pull/1364)
51
+ * \[[`9776d148b3`](https://github.com/nodejs/node-addon-api/commit/9776d148b3)] - build(deps): bump github/codeql-action from 2.21.1 to 2.21.2 (dependabot\[bot]) [#1358](https://github.com/nodejs/node-addon-api/pull/1358)
52
+ * \[[`59dc6be097`](https://github.com/nodejs/node-addon-api/commit/59dc6be097)] - build(deps): bump github/codeql-action from 2.21.0 to 2.21.1 (dependabot\[bot]) [#1357](https://github.com/nodejs/node-addon-api/pull/1357)
53
+ * \[[`5e72796cd5`](https://github.com/nodejs/node-addon-api/commit/5e72796cd5)] - build(deps): bump step-security/harden-runner from 2.4.1 to 2.5.0 (dependabot\[bot]) [#1356](https://github.com/nodejs/node-addon-api/pull/1356)
54
+ * \[[`4e62db45e4`](https://github.com/nodejs/node-addon-api/commit/4e62db45e4)] - build(deps): bump github/codeql-action from 2.20.3 to 2.21.0 (dependabot\[bot]) [#1353](https://github.com/nodejs/node-addon-api/pull/1353)
55
+ * \[[`0c093a33e8`](https://github.com/nodejs/node-addon-api/commit/0c093a33e8)] - build(deps): bump github/codeql-action from 2.20.1 to 2.20.3 (dependabot\[bot]) [#1349](https://github.com/nodejs/node-addon-api/pull/1349)
56
+ * \[[`5523b2d3fa`](https://github.com/nodejs/node-addon-api/commit/5523b2d3fa)] - build(deps): bump actions/setup-node from 3.6.0 to 3.7.0 (dependabot\[bot]) [#1348](https://github.com/nodejs/node-addon-api/pull/1348)
57
+ * \[[`afa494ef7f`](https://github.com/nodejs/node-addon-api/commit/afa494ef7f)] - Add Node.js version restrictions (Ingo Fischer) [#1340](https://github.com/nodejs/node-addon-api/pull/1340)
58
+ * \[[`ac4c87f660`](https://github.com/nodejs/node-addon-api/commit/ac4c87f660)] - build(deps): bump ossf/scorecard-action from 2.0.6 to 2.2.0 (dependabot\[bot]) [#1344](https://github.com/nodejs/node-addon-api/pull/1344)
59
+ * \[[`47aeb6689d`](https://github.com/nodejs/node-addon-api/commit/47aeb6689d)] - build(deps): bump github/codeql-action from 2.2.12 to 2.20.1 (dependabot\[bot]) [#1343](https://github.com/nodejs/node-addon-api/pull/1343)
60
+ * \[[`bd45a8fffc`](https://github.com/nodejs/node-addon-api/commit/bd45a8fffc)] - build(deps): bump step-security/harden-runner from 2.3.0 to 2.4.1 (dependabot\[bot]) [#1342](https://github.com/nodejs/node-addon-api/pull/1342)
61
+ * \[[`343a1e1708`](https://github.com/nodejs/node-addon-api/commit/343a1e1708)] - build(deps-dev): bump fs-extra from 9.1.0 to 11.1.1 (dependabot\[bot]) [#1335](https://github.com/nodejs/node-addon-api/pull/1335)
62
+ * \[[`4168c10182`](https://github.com/nodejs/node-addon-api/commit/4168c10182)] - build(deps): bump actions/stale from 5.2.1 to 8.0.0 (dependabot\[bot]) [#1333](https://github.com/nodejs/node-addon-api/pull/1333)
63
+ * \[[`1c182abd1f`](https://github.com/nodejs/node-addon-api/commit/1c182abd1f)] - build(deps): bump actions/dependency-review-action from 2.5.1 to 3.0.6 (dependabot\[bot]) [#1331](https://github.com/nodejs/node-addon-api/pull/1331)
64
+ * \[[`717a61931d`](https://github.com/nodejs/node-addon-api/commit/717a61931d)] - build(deps): bump actions/checkout from 3.5.2 to 3.5.3 (dependabot\[bot]) [#1329](https://github.com/nodejs/node-addon-api/pull/1329)
65
+ * \[[`d605d62c89`](https://github.com/nodejs/node-addon-api/commit/d605d62c89)] - **chore**: lock python version in actions (Chengzhong Wu) [#1403](https://github.com/nodejs/node-addon-api/pull/1403)
66
+ * \[[`734e3f2509`](https://github.com/nodejs/node-addon-api/commit/734e3f2509)] - **doc**: fix rendering of code blocks in list (Tobias Nießen) [#1401](https://github.com/nodejs/node-addon-api/pull/1401)
67
+ * \[[`dfdf6eb6e6`](https://github.com/nodejs/node-addon-api/commit/dfdf6eb6e6)] - **doc**: add missing title IsBigInt (Marx) [#1352](https://github.com/nodejs/node-addon-api/pull/1352)
68
+ * \[[`8850997f38`](https://github.com/nodejs/node-addon-api/commit/8850997f38)] - **doc**: fix typo AsyncProgressWorker::ExecutionProgress (JerryZhongJ) [#1350](https://github.com/nodejs/node-addon-api/pull/1350)
69
+ * \[[`8192a471a1`](https://github.com/nodejs/node-addon-api/commit/8192a471a1)] - **docs**: fixed Broken Links (Ömer AKGÜL) [#1405](https://github.com/nodejs/node-addon-api/pull/1405)
70
+ * \[[`16a18c047a`](https://github.com/nodejs/node-addon-api/commit/16a18c047a)] - **fix**: handle c++ exception in TSFN callback (Chengzhong Wu) [#1345](https://github.com/nodejs/node-addon-api/pull/1345)
71
+ * \[[`ab14347080`](https://github.com/nodejs/node-addon-api/commit/ab14347080)] - **gyp**: add common targets (Chengzhong Wu) [#1389](https://github.com/nodejs/node-addon-api/pull/1389)
72
+ * \[[`fa3518bc08`](https://github.com/nodejs/node-addon-api/commit/fa3518bc08)] - **src**: remove duplicate buffer info calls (Chengzhong Wu) [#1354](https://github.com/nodejs/node-addon-api/pull/1354)
73
+ * \[[`b83e453e6e`](https://github.com/nodejs/node-addon-api/commit/b83e453e6e)] - **src**: add Env::GetModuleFileName (Kevin Eady) [#1327](https://github.com/nodejs/node-addon-api/pull/1327)
74
+ * \[[`d9828c6264`](https://github.com/nodejs/node-addon-api/commit/d9828c6264)] - **src**: add SyntaxError (Kevin Eady) [#1326](https://github.com/nodejs/node-addon-api/pull/1326)
75
+ * \[[`c52e764bb2`](https://github.com/nodejs/node-addon-api/commit/c52e764bb2)] - **src,test,build**: allow NAPI\_VERSION env var and templatize AttachData callback (Gabriel Schulhof) [#1399](https://github.com/nodejs/node-addon-api/pull/1399)
76
+ * \[[`8f028d630a`](https://github.com/nodejs/node-addon-api/commit/8f028d630a)] - **test**: remove experimental flag from bigint (Gabriel Schulhof) [#1395](https://github.com/nodejs/node-addon-api/pull/1395)
77
+ * \[[`414be9e000`](https://github.com/nodejs/node-addon-api/commit/414be9e000)] - **test**: run interfering tests in their own process (Gabriel Schulhof) [#1325](https://github.com/nodejs/node-addon-api/pull/1325)
78
+
3
79
  ## 2023-06-13 Version 7.0.0, @KevinEady
4
80
 
5
81
  ### Notable changes
@@ -1,13 +1,9 @@
1
1
  The MIT License (MIT)
2
- =====================
3
2
 
4
- Copyright (c) 2017 Node.js API collaborators
5
- -----------------------------------
6
-
7
- *Node.js API collaborators listed at <https://github.com/nodejs/node-addon-api#collaborators>*
3
+ Copyright (c) 2017 [Node.js API collaborators](https://github.com/nodejs/node-addon-api#collaborators)
8
4
 
9
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
6
 
11
7
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
8
 
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -70,7 +70,7 @@ and node-addon-api.
70
70
  - **[Contributors](#contributors)**
71
71
  - **[License](#license)**
72
72
 
73
- ## **Current version: 7.0.0**
73
+ ## **Current version: 7.1.0**
74
74
 
75
75
  (See [CHANGELOG.md](CHANGELOG.md) for complete Changelog)
76
76
 
@@ -132,6 +132,7 @@ The following is the documentation for node-addon-api.
132
132
  - [Error](doc/error.md)
133
133
  - [TypeError](doc/type_error.md)
134
134
  - [RangeError](doc/range_error.md)
135
+ - [SyntaxError](doc/syntax_error.md)
135
136
  - [Object Lifetime Management](doc/object_lifetime_management.md)
136
137
  - [HandleScope](doc/handle_scope.md)
137
138
  - [EscapableHandleScope](doc/escapable_handle_scope.md)
@@ -152,14 +153,14 @@ The following is the documentation for node-addon-api.
152
153
 
153
154
  Are you new to **node-addon-api**? Take a look at our **[examples](https://github.com/nodejs/node-addon-examples)**
154
155
 
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)**
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)**
163
164
 
164
165
  <a name="tests"></a>
165
166
 
@@ -4,22 +4,22 @@
4
4
  {
5
5
  'target_name': 'function_args',
6
6
  'sources': [ 'function_args.cc' ],
7
- 'includes': [ '../except.gypi' ],
7
+ 'dependencies': ['../node_addon_api.gyp:node_addon_api_except'],
8
8
  },
9
9
  {
10
10
  'target_name': 'function_args_noexcept',
11
11
  'sources': [ 'function_args.cc' ],
12
- 'includes': [ '../noexcept.gypi' ],
12
+ 'dependencies': ['../node_addon_api.gyp:node_addon_api'],
13
13
  },
14
14
  {
15
15
  'target_name': 'property_descriptor',
16
16
  'sources': [ 'property_descriptor.cc' ],
17
- 'includes': [ '../except.gypi' ],
17
+ 'dependencies': ['../node_addon_api.gyp:node_addon_api_except'],
18
18
  },
19
19
  {
20
20
  'target_name': 'property_descriptor_noexcept',
21
21
  'sources': [ 'property_descriptor.cc' ],
22
- 'includes': [ '../noexcept.gypi' ],
22
+ 'dependencies': ['../node_addon_api.gyp:node_addon_api'],
23
23
  },
24
24
  ]
25
25
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  'variables': {
3
- 'NAPI_VERSION%': "<!(node -p \"process.versions.napi\")",
3
+ 'NAPI_VERSION%': "<!(node -p \"process.env.NAPI_VERSION || process.versions.napi\")",
4
4
  'disable_deprecated': "<!(node -p \"process.env['npm_config_disable_deprecated']\")"
5
5
  },
6
6
  'conditions': [
@@ -15,7 +15,6 @@
15
15
  }
16
16
  }]
17
17
  ],
18
- 'include_dirs': ["<!(node -p \"require('../').include_dir\")"],
19
18
  'cflags': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ],
20
19
  'cflags_cc': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ]
21
20
  }
@@ -9,7 +9,7 @@ around `napi_value` representing a JavaScript Array.
9
9
  types such as [`Napi::Int32Array`][] and [`Napi::ArrayBuffer`][], respectively,
10
10
  that can be used for transferring large amounts of data from JavaScript to the
11
11
  native side. An example illustrating the use of a JavaScript-provided
12
- `ArrayBuffer` in native code is available [here](https://github.com/nodejs/node-addon-examples/tree/HEAD/array_buffer_to_native/node-addon-api).
12
+ `ArrayBuffer` in native code is available [here](https://github.com/nodejs/node-addon-examples/tree/main/src/2-js-to-native-conversion/array_buffer_to_native/node-addon-api).
13
13
 
14
14
  ## Constructor
15
15
  ```cpp
@@ -52,9 +52,9 @@ virtual void Napi::AsyncProgressWorker::OnOK();
52
52
  ### OnProgress
53
53
 
54
54
  This method is invoked when the computation in the
55
- `Napi::AsyncProgressWorker::ExecutionProcess::Send` method was called during
55
+ `Napi::AsyncProgressWorker::ExecutionProgress::Send` method was called during
56
56
  worker thread execution. This method can also be triggered via a call to
57
- `Napi::AsyncProgress[Queue]Worker::ExecutionProcess::Signal`, in which case the
57
+ `Napi::AsyncProgress[Queue]Worker::ExecutionProgress::Signal`, in which case the
58
58
  `data` parameter will be `nullptr`.
59
59
 
60
60
  ```cpp
@@ -227,7 +227,7 @@ unexpected upcoming thread safe calls.
227
227
  virtual Napi::AsyncProgressWorker::~AsyncProgressWorker();
228
228
  ```
229
229
 
230
- # AsyncProgressWorker::ExecutionProcess
230
+ # AsyncProgressWorker::ExecutionProgress
231
231
 
232
232
  A bridge class created before the worker thread execution of `Napi::AsyncProgressWorker::Execute`.
233
233
 
@@ -235,15 +235,15 @@ A bridge class created before the worker thread execution of `Napi::AsyncProgres
235
235
 
236
236
  ### Send
237
237
 
238
- `Napi::AsyncProgressWorker::ExecutionProcess::Send` takes two arguments, a pointer
238
+ `Napi::AsyncProgressWorker::ExecutionProgress::Send` takes two arguments, a pointer
239
239
  to a generic type of data, and a `size_t` to indicate how many items the pointer is
240
240
  pointing to.
241
241
 
242
242
  The data pointed to will be copied to internal slots of `Napi::AsyncProgressWorker` so
243
- after the call to `Napi::AsyncProgressWorker::ExecutionProcess::Send` the data can
243
+ after the call to `Napi::AsyncProgressWorker::ExecutionProgress::Send` the data can
244
244
  be safely released.
245
245
 
246
- Note that `Napi::AsyncProgressWorker::ExecutionProcess::Send` merely guarantees
246
+ Note that `Napi::AsyncProgressWorker::ExecutionProgress::Send` merely guarantees
247
247
  **eventual** invocation of `Napi::AsyncProgressWorker::OnProgress`, which means
248
248
  multiple send might be coalesced into single invocation of `Napi::AsyncProgressWorker::OnProgress`
249
249
  with latest data. If you would like to guarantee that there is one invocation of
@@ -251,16 +251,16 @@ with latest data. If you would like to guarantee that there is one invocation of
251
251
  class instead which is documented further down this page.
252
252
 
253
253
  ```cpp
254
- void Napi::AsyncProgressWorker::ExecutionProcess::Send(const T* data, size_t count) const;
254
+ void Napi::AsyncProgressWorker::ExecutionProgress::Send(const T* data, size_t count) const;
255
255
  ```
256
256
 
257
257
  ### Signal
258
258
 
259
- `Napi::AsyncProgressWorker::ExecutionProcess::Signal` triggers an invocation of
259
+ `Napi::AsyncProgressWorker::ExecutionProgress::Signal` triggers an invocation of
260
260
  `Napi::AsyncProgressWorker::OnProgress` with `nullptr` as the `data` parameter.
261
261
 
262
262
  ```cpp
263
- void Napi::AsyncProgressWorker::ExecutionProcess::Signal();
263
+ void Napi::AsyncProgressWorker::ExecutionProgress::Signal();
264
264
  ```
265
265
 
266
266
  ## Example
@@ -402,7 +402,7 @@ thread in the order it was committed.
402
402
  For the most basic use, only the `Napi::AsyncProgressQueueWorker::Execute` and
403
403
  `Napi::AsyncProgressQueueWorker::OnProgress` method must be implemented in a subclass.
404
404
 
405
- # AsyncProgressQueueWorker::ExecutionProcess
405
+ # AsyncProgressQueueWorker::ExecutionProgress
406
406
 
407
407
  A bridge class created before the worker thread execution of `Napi::AsyncProgressQueueWorker::Execute`.
408
408
 
@@ -410,30 +410,30 @@ A bridge class created before the worker thread execution of `Napi::AsyncProgres
410
410
 
411
411
  ### Send
412
412
 
413
- `Napi::AsyncProgressQueueWorker::ExecutionProcess::Send` takes two arguments, a pointer
413
+ `Napi::AsyncProgressQueueWorker::ExecutionProgress::Send` takes two arguments, a pointer
414
414
  to a generic type of data, and a `size_t` to indicate how many items the pointer is
415
415
  pointing to.
416
416
 
417
417
  The data pointed to will be copied to internal slots of `Napi::AsyncProgressQueueWorker` so
418
- after the call to `Napi::AsyncProgressQueueWorker::ExecutionProcess::Send` the data can
418
+ after the call to `Napi::AsyncProgressQueueWorker::ExecutionProgress::Send` the data can
419
419
  be safely released.
420
420
 
421
- `Napi::AsyncProgressQueueWorker::ExecutionProcess::Send` guarantees invocation
421
+ `Napi::AsyncProgressQueueWorker::ExecutionProgress::Send` guarantees invocation
422
422
  of `Napi::AsyncProgressQueueWorker::OnProgress`, which means multiple `Send`
423
423
  call will result in the in-order invocation of `Napi::AsyncProgressQueueWorker::OnProgress`
424
424
  with each data item.
425
425
 
426
426
  ```cpp
427
- void Napi::AsyncProgressQueueWorker::ExecutionProcess::Send(const T* data, size_t count) const;
427
+ void Napi::AsyncProgressQueueWorker::ExecutionProgress::Send(const T* data, size_t count) const;
428
428
  ```
429
429
 
430
430
  ### Signal
431
431
 
432
- `Napi::AsyncProgressQueueWorker::ExecutionProcess::Signal` triggers an invocation of
432
+ `Napi::AsyncProgressQueueWorker::ExecutionProgress::Signal` triggers an invocation of
433
433
  `Napi::AsyncProgressQueueWorker::OnProgress` with `nullptr` as the `data` parameter.
434
434
 
435
435
  ```cpp
436
- void Napi::AsyncProgressQueueWorker::ExecutionProcess::Signal() const;
436
+ void Napi::AsyncProgressQueueWorker::ExecutionProgress::Signal() const;
437
437
  ```
438
438
 
439
439
  ## Example
@@ -51,7 +51,7 @@ If your Node-API native add-on uses the optional [**node-addon-api**](https://gi
51
51
 
52
52
  ## Example
53
53
 
54
- A working example of an Node-API native addon built using CMake.js can be found on the [node-addon-examples repository](https://github.com/nodejs/node-addon-examples/tree/HEAD/build_with_cmake#building-n-api-addons-using-cmakejs).
54
+ A working example of an Node-API native addon built using CMake.js can be found on the [node-addon-examples repository](https://github.com/nodejs/node-addon-examples/tree/main/src/8-tooling/build_with_cmake#building-node-api-addons-using-cmakejs).
55
55
 
56
56
  ## **CMake** Reference
57
57
 
@@ -131,6 +131,17 @@ addon. The item will be passed to the function `fini` which gets called when an
131
131
  instance of the addon is unloaded. This overload accepts an additional hint to
132
132
  be passed to `fini`.
133
133
 
134
+ ### GetModuleFileName
135
+
136
+ ```cpp
137
+ const char* Napi::Env::GetModuleFileName() const;
138
+ ```
139
+
140
+ Returns a A URL containing the absolute path of the location from which the
141
+ add-on was loaded. For a file on the local file system it will start with
142
+ `file://`. The string is null-terminated and owned by env and must thus not be
143
+ modified or freed. It is only valid while the add-on is loaded.
144
+
134
145
  ### AddCleanupHook
135
146
 
136
147
  ```cpp
@@ -37,6 +37,7 @@
37
37
  | [`Napi::Reference`] | |
38
38
  | [`Napi::String`][] | [`Napi::Name`][] |
39
39
  | [`Napi::Symbol`][] | [`Napi::Name`][] |
40
+ | [`Napi::SyntaxError`][] | [`Napi::Error`][] |
40
41
  | [`Napi::ThreadSafeFunction`][] | |
41
42
  | [`Napi::TypeTaggable`][] | [`Napi::Value][] |
42
43
  | [`Napi::TypeError`][] | [`Napi::Error`][] |
@@ -82,6 +83,7 @@
82
83
  [`Napi::Reference<Napi::Object>`]: ./reference.md
83
84
  [`Napi::String`]: ./string.md
84
85
  [`Napi::Symbol`]: ./symbol.md
86
+ [`Napi::SyntaxError`]: ./syntax_error.md
85
87
  [`Napi::ThreadSafeFunction`]: ./threadsafe_function.md
86
88
  [`Napi::TypeError`]: ./type_error.md
87
89
  [`Napi::TypeTaggable`]: ./type_taggable.md