emnapi 1.3.1 → 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 +10 -0
- package/common.gypi +2 -2
- package/dist/library_napi.js +95 -84
- package/include/node/emnapi.h +2 -2
- package/include/node/js_native_api.h +2 -6
- package/include/node/node_api.h +2 -6
- package/package.json +1 -1
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:
|
|
@@ -187,6 +189,7 @@ emcc -O3 \
|
|
|
187
189
|
-L./node_modules/emnapi/lib/wasm32-emscripten \
|
|
188
190
|
--js-library=./node_modules/emnapi/dist/library_napi.js \
|
|
189
191
|
-sEXPORTED_FUNCTIONS="['_malloc','_free','_napi_register_wasm_v1','_node_api_module_get_api_version_v1']" \
|
|
192
|
+
-sEXPORTED_RUNTIME_METHODS=['emnapiInit'] \
|
|
190
193
|
-o hello.js \
|
|
191
194
|
hello.c \
|
|
192
195
|
-lemnapi
|
|
@@ -477,6 +480,7 @@ em++ -O3 \
|
|
|
477
480
|
-L./node_modules/emnapi/lib/wasm32-emscripten \
|
|
478
481
|
--js-library=./node_modules/emnapi/dist/library_napi.js \
|
|
479
482
|
-sEXPORTED_FUNCTIONS="['_malloc','_free','_napi_register_wasm_v1','_node_api_module_get_api_version_v1']" \
|
|
483
|
+
-sEXPORTED_RUNTIME_METHODS=['emnapiInit'] \
|
|
480
484
|
-o hello.js \
|
|
481
485
|
hello.cpp \
|
|
482
486
|
-lemnapi
|
|
@@ -559,6 +563,10 @@ void* operator new(size_t size) {
|
|
|
559
563
|
void operator delete(void* p) noexcept {
|
|
560
564
|
free(p);
|
|
561
565
|
}
|
|
566
|
+
|
|
567
|
+
void operator delete(void* p, size_t) noexcept {
|
|
568
|
+
free(p);
|
|
569
|
+
}
|
|
562
570
|
```
|
|
563
571
|
|
|
564
572
|
</details>
|
|
@@ -580,6 +588,7 @@ target_link_libraries(hello emnapi)
|
|
|
580
588
|
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
|
581
589
|
target_link_options(hello PRIVATE
|
|
582
590
|
"-sEXPORTED_FUNCTIONS=['_malloc','_free','_napi_register_wasm_v1','_node_api_module_get_api_version_v1']"
|
|
591
|
+
"-sEXPORTED_RUNTIME_METHODS=['emnapiInit']"
|
|
583
592
|
)
|
|
584
593
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "WASI")
|
|
585
594
|
set_target_properties(hello PROPERTIES SUFFIX ".wasm")
|
|
@@ -849,6 +858,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
|
|
849
858
|
target_link_options(hello PRIVATE
|
|
850
859
|
"-sALLOW_MEMORY_GROWTH=1"
|
|
851
860
|
"-sEXPORTED_FUNCTIONS=['_malloc','_free','_napi_register_wasm_v1','_node_api_module_get_api_version_v1']"
|
|
861
|
+
"-sEXPORTED_RUNTIME_METHODS=['emnapiInit']"
|
|
852
862
|
"-pthread"
|
|
853
863
|
"-sPTHREAD_POOL_SIZE=4"
|
|
854
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=
|
|
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=
|
|
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)',
|
package/dist/library_napi.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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)
|
|
@@ -1298,7 +1298,7 @@ function _napi_get_date_value(env, value, result) {
|
|
|
1298
1298
|
if (!envObject.tryCatch.isEmpty())
|
|
1299
1299
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
1300
1300
|
if (!envObject.canCallIntoJs())
|
|
1301
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
1301
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
1302
1302
|
envObject.clearLastError();
|
|
1303
1303
|
try {
|
|
1304
1304
|
if (!value)
|
|
@@ -1529,7 +1529,7 @@ function _napi_get_value_external(env, value, result) {
|
|
|
1529
1529
|
}
|
|
1530
1530
|
{{{ from64('result') }}};
|
|
1531
1531
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1532
|
-
var p = handle.data(
|
|
1532
|
+
var p = handle.data();
|
|
1533
1533
|
{{{ makeSetValue('result', 0, 'p', '*') }}};
|
|
1534
1534
|
return envObject.clearLastError();
|
|
1535
1535
|
}
|
|
@@ -1964,7 +1964,7 @@ function _napi_create_bigint_words(env, sign_bit, word_count, words, result) {
|
|
|
1964
1964
|
if (!envObject.tryCatch.isEmpty())
|
|
1965
1965
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
1966
1966
|
if (!envObject.canCallIntoJs())
|
|
1967
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
1967
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
1968
1968
|
envObject.clearLastError();
|
|
1969
1969
|
try {
|
|
1970
1970
|
if (!emnapiCtx.feature.supportBigInt) {
|
|
@@ -2006,25 +2006,34 @@ function emnapiCreateFunction(envObject, utf8name, length, cb, data) {
|
|
|
2006
2006
|
{{{ from64('utf8name') }}};
|
|
2007
2007
|
var functionName = (!utf8name || !length) ? '' : (emnapiString.UTF8ToString(utf8name, length));
|
|
2008
2008
|
var f;
|
|
2009
|
-
var
|
|
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) {
|
|
2010
2014
|
return function () {
|
|
2011
2015
|
'use strict';
|
|
2012
|
-
var
|
|
2013
|
-
var
|
|
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;
|
|
2014
2022
|
try {
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
return (!napiValue) ? undefined : emnapiCtx.handleStore.get(napiValue).value;
|
|
2018
|
-
});
|
|
2023
|
+
var napiValue = envObject.callIntoModule(callback);
|
|
2024
|
+
return (!napiValue) ? undefined : envObject.ctx.handleStore.get(napiValue).value;
|
|
2019
2025
|
}
|
|
2020
2026
|
finally {
|
|
2021
|
-
|
|
2022
|
-
|
|
2027
|
+
callbackInfo.data = 0;
|
|
2028
|
+
callbackInfo.args = undefined;
|
|
2029
|
+
callbackInfo.thiz = undefined;
|
|
2030
|
+
callbackInfo.fn = undefined;
|
|
2031
|
+
envObject.ctx.closeScope(envObject, scope);
|
|
2023
2032
|
}
|
|
2024
2033
|
};
|
|
2025
2034
|
};
|
|
2026
2035
|
if (functionName === '') {
|
|
2027
|
-
f = makeFunction();
|
|
2036
|
+
f = makeFunction(envObject, callback);
|
|
2028
2037
|
return { status: 0 /* napi_status.napi_ok */, f: f };
|
|
2029
2038
|
}
|
|
2030
2039
|
if (!(/^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(functionName))) {
|
|
@@ -2032,7 +2041,7 @@ function emnapiCreateFunction(envObject, utf8name, length, cb, data) {
|
|
|
2032
2041
|
}
|
|
2033
2042
|
#if DYNAMIC_EXECUTION
|
|
2034
2043
|
if (emnapiCtx.feature.supportNewFunction) {
|
|
2035
|
-
var _ = makeFunction();
|
|
2044
|
+
var _ = makeFunction(envObject, callback);
|
|
2036
2045
|
try {
|
|
2037
2046
|
f = (new Function('_', 'return function ' + functionName + '(){' +
|
|
2038
2047
|
'"use strict";' +
|
|
@@ -2040,18 +2049,18 @@ function emnapiCreateFunction(envObject, utf8name, length, cb, data) {
|
|
|
2040
2049
|
'};'))(_);
|
|
2041
2050
|
}
|
|
2042
2051
|
catch (_err) {
|
|
2043
|
-
f = makeFunction();
|
|
2052
|
+
f = makeFunction(envObject, callback);
|
|
2044
2053
|
if (emnapiCtx.feature.canSetFunctionName)
|
|
2045
2054
|
Object.defineProperty(f, 'name', { value: functionName });
|
|
2046
2055
|
}
|
|
2047
2056
|
}
|
|
2048
2057
|
else {
|
|
2049
|
-
f = makeFunction();
|
|
2058
|
+
f = makeFunction(envObject, callback);
|
|
2050
2059
|
if (emnapiCtx.feature.canSetFunctionName)
|
|
2051
2060
|
Object.defineProperty(f, 'name', { value: functionName });
|
|
2052
2061
|
}
|
|
2053
2062
|
#else
|
|
2054
|
-
f = makeFunction();
|
|
2063
|
+
f = makeFunction(envObject, callback);
|
|
2055
2064
|
if (emnapiCtx.feature.canSetFunctionName)
|
|
2056
2065
|
Object.defineProperty(f, 'name', { value: functionName });
|
|
2057
2066
|
#endif
|
|
@@ -2118,7 +2127,7 @@ function emnapiWrap(env, js_object, native_object, finalize_cb, finalize_hint, r
|
|
|
2118
2127
|
if (!envObject.tryCatch.isEmpty())
|
|
2119
2128
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
2120
2129
|
if (!envObject.canCallIntoJs())
|
|
2121
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
2130
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
2122
2131
|
envObject.clearLastError();
|
|
2123
2132
|
try {
|
|
2124
2133
|
if (!emnapiCtx.feature.supportFinalizer) {
|
|
@@ -2173,7 +2182,7 @@ function emnapiUnwrap(env, js_object, result, action) {
|
|
|
2173
2182
|
if (!envObject.tryCatch.isEmpty())
|
|
2174
2183
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
2175
2184
|
if (!envObject.canCallIntoJs())
|
|
2176
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
2185
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
2177
2186
|
envObject.clearLastError();
|
|
2178
2187
|
try {
|
|
2179
2188
|
if (!js_object)
|
|
@@ -2228,7 +2237,7 @@ function _napi_define_class(env, utf8name, length, constructor, callback_data, p
|
|
|
2228
2237
|
if (!envObject.tryCatch.isEmpty())
|
|
2229
2238
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
2230
2239
|
if (!envObject.canCallIntoJs())
|
|
2231
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
2240
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
2232
2241
|
envObject.clearLastError();
|
|
2233
2242
|
try {
|
|
2234
2243
|
if (!result)
|
|
@@ -2323,7 +2332,7 @@ function _napi_type_tag_object(env, object, type_tag) {
|
|
|
2323
2332
|
if (!envObject.tryCatch.isEmpty())
|
|
2324
2333
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
2325
2334
|
if (!envObject.canCallIntoJs())
|
|
2326
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
2335
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
2327
2336
|
envObject.clearLastError();
|
|
2328
2337
|
try {
|
|
2329
2338
|
if (!object) {
|
|
@@ -2365,7 +2374,7 @@ function _napi_check_object_type_tag(env, object, type_tag, result) {
|
|
|
2365
2374
|
if (!envObject.tryCatch.isEmpty())
|
|
2366
2375
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
2367
2376
|
if (!envObject.canCallIntoJs())
|
|
2368
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
2377
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
2369
2378
|
envObject.clearLastError();
|
|
2370
2379
|
try {
|
|
2371
2380
|
if (!object) {
|
|
@@ -2461,7 +2470,7 @@ function _emnapi_create_memory_view(env, typedarray_type, external_data, byte_le
|
|
|
2461
2470
|
if (!envObject.tryCatch.isEmpty())
|
|
2462
2471
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
2463
2472
|
if (!envObject.canCallIntoJs())
|
|
2464
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
2473
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
2465
2474
|
envObject.clearLastError();
|
|
2466
2475
|
try {
|
|
2467
2476
|
if (!result)
|
|
@@ -2635,7 +2644,7 @@ function _emnapi_sync_memory(env, js_to_wasm, arraybuffer_or_view, offset, len)
|
|
|
2635
2644
|
if (!envObject.tryCatch.isEmpty())
|
|
2636
2645
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
2637
2646
|
if (!envObject.canCallIntoJs())
|
|
2638
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
2647
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
2639
2648
|
envObject.clearLastError();
|
|
2640
2649
|
try {
|
|
2641
2650
|
if (!arraybuffer_or_view)
|
|
@@ -2696,7 +2705,7 @@ function _emnapi_get_memory_address(env, arraybuffer_or_view, address, ownership
|
|
|
2696
2705
|
if (!envObject.tryCatch.isEmpty())
|
|
2697
2706
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
2698
2707
|
if (!envObject.canCallIntoJs())
|
|
2699
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
2708
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
2700
2709
|
envObject.clearLastError();
|
|
2701
2710
|
try {
|
|
2702
2711
|
if (!arraybuffer_or_view)
|
|
@@ -2817,7 +2826,7 @@ function _napi_create_arraybuffer(env, byte_length, data, result) {
|
|
|
2817
2826
|
if (!envObject.tryCatch.isEmpty())
|
|
2818
2827
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
2819
2828
|
if (!envObject.canCallIntoJs())
|
|
2820
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
2829
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
2821
2830
|
envObject.clearLastError();
|
|
2822
2831
|
try {
|
|
2823
2832
|
if (!result)
|
|
@@ -2847,7 +2856,7 @@ function _napi_create_date(env, time, result) {
|
|
|
2847
2856
|
if (!envObject.tryCatch.isEmpty())
|
|
2848
2857
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
2849
2858
|
if (!envObject.canCallIntoJs())
|
|
2850
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
2859
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
2851
2860
|
envObject.clearLastError();
|
|
2852
2861
|
try {
|
|
2853
2862
|
if (!result)
|
|
@@ -2877,7 +2886,7 @@ function _napi_create_external(env, data, finalize_cb, finalize_hint, result) {
|
|
|
2877
2886
|
if (!envObject.tryCatch.isEmpty())
|
|
2878
2887
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
2879
2888
|
if (!envObject.canCallIntoJs())
|
|
2880
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
2889
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
2881
2890
|
envObject.clearLastError();
|
|
2882
2891
|
try {
|
|
2883
2892
|
if (!result)
|
|
@@ -2885,7 +2894,7 @@ function _napi_create_external(env, data, finalize_cb, finalize_hint, result) {
|
|
|
2885
2894
|
if (!emnapiCtx.feature.supportFinalizer && finalize_cb) {
|
|
2886
2895
|
throw emnapiCtx.createNotSupportWeakRefError('napi_create_external', 'Parameter "finalize_cb" must be 0(NULL)');
|
|
2887
2896
|
}
|
|
2888
|
-
var externalHandle = emnapiCtx.getCurrentScope().addExternal(
|
|
2897
|
+
var externalHandle = emnapiCtx.getCurrentScope().addExternal(data);
|
|
2889
2898
|
if (finalize_cb) {
|
|
2890
2899
|
emnapiCtx.createReferenceWithFinalizer(envObject, externalHandle.id, 0, 0 /* ReferenceOwnership.kRuntime */, finalize_cb, data, finalize_hint);
|
|
2891
2900
|
}
|
|
@@ -2913,7 +2922,7 @@ function _napi_create_external_arraybuffer(env, external_data, byte_length, fina
|
|
|
2913
2922
|
if (!envObject.tryCatch.isEmpty())
|
|
2914
2923
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
2915
2924
|
if (!envObject.canCallIntoJs())
|
|
2916
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
2925
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
2917
2926
|
envObject.clearLastError();
|
|
2918
2927
|
try {
|
|
2919
2928
|
if (!result)
|
|
@@ -3030,7 +3039,7 @@ function _napi_create_typedarray(env, type, length, arraybuffer, byte_offset, re
|
|
|
3030
3039
|
if (!envObject.tryCatch.isEmpty())
|
|
3031
3040
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
3032
3041
|
if (!envObject.canCallIntoJs())
|
|
3033
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
3042
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
3034
3043
|
envObject.clearLastError();
|
|
3035
3044
|
try {
|
|
3036
3045
|
if (!arraybuffer)
|
|
@@ -3128,7 +3137,7 @@ function _napi_create_buffer(env, size, data, result) {
|
|
|
3128
3137
|
if (!envObject.tryCatch.isEmpty())
|
|
3129
3138
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
3130
3139
|
if (!envObject.canCallIntoJs())
|
|
3131
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
3140
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
3132
3141
|
envObject.clearLastError();
|
|
3133
3142
|
try {
|
|
3134
3143
|
if (!result)
|
|
@@ -3187,7 +3196,7 @@ function _napi_create_buffer_copy(env, length, data, result_data, result) {
|
|
|
3187
3196
|
if (!envObject.tryCatch.isEmpty())
|
|
3188
3197
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
3189
3198
|
if (!envObject.canCallIntoJs())
|
|
3190
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
3199
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
3191
3200
|
envObject.clearLastError();
|
|
3192
3201
|
try {
|
|
3193
3202
|
if (!result)
|
|
@@ -3231,7 +3240,7 @@ function _node_api_create_buffer_from_arraybuffer(env, arraybuffer, byte_offset,
|
|
|
3231
3240
|
if (!envObject.tryCatch.isEmpty())
|
|
3232
3241
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
3233
3242
|
if (!envObject.canCallIntoJs())
|
|
3234
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
3243
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
3235
3244
|
envObject.clearLastError();
|
|
3236
3245
|
try {
|
|
3237
3246
|
if (!arraybuffer)
|
|
@@ -3293,7 +3302,7 @@ function _napi_create_dataview(env, byte_length, arraybuffer, byte_offset, resul
|
|
|
3293
3302
|
if (!envObject.tryCatch.isEmpty())
|
|
3294
3303
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
3295
3304
|
if (!envObject.canCallIntoJs())
|
|
3296
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
3305
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
3297
3306
|
envObject.clearLastError();
|
|
3298
3307
|
try {
|
|
3299
3308
|
if (!arraybuffer)
|
|
@@ -3479,7 +3488,7 @@ function _napi_throw(env, error) {
|
|
|
3479
3488
|
if (!envObject.tryCatch.isEmpty())
|
|
3480
3489
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
3481
3490
|
if (!envObject.canCallIntoJs())
|
|
3482
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
3491
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
3483
3492
|
envObject.clearLastError();
|
|
3484
3493
|
try {
|
|
3485
3494
|
if (!error)
|
|
@@ -3502,7 +3511,7 @@ function _napi_throw_error(env, code, msg) {
|
|
|
3502
3511
|
if (!envObject.tryCatch.isEmpty())
|
|
3503
3512
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
3504
3513
|
if (!envObject.canCallIntoJs())
|
|
3505
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
3514
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
3506
3515
|
envObject.clearLastError();
|
|
3507
3516
|
try {
|
|
3508
3517
|
if (!msg)
|
|
@@ -3530,7 +3539,7 @@ function _napi_throw_type_error(env, code, msg) {
|
|
|
3530
3539
|
if (!envObject.tryCatch.isEmpty())
|
|
3531
3540
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
3532
3541
|
if (!envObject.canCallIntoJs())
|
|
3533
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
3542
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
3534
3543
|
envObject.clearLastError();
|
|
3535
3544
|
try {
|
|
3536
3545
|
if (!msg)
|
|
@@ -3558,7 +3567,7 @@ function _napi_throw_range_error(env, code, msg) {
|
|
|
3558
3567
|
if (!envObject.tryCatch.isEmpty())
|
|
3559
3568
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
3560
3569
|
if (!envObject.canCallIntoJs())
|
|
3561
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
3570
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
3562
3571
|
envObject.clearLastError();
|
|
3563
3572
|
try {
|
|
3564
3573
|
if (!msg)
|
|
@@ -3586,7 +3595,7 @@ function _node_api_throw_syntax_error(env, code, msg) {
|
|
|
3586
3595
|
if (!envObject.tryCatch.isEmpty())
|
|
3587
3596
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
3588
3597
|
if (!envObject.canCallIntoJs())
|
|
3589
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
3598
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
3590
3599
|
envObject.clearLastError();
|
|
3591
3600
|
try {
|
|
3592
3601
|
if (!msg)
|
|
@@ -3783,7 +3792,7 @@ function _napi_fatal_exception(env, err) {
|
|
|
3783
3792
|
if (!envObject.tryCatch.isEmpty())
|
|
3784
3793
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
3785
3794
|
if (!envObject.canCallIntoJs())
|
|
3786
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
3795
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
3787
3796
|
envObject.clearLastError();
|
|
3788
3797
|
try {
|
|
3789
3798
|
if (!err)
|
|
@@ -3814,7 +3823,7 @@ function _napi_create_function(env, utf8name, length, cb, data, result) {
|
|
|
3814
3823
|
if (!envObject.tryCatch.isEmpty())
|
|
3815
3824
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
3816
3825
|
if (!envObject.canCallIntoJs())
|
|
3817
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
3826
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
3818
3827
|
envObject.clearLastError();
|
|
3819
3828
|
try {
|
|
3820
3829
|
if (!result)
|
|
@@ -3844,7 +3853,7 @@ function _napi_get_cb_info(env, cbinfo, argc, argv, this_arg, data) {
|
|
|
3844
3853
|
var envObject = emnapiCtx.envStore.get(env);
|
|
3845
3854
|
if (!cbinfo)
|
|
3846
3855
|
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
3847
|
-
var cbinfoValue = emnapiCtx.
|
|
3856
|
+
var cbinfoValue = emnapiCtx.scopeStore.get(cbinfo).callbackInfo;
|
|
3848
3857
|
{{{ from64('argc') }}};
|
|
3849
3858
|
{{{ from64('argv') }}};
|
|
3850
3859
|
if (argv) {
|
|
@@ -3894,7 +3903,7 @@ function _napi_call_function(env, recv, func, argc, argv, result) {
|
|
|
3894
3903
|
if (!envObject.tryCatch.isEmpty())
|
|
3895
3904
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
3896
3905
|
if (!envObject.canCallIntoJs())
|
|
3897
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
3906
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
3898
3907
|
envObject.clearLastError();
|
|
3899
3908
|
try {
|
|
3900
3909
|
if (!recv)
|
|
@@ -3943,7 +3952,7 @@ function _napi_new_instance(env, constructor, argc, argv, result) {
|
|
|
3943
3952
|
if (!envObject.tryCatch.isEmpty())
|
|
3944
3953
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
3945
3954
|
if (!envObject.canCallIntoJs())
|
|
3946
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
3955
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
3947
3956
|
envObject.clearLastError();
|
|
3948
3957
|
try {
|
|
3949
3958
|
if (!constructor)
|
|
@@ -4003,9 +4012,13 @@ function _napi_get_new_target(env, cbinfo, result) {
|
|
|
4003
4012
|
if (!result)
|
|
4004
4013
|
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
4005
4014
|
{{{ from64('result') }}};
|
|
4006
|
-
var cbinfoValue = emnapiCtx.
|
|
4007
|
-
|
|
4008
|
-
var value =
|
|
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;
|
|
4009
4022
|
{{{ makeSetValue('result', 0, 'value', '*') }}};
|
|
4010
4023
|
return envObject.clearLastError();
|
|
4011
4024
|
}
|
|
@@ -4106,7 +4119,7 @@ function _napi_create_reference(env, value, initial_refcount, result) {
|
|
|
4106
4119
|
if (!result)
|
|
4107
4120
|
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
4108
4121
|
var handle = emnapiCtx.handleStore.get(value);
|
|
4109
|
-
if (envObject.moduleApiVersion
|
|
4122
|
+
if (envObject.moduleApiVersion < 10) {
|
|
4110
4123
|
if (!(handle.isObject() || handle.isFunction() || handle.isSymbol())) {
|
|
4111
4124
|
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
4112
4125
|
}
|
|
@@ -4121,9 +4134,7 @@ function _napi_create_reference(env, value, initial_refcount, result) {
|
|
|
4121
4134
|
function _napi_delete_reference(env, ref) {
|
|
4122
4135
|
if (!env)
|
|
4123
4136
|
return 1 /* napi_status.napi_invalid_arg */;
|
|
4124
|
-
// @ts-expect-error
|
|
4125
4137
|
var envObject = emnapiCtx.envStore.get(env);
|
|
4126
|
-
envObject.checkGCAccess();
|
|
4127
4138
|
if (!ref)
|
|
4128
4139
|
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
4129
4140
|
emnapiCtx.refStore.get(ref).dispose();
|
|
@@ -4368,7 +4379,7 @@ function _napi_make_callback(env, async_context, recv, func, argc, argv, result)
|
|
|
4368
4379
|
if (!envObject.tryCatch.isEmpty())
|
|
4369
4380
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
4370
4381
|
if (!envObject.canCallIntoJs())
|
|
4371
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
4382
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
4372
4383
|
envObject.clearLastError();
|
|
4373
4384
|
try {
|
|
4374
4385
|
if (!emnapiNodeBinding) {
|
|
@@ -4433,7 +4444,7 @@ function _napi_create_promise(env, deferred, promise) {
|
|
|
4433
4444
|
if (!envObject.tryCatch.isEmpty())
|
|
4434
4445
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
4435
4446
|
if (!envObject.canCallIntoJs())
|
|
4436
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
4447
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
4437
4448
|
envObject.clearLastError();
|
|
4438
4449
|
try {
|
|
4439
4450
|
if (!deferred)
|
|
@@ -4467,7 +4478,7 @@ function _napi_resolve_deferred(env, deferred, resolution) {
|
|
|
4467
4478
|
if (!envObject.tryCatch.isEmpty())
|
|
4468
4479
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
4469
4480
|
if (!envObject.canCallIntoJs())
|
|
4470
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
4481
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
4471
4482
|
envObject.clearLastError();
|
|
4472
4483
|
try {
|
|
4473
4484
|
if (!deferred)
|
|
@@ -4493,7 +4504,7 @@ function _napi_reject_deferred(env, deferred, resolution) {
|
|
|
4493
4504
|
if (!envObject.tryCatch.isEmpty())
|
|
4494
4505
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
4495
4506
|
if (!envObject.canCallIntoJs())
|
|
4496
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
4507
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
4497
4508
|
envObject.clearLastError();
|
|
4498
4509
|
try {
|
|
4499
4510
|
if (!deferred)
|
|
@@ -4539,7 +4550,7 @@ function _napi_get_all_property_names(env, object, key_mode, key_filter, key_con
|
|
|
4539
4550
|
if (!envObject.tryCatch.isEmpty())
|
|
4540
4551
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
4541
4552
|
if (!envObject.canCallIntoJs())
|
|
4542
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
4553
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
4543
4554
|
envObject.clearLastError();
|
|
4544
4555
|
try {
|
|
4545
4556
|
if (!result)
|
|
@@ -4686,7 +4697,7 @@ function _napi_set_property(env, object, key, value) {
|
|
|
4686
4697
|
if (!envObject.tryCatch.isEmpty())
|
|
4687
4698
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
4688
4699
|
if (!envObject.canCallIntoJs())
|
|
4689
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
4700
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
4690
4701
|
envObject.clearLastError();
|
|
4691
4702
|
try {
|
|
4692
4703
|
if (!key)
|
|
@@ -4719,7 +4730,7 @@ function _napi_has_property(env, object, key, result) {
|
|
|
4719
4730
|
if (!envObject.tryCatch.isEmpty())
|
|
4720
4731
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
4721
4732
|
if (!envObject.canCallIntoJs())
|
|
4722
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
4733
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
4723
4734
|
envObject.clearLastError();
|
|
4724
4735
|
try {
|
|
4725
4736
|
if (!key)
|
|
@@ -4761,7 +4772,7 @@ function _napi_get_property(env, object, key, result) {
|
|
|
4761
4772
|
if (!envObject.tryCatch.isEmpty())
|
|
4762
4773
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
4763
4774
|
if (!envObject.canCallIntoJs())
|
|
4764
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
4775
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
4765
4776
|
envObject.clearLastError();
|
|
4766
4777
|
try {
|
|
4767
4778
|
if (!key)
|
|
@@ -4804,7 +4815,7 @@ function _napi_delete_property(env, object, key, result) {
|
|
|
4804
4815
|
if (!envObject.tryCatch.isEmpty())
|
|
4805
4816
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
4806
4817
|
if (!envObject.canCallIntoJs())
|
|
4807
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
4818
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
4808
4819
|
envObject.clearLastError();
|
|
4809
4820
|
try {
|
|
4810
4821
|
if (!key)
|
|
@@ -4850,7 +4861,7 @@ function _napi_has_own_property(env, object, key, result) {
|
|
|
4850
4861
|
if (!envObject.tryCatch.isEmpty())
|
|
4851
4862
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
4852
4863
|
if (!envObject.canCallIntoJs())
|
|
4853
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
4864
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
4854
4865
|
envObject.clearLastError();
|
|
4855
4866
|
try {
|
|
4856
4867
|
if (!key)
|
|
@@ -4894,7 +4905,7 @@ function _napi_set_named_property(env, object, cname, value) {
|
|
|
4894
4905
|
if (!envObject.tryCatch.isEmpty())
|
|
4895
4906
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
4896
4907
|
if (!envObject.canCallIntoJs())
|
|
4897
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
4908
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
4898
4909
|
envObject.clearLastError();
|
|
4899
4910
|
try {
|
|
4900
4911
|
if (!value)
|
|
@@ -4929,7 +4940,7 @@ function _napi_has_named_property(env, object, utf8name, result) {
|
|
|
4929
4940
|
if (!envObject.tryCatch.isEmpty())
|
|
4930
4941
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
4931
4942
|
if (!envObject.canCallIntoJs())
|
|
4932
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
4943
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
4933
4944
|
envObject.clearLastError();
|
|
4934
4945
|
try {
|
|
4935
4946
|
if (!result)
|
|
@@ -4973,7 +4984,7 @@ function _napi_get_named_property(env, object, utf8name, result) {
|
|
|
4973
4984
|
if (!envObject.tryCatch.isEmpty())
|
|
4974
4985
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
4975
4986
|
if (!envObject.canCallIntoJs())
|
|
4976
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
4987
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
4977
4988
|
envObject.clearLastError();
|
|
4978
4989
|
try {
|
|
4979
4990
|
if (!result)
|
|
@@ -5016,7 +5027,7 @@ function _napi_set_element(env, object, index, value) {
|
|
|
5016
5027
|
if (!envObject.tryCatch.isEmpty())
|
|
5017
5028
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
5018
5029
|
if (!envObject.canCallIntoJs())
|
|
5019
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
5030
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
5020
5031
|
envObject.clearLastError();
|
|
5021
5032
|
try {
|
|
5022
5033
|
if (!value)
|
|
@@ -5047,7 +5058,7 @@ function _napi_has_element(env, object, index, result) {
|
|
|
5047
5058
|
if (!envObject.tryCatch.isEmpty())
|
|
5048
5059
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
5049
5060
|
if (!envObject.canCallIntoJs())
|
|
5050
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
5061
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
5051
5062
|
envObject.clearLastError();
|
|
5052
5063
|
try {
|
|
5053
5064
|
if (!result)
|
|
@@ -5087,7 +5098,7 @@ function _napi_get_element(env, object, index, result) {
|
|
|
5087
5098
|
if (!envObject.tryCatch.isEmpty())
|
|
5088
5099
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
5089
5100
|
if (!envObject.canCallIntoJs())
|
|
5090
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
5101
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
5091
5102
|
envObject.clearLastError();
|
|
5092
5103
|
try {
|
|
5093
5104
|
if (!result)
|
|
@@ -5128,7 +5139,7 @@ function _napi_delete_element(env, object, index, result) {
|
|
|
5128
5139
|
if (!envObject.tryCatch.isEmpty())
|
|
5129
5140
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
5130
5141
|
if (!envObject.canCallIntoJs())
|
|
5131
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
5142
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
5132
5143
|
envObject.clearLastError();
|
|
5133
5144
|
try {
|
|
5134
5145
|
if (!object)
|
|
@@ -5171,7 +5182,7 @@ function _napi_define_properties(env, object, property_count, properties) {
|
|
|
5171
5182
|
if (!envObject.tryCatch.isEmpty())
|
|
5172
5183
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
5173
5184
|
if (!envObject.canCallIntoJs())
|
|
5174
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
5185
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
5175
5186
|
envObject.clearLastError();
|
|
5176
5187
|
try {
|
|
5177
5188
|
{{{ from64('properties') }}};
|
|
@@ -5232,7 +5243,7 @@ function _napi_object_freeze(env, object) {
|
|
|
5232
5243
|
if (!envObject.tryCatch.isEmpty())
|
|
5233
5244
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
5234
5245
|
if (!envObject.canCallIntoJs())
|
|
5235
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
5246
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
5236
5247
|
envObject.clearLastError();
|
|
5237
5248
|
try {
|
|
5238
5249
|
if (!object)
|
|
@@ -5260,7 +5271,7 @@ function _napi_object_seal(env, object) {
|
|
|
5260
5271
|
if (!envObject.tryCatch.isEmpty())
|
|
5261
5272
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
5262
5273
|
if (!envObject.canCallIntoJs())
|
|
5263
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
5274
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
5264
5275
|
envObject.clearLastError();
|
|
5265
5276
|
try {
|
|
5266
5277
|
if (!object)
|
|
@@ -5293,7 +5304,7 @@ function _napi_run_script(env, script, result) {
|
|
|
5293
5304
|
if (!envObject.tryCatch.isEmpty())
|
|
5294
5305
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
5295
5306
|
if (!envObject.canCallIntoJs())
|
|
5296
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
5307
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
5297
5308
|
envObject.clearLastError();
|
|
5298
5309
|
try {
|
|
5299
5310
|
if (!script)
|
|
@@ -6211,7 +6222,7 @@ function _napi_coerce_to_bool(env, value, result) {
|
|
|
6211
6222
|
if (!envObject.tryCatch.isEmpty())
|
|
6212
6223
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
6213
6224
|
if (!envObject.canCallIntoJs())
|
|
6214
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
6225
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
6215
6226
|
envObject.clearLastError();
|
|
6216
6227
|
try {
|
|
6217
6228
|
if (!value)
|
|
@@ -6241,7 +6252,7 @@ function _napi_coerce_to_number(env, value, result) {
|
|
|
6241
6252
|
if (!envObject.tryCatch.isEmpty())
|
|
6242
6253
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
6243
6254
|
if (!envObject.canCallIntoJs())
|
|
6244
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
6255
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
6245
6256
|
envObject.clearLastError();
|
|
6246
6257
|
try {
|
|
6247
6258
|
if (!value)
|
|
@@ -6275,7 +6286,7 @@ function _napi_coerce_to_object(env, value, result) {
|
|
|
6275
6286
|
if (!envObject.tryCatch.isEmpty())
|
|
6276
6287
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
6277
6288
|
if (!envObject.canCallIntoJs())
|
|
6278
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
6289
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
6279
6290
|
envObject.clearLastError();
|
|
6280
6291
|
try {
|
|
6281
6292
|
if (!value)
|
|
@@ -6309,7 +6320,7 @@ function _napi_coerce_to_string(env, value, result) {
|
|
|
6309
6320
|
if (!envObject.tryCatch.isEmpty())
|
|
6310
6321
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
6311
6322
|
if (!envObject.canCallIntoJs())
|
|
6312
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
6323
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
6313
6324
|
envObject.clearLastError();
|
|
6314
6325
|
try {
|
|
6315
6326
|
if (!value)
|
|
@@ -6343,7 +6354,7 @@ function _napi_instanceof(env, object, constructor, result) {
|
|
|
6343
6354
|
if (!envObject.tryCatch.isEmpty())
|
|
6344
6355
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
6345
6356
|
if (!envObject.canCallIntoJs())
|
|
6346
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
6357
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
6347
6358
|
envObject.clearLastError();
|
|
6348
6359
|
try {
|
|
6349
6360
|
if (!object)
|
|
@@ -6507,7 +6518,7 @@ function _napi_strict_equals(env, lhs, rhs, result) {
|
|
|
6507
6518
|
if (!envObject.tryCatch.isEmpty())
|
|
6508
6519
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
6509
6520
|
if (!envObject.canCallIntoJs())
|
|
6510
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
6521
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
6511
6522
|
envObject.clearLastError();
|
|
6512
6523
|
try {
|
|
6513
6524
|
if (!lhs)
|
|
@@ -6564,7 +6575,7 @@ function _napi_is_detached_arraybuffer(env, arraybuffer, result) {
|
|
|
6564
6575
|
if (!envObject.tryCatch.isEmpty())
|
|
6565
6576
|
return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
|
|
6566
6577
|
if (!envObject.canCallIntoJs())
|
|
6567
|
-
return envObject.setLastError(envObject.moduleApiVersion
|
|
6578
|
+
return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
|
|
6568
6579
|
envObject.clearLastError();
|
|
6569
6580
|
try {
|
|
6570
6581
|
if (!arraybuffer)
|
|
@@ -6599,7 +6610,7 @@ function _napi_get_version(env, result) {
|
|
|
6599
6610
|
if (!result)
|
|
6600
6611
|
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
6601
6612
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6602
|
-
var NODE_API_SUPPORTED_VERSION_MAX =
|
|
6613
|
+
var NODE_API_SUPPORTED_VERSION_MAX = 10 /* Version.NODE_API_SUPPORTED_VERSION_MAX */;
|
|
6603
6614
|
{{{ makeSetValue('result', 0, 'NODE_API_SUPPORTED_VERSION_MAX', 'u32') }}};
|
|
6604
6615
|
return envObject.clearLastError();
|
|
6605
6616
|
}
|
package/include/node/emnapi.h
CHANGED
|
@@ -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
|
-
#
|
|
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 //
|
|
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,
|
package/include/node/node_api.h
CHANGED
|
@@ -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
|
|
|
@@ -146,8 +143,7 @@ napi_create_external_buffer(napi_env env,
|
|
|
146
143
|
napi_value* result);
|
|
147
144
|
#endif // NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED
|
|
148
145
|
|
|
149
|
-
#
|
|
150
|
-
#define NODE_API_EXPERIMENTAL_HAS_CREATE_BUFFER_FROM_ARRAYBUFFER
|
|
146
|
+
#if NAPI_VERSION >= 10
|
|
151
147
|
|
|
152
148
|
NAPI_EXTERN napi_status NAPI_CDECL
|
|
153
149
|
node_api_create_buffer_from_arraybuffer(napi_env env,
|
|
@@ -155,7 +151,7 @@ node_api_create_buffer_from_arraybuffer(napi_env env,
|
|
|
155
151
|
size_t byte_offset,
|
|
156
152
|
size_t byte_length,
|
|
157
153
|
napi_value* result);
|
|
158
|
-
#endif //
|
|
154
|
+
#endif // NAPI_VERSION >= 10
|
|
159
155
|
|
|
160
156
|
NAPI_EXTERN napi_status NAPI_CDECL napi_create_buffer_copy(napi_env env,
|
|
161
157
|
size_t length,
|