emnapi 0.38.2 → 0.39.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 +15 -4
- package/dist/library_napi.js +300 -69
- package/include/js_native_api.h +6 -6
- package/include/js_native_api_types.h +2 -1
- package/include/node_api.h +12 -2
- package/lib/wasm32/libemnapi-basic-mt.a +0 -0
- package/lib/wasm32/libemnapi-basic.a +0 -0
- package/lib/wasm32/libemnapi.a +0 -0
- package/lib/wasm32-emscripten/libemnapi-basic.a +0 -0
- package/lib/wasm32-emscripten/libemnapi-mt.a +0 -0
- package/lib/wasm32-emscripten/libemnapi.a +0 -0
- package/lib/wasm32-wasi/libemnapi-basic-mt.a +0 -0
- package/lib/wasm32-wasi/libemnapi-basic.a +0 -0
- package/lib/wasm32-wasi/libemnapi.a +0 -0
- package/lib/wasm32-wasi-threads/libemnapi-basic-mt.a +0 -0
- package/lib/wasm32-wasi-threads/libemnapi-basic.a +0 -0
- package/lib/wasm32-wasi-threads/libemnapi-mt.a +0 -0
- package/lib/wasm32-wasi-threads/libemnapi.a +0 -0
- package/package.json +1 -1
- package/src/async_work.c +2 -2
- package/src/emnapi_internal.h +5 -4
- package/src/js_native_api.c +4 -10
- package/src/node_api.c +3 -3
- package/src/threadsafe_function.c +5 -5
package/README.md
CHANGED
|
@@ -168,7 +168,7 @@ emcc -O3 \
|
|
|
168
168
|
-I./node_modules/emnapi/include \
|
|
169
169
|
-L./node_modules/emnapi/lib/wasm32-emscripten \
|
|
170
170
|
--js-library=./node_modules/emnapi/dist/library_napi.js \
|
|
171
|
-
-sEXPORTED_FUNCTIONS="['
|
|
171
|
+
-sEXPORTED_FUNCTIONS="['_malloc','_free','_napi_register_wasm_v1','_node_api_module_get_api_version_v1']" \
|
|
172
172
|
-o hello.js \
|
|
173
173
|
hello.c \
|
|
174
174
|
-lemnapi
|
|
@@ -191,6 +191,7 @@ clang -O3 \
|
|
|
191
191
|
-Wl,--export=malloc \
|
|
192
192
|
-Wl,--export=free \
|
|
193
193
|
-Wl,--export=napi_register_wasm_v1 \
|
|
194
|
+
-Wl,--export-if-defined=node_api_module_get_api_version_v1 \
|
|
194
195
|
-Wl,--import-undefined \
|
|
195
196
|
-Wl,--export-table \
|
|
196
197
|
-o hello.wasm \
|
|
@@ -217,6 +218,7 @@ clang -O3 \
|
|
|
217
218
|
-Wl,--export=malloc \
|
|
218
219
|
-Wl,--export=free \
|
|
219
220
|
-Wl,--export=napi_register_wasm_v1 \
|
|
221
|
+
-Wl,--export-if-defined=node_api_module_get_api_version_v1 \
|
|
220
222
|
-Wl,--import-undefined \
|
|
221
223
|
-Wl,--export-table \
|
|
222
224
|
-o hello.wasm \
|
|
@@ -452,7 +454,7 @@ em++ -O3 \
|
|
|
452
454
|
-I./node_modules/node-addon-api \
|
|
453
455
|
-L./node_modules/emnapi/lib/wasm32-emscripten \
|
|
454
456
|
--js-library=./node_modules/emnapi/dist/library_napi.js \
|
|
455
|
-
-sEXPORTED_FUNCTIONS="['
|
|
457
|
+
-sEXPORTED_FUNCTIONS="['_malloc','_free','_napi_register_wasm_v1','_node_api_module_get_api_version_v1']" \
|
|
456
458
|
-o hello.js \
|
|
457
459
|
hello.cpp \
|
|
458
460
|
-lemnapi
|
|
@@ -479,6 +481,7 @@ clang++ -O3 \
|
|
|
479
481
|
-Wl,--export=malloc \
|
|
480
482
|
-Wl,--export=free \
|
|
481
483
|
-Wl,--export=napi_register_wasm_v1 \
|
|
484
|
+
-Wl,--export-if-defined=node_api_module_get_api_version_v1 \
|
|
482
485
|
-Wl,--import-undefined \
|
|
483
486
|
-Wl,--export-table \
|
|
484
487
|
-o hello.wasm \
|
|
@@ -508,6 +511,7 @@ clang++ -O3 \
|
|
|
508
511
|
-Wl,--export=malloc \
|
|
509
512
|
-Wl,--export=free \
|
|
510
513
|
-Wl,--export=napi_register_wasm_v1 \
|
|
514
|
+
-Wl,--export-if-defined=node_api_module_get_api_version_v1 \
|
|
511
515
|
-Wl,--import-undefined \
|
|
512
516
|
-Wl,--export-table \
|
|
513
517
|
-o node_api_c_api_only.wasm \
|
|
@@ -551,13 +555,14 @@ add_executable(hello hello.c)
|
|
|
551
555
|
target_link_libraries(hello emnapi)
|
|
552
556
|
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
|
553
557
|
target_link_options(hello PRIVATE
|
|
554
|
-
"-sEXPORTED_FUNCTIONS=['
|
|
558
|
+
"-sEXPORTED_FUNCTIONS=['_malloc','_free','_napi_register_wasm_v1','_node_api_module_get_api_version_v1']"
|
|
555
559
|
)
|
|
556
560
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "WASI")
|
|
557
561
|
set_target_properties(hello PROPERTIES SUFFIX ".wasm")
|
|
558
562
|
target_link_options(hello PRIVATE
|
|
559
563
|
"-mexec-model=reactor"
|
|
560
564
|
"-Wl,--export=napi_register_wasm_v1"
|
|
565
|
+
"-Wl,--export-if-defined=node_api_module_get_api_version_v1"
|
|
561
566
|
"-Wl,--initial-memory=16777216,--export-dynamic,--export=malloc,--export=free,--import-undefined,--export-table"
|
|
562
567
|
)
|
|
563
568
|
elseif((CMAKE_C_COMPILER_TARGET STREQUAL "wasm32") OR (CMAKE_C_COMPILER_TARGET STREQUAL "wasm32-unknown-unknown"))
|
|
@@ -565,6 +570,7 @@ elseif((CMAKE_C_COMPILER_TARGET STREQUAL "wasm32") OR (CMAKE_C_COMPILER_TARGET S
|
|
|
565
570
|
target_link_options(hello PRIVATE
|
|
566
571
|
"-nostdlib"
|
|
567
572
|
"-Wl,--export=napi_register_wasm_v1"
|
|
573
|
+
"-Wl,--export-if-defined=node_api_module_get_api_version_v1"
|
|
568
574
|
"-Wl,--no-entry"
|
|
569
575
|
"-Wl,--initial-memory=16777216,--export-dynamic,--export=malloc,--export=free,--import-undefined,--export-table"
|
|
570
576
|
)
|
|
@@ -666,6 +672,7 @@ rustflags = [
|
|
|
666
672
|
"-C", "link-arg=--export=malloc",
|
|
667
673
|
"-C", "link-arg=--export=free",
|
|
668
674
|
"-C", "link-arg=--export=napi_register_wasm_v1",
|
|
675
|
+
"-C", "link-arg=--export-if-defined=node_api_module_get_api_version_v1",
|
|
669
676
|
"-C", "link-arg=--export-table",
|
|
670
677
|
"-C", "link-arg=--import-undefined",
|
|
671
678
|
]
|
|
@@ -679,6 +686,7 @@ rustflags = [
|
|
|
679
686
|
"-C", "link-arg=--export=malloc",
|
|
680
687
|
"-C", "link-arg=--export=free",
|
|
681
688
|
"-C", "link-arg=--export=napi_register_wasm_v1",
|
|
689
|
+
"-C", "link-arg=--export-if-defined=node_api_module_get_api_version_v1",
|
|
682
690
|
"-C", "link-arg=--export-table",
|
|
683
691
|
"-C", "link-arg=--import-undefined",
|
|
684
692
|
"-Z", "wasi-exec-model=reactor", # +nightly
|
|
@@ -822,7 +830,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
|
|
822
830
|
target_compile_options(hello PRIVATE "-pthread")
|
|
823
831
|
target_link_options(hello PRIVATE
|
|
824
832
|
"-sALLOW_MEMORY_GROWTH=1"
|
|
825
|
-
"-sEXPORTED_FUNCTIONS=['
|
|
833
|
+
"-sEXPORTED_FUNCTIONS=['_malloc','_free','_napi_register_wasm_v1','_node_api_module_get_api_version_v1']"
|
|
826
834
|
"-pthread"
|
|
827
835
|
"-sPTHREAD_POOL_SIZE=4"
|
|
828
836
|
# try to specify stack size if you experience pthread errors
|
|
@@ -840,6 +848,8 @@ elseif(CMAKE_C_COMPILER_TARGET STREQUAL "wasm32-wasi-threads")
|
|
|
840
848
|
"-Wl,--import-memory"
|
|
841
849
|
"-Wl,--max-memory=2147483648"
|
|
842
850
|
"-Wl,--export-dynamic"
|
|
851
|
+
"-Wl,--export=napi_register_wasm_v1"
|
|
852
|
+
"-Wl,--export-if-defined=node_api_module_get_api_version_v1"
|
|
843
853
|
"-Wl,--export=malloc"
|
|
844
854
|
"-Wl,--export=free"
|
|
845
855
|
"-Wl,--import-undefined"
|
|
@@ -853,6 +863,7 @@ elseif((CMAKE_C_COMPILER_TARGET STREQUAL "wasm32") OR (CMAKE_C_COMPILER_TARGET S
|
|
|
853
863
|
"-nostdlib"
|
|
854
864
|
"-Wl,--no-entry"
|
|
855
865
|
"-Wl,--export=napi_register_wasm_v1"
|
|
866
|
+
"-Wl,--export-if-defined=node_api_module_get_api_version_v1"
|
|
856
867
|
"-Wl,--export=emnapi_async_worker_create"
|
|
857
868
|
"-Wl,--export=emnapi_async_worker_init"
|
|
858
869
|
"-Wl,--import-memory,--shared-memory,--max-memory=2147483648,--import-undefined"
|