emnapi 1.3.0 → 1.4.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/README.md CHANGED
@@ -37,6 +37,8 @@ See documentation for more details:
37
37
 
38
38
  [How to build Node-API official examples](https://github.com/toyobayashi/node-addon-examples)
39
39
 
40
+ If you want to deep dive into WebAssembly, highly recommend you to visit [learn-wasm.dev](https://learn-wasm.dev?via=toyobayashi).
41
+
40
42
  ## Prerequests
41
43
 
42
44
  You will need to install:
@@ -45,6 +47,7 @@ You will need to install:
45
47
  - npm `>= v8`
46
48
  - Emscripten `>= v3.1.9` / wasi-sdk / LLVM clang with wasm support
47
49
  - (Optional) CMake `>= v3.13`
50
+ - (Optional) node-gyp `>= v10.2.0`
48
51
  - (Optional) ninja
49
52
  - (Optional) make
50
53
  - (Optional) [node-addon-api](https://github.com/nodejs/node-addon-api) `>= 6.1.0`
@@ -68,6 +71,9 @@ emcc -v
68
71
 
69
72
  cmake --version
70
73
 
74
+ # if you use node-gyp
75
+ node-gyp --version
76
+
71
77
  # if you use ninja
72
78
  ninja --version
73
79
 
@@ -183,6 +189,7 @@ emcc -O3 \
183
189
  -L./node_modules/emnapi/lib/wasm32-emscripten \
184
190
  --js-library=./node_modules/emnapi/dist/library_napi.js \
185
191
  -sEXPORTED_FUNCTIONS="['_malloc','_free','_napi_register_wasm_v1','_node_api_module_get_api_version_v1']" \
192
+ -sEXPORTED_RUNTIME_METHODS=['emnapiInit'] \
186
193
  -o hello.js \
187
194
  hello.c \
188
195
  -lemnapi
@@ -473,6 +480,7 @@ em++ -O3 \
473
480
  -L./node_modules/emnapi/lib/wasm32-emscripten \
474
481
  --js-library=./node_modules/emnapi/dist/library_napi.js \
475
482
  -sEXPORTED_FUNCTIONS="['_malloc','_free','_napi_register_wasm_v1','_node_api_module_get_api_version_v1']" \
483
+ -sEXPORTED_RUNTIME_METHODS=['emnapiInit'] \
476
484
  -o hello.js \
477
485
  hello.cpp \
478
486
  -lemnapi
@@ -555,6 +563,10 @@ void* operator new(size_t size) {
555
563
  void operator delete(void* p) noexcept {
556
564
  free(p);
557
565
  }
566
+
567
+ void operator delete(void* p, size_t) noexcept {
568
+ free(p);
569
+ }
558
570
  ```
559
571
 
560
572
  </details>
@@ -576,6 +588,7 @@ target_link_libraries(hello emnapi)
576
588
  if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
577
589
  target_link_options(hello PRIVATE
578
590
  "-sEXPORTED_FUNCTIONS=['_malloc','_free','_napi_register_wasm_v1','_node_api_module_get_api_version_v1']"
591
+ "-sEXPORTED_RUNTIME_METHODS=['emnapiInit']"
579
592
  )
580
593
  elseif(CMAKE_SYSTEM_NAME STREQUAL "WASI")
581
594
  set_target_properties(hello PROPERTIES SUFFIX ".wasm")
@@ -629,15 +642,9 @@ Output code can run in recent version modern browsers and Node.js latest LTS. IE
629
642
 
630
643
  ### Using node-gyp (Experimental)
631
644
 
632
- Currently node-gyp works on Linux only and don't support static library linking in cross-compiling.
633
- There are related PRs to try to make node-gyp work fine.
634
-
635
- - https://github.com/nodejs/gyp-next/pull/222
636
- - https://github.com/nodejs/gyp-next/pull/240
637
- - https://github.com/nodejs/node-gyp/pull/2974
645
+ Require node-gyp `>= 10.2.0`
638
646
 
639
- If you experienced issues on Windows or macOS, please check the PRs for upstream changes detail and see
640
- [emnapi-node-gyp-test](https://github.com/toyobayashi/emnapi-node-gyp-test) for examples.
647
+ See [emnapi-node-gyp-test](https://github.com/toyobayashi/emnapi-node-gyp-test) for examples.
641
648
 
642
649
  - Variables
643
650
 
@@ -685,19 +692,10 @@ declare var emnapi_manual_linking: 0 | 1
685
692
  ["OS == 'emscripten'", {
686
693
  "product_extension": "js", # required
687
694
 
688
- # Windows and Linux
689
695
  "cflags": [],
690
696
  "cflags_c": [],
691
697
  "cflags_cc": [],
692
- "ldflags": [],
693
-
694
- # macOS uses following config
695
- 'xcode_settings': {
696
- "WARNING_CFLAGS": [], # cflags
697
- "OTHER_CFLAGS": [], # cflags_c
698
- "OTHER_CPLUSPLUSFLAGS": [], # cflags_cc
699
- "OTHER_LDFLAGS": [] # ldflags
700
- }
698
+ "ldflags": []
701
699
  }],
702
700
  ["OS == 'wasi'", {
703
701
  # ...
@@ -860,6 +858,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
860
858
  target_link_options(hello PRIVATE
861
859
  "-sALLOW_MEMORY_GROWTH=1"
862
860
  "-sEXPORTED_FUNCTIONS=['_malloc','_free','_napi_register_wasm_v1','_node_api_module_get_api_version_v1']"
861
+ "-sEXPORTED_RUNTIME_METHODS=['emnapiInit']"
863
862
  "-pthread"
864
863
  "-sPTHREAD_POOL_SIZE=4"
865
864
  # try to specify stack size if you experience pthread errors
package/common.gypi CHANGED
@@ -85,7 +85,7 @@
85
85
  '-sNODEJS_CATCH_EXIT=0',
86
86
  '-sNODEJS_CATCH_REJECTION=0',
87
87
  '-sWASM_BIGINT=1',
88
- '-sMIN_CHROME_VERSION=84',
88
+ '-sMIN_CHROME_VERSION=85',
89
89
  '-sMIN_NODE_VERSION=161500',
90
90
  '-sSTACK_SIZE=<(stack_size)',
91
91
  '-sDEFAULT_PTHREAD_STACK_SIZE=<(stack_size)',
@@ -102,7 +102,7 @@
102
102
  '-sNODEJS_CATCH_EXIT=0',
103
103
  '-sNODEJS_CATCH_REJECTION=0',
104
104
  '-sWASM_BIGINT=1',
105
- '-sMIN_CHROME_VERSION=84',
105
+ '-sMIN_CHROME_VERSION=85',
106
106
  '-sMIN_NODE_VERSION=161500',
107
107
  '-sSTACK_SIZE=<(stack_size)',
108
108
  '-sDEFAULT_PTHREAD_STACK_SIZE=<(stack_size)',
@@ -312,6 +312,7 @@
312
312
  'src/uv/uv-common.c',
313
313
  'src/uv/threadpool.c',
314
314
  'src/uv/unix/loop.c',
315
+ 'src/uv/unix/posix-hrtime.c',
315
316
  'src/uv/unix/thread.c',
316
317
  'src/uv/unix/async.c',
317
318
  'src/uv/unix/core.c',
@@ -876,7 +876,7 @@ function _emnapi_get_module_object(env, result) {
876
876
  if (!envObject.tryCatch.isEmpty())
877
877
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
878
878
  if (!envObject.canCallIntoJs())
879
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
879
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
880
880
  envObject.clearLastError();
881
881
  try {
882
882
  if (!result)
@@ -906,7 +906,7 @@ function _emnapi_get_module_property(env, utf8name, result) {
906
906
  if (!envObject.tryCatch.isEmpty())
907
907
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
908
908
  if (!envObject.canCallIntoJs())
909
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
909
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
910
910
  envObject.clearLastError();
911
911
  try {
912
912
  if (!utf8name)
@@ -1049,7 +1049,7 @@ function _napi_get_array_length(env, value, result) {
1049
1049
  if (!envObject.tryCatch.isEmpty())
1050
1050
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
1051
1051
  if (!envObject.canCallIntoJs())
1052
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
1052
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
1053
1053
  envObject.clearLastError();
1054
1054
  try {
1055
1055
  if (!value)
@@ -1110,7 +1110,7 @@ function _napi_get_prototype(env, value, result) {
1110
1110
  if (!envObject.tryCatch.isEmpty())
1111
1111
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
1112
1112
  if (!envObject.canCallIntoJs())
1113
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
1113
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
1114
1114
  envObject.clearLastError();
1115
1115
  try {
1116
1116
  if (!value)
@@ -1237,6 +1237,9 @@ function _napi_get_buffer_info(env, buffer, data, length) {
1237
1237
  var handle = emnapiCtx.handleStore.get(buffer);
1238
1238
  if (!handle.isBuffer(emnapiCtx.feature.Buffer))
1239
1239
  return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
1240
+ if (handle.isDataView()) {
1241
+ return _napi_get_dataview_info(env, buffer, length, data, 0, 0);
1242
+ }
1240
1243
  return _napi_get_typedarray_info(env, buffer, 0, length, data, 0, 0);
1241
1244
  }
1242
1245
  /**
@@ -1295,7 +1298,7 @@ function _napi_get_date_value(env, value, result) {
1295
1298
  if (!envObject.tryCatch.isEmpty())
1296
1299
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
1297
1300
  if (!envObject.canCallIntoJs())
1298
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
1301
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
1299
1302
  envObject.clearLastError();
1300
1303
  try {
1301
1304
  if (!value)
@@ -1526,7 +1529,7 @@ function _napi_get_value_external(env, value, result) {
1526
1529
  }
1527
1530
  {{{ from64('result') }}};
1528
1531
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1529
- var p = handle.data(envObject);
1532
+ var p = handle.data();
1530
1533
  {{{ makeSetValue('result', 0, 'p', '*') }}};
1531
1534
  return envObject.clearLastError();
1532
1535
  }
@@ -1961,7 +1964,7 @@ function _napi_create_bigint_words(env, sign_bit, word_count, words, result) {
1961
1964
  if (!envObject.tryCatch.isEmpty())
1962
1965
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
1963
1966
  if (!envObject.canCallIntoJs())
1964
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
1967
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
1965
1968
  envObject.clearLastError();
1966
1969
  try {
1967
1970
  if (!emnapiCtx.feature.supportBigInt) {
@@ -2003,25 +2006,34 @@ function emnapiCreateFunction(envObject, utf8name, length, cb, data) {
2003
2006
  {{{ from64('utf8name') }}};
2004
2007
  var functionName = (!utf8name || !length) ? '' : (emnapiString.UTF8ToString(utf8name, length));
2005
2008
  var f;
2006
- var makeFunction = function () {
2009
+ var napiCallback = {{{ makeDynCall('ppp', 'cb') }}};
2010
+ var callback = function (envObject) {
2011
+ return napiCallback(envObject.id, envObject.ctx.scopeStore.currentScope.id);
2012
+ };
2013
+ var makeFunction = function (envObject, callback) {
2007
2014
  return function () {
2008
2015
  'use strict';
2009
- var cbinfo = emnapiCtx.cbinfoStack.push(this, data, arguments, f);
2010
- var scope = emnapiCtx.openScope(envObject);
2016
+ var scope = envObject.ctx.openScope(envObject);
2017
+ var callbackInfo = scope.callbackInfo;
2018
+ callbackInfo.data = data;
2019
+ callbackInfo.args = arguments;
2020
+ callbackInfo.thiz = this;
2021
+ callbackInfo.fn = f;
2011
2022
  try {
2012
- return envObject.callIntoModule(function (envObject) {
2013
- var napiValue = {{{ makeDynCall('ppp', 'cb') }}}(envObject.id, cbinfo);
2014
- return (!napiValue) ? undefined : emnapiCtx.handleStore.get(napiValue).value;
2015
- });
2023
+ var napiValue = envObject.callIntoModule(callback);
2024
+ return (!napiValue) ? undefined : envObject.ctx.handleStore.get(napiValue).value;
2016
2025
  }
2017
2026
  finally {
2018
- emnapiCtx.cbinfoStack.pop();
2019
- emnapiCtx.closeScope(envObject, scope);
2027
+ callbackInfo.data = 0;
2028
+ callbackInfo.args = undefined;
2029
+ callbackInfo.thiz = undefined;
2030
+ callbackInfo.fn = undefined;
2031
+ envObject.ctx.closeScope(envObject, scope);
2020
2032
  }
2021
2033
  };
2022
2034
  };
2023
2035
  if (functionName === '') {
2024
- f = makeFunction();
2036
+ f = makeFunction(envObject, callback);
2025
2037
  return { status: 0 /* napi_status.napi_ok */, f: f };
2026
2038
  }
2027
2039
  if (!(/^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(functionName))) {
@@ -2029,7 +2041,7 @@ function emnapiCreateFunction(envObject, utf8name, length, cb, data) {
2029
2041
  }
2030
2042
  #if DYNAMIC_EXECUTION
2031
2043
  if (emnapiCtx.feature.supportNewFunction) {
2032
- var _ = makeFunction();
2044
+ var _ = makeFunction(envObject, callback);
2033
2045
  try {
2034
2046
  f = (new Function('_', 'return function ' + functionName + '(){' +
2035
2047
  '"use strict";' +
@@ -2037,18 +2049,18 @@ function emnapiCreateFunction(envObject, utf8name, length, cb, data) {
2037
2049
  '};'))(_);
2038
2050
  }
2039
2051
  catch (_err) {
2040
- f = makeFunction();
2052
+ f = makeFunction(envObject, callback);
2041
2053
  if (emnapiCtx.feature.canSetFunctionName)
2042
2054
  Object.defineProperty(f, 'name', { value: functionName });
2043
2055
  }
2044
2056
  }
2045
2057
  else {
2046
- f = makeFunction();
2058
+ f = makeFunction(envObject, callback);
2047
2059
  if (emnapiCtx.feature.canSetFunctionName)
2048
2060
  Object.defineProperty(f, 'name', { value: functionName });
2049
2061
  }
2050
2062
  #else
2051
- f = makeFunction();
2063
+ f = makeFunction(envObject, callback);
2052
2064
  if (emnapiCtx.feature.canSetFunctionName)
2053
2065
  Object.defineProperty(f, 'name', { value: functionName });
2054
2066
  #endif
@@ -2115,7 +2127,7 @@ function emnapiWrap(env, js_object, native_object, finalize_cb, finalize_hint, r
2115
2127
  if (!envObject.tryCatch.isEmpty())
2116
2128
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
2117
2129
  if (!envObject.canCallIntoJs())
2118
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2130
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2119
2131
  envObject.clearLastError();
2120
2132
  try {
2121
2133
  if (!emnapiCtx.feature.supportFinalizer) {
@@ -2170,7 +2182,7 @@ function emnapiUnwrap(env, js_object, result, action) {
2170
2182
  if (!envObject.tryCatch.isEmpty())
2171
2183
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
2172
2184
  if (!envObject.canCallIntoJs())
2173
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2185
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2174
2186
  envObject.clearLastError();
2175
2187
  try {
2176
2188
  if (!js_object)
@@ -2225,7 +2237,7 @@ function _napi_define_class(env, utf8name, length, constructor, callback_data, p
2225
2237
  if (!envObject.tryCatch.isEmpty())
2226
2238
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
2227
2239
  if (!envObject.canCallIntoJs())
2228
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2240
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2229
2241
  envObject.clearLastError();
2230
2242
  try {
2231
2243
  if (!result)
@@ -2320,7 +2332,7 @@ function _napi_type_tag_object(env, object, type_tag) {
2320
2332
  if (!envObject.tryCatch.isEmpty())
2321
2333
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
2322
2334
  if (!envObject.canCallIntoJs())
2323
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2335
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2324
2336
  envObject.clearLastError();
2325
2337
  try {
2326
2338
  if (!object) {
@@ -2362,7 +2374,7 @@ function _napi_check_object_type_tag(env, object, type_tag, result) {
2362
2374
  if (!envObject.tryCatch.isEmpty())
2363
2375
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
2364
2376
  if (!envObject.canCallIntoJs())
2365
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2377
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2366
2378
  envObject.clearLastError();
2367
2379
  try {
2368
2380
  if (!object) {
@@ -2458,7 +2470,7 @@ function _emnapi_create_memory_view(env, typedarray_type, external_data, byte_le
2458
2470
  if (!envObject.tryCatch.isEmpty())
2459
2471
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
2460
2472
  if (!envObject.canCallIntoJs())
2461
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2473
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2462
2474
  envObject.clearLastError();
2463
2475
  try {
2464
2476
  if (!result)
@@ -2632,7 +2644,7 @@ function _emnapi_sync_memory(env, js_to_wasm, arraybuffer_or_view, offset, len)
2632
2644
  if (!envObject.tryCatch.isEmpty())
2633
2645
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
2634
2646
  if (!envObject.canCallIntoJs())
2635
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2647
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2636
2648
  envObject.clearLastError();
2637
2649
  try {
2638
2650
  if (!arraybuffer_or_view)
@@ -2693,7 +2705,7 @@ function _emnapi_get_memory_address(env, arraybuffer_or_view, address, ownership
2693
2705
  if (!envObject.tryCatch.isEmpty())
2694
2706
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
2695
2707
  if (!envObject.canCallIntoJs())
2696
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2708
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2697
2709
  envObject.clearLastError();
2698
2710
  try {
2699
2711
  if (!arraybuffer_or_view)
@@ -2814,7 +2826,7 @@ function _napi_create_arraybuffer(env, byte_length, data, result) {
2814
2826
  if (!envObject.tryCatch.isEmpty())
2815
2827
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
2816
2828
  if (!envObject.canCallIntoJs())
2817
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2829
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2818
2830
  envObject.clearLastError();
2819
2831
  try {
2820
2832
  if (!result)
@@ -2844,7 +2856,7 @@ function _napi_create_date(env, time, result) {
2844
2856
  if (!envObject.tryCatch.isEmpty())
2845
2857
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
2846
2858
  if (!envObject.canCallIntoJs())
2847
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2859
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2848
2860
  envObject.clearLastError();
2849
2861
  try {
2850
2862
  if (!result)
@@ -2874,7 +2886,7 @@ function _napi_create_external(env, data, finalize_cb, finalize_hint, result) {
2874
2886
  if (!envObject.tryCatch.isEmpty())
2875
2887
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
2876
2888
  if (!envObject.canCallIntoJs())
2877
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2889
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2878
2890
  envObject.clearLastError();
2879
2891
  try {
2880
2892
  if (!result)
@@ -2882,7 +2894,7 @@ function _napi_create_external(env, data, finalize_cb, finalize_hint, result) {
2882
2894
  if (!emnapiCtx.feature.supportFinalizer && finalize_cb) {
2883
2895
  throw emnapiCtx.createNotSupportWeakRefError('napi_create_external', 'Parameter "finalize_cb" must be 0(NULL)');
2884
2896
  }
2885
- var externalHandle = emnapiCtx.getCurrentScope().addExternal(envObject, data);
2897
+ var externalHandle = emnapiCtx.getCurrentScope().addExternal(data);
2886
2898
  if (finalize_cb) {
2887
2899
  emnapiCtx.createReferenceWithFinalizer(envObject, externalHandle.id, 0, 0 /* ReferenceOwnership.kRuntime */, finalize_cb, data, finalize_hint);
2888
2900
  }
@@ -2910,7 +2922,7 @@ function _napi_create_external_arraybuffer(env, external_data, byte_length, fina
2910
2922
  if (!envObject.tryCatch.isEmpty())
2911
2923
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
2912
2924
  if (!envObject.canCallIntoJs())
2913
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2925
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
2914
2926
  envObject.clearLastError();
2915
2927
  try {
2916
2928
  if (!result)
@@ -3027,7 +3039,7 @@ function _napi_create_typedarray(env, type, length, arraybuffer, byte_offset, re
3027
3039
  if (!envObject.tryCatch.isEmpty())
3028
3040
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
3029
3041
  if (!envObject.canCallIntoJs())
3030
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3042
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3031
3043
  envObject.clearLastError();
3032
3044
  try {
3033
3045
  if (!arraybuffer)
@@ -3035,10 +3047,10 @@ function _napi_create_typedarray(env, type, length, arraybuffer, byte_offset, re
3035
3047
  if (!result)
3036
3048
  return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
3037
3049
  var handle = emnapiCtx.handleStore.get(arraybuffer);
3038
- var buffer = handle.value;
3039
- if (!(buffer instanceof ArrayBuffer)) {
3050
+ if (!handle.isArrayBuffer()) {
3040
3051
  return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
3041
3052
  }
3053
+ var buffer = handle.value;
3042
3054
  {{{ from64('byte_offset') }}};
3043
3055
  {{{ from64('length') }}};
3044
3056
  var createTypedArray = function (envObject, Type, size_of_element, buffer, byte_offset, length) {
@@ -3125,7 +3137,7 @@ function _napi_create_buffer(env, size, data, result) {
3125
3137
  if (!envObject.tryCatch.isEmpty())
3126
3138
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
3127
3139
  if (!envObject.canCallIntoJs())
3128
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3140
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3129
3141
  envObject.clearLastError();
3130
3142
  try {
3131
3143
  if (!result)
@@ -3184,7 +3196,7 @@ function _napi_create_buffer_copy(env, length, data, result_data, result) {
3184
3196
  if (!envObject.tryCatch.isEmpty())
3185
3197
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
3186
3198
  if (!envObject.canCallIntoJs())
3187
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3199
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3188
3200
  envObject.clearLastError();
3189
3201
  try {
3190
3202
  if (!result)
@@ -3214,6 +3226,68 @@ function _napi_create_buffer_copy(env, length, data, result_data, result) {
3214
3226
  function _napi_create_external_buffer(env, length, data, finalize_cb, finalize_hint, result) {
3215
3227
  return _emnapi_create_memory_view(env, -2 /* emnapi_memory_view_type.emnapi_buffer */, data, length, finalize_cb, finalize_hint, result);
3216
3228
  }
3229
+ /**
3230
+ * @__sig ippppp
3231
+ */
3232
+ function _node_api_create_buffer_from_arraybuffer(env, arraybuffer, byte_offset, byte_length, result) {
3233
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3234
+ var value;
3235
+ if (!env)
3236
+ return 1 /* napi_status.napi_invalid_arg */;
3237
+ // @ts-expect-error
3238
+ var envObject = emnapiCtx.envStore.get(env);
3239
+ envObject.checkGCAccess();
3240
+ if (!envObject.tryCatch.isEmpty())
3241
+ return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
3242
+ if (!envObject.canCallIntoJs())
3243
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3244
+ envObject.clearLastError();
3245
+ try {
3246
+ if (!arraybuffer)
3247
+ return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
3248
+ if (!result)
3249
+ return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
3250
+ {{{ from64('byte_offset') }}};
3251
+ {{{ from64('byte_length') }}};
3252
+ byte_offset = byte_offset >>> 0;
3253
+ byte_length = byte_length >>> 0;
3254
+ var handle = emnapiCtx.handleStore.get(arraybuffer);
3255
+ if (!handle.isArrayBuffer()) {
3256
+ return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
3257
+ }
3258
+ var buffer = handle.value;
3259
+ if ((byte_length + byte_offset) > buffer.byteLength) {
3260
+ var err = new RangeError('The byte offset + length is out of range');
3261
+ err.code = 'ERR_OUT_OF_RANGE';
3262
+ throw err;
3263
+ }
3264
+ var Buffer = emnapiCtx.feature.Buffer;
3265
+ if (!Buffer) {
3266
+ throw emnapiCtx.createNotSupportBufferError('node_api_create_buffer_from_arraybuffer', '');
3267
+ }
3268
+ var out = Buffer.from(buffer, byte_offset, byte_length);
3269
+ if (buffer === wasmMemory.buffer) {
3270
+ if (!emnapiExternalMemory.wasmMemoryViewTable.has(out)) {
3271
+ emnapiExternalMemory.wasmMemoryViewTable.set(out, {
3272
+ Ctor: Buffer,
3273
+ address: byte_offset,
3274
+ length: byte_length,
3275
+ ownership: 1 /* ReferenceOwnership.kUserland */,
3276
+ runtimeAllocated: 0
3277
+ });
3278
+ }
3279
+ }
3280
+ {{{ from64('result') }}};
3281
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3282
+ value = emnapiCtx.addToCurrentScope(out).id;
3283
+ {{{ makeSetValue('result', 0, 'value', '*') }}};
3284
+ return envObject.getReturnStatus();
3285
+ }
3286
+ catch (err) {
3287
+ envObject.tryCatch.setError(err);
3288
+ return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
3289
+ }
3290
+ }
3217
3291
  /**
3218
3292
  * @__sig ippppp
3219
3293
  */
@@ -3228,7 +3302,7 @@ function _napi_create_dataview(env, byte_length, arraybuffer, byte_offset, resul
3228
3302
  if (!envObject.tryCatch.isEmpty())
3229
3303
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
3230
3304
  if (!envObject.canCallIntoJs())
3231
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3305
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3232
3306
  envObject.clearLastError();
3233
3307
  try {
3234
3308
  if (!arraybuffer)
@@ -3240,10 +3314,10 @@ function _napi_create_dataview(env, byte_length, arraybuffer, byte_offset, resul
3240
3314
  byte_length = byte_length >>> 0;
3241
3315
  byte_offset = byte_offset >>> 0;
3242
3316
  var handle = emnapiCtx.handleStore.get(arraybuffer);
3243
- var buffer = handle.value;
3244
- if (!(buffer instanceof ArrayBuffer)) {
3317
+ if (!handle.isArrayBuffer()) {
3245
3318
  return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
3246
3319
  }
3320
+ var buffer = handle.value;
3247
3321
  if ((byte_length + byte_offset) > buffer.byteLength) {
3248
3322
  var err = new RangeError('byte_offset + byte_length should be less than or equal to the size in bytes of the array passed in');
3249
3323
  err.code = 'ERR_NAPI_INVALID_DATAVIEW_ARGS';
@@ -3414,7 +3488,7 @@ function _napi_throw(env, error) {
3414
3488
  if (!envObject.tryCatch.isEmpty())
3415
3489
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
3416
3490
  if (!envObject.canCallIntoJs())
3417
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3491
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3418
3492
  envObject.clearLastError();
3419
3493
  try {
3420
3494
  if (!error)
@@ -3437,7 +3511,7 @@ function _napi_throw_error(env, code, msg) {
3437
3511
  if (!envObject.tryCatch.isEmpty())
3438
3512
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
3439
3513
  if (!envObject.canCallIntoJs())
3440
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3514
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3441
3515
  envObject.clearLastError();
3442
3516
  try {
3443
3517
  if (!msg)
@@ -3465,7 +3539,7 @@ function _napi_throw_type_error(env, code, msg) {
3465
3539
  if (!envObject.tryCatch.isEmpty())
3466
3540
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
3467
3541
  if (!envObject.canCallIntoJs())
3468
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3542
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3469
3543
  envObject.clearLastError();
3470
3544
  try {
3471
3545
  if (!msg)
@@ -3493,7 +3567,7 @@ function _napi_throw_range_error(env, code, msg) {
3493
3567
  if (!envObject.tryCatch.isEmpty())
3494
3568
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
3495
3569
  if (!envObject.canCallIntoJs())
3496
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3570
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3497
3571
  envObject.clearLastError();
3498
3572
  try {
3499
3573
  if (!msg)
@@ -3521,7 +3595,7 @@ function _node_api_throw_syntax_error(env, code, msg) {
3521
3595
  if (!envObject.tryCatch.isEmpty())
3522
3596
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
3523
3597
  if (!envObject.canCallIntoJs())
3524
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3598
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3525
3599
  envObject.clearLastError();
3526
3600
  try {
3527
3601
  if (!msg)
@@ -3718,7 +3792,7 @@ function _napi_fatal_exception(env, err) {
3718
3792
  if (!envObject.tryCatch.isEmpty())
3719
3793
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
3720
3794
  if (!envObject.canCallIntoJs())
3721
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3795
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3722
3796
  envObject.clearLastError();
3723
3797
  try {
3724
3798
  if (!err)
@@ -3749,7 +3823,7 @@ function _napi_create_function(env, utf8name, length, cb, data, result) {
3749
3823
  if (!envObject.tryCatch.isEmpty())
3750
3824
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
3751
3825
  if (!envObject.canCallIntoJs())
3752
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3826
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3753
3827
  envObject.clearLastError();
3754
3828
  try {
3755
3829
  if (!result)
@@ -3779,7 +3853,7 @@ function _napi_get_cb_info(env, cbinfo, argc, argv, this_arg, data) {
3779
3853
  var envObject = emnapiCtx.envStore.get(env);
3780
3854
  if (!cbinfo)
3781
3855
  return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
3782
- var cbinfoValue = emnapiCtx.cbinfoStack.get(cbinfo);
3856
+ var cbinfoValue = emnapiCtx.scopeStore.get(cbinfo).callbackInfo;
3783
3857
  {{{ from64('argc') }}};
3784
3858
  {{{ from64('argv') }}};
3785
3859
  if (argv) {
@@ -3829,7 +3903,7 @@ function _napi_call_function(env, recv, func, argc, argv, result) {
3829
3903
  if (!envObject.tryCatch.isEmpty())
3830
3904
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
3831
3905
  if (!envObject.canCallIntoJs())
3832
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3906
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3833
3907
  envObject.clearLastError();
3834
3908
  try {
3835
3909
  if (!recv)
@@ -3878,7 +3952,7 @@ function _napi_new_instance(env, constructor, argc, argv, result) {
3878
3952
  if (!envObject.tryCatch.isEmpty())
3879
3953
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
3880
3954
  if (!envObject.canCallIntoJs())
3881
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3955
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
3882
3956
  envObject.clearLastError();
3883
3957
  try {
3884
3958
  if (!constructor)
@@ -3938,9 +4012,13 @@ function _napi_get_new_target(env, cbinfo, result) {
3938
4012
  if (!result)
3939
4013
  return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
3940
4014
  {{{ from64('result') }}};
3941
- var cbinfoValue = emnapiCtx.cbinfoStack.get(cbinfo);
3942
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3943
- var value = cbinfoValue.getNewTarget(envObject);
4015
+ var cbinfoValue = emnapiCtx.scopeStore.get(cbinfo).callbackInfo;
4016
+ var thiz = cbinfoValue.thiz, fn = cbinfoValue.fn;
4017
+ var value = thiz == null || thiz.constructor == null
4018
+ ? 0
4019
+ : thiz instanceof fn
4020
+ ? envObject.ensureHandleId(thiz.constructor)
4021
+ : 0;
3944
4022
  {{{ makeSetValue('result', 0, 'value', '*') }}};
3945
4023
  return envObject.clearLastError();
3946
4024
  }
@@ -4041,7 +4119,7 @@ function _napi_create_reference(env, value, initial_refcount, result) {
4041
4119
  if (!result)
4042
4120
  return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
4043
4121
  var handle = emnapiCtx.handleStore.get(value);
4044
- if (envObject.moduleApiVersion !== 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */) {
4122
+ if (envObject.moduleApiVersion < 10) {
4045
4123
  if (!(handle.isObject() || handle.isFunction() || handle.isSymbol())) {
4046
4124
  return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
4047
4125
  }
@@ -4056,9 +4134,7 @@ function _napi_create_reference(env, value, initial_refcount, result) {
4056
4134
  function _napi_delete_reference(env, ref) {
4057
4135
  if (!env)
4058
4136
  return 1 /* napi_status.napi_invalid_arg */;
4059
- // @ts-expect-error
4060
4137
  var envObject = emnapiCtx.envStore.get(env);
4061
- envObject.checkGCAccess();
4062
4138
  if (!ref)
4063
4139
  return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
4064
4140
  emnapiCtx.refStore.get(ref).dispose();
@@ -4303,7 +4379,7 @@ function _napi_make_callback(env, async_context, recv, func, argc, argv, result)
4303
4379
  if (!envObject.tryCatch.isEmpty())
4304
4380
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
4305
4381
  if (!envObject.canCallIntoJs())
4306
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4382
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4307
4383
  envObject.clearLastError();
4308
4384
  try {
4309
4385
  if (!emnapiNodeBinding) {
@@ -4368,7 +4444,7 @@ function _napi_create_promise(env, deferred, promise) {
4368
4444
  if (!envObject.tryCatch.isEmpty())
4369
4445
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
4370
4446
  if (!envObject.canCallIntoJs())
4371
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4447
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4372
4448
  envObject.clearLastError();
4373
4449
  try {
4374
4450
  if (!deferred)
@@ -4402,7 +4478,7 @@ function _napi_resolve_deferred(env, deferred, resolution) {
4402
4478
  if (!envObject.tryCatch.isEmpty())
4403
4479
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
4404
4480
  if (!envObject.canCallIntoJs())
4405
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4481
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4406
4482
  envObject.clearLastError();
4407
4483
  try {
4408
4484
  if (!deferred)
@@ -4428,7 +4504,7 @@ function _napi_reject_deferred(env, deferred, resolution) {
4428
4504
  if (!envObject.tryCatch.isEmpty())
4429
4505
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
4430
4506
  if (!envObject.canCallIntoJs())
4431
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4507
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4432
4508
  envObject.clearLastError();
4433
4509
  try {
4434
4510
  if (!deferred)
@@ -4474,7 +4550,7 @@ function _napi_get_all_property_names(env, object, key_mode, key_filter, key_con
4474
4550
  if (!envObject.tryCatch.isEmpty())
4475
4551
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
4476
4552
  if (!envObject.canCallIntoJs())
4477
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4553
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4478
4554
  envObject.clearLastError();
4479
4555
  try {
4480
4556
  if (!result)
@@ -4621,7 +4697,7 @@ function _napi_set_property(env, object, key, value) {
4621
4697
  if (!envObject.tryCatch.isEmpty())
4622
4698
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
4623
4699
  if (!envObject.canCallIntoJs())
4624
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4700
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4625
4701
  envObject.clearLastError();
4626
4702
  try {
4627
4703
  if (!key)
@@ -4654,7 +4730,7 @@ function _napi_has_property(env, object, key, result) {
4654
4730
  if (!envObject.tryCatch.isEmpty())
4655
4731
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
4656
4732
  if (!envObject.canCallIntoJs())
4657
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4733
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4658
4734
  envObject.clearLastError();
4659
4735
  try {
4660
4736
  if (!key)
@@ -4696,7 +4772,7 @@ function _napi_get_property(env, object, key, result) {
4696
4772
  if (!envObject.tryCatch.isEmpty())
4697
4773
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
4698
4774
  if (!envObject.canCallIntoJs())
4699
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4775
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4700
4776
  envObject.clearLastError();
4701
4777
  try {
4702
4778
  if (!key)
@@ -4739,7 +4815,7 @@ function _napi_delete_property(env, object, key, result) {
4739
4815
  if (!envObject.tryCatch.isEmpty())
4740
4816
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
4741
4817
  if (!envObject.canCallIntoJs())
4742
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4818
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4743
4819
  envObject.clearLastError();
4744
4820
  try {
4745
4821
  if (!key)
@@ -4785,7 +4861,7 @@ function _napi_has_own_property(env, object, key, result) {
4785
4861
  if (!envObject.tryCatch.isEmpty())
4786
4862
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
4787
4863
  if (!envObject.canCallIntoJs())
4788
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4864
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4789
4865
  envObject.clearLastError();
4790
4866
  try {
4791
4867
  if (!key)
@@ -4829,7 +4905,7 @@ function _napi_set_named_property(env, object, cname, value) {
4829
4905
  if (!envObject.tryCatch.isEmpty())
4830
4906
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
4831
4907
  if (!envObject.canCallIntoJs())
4832
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4908
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4833
4909
  envObject.clearLastError();
4834
4910
  try {
4835
4911
  if (!value)
@@ -4864,7 +4940,7 @@ function _napi_has_named_property(env, object, utf8name, result) {
4864
4940
  if (!envObject.tryCatch.isEmpty())
4865
4941
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
4866
4942
  if (!envObject.canCallIntoJs())
4867
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4943
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4868
4944
  envObject.clearLastError();
4869
4945
  try {
4870
4946
  if (!result)
@@ -4908,7 +4984,7 @@ function _napi_get_named_property(env, object, utf8name, result) {
4908
4984
  if (!envObject.tryCatch.isEmpty())
4909
4985
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
4910
4986
  if (!envObject.canCallIntoJs())
4911
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4987
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4912
4988
  envObject.clearLastError();
4913
4989
  try {
4914
4990
  if (!result)
@@ -4951,7 +5027,7 @@ function _napi_set_element(env, object, index, value) {
4951
5027
  if (!envObject.tryCatch.isEmpty())
4952
5028
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
4953
5029
  if (!envObject.canCallIntoJs())
4954
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
5030
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4955
5031
  envObject.clearLastError();
4956
5032
  try {
4957
5033
  if (!value)
@@ -4982,7 +5058,7 @@ function _napi_has_element(env, object, index, result) {
4982
5058
  if (!envObject.tryCatch.isEmpty())
4983
5059
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
4984
5060
  if (!envObject.canCallIntoJs())
4985
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
5061
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
4986
5062
  envObject.clearLastError();
4987
5063
  try {
4988
5064
  if (!result)
@@ -5022,7 +5098,7 @@ function _napi_get_element(env, object, index, result) {
5022
5098
  if (!envObject.tryCatch.isEmpty())
5023
5099
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
5024
5100
  if (!envObject.canCallIntoJs())
5025
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
5101
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
5026
5102
  envObject.clearLastError();
5027
5103
  try {
5028
5104
  if (!result)
@@ -5063,7 +5139,7 @@ function _napi_delete_element(env, object, index, result) {
5063
5139
  if (!envObject.tryCatch.isEmpty())
5064
5140
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
5065
5141
  if (!envObject.canCallIntoJs())
5066
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
5142
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
5067
5143
  envObject.clearLastError();
5068
5144
  try {
5069
5145
  if (!object)
@@ -5106,7 +5182,7 @@ function _napi_define_properties(env, object, property_count, properties) {
5106
5182
  if (!envObject.tryCatch.isEmpty())
5107
5183
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
5108
5184
  if (!envObject.canCallIntoJs())
5109
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
5185
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
5110
5186
  envObject.clearLastError();
5111
5187
  try {
5112
5188
  {{{ from64('properties') }}};
@@ -5167,7 +5243,7 @@ function _napi_object_freeze(env, object) {
5167
5243
  if (!envObject.tryCatch.isEmpty())
5168
5244
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
5169
5245
  if (!envObject.canCallIntoJs())
5170
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
5246
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
5171
5247
  envObject.clearLastError();
5172
5248
  try {
5173
5249
  if (!object)
@@ -5195,7 +5271,7 @@ function _napi_object_seal(env, object) {
5195
5271
  if (!envObject.tryCatch.isEmpty())
5196
5272
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
5197
5273
  if (!envObject.canCallIntoJs())
5198
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
5274
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
5199
5275
  envObject.clearLastError();
5200
5276
  try {
5201
5277
  if (!object)
@@ -5228,7 +5304,7 @@ function _napi_run_script(env, script, result) {
5228
5304
  if (!envObject.tryCatch.isEmpty())
5229
5305
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
5230
5306
  if (!envObject.canCallIntoJs())
5231
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
5307
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
5232
5308
  envObject.clearLastError();
5233
5309
  try {
5234
5310
  if (!script)
@@ -6146,7 +6222,7 @@ function _napi_coerce_to_bool(env, value, result) {
6146
6222
  if (!envObject.tryCatch.isEmpty())
6147
6223
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
6148
6224
  if (!envObject.canCallIntoJs())
6149
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
6225
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
6150
6226
  envObject.clearLastError();
6151
6227
  try {
6152
6228
  if (!value)
@@ -6176,7 +6252,7 @@ function _napi_coerce_to_number(env, value, result) {
6176
6252
  if (!envObject.tryCatch.isEmpty())
6177
6253
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
6178
6254
  if (!envObject.canCallIntoJs())
6179
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
6255
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
6180
6256
  envObject.clearLastError();
6181
6257
  try {
6182
6258
  if (!value)
@@ -6210,7 +6286,7 @@ function _napi_coerce_to_object(env, value, result) {
6210
6286
  if (!envObject.tryCatch.isEmpty())
6211
6287
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
6212
6288
  if (!envObject.canCallIntoJs())
6213
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
6289
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
6214
6290
  envObject.clearLastError();
6215
6291
  try {
6216
6292
  if (!value)
@@ -6244,7 +6320,7 @@ function _napi_coerce_to_string(env, value, result) {
6244
6320
  if (!envObject.tryCatch.isEmpty())
6245
6321
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
6246
6322
  if (!envObject.canCallIntoJs())
6247
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
6323
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
6248
6324
  envObject.clearLastError();
6249
6325
  try {
6250
6326
  if (!value)
@@ -6278,7 +6354,7 @@ function _napi_instanceof(env, object, constructor, result) {
6278
6354
  if (!envObject.tryCatch.isEmpty())
6279
6355
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
6280
6356
  if (!envObject.canCallIntoJs())
6281
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
6357
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
6282
6358
  envObject.clearLastError();
6283
6359
  try {
6284
6360
  if (!object)
@@ -6442,7 +6518,7 @@ function _napi_strict_equals(env, lhs, rhs, result) {
6442
6518
  if (!envObject.tryCatch.isEmpty())
6443
6519
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
6444
6520
  if (!envObject.canCallIntoJs())
6445
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
6521
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
6446
6522
  envObject.clearLastError();
6447
6523
  try {
6448
6524
  if (!lhs)
@@ -6499,7 +6575,7 @@ function _napi_is_detached_arraybuffer(env, arraybuffer, result) {
6499
6575
  if (!envObject.tryCatch.isEmpty())
6500
6576
  return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
6501
6577
  if (!envObject.canCallIntoJs())
6502
- return envObject.setLastError(envObject.moduleApiVersion === 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */ ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
6578
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
6503
6579
  envObject.clearLastError();
6504
6580
  try {
6505
6581
  if (!arraybuffer)
@@ -6534,7 +6610,7 @@ function _napi_get_version(env, result) {
6534
6610
  if (!result)
6535
6611
  return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
6536
6612
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
6537
- var NODE_API_SUPPORTED_VERSION_MAX = 9 /* Version.NODE_API_SUPPORTED_VERSION_MAX */;
6613
+ var NODE_API_SUPPORTED_VERSION_MAX = 10 /* Version.NODE_API_SUPPORTED_VERSION_MAX */;
6538
6614
  {{{ makeSetValue('result', 0, 'NODE_API_SUPPORTED_VERSION_MAX', 'u32') }}};
6539
6615
  return envObject.clearLastError();
6540
6616
  }
@@ -6849,18 +6925,18 @@ function _napi_get_version(env, result) {
6849
6925
  napi_get_boolean: _napi_get_boolean,
6850
6926
  napi_get_boolean__deps: ["$emnapiCtx"],
6851
6927
  napi_get_boolean__sig: "ipip",
6928
+ napi_get_dataview_info: _napi_get_dataview_info,
6929
+ napi_get_dataview_info__deps: ["$emnapiCtx", "$emnapiExternalMemory"],
6930
+ napi_get_dataview_info__sig: "ipppppp",
6852
6931
  napi_get_typedarray_info: _napi_get_typedarray_info,
6853
6932
  napi_get_typedarray_info__deps: ["$emnapiCtx", "$emnapiExternalMemory"],
6854
6933
  napi_get_typedarray_info__sig: "ippppppp",
6855
6934
  napi_get_buffer_info: _napi_get_buffer_info,
6856
- napi_get_buffer_info__deps: ["$emnapiCtx", "napi_get_typedarray_info"],
6935
+ napi_get_buffer_info__deps: ["$emnapiCtx", "napi_get_dataview_info", "napi_get_typedarray_info"],
6857
6936
  napi_get_buffer_info__sig: "ipppp",
6858
6937
  napi_get_cb_info: _napi_get_cb_info,
6859
6938
  napi_get_cb_info__deps: ["$emnapiCtx"],
6860
6939
  napi_get_cb_info__sig: "ipppppp",
6861
- napi_get_dataview_info: _napi_get_dataview_info,
6862
- napi_get_dataview_info__deps: ["$emnapiCtx", "$emnapiExternalMemory"],
6863
- napi_get_dataview_info__sig: "ipppppp",
6864
6940
  napi_get_date_value: _napi_get_date_value,
6865
6941
  napi_get_date_value__deps: ["$emnapiCtx"],
6866
6942
  napi_get_date_value__sig: "ippp",
@@ -7083,6 +7159,9 @@ function _napi_get_version(env, result) {
7083
7159
  napi_wrap: _napi_wrap,
7084
7160
  napi_wrap__deps: ["$emnapiWrap"],
7085
7161
  napi_wrap__sig: "ipppppp",
7162
+ node_api_create_buffer_from_arraybuffer: _node_api_create_buffer_from_arraybuffer,
7163
+ node_api_create_buffer_from_arraybuffer__deps: ["$emnapiCtx", "$emnapiExternalMemory"],
7164
+ node_api_create_buffer_from_arraybuffer__sig: "ippppp",
7086
7165
  node_api_create_external_string_latin1: _node_api_create_external_string_latin1,
7087
7166
  node_api_create_external_string_latin1__deps: ["$emnapiString", "napi_create_string_latin1"],
7088
7167
  node_api_create_external_string_latin1__sig: "ippppppp",
package/emnapi.gyp CHANGED
@@ -102,6 +102,7 @@
102
102
  'src/uv/uv-common.c',
103
103
  'src/uv/threadpool.c',
104
104
  'src/uv/unix/loop.c',
105
+ 'src/uv/unix/posix-hrtime.c',
105
106
  'src/uv/unix/thread.c',
106
107
  'src/uv/unix/async.c',
107
108
  'src/uv/unix/core.c',
@@ -6,7 +6,7 @@
6
6
  #include "emnapi_common.h"
7
7
 
8
8
  #define EMNAPI_MAJOR_VERSION 1
9
- #define EMNAPI_MINOR_VERSION 3
9
+ #define EMNAPI_MINOR_VERSION 4
10
10
  #define EMNAPI_PATCH_VERSION 0
11
11
 
12
12
  typedef enum {
@@ -98,8 +98,7 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_create_string_utf16(napi_env env,
98
98
  const char16_t* str,
99
99
  size_t length,
100
100
  napi_value* result);
101
- #ifdef NAPI_EXPERIMENTAL
102
- #define NODE_API_EXPERIMENTAL_HAS_EXTERNAL_STRINGS
101
+ #if NAPI_VERSION >= 10
103
102
  NAPI_EXTERN napi_status NAPI_CDECL node_api_create_external_string_latin1(
104
103
  napi_env env,
105
104
  char* str,
@@ -116,17 +115,14 @@ node_api_create_external_string_utf16(napi_env env,
116
115
  void* finalize_hint,
117
116
  napi_value* result,
118
117
  bool* copied);
119
- #endif // NAPI_EXPERIMENTAL
120
118
 
121
- #ifdef NAPI_EXPERIMENTAL
122
- #define NODE_API_EXPERIMENTAL_HAS_PROPERTY_KEYS
123
119
  NAPI_EXTERN napi_status NAPI_CDECL node_api_create_property_key_latin1(
124
120
  napi_env env, const char* str, size_t length, napi_value* result);
125
121
  NAPI_EXTERN napi_status NAPI_CDECL node_api_create_property_key_utf8(
126
122
  napi_env env, const char* str, size_t length, napi_value* result);
127
123
  NAPI_EXTERN napi_status NAPI_CDECL node_api_create_property_key_utf16(
128
124
  napi_env env, const char16_t* str, size_t length, napi_value* result);
129
- #endif // NAPI_EXPERIMENTAL
125
+ #endif // NAPI_VERSION >= 10
130
126
 
131
127
  NAPI_EXTERN napi_status NAPI_CDECL napi_create_symbol(napi_env env,
132
128
  napi_value description,
@@ -100,9 +100,6 @@ EXTERN_C_START
100
100
 
101
101
  // Deprecated. Replaced by symbol-based registration defined by NAPI_MODULE
102
102
  // and NAPI_MODULE_INIT macros.
103
- #if defined(__cplusplus) && __cplusplus >= 201402L
104
- [[deprecated]]
105
- #endif
106
103
  NAPI_EXTERN void NAPI_CDECL
107
104
  napi_module_register(napi_module* mod);
108
105
 
@@ -145,6 +142,17 @@ napi_create_external_buffer(napi_env env,
145
142
  void* finalize_hint,
146
143
  napi_value* result);
147
144
  #endif // NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED
145
+
146
+ #if NAPI_VERSION >= 10
147
+
148
+ NAPI_EXTERN napi_status NAPI_CDECL
149
+ node_api_create_buffer_from_arraybuffer(napi_env env,
150
+ napi_value arraybuffer,
151
+ size_t byte_offset,
152
+ size_t byte_length,
153
+ napi_value* result);
154
+ #endif // NAPI_VERSION >= 10
155
+
148
156
  NAPI_EXTERN napi_status NAPI_CDECL napi_create_buffer_copy(napi_env env,
149
157
  size_t length,
150
158
  const void* data,
package/index.js CHANGED
@@ -16,6 +16,7 @@ const sources = [
16
16
  path.join(__dirname, './src/uv/uv-common.c'),
17
17
  path.join(__dirname, './src/uv/threadpool.c'),
18
18
  path.join(__dirname, './src/uv/unix/loop.c'),
19
+ path.join(__dirname, './src/uv/unix/posix-hrtime.c'),
19
20
  path.join(__dirname, './src/uv/unix/thread.c'),
20
21
  path.join(__dirname, './src/uv/unix/async.c'),
21
22
  path.join(__dirname, './src/uv/unix/core.c')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emnapi",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Node-API implementation for Emscripten",
5
5
  "main": "index.js",
6
6
  "gypfile": false,