koffi 2.12.1 → 2.12.2

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 (188) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE.txt +2 -2
  3. package/README.md +8 -8
  4. package/build/koffi/darwin_arm64/koffi.node +0 -0
  5. package/build/koffi/darwin_x64/koffi.node +0 -0
  6. package/build/koffi/freebsd_arm64/koffi.node +0 -0
  7. package/build/koffi/freebsd_ia32/koffi.node +0 -0
  8. package/build/koffi/freebsd_x64/koffi.node +0 -0
  9. package/build/koffi/linux_arm64/koffi.node +0 -0
  10. package/build/koffi/linux_armhf/koffi.node +0 -0
  11. package/build/koffi/linux_ia32/koffi.node +0 -0
  12. package/build/koffi/linux_loong64/koffi.node +0 -0
  13. package/build/koffi/linux_riscv64d/koffi.node +0 -0
  14. package/build/koffi/linux_x64/koffi.node +0 -0
  15. package/build/koffi/musl_arm64/koffi.node +0 -0
  16. package/build/koffi/musl_x64/koffi.node +0 -0
  17. package/build/koffi/openbsd_ia32/koffi.node +0 -0
  18. package/build/koffi/openbsd_x64/koffi.node +0 -0
  19. package/build/koffi/win32_arm64/koffi.exp +0 -0
  20. package/build/koffi/win32_arm64/koffi.node +0 -0
  21. package/build/koffi/win32_ia32/koffi.exp +0 -0
  22. package/build/koffi/win32_ia32/koffi.node +0 -0
  23. package/build/koffi/win32_x64/koffi.exp +0 -0
  24. package/build/koffi/win32_x64/koffi.node +0 -0
  25. package/doc/assets.ini +3 -3
  26. package/doc/develop.sh +4 -3
  27. package/doc/pages/platforms.md +1 -1
  28. package/doc/static/highlight.js +1 -1
  29. package/doc/static/koffi.css +3 -2
  30. package/doc/static/print.css +1 -1
  31. package/doc/templates/code.html +5 -5
  32. package/doc/templates/page.html +4 -4
  33. package/index.d.ts +2 -2
  34. package/index.js +32 -32
  35. package/indirect.js +32 -12
  36. package/package.json +2 -2
  37. package/src/cnoke/LICENSE.txt +2 -2
  38. package/src/cnoke/README.md +2 -0
  39. package/src/cnoke/assets/FindCNoke.cmake +12 -2
  40. package/src/cnoke/assets/win_delay_hook.c +4 -4
  41. package/src/cnoke/cnoke.js +4 -2
  42. package/src/cnoke/package.json +1 -1
  43. package/src/cnoke/src/builder.js +11 -14
  44. package/src/cnoke/src/index.js +2 -2
  45. package/src/cnoke/src/tools.js +34 -2
  46. package/src/core/{libcc/libcc.cc → base/base.cc} +3092 -1674
  47. package/src/core/{libcc/libcc.hh → base/base.hh} +3059 -2432
  48. package/src/core/{libcc → base}/mimetypes.inc +42 -4
  49. package/src/core/{libcc → base}/mimetypes_gen.py +3 -3
  50. package/src/core/unicode/generate.py +124 -0
  51. package/src/core/unicode/xid.cc +52 -0
  52. package/src/core/unicode/xid.hh +29 -0
  53. package/src/core/unicode/xid.inc +465 -0
  54. package/src/koffi/CMakeLists.txt +8 -5
  55. package/src/koffi/cmake/raylib.cmake +6 -2
  56. package/src/koffi/cmake/{sqlite.cmake → sqlite3.cmake} +3 -3
  57. package/src/koffi/examples/electron-forge/forge.config.js +23 -3
  58. package/src/koffi/examples/electron-forge/package.json +18 -16
  59. package/src/koffi/src/abi_arm32.cc +7 -7
  60. package/src/koffi/src/abi_arm32_asm.S +2 -2
  61. package/src/koffi/src/abi_arm64.cc +45 -45
  62. package/src/koffi/src/abi_arm64_asm.S +4 -4
  63. package/src/koffi/src/abi_arm64_asm.asm +2 -2
  64. package/src/koffi/src/abi_loong64_asm.S +2 -2
  65. package/src/koffi/src/abi_riscv64.cc +5 -5
  66. package/src/koffi/src/abi_riscv64_asm.S +2 -2
  67. package/src/koffi/src/abi_x64_sysv.cc +3 -3
  68. package/src/koffi/src/abi_x64_sysv_asm.S +5 -5
  69. package/src/koffi/src/abi_x64_win.cc +3 -3
  70. package/src/koffi/src/abi_x64_win_asm.asm +2 -2
  71. package/src/koffi/src/abi_x86.cc +8 -8
  72. package/src/koffi/src/abi_x86_asm.S +2 -2
  73. package/src/koffi/src/abi_x86_asm.asm +2 -2
  74. package/src/koffi/src/call.cc +12 -12
  75. package/src/koffi/src/call.hh +8 -8
  76. package/src/koffi/src/errno.inc +152 -152
  77. package/src/koffi/src/ffi.cc +45 -39
  78. package/src/koffi/src/ffi.hh +6 -6
  79. package/src/koffi/src/init.js +1 -1
  80. package/src/koffi/src/parser.cc +6 -5
  81. package/src/koffi/src/parser.hh +3 -3
  82. package/src/koffi/src/trampolines/armasm.inc +2 -2
  83. package/src/koffi/src/trampolines/gnu.inc +2 -2
  84. package/src/koffi/src/trampolines/masm32.inc +2 -2
  85. package/src/koffi/src/trampolines/masm64.inc +2 -2
  86. package/src/koffi/src/trampolines/prototypes.inc +2 -2
  87. package/src/koffi/src/util.cc +9 -9
  88. package/src/koffi/src/util.hh +3 -3
  89. package/src/koffi/src/win32.cc +5 -5
  90. package/src/koffi/src/win32.hh +9 -9
  91. package/vendor/node-addon-api/CHANGELOG.md +97 -2
  92. package/vendor/node-addon-api/CONTRIBUTING.md +117 -7
  93. package/vendor/node-addon-api/README.md +25 -249
  94. package/vendor/node-addon-api/common.gypi +1 -0
  95. package/vendor/node-addon-api/doc/README.md +145 -0
  96. package/vendor/node-addon-api/doc/array_buffer.md +15 -15
  97. package/vendor/node-addon-api/doc/basic_env.md +200 -0
  98. package/vendor/node-addon-api/doc/buffer.md +24 -26
  99. package/vendor/node-addon-api/doc/cmake-js.md +19 -0
  100. package/vendor/node-addon-api/doc/{creating_a_release.md → contributing/creating_a_release.md} +16 -4
  101. package/vendor/node-addon-api/doc/env.md +11 -131
  102. package/vendor/node-addon-api/doc/error_handling.md +12 -0
  103. package/vendor/node-addon-api/doc/external.md +13 -4
  104. package/vendor/node-addon-api/doc/finalization.md +153 -0
  105. package/vendor/node-addon-api/doc/memory_management.md +1 -1
  106. package/vendor/node-addon-api/doc/object_wrap.md +19 -3
  107. package/vendor/node-addon-api/doc/promises.md +51 -0
  108. package/vendor/node-addon-api/doc/setup.md +29 -6
  109. package/vendor/node-addon-api/doc/value.md +13 -0
  110. package/vendor/node-addon-api/doc/version_management.md +2 -2
  111. package/vendor/node-addon-api/eslint.config.js +5 -0
  112. package/vendor/node-addon-api/index.js +2 -0
  113. package/vendor/node-addon-api/napi-inl.h +592 -166
  114. package/vendor/node-addon-api/napi.h +167 -59
  115. package/vendor/node-addon-api/node_addon_api.gyp +10 -0
  116. package/vendor/node-addon-api/noexcept.gypi +1 -1
  117. package/vendor/node-addon-api/package.json +10 -13
  118. package/vendor/node-addon-api/release-please-config.json +15 -0
  119. package/vendor/node-addon-api/test/addon_build/tpl/binding.gyp +2 -1
  120. package/vendor/node-addon-api/test/array_buffer.js +1 -1
  121. package/vendor/node-addon-api/test/async_context.js +2 -2
  122. package/vendor/node-addon-api/test/async_progress_queue_worker.js +3 -3
  123. package/vendor/node-addon-api/test/async_progress_worker.js +3 -3
  124. package/vendor/node-addon-api/test/async_worker.cc +15 -13
  125. package/vendor/node-addon-api/test/async_worker.js +5 -5
  126. package/vendor/node-addon-api/test/basic_types/value.cc +6 -0
  127. package/vendor/node-addon-api/test/basic_types/value.js +17 -0
  128. package/vendor/node-addon-api/test/binding.cc +8 -0
  129. package/vendor/node-addon-api/test/binding.gyp +23 -1
  130. package/vendor/node-addon-api/test/buffer.js +1 -2
  131. package/vendor/node-addon-api/test/common/index.js +1 -1
  132. package/vendor/node-addon-api/test/except_all.cc +22 -0
  133. package/vendor/node-addon-api/test/except_all.js +14 -0
  134. package/vendor/node-addon-api/test/exports.js +19 -0
  135. package/vendor/node-addon-api/test/finalizer_order.cc +152 -0
  136. package/vendor/node-addon-api/test/finalizer_order.js +98 -0
  137. package/vendor/node-addon-api/test/function.js +2 -2
  138. package/vendor/node-addon-api/test/function_reference.js +2 -2
  139. package/vendor/node-addon-api/test/globalObject/global_object_delete_property.cc +4 -4
  140. package/vendor/node-addon-api/test/globalObject/global_object_get_property.cc +4 -4
  141. package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.cc +3 -3
  142. package/vendor/node-addon-api/test/globalObject/global_object_set_property.cc +5 -5
  143. package/vendor/node-addon-api/test/name.cc +10 -8
  144. package/vendor/node-addon-api/test/object/delete_property.cc +5 -5
  145. package/vendor/node-addon-api/test/object/get_property.cc +5 -5
  146. package/vendor/node-addon-api/test/object/has_own_property.cc +4 -4
  147. package/vendor/node-addon-api/test/object/has_property.cc +5 -5
  148. package/vendor/node-addon-api/test/object/object.cc +1 -1
  149. package/vendor/node-addon-api/test/object/set_property.cc +5 -5
  150. package/vendor/node-addon-api/test/object/subscript_operator.cc +3 -3
  151. package/vendor/node-addon-api/test/object_reference.cc +18 -18
  152. package/vendor/node-addon-api/test/promise.cc +75 -0
  153. package/vendor/node-addon-api/test/promise.js +23 -0
  154. package/vendor/node-addon-api/test/require_basic_finalizers/index.js +38 -0
  155. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/addon.cc +12 -0
  156. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/binding.gyp +48 -0
  157. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/index.js +3 -0
  158. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/package.json +11 -0
  159. package/vendor/node-addon-api/test/run_script.cc +1 -1
  160. package/vendor/node-addon-api/test/type_taggable.cc +1 -1
  161. package/vendor/node-addon-api/test/type_taggable.js +3 -4
  162. package/vendor/node-addon-api/test/typedarray.cc +28 -24
  163. package/vendor/node-addon-api/tools/conversion.js +1 -1
  164. package/vendor/node-api-headers/CHANGELOG.md +29 -0
  165. package/vendor/node-api-headers/CREATING_A_RELEASE.md +12 -2
  166. package/vendor/node-api-headers/def/js_native_api.def +6 -1
  167. package/vendor/node-api-headers/def/node_api.def +7 -1
  168. package/vendor/node-api-headers/include/js_native_api.h +56 -24
  169. package/vendor/node-api-headers/include/js_native_api_types.h +27 -0
  170. package/vendor/node-api-headers/include/node_api.h +38 -29
  171. package/vendor/node-api-headers/lib/parse-utils.js +92 -0
  172. package/vendor/node-api-headers/package.json +7 -7
  173. package/vendor/node-api-headers/release-please-config.json +12 -0
  174. package/vendor/node-api-headers/scripts/update-headers.js +63 -12
  175. package/vendor/node-api-headers/scripts/write-symbols.js +1 -1
  176. package/vendor/node-api-headers/symbols.js +17 -1
  177. package/vendor/node-api-headers/test/parse-utils.js +21 -0
  178. package/doc/flat/flat.css +0 -27
  179. package/doc/flat/normal.css +0 -429
  180. package/doc/flat/print.css +0 -29
  181. package/doc/flat/reset.css +0 -41
  182. package/doc/flat/small.css +0 -104
  183. package/doc/flat/static.js +0 -161
  184. package/src/core/libcc/brotli.cc +0 -186
  185. package/src/core/libcc/lz4.cc +0 -197
  186. package/src/core/libcc/miniz.cc +0 -353
  187. package/vendor/node-addon-api/tools/eslint-format.js +0 -79
  188. /package/vendor/node-api-headers/{scripts → lib}/clang-utils.js +0 -0
@@ -0,0 +1,48 @@
1
+ {
2
+ 'target_defaults': {
3
+ 'include_dirs': [
4
+ "<!(node -p \"require('node-addon-api').include_dir\")"
5
+ ],
6
+ 'variables': {
7
+ 'NAPI_VERSION%': "<!(node -p \"process.env.NAPI_VERSION || process.versions.napi\")",
8
+ 'require_basic_finalizers': "<!(node -p \"process.env['npm_config_require_basic_finalizers']\")",
9
+ },
10
+ 'conditions': [
11
+ ['NAPI_VERSION!=""', { 'defines': ['NAPI_VERSION=<@(NAPI_VERSION)'] } ],
12
+ ['NAPI_VERSION==2147483647', { 'defines': ['NAPI_EXPERIMENTAL'] } ],
13
+ ['require_basic_finalizers=="true"', {
14
+ 'defines': ['NODE_ADDON_API_REQUIRE_BASIC_FINALIZERS'],
15
+ }],
16
+ ['OS=="mac"', {
17
+ 'cflags+': ['-fvisibility=hidden'],
18
+ 'xcode_settings': {
19
+ 'OTHER_CFLAGS': ['-fvisibility=hidden']
20
+ }
21
+ }]
22
+ ],
23
+ 'sources': [
24
+ 'addon.cc',
25
+ ],
26
+ },
27
+ 'targets': [
28
+ {
29
+ 'target_name': 'addon',
30
+ 'defines': [
31
+ 'NAPI_CPP_EXCEPTIONS'
32
+ ],
33
+ 'cflags!': [ '-fno-exceptions' ],
34
+ 'cflags_cc!': [ '-fno-exceptions' ],
35
+ 'msvs_settings': {
36
+ 'VCCLCompilerTool': {
37
+ 'ExceptionHandling': 1,
38
+ 'EnablePREfast': 'true',
39
+ },
40
+ },
41
+ 'xcode_settings': {
42
+ 'CLANG_CXX_LIBRARY': 'libc++',
43
+ 'MACOSX_DEPLOYMENT_TARGET': '10.7',
44
+ 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
45
+ },
46
+ }
47
+ ]
48
+ }
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('bindings')('addon');
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "addon",
3
+ "version": "0.0.0",
4
+ "description": "Node.js addon",
5
+ "private": true,
6
+ "scripts": {},
7
+ "dependencies": {
8
+ "node-addon-api": "file:../../../../"
9
+ },
10
+ "gypfile": true
11
+ }
@@ -18,7 +18,7 @@ Value RunStdString(const CallbackInfo& info) {
18
18
 
19
19
  Value RunJsString(const CallbackInfo& info) {
20
20
  Env env = info.Env();
21
- return MaybeUnwrapOr(env.RunScript(info[0].As<String>()), Value());
21
+ return MaybeUnwrapOr(env.RunScript(info[0].UnsafeAs<String>()), Value());
22
22
  }
23
23
 
24
24
  Value RunWithContext(const CallbackInfo& info) {
@@ -26,7 +26,7 @@ class TestTypeTaggable {
26
26
 
27
27
  static Value CheckTypeTag(const CallbackInfo& info) {
28
28
  uint32_t type_index = info[0].As<Number>().Int32Value();
29
- TypeTaggable instance = info[1].As<NodeApiClass>();
29
+ TypeTaggable instance = info[1].UnsafeAs<NodeApiClass>();
30
30
 
31
31
  return Boolean::New(info.Env(),
32
32
  instance.CheckTypeTag(&type_tags[type_index]));
@@ -53,8 +53,7 @@ function testTypeTaggable ({ typeTaggedInstance, checkTypeTag }) {
53
53
  assert.strictEqual(checkTypeTag(4, obj3), false);
54
54
  }
55
55
 
56
- // eslint-disable-next-line camelcase
57
- function test ({ type_taggable }) {
58
- testTypeTaggable(type_taggable.external);
59
- testTypeTaggable(type_taggable.object);
56
+ function test (binding) {
57
+ testTypeTaggable(binding.type_taggable.external);
58
+ testTypeTaggable(binding.type_taggable.object);
60
59
  }
@@ -21,7 +21,7 @@ namespace {
21
21
  Value CreateTypedArray(const CallbackInfo& info) {
22
22
  std::string arrayType = info[0].As<String>();
23
23
  size_t length = info[1].As<Number>().Uint32Value();
24
- ArrayBuffer buffer = info[2].As<ArrayBuffer>();
24
+ Value buffer = info[2];
25
25
  size_t bufferOffset =
26
26
  info[3].IsUndefined() ? 0 : info[3].As<Number>().Uint32Value();
27
27
 
@@ -32,7 +32,7 @@ Value CreateTypedArray(const CallbackInfo& info) {
32
32
  : NAPI_TYPEDARRAY_NEW_BUFFER(Int8Array,
33
33
  info.Env(),
34
34
  length,
35
- buffer,
35
+ buffer.As<ArrayBuffer>(),
36
36
  bufferOffset,
37
37
  napi_int8_array);
38
38
  } else if (arrayType == "uint8") {
@@ -42,7 +42,7 @@ Value CreateTypedArray(const CallbackInfo& info) {
42
42
  : NAPI_TYPEDARRAY_NEW_BUFFER(Uint8Array,
43
43
  info.Env(),
44
44
  length,
45
- buffer,
45
+ buffer.As<ArrayBuffer>(),
46
46
  bufferOffset,
47
47
  napi_uint8_array);
48
48
  } else if (arrayType == "uint8_clamped") {
@@ -50,7 +50,7 @@ Value CreateTypedArray(const CallbackInfo& info) {
50
50
  ? Uint8Array::New(info.Env(), length, napi_uint8_clamped_array)
51
51
  : Uint8Array::New(info.Env(),
52
52
  length,
53
- buffer,
53
+ buffer.As<ArrayBuffer>(),
54
54
  bufferOffset,
55
55
  napi_uint8_clamped_array);
56
56
  } else if (arrayType == "int16") {
@@ -60,7 +60,7 @@ Value CreateTypedArray(const CallbackInfo& info) {
60
60
  : NAPI_TYPEDARRAY_NEW_BUFFER(Int16Array,
61
61
  info.Env(),
62
62
  length,
63
- buffer,
63
+ buffer.As<ArrayBuffer>(),
64
64
  bufferOffset,
65
65
  napi_int16_array);
66
66
  } else if (arrayType == "uint16") {
@@ -70,7 +70,7 @@ Value CreateTypedArray(const CallbackInfo& info) {
70
70
  : NAPI_TYPEDARRAY_NEW_BUFFER(Uint16Array,
71
71
  info.Env(),
72
72
  length,
73
- buffer,
73
+ buffer.As<ArrayBuffer>(),
74
74
  bufferOffset,
75
75
  napi_uint16_array);
76
76
  } else if (arrayType == "int32") {
@@ -80,7 +80,7 @@ Value CreateTypedArray(const CallbackInfo& info) {
80
80
  : NAPI_TYPEDARRAY_NEW_BUFFER(Int32Array,
81
81
  info.Env(),
82
82
  length,
83
- buffer,
83
+ buffer.As<ArrayBuffer>(),
84
84
  bufferOffset,
85
85
  napi_int32_array);
86
86
  } else if (arrayType == "uint32") {
@@ -90,7 +90,7 @@ Value CreateTypedArray(const CallbackInfo& info) {
90
90
  : NAPI_TYPEDARRAY_NEW_BUFFER(Uint32Array,
91
91
  info.Env(),
92
92
  length,
93
- buffer,
93
+ buffer.As<ArrayBuffer>(),
94
94
  bufferOffset,
95
95
  napi_uint32_array);
96
96
  } else if (arrayType == "float32") {
@@ -100,7 +100,7 @@ Value CreateTypedArray(const CallbackInfo& info) {
100
100
  : NAPI_TYPEDARRAY_NEW_BUFFER(Float32Array,
101
101
  info.Env(),
102
102
  length,
103
- buffer,
103
+ buffer.As<ArrayBuffer>(),
104
104
  bufferOffset,
105
105
  napi_float32_array);
106
106
  } else if (arrayType == "float64") {
@@ -110,7 +110,7 @@ Value CreateTypedArray(const CallbackInfo& info) {
110
110
  : NAPI_TYPEDARRAY_NEW_BUFFER(Float64Array,
111
111
  info.Env(),
112
112
  length,
113
- buffer,
113
+ buffer.As<ArrayBuffer>(),
114
114
  bufferOffset,
115
115
  napi_float64_array);
116
116
  #if (NAPI_VERSION > 5)
@@ -121,7 +121,7 @@ Value CreateTypedArray(const CallbackInfo& info) {
121
121
  : NAPI_TYPEDARRAY_NEW_BUFFER(BigInt64Array,
122
122
  info.Env(),
123
123
  length,
124
- buffer,
124
+ buffer.As<ArrayBuffer>(),
125
125
  bufferOffset,
126
126
  napi_bigint64_array);
127
127
  } else if (arrayType == "biguint64") {
@@ -131,7 +131,7 @@ Value CreateTypedArray(const CallbackInfo& info) {
131
131
  : NAPI_TYPEDARRAY_NEW_BUFFER(BigUint64Array,
132
132
  info.Env(),
133
133
  length,
134
- buffer,
134
+ buffer.As<ArrayBuffer>(),
135
135
  bufferOffset,
136
136
  napi_biguint64_array);
137
137
  #endif
@@ -208,8 +208,8 @@ Value CheckBufferContent(const CallbackInfo& info) {
208
208
  case napi_uint8_array:
209
209
  return Boolean::New(
210
210
  info.Env(),
211
- TypedArrayDataIsEquivalent<int8_t>(info[0].As<Int8Array>(),
212
- info[1].As<Int8Array>()));
211
+ TypedArrayDataIsEquivalent<uint8_t>(info[0].As<Uint8Array>(),
212
+ info[1].As<Uint8Array>()));
213
213
 
214
214
  case napi_uint8_clamped_array:
215
215
  return Boolean::New(
@@ -335,35 +335,39 @@ Value GetTypedArrayElement(const CallbackInfo& info) {
335
335
  void SetTypedArrayElement(const CallbackInfo& info) {
336
336
  TypedArray array = info[0].As<TypedArray>();
337
337
  size_t index = info[1].As<Number>().Uint32Value();
338
- Number value = info[2].As<Number>();
338
+ Value value = info[2];
339
339
  switch (array.TypedArrayType()) {
340
340
  case napi_int8_array:
341
- array.As<Int8Array>()[index] = static_cast<int8_t>(value.Int32Value());
341
+ array.As<Int8Array>()[index] =
342
+ static_cast<int8_t>(value.As<Number>().Int32Value());
342
343
  break;
343
344
  case napi_uint8_array:
344
- array.As<Uint8Array>()[index] = static_cast<uint8_t>(value.Uint32Value());
345
+ array.As<Uint8Array>()[index] =
346
+ static_cast<uint8_t>(value.As<Number>().Uint32Value());
345
347
  break;
346
348
  case napi_uint8_clamped_array:
347
- array.As<Uint8Array>()[index] = static_cast<uint8_t>(value.Uint32Value());
349
+ array.As<Uint8Array>()[index] =
350
+ static_cast<uint8_t>(value.As<Number>().Uint32Value());
348
351
  break;
349
352
  case napi_int16_array:
350
- array.As<Int16Array>()[index] = static_cast<int16_t>(value.Int32Value());
353
+ array.As<Int16Array>()[index] =
354
+ static_cast<int16_t>(value.As<Number>().Int32Value());
351
355
  break;
352
356
  case napi_uint16_array:
353
357
  array.As<Uint16Array>()[index] =
354
- static_cast<uint16_t>(value.Uint32Value());
358
+ static_cast<uint16_t>(value.As<Number>().Uint32Value());
355
359
  break;
356
360
  case napi_int32_array:
357
- array.As<Int32Array>()[index] = value.Int32Value();
361
+ array.As<Int32Array>()[index] = value.As<Number>().Int32Value();
358
362
  break;
359
363
  case napi_uint32_array:
360
- array.As<Uint32Array>()[index] = value.Uint32Value();
364
+ array.As<Uint32Array>()[index] = value.As<Number>().Uint32Value();
361
365
  break;
362
366
  case napi_float32_array:
363
- array.As<Float32Array>()[index] = value.FloatValue();
367
+ array.As<Float32Array>()[index] = value.As<Number>().FloatValue();
364
368
  break;
365
369
  case napi_float64_array:
366
- array.As<Float64Array>()[index] = value.DoubleValue();
370
+ array.As<Float64Array>()[index] = value.As<Number>().DoubleValue();
367
371
  break;
368
372
  #if (NAPI_VERSION > 5)
369
373
  case napi_bigint64_array: {
@@ -12,7 +12,7 @@ if (!dir) {
12
12
  process.exit(1);
13
13
  }
14
14
 
15
- const NodeApiVersion = require('../package.json').version;
15
+ const NodeApiVersion = require('../').version;
16
16
 
17
17
  const disable = args[1];
18
18
  let ConfigFileOperations;
@@ -1,5 +1,34 @@
1
1
  # node-api-headers Changelog
2
2
 
3
+ ## [1.5.0](https://github.com/nodejs/node-api-headers/compare/v1.4.0...v1.5.0) (2025-01-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * update headers from nodejs/node tag v23.6.0 ([#57](https://github.com/nodejs/node-api-headers/issues/57)) ([64747b1](https://github.com/nodejs/node-api-headers/commit/64747b17a73e8356ed606d1b4dccb626804777f2))
9
+
10
+ ## [1.4.0](https://github.com/nodejs/node-api-headers/compare/v1.3.0...v1.4.0) (2024-10-30)
11
+
12
+
13
+ ### Features
14
+
15
+ * **no-release:** add conditional support in `#if` ([#52](https://github.com/nodejs/node-api-headers/issues/52)) ([e1b8feb](https://github.com/nodejs/node-api-headers/commit/e1b8feb060cf85522538ec1b8a1d6eb782620022))
16
+ * update headers from nodejs/node tag v23.1.0 ([#56](https://github.com/nodejs/node-api-headers/issues/56)) ([3336912](https://github.com/nodejs/node-api-headers/commit/33369124c7f8a670422a0c5a27ad149da83ed8d6))
17
+
18
+ ## [1.3.0](https://github.com/nodejs/node-api-headers/compare/v1.2.0...v1.3.0) (2024-09-04)
19
+
20
+
21
+ ### Features
22
+
23
+ * update headers from nodejs/node tag v22.7.0 ([#48](https://github.com/nodejs/node-api-headers/issues/48)) ([6c73c34](https://github.com/nodejs/node-api-headers/commit/6c73c34b72e836531530f863eac315bd42e4569e))
24
+
25
+ ## [1.2.0](https://github.com/nodejs/node-api-headers/compare/node-api-headers-v1.1.0...node-api-headers-v1.2.0) (2024-07-09)
26
+
27
+
28
+ ### Features
29
+
30
+ * update headers from nodejs/node tag v22.1.0 ([d5cfe19](https://github.com/nodejs/node-api-headers/commit/d5cfe19da8b974ca35764dd1c73b91d57cd3c4ce))
31
+
3
32
  ## 2023-08-05 Version 1.1.0, @NickNaso
4
33
 
5
34
  ### Notable changes
@@ -5,7 +5,17 @@ want to be able to do releases ask one of the existing collaborators to add
5
5
  you. If necessary you can ask the build Working Group who manages the Node.js
6
6
  npm user to add you if there are no other active collaborators.
7
7
 
8
- ## Prerequisites
8
+ Generally, the release is handled by the
9
+ [release-please](https://github.com/nodejs/node-api-headers/blob/main/.github/workflows/release-please.yml)
10
+ GitHub action. It will bump the version in `package.json` and publish
11
+ node-api-headers to npm.
12
+
13
+ In cases that the release-please action is not working, please follow the steps
14
+ below to publish node-api-headers manually.
15
+
16
+ ## Publish new release manually
17
+
18
+ ### Prerequisites
9
19
 
10
20
  Before to start creating a new release check if you have installed the following
11
21
  tools:
@@ -15,7 +25,7 @@ tools:
15
25
  If not please follow the instruction reported in the tool's documentation to
16
26
  install it.
17
27
 
18
- ## Publish new release
28
+ ### Steps
19
29
 
20
30
  These are the steps to follow to create a new release:
21
31
 
@@ -117,4 +117,9 @@ napi_object_seal
117
117
  napi_type_tag_object
118
118
  node_api_create_syntax_error
119
119
  node_api_symbol_for
120
- node_api_throw_syntax_error
120
+ node_api_throw_syntax_error
121
+ node_api_create_external_string_latin1
122
+ node_api_create_external_string_utf16
123
+ node_api_create_property_key_latin1
124
+ node_api_create_property_key_utf16
125
+ node_api_create_property_key_utf8
@@ -148,4 +148,10 @@ napi_type_tag_object
148
148
  node_api_get_module_file_name
149
149
  node_api_create_syntax_error
150
150
  node_api_symbol_for
151
- node_api_throw_syntax_error
151
+ node_api_throw_syntax_error
152
+ node_api_create_buffer_from_arraybuffer
153
+ node_api_create_external_string_latin1
154
+ node_api_create_external_string_utf16
155
+ node_api_create_property_key_latin1
156
+ node_api_create_property_key_utf16
157
+ node_api_create_property_key_utf8
@@ -24,7 +24,7 @@
24
24
  #ifndef NAPI_EXTERN
25
25
  #ifdef _WIN32
26
26
  #define NAPI_EXTERN __declspec(dllexport)
27
- #elif defined(__wasm32__)
27
+ #elif defined(__wasm__)
28
28
  #define NAPI_EXTERN \
29
29
  __attribute__((visibility("default"))) \
30
30
  __attribute__((__import_module__("napi")))
@@ -45,8 +45,8 @@
45
45
 
46
46
  EXTERN_C_START
47
47
 
48
- NAPI_EXTERN napi_status NAPI_CDECL
49
- napi_get_last_error_info(napi_env env, const napi_extended_error_info** result);
48
+ NAPI_EXTERN napi_status NAPI_CDECL napi_get_last_error_info(
49
+ node_api_basic_env env, const napi_extended_error_info** result);
50
50
 
51
51
  // Getters for defined singletons
52
52
  NAPI_EXTERN napi_status NAPI_CDECL napi_get_undefined(napi_env env,
@@ -88,6 +88,32 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_create_string_utf16(napi_env env,
88
88
  const char16_t* str,
89
89
  size_t length,
90
90
  napi_value* result);
91
+ #if NAPI_VERSION >= 10
92
+ NAPI_EXTERN napi_status NAPI_CDECL node_api_create_external_string_latin1(
93
+ napi_env env,
94
+ char* str,
95
+ size_t length,
96
+ node_api_basic_finalize finalize_callback,
97
+ void* finalize_hint,
98
+ napi_value* result,
99
+ bool* copied);
100
+ NAPI_EXTERN napi_status NAPI_CDECL
101
+ node_api_create_external_string_utf16(napi_env env,
102
+ char16_t* str,
103
+ size_t length,
104
+ node_api_basic_finalize finalize_callback,
105
+ void* finalize_hint,
106
+ napi_value* result,
107
+ bool* copied);
108
+
109
+ NAPI_EXTERN napi_status NAPI_CDECL node_api_create_property_key_latin1(
110
+ napi_env env, const char* str, size_t length, napi_value* result);
111
+ NAPI_EXTERN napi_status NAPI_CDECL node_api_create_property_key_utf8(
112
+ napi_env env, const char* str, size_t length, napi_value* result);
113
+ NAPI_EXTERN napi_status NAPI_CDECL node_api_create_property_key_utf16(
114
+ napi_env env, const char16_t* str, size_t length, napi_value* result);
115
+ #endif // NAPI_VERSION >= 10
116
+
91
117
  NAPI_EXTERN napi_status NAPI_CDECL napi_create_symbol(napi_env env,
92
118
  napi_value description,
93
119
  napi_value* result);
@@ -267,7 +293,7 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_instanceof(napi_env env,
267
293
 
268
294
  // Gets all callback info in a single call. (Ugly, but faster.)
269
295
  NAPI_EXTERN napi_status NAPI_CDECL napi_get_cb_info(
270
- napi_env env, // [in] NAPI environment handle
296
+ napi_env env, // [in] Node-API environment handle
271
297
  napi_callback_info cbinfo, // [in] Opaque callback-info handle
272
298
  size_t* argc, // [in-out] Specifies the size of the provided argv array
273
299
  // and receives the actual count of args.
@@ -288,12 +314,13 @@ napi_define_class(napi_env env,
288
314
  napi_value* result);
289
315
 
290
316
  // Methods to work with external data objects
291
- NAPI_EXTERN napi_status NAPI_CDECL napi_wrap(napi_env env,
292
- napi_value js_object,
293
- void* native_object,
294
- napi_finalize finalize_cb,
295
- void* finalize_hint,
296
- napi_ref* result);
317
+ NAPI_EXTERN napi_status NAPI_CDECL
318
+ napi_wrap(napi_env env,
319
+ napi_value js_object,
320
+ void* native_object,
321
+ node_api_basic_finalize finalize_cb,
322
+ void* finalize_hint,
323
+ napi_ref* result);
297
324
  NAPI_EXTERN napi_status NAPI_CDECL napi_unwrap(napi_env env,
298
325
  napi_value js_object,
299
326
  void** result);
@@ -303,7 +330,7 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_remove_wrap(napi_env env,
303
330
  NAPI_EXTERN napi_status NAPI_CDECL
304
331
  napi_create_external(napi_env env,
305
332
  void* data,
306
- napi_finalize finalize_cb,
333
+ node_api_basic_finalize finalize_cb,
307
334
  void* finalize_hint,
308
335
  napi_value* result);
309
336
  NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_external(napi_env env,
@@ -402,7 +429,7 @@ NAPI_EXTERN napi_status NAPI_CDECL
402
429
  napi_create_external_arraybuffer(napi_env env,
403
430
  void* external_data,
404
431
  size_t byte_length,
405
- napi_finalize finalize_cb,
432
+ node_api_basic_finalize finalize_cb,
406
433
  void* finalize_hint,
407
434
  napi_value* result);
408
435
  #endif // NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED
@@ -444,7 +471,7 @@ napi_get_dataview_info(napi_env env,
444
471
  size_t* byte_offset);
445
472
 
446
473
  // version management
447
- NAPI_EXTERN napi_status NAPI_CDECL napi_get_version(napi_env env,
474
+ NAPI_EXTERN napi_status NAPI_CDECL napi_get_version(node_api_basic_env env,
448
475
  uint32_t* result);
449
476
 
450
477
  // Promises
@@ -468,7 +495,7 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_run_script(napi_env env,
468
495
 
469
496
  // Memory management
470
497
  NAPI_EXTERN napi_status NAPI_CDECL napi_adjust_external_memory(
471
- napi_env env, int64_t change_in_bytes, int64_t* adjusted_value);
498
+ node_api_basic_env env, int64_t change_in_bytes, int64_t* adjusted_value);
472
499
 
473
500
  #if NAPI_VERSION >= 5
474
501
 
@@ -486,15 +513,17 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_get_date_value(napi_env env,
486
513
  double* result);
487
514
 
488
515
  // Add finalizer for pointer
489
- NAPI_EXTERN napi_status NAPI_CDECL napi_add_finalizer(napi_env env,
490
- napi_value js_object,
491
- void* finalize_data,
492
- napi_finalize finalize_cb,
493
- void* finalize_hint,
494
- napi_ref* result);
516
+ NAPI_EXTERN napi_status NAPI_CDECL
517
+ napi_add_finalizer(napi_env env,
518
+ napi_value js_object,
519
+ void* finalize_data,
520
+ node_api_basic_finalize finalize_cb,
521
+ void* finalize_hint,
522
+ napi_ref* result);
495
523
 
496
524
  #endif // NAPI_VERSION >= 5
497
525
 
526
+
498
527
  #if NAPI_VERSION >= 6
499
528
 
500
529
  // BigInt
@@ -532,11 +561,14 @@ napi_get_all_property_names(napi_env env,
532
561
  napi_value* result);
533
562
 
534
563
  // Instance data
535
- NAPI_EXTERN napi_status NAPI_CDECL napi_set_instance_data(
536
- napi_env env, void* data, napi_finalize finalize_cb, void* finalize_hint);
564
+ NAPI_EXTERN napi_status NAPI_CDECL
565
+ napi_set_instance_data(node_api_basic_env env,
566
+ void* data,
567
+ napi_finalize finalize_cb,
568
+ void* finalize_hint);
537
569
 
538
- NAPI_EXTERN napi_status NAPI_CDECL napi_get_instance_data(napi_env env,
539
- void** data);
570
+ NAPI_EXTERN napi_status NAPI_CDECL
571
+ napi_get_instance_data(node_api_basic_env env, void** data);
540
572
  #endif // NAPI_VERSION >= 6
541
573
 
542
574
  #if NAPI_VERSION >= 7
@@ -22,6 +22,30 @@ typedef uint16_t char16_t;
22
22
  // JSVM API types are all opaque pointers for ABI stability
23
23
  // typedef undefined structs instead of void* for compile time type safety
24
24
  typedef struct napi_env__* napi_env;
25
+
26
+ // We need to mark APIs which can be called during garbage collection (GC),
27
+ // meaning that they do not affect the state of the JS engine, and can
28
+ // therefore be called synchronously from a finalizer that itself runs
29
+ // synchronously during GC. Such APIs can receive either a `napi_env` or a
30
+ // `node_api_basic_env` as their first parameter, because we should be able to
31
+ // also call them during normal, non-garbage-collecting operations, whereas
32
+ // APIs that affect the state of the JS engine can only receive a `napi_env` as
33
+ // their first parameter, because we must not call them during GC. In lieu of
34
+ // inheritance, we use the properties of the const qualifier to accomplish
35
+ // this, because both a const and a non-const value can be passed to an API
36
+ // expecting a const value, but only a non-const value can be passed to an API
37
+ // expecting a non-const value.
38
+ //
39
+ // In conjunction with appropriate CFLAGS to warn us if we're passing a const
40
+ // (basic) environment into an API that expects a non-const environment, and
41
+ // the definition of basic finalizer function pointer types below, which
42
+ // receive a basic environment as their first parameter, and can thus only call
43
+ // basic APIs (unless the user explicitly casts the environment), we achieve
44
+ // the ability to ensure at compile time that we do not call APIs that affect
45
+ // the state of the JS engine from a synchronous (basic) finalizer.
46
+ typedef struct napi_env__* node_api_nogc_env;
47
+ typedef node_api_nogc_env node_api_basic_env;
48
+
25
49
  typedef struct napi_value__* napi_value;
26
50
  typedef struct napi_ref__* napi_ref;
27
51
  typedef struct napi_handle_scope__* napi_handle_scope;
@@ -116,6 +140,9 @@ typedef void(NAPI_CDECL* napi_finalize)(napi_env env,
116
140
  void* finalize_data,
117
141
  void* finalize_hint);
118
142
 
143
+ typedef napi_finalize node_api_nogc_finalize;
144
+ typedef node_api_nogc_finalize node_api_basic_finalize;
145
+
119
146
  typedef struct {
120
147
  // One of utf8name or name should be NULL.
121
148
  const char* utf8name;