@auto_js/napi_exports 0.0.6 → 0.0.8

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/CMakeLists.txt CHANGED
@@ -4,8 +4,11 @@ target_compile_features(nodejs PUBLIC cxx_std_23)
4
4
  # Set `NAPI_VERSION` macro
5
5
  if(NOT DEFINED NAPI_VERSION)
6
6
  message(FATAL_ERROR "Missing 'NAPI_VERSION' cmake variable.")
7
+ elseif(NAPI_VERSION STREQUAL EXPERIMENTAL)
8
+ target_compile_definitions(nodejs PUBLIC NAPI_EXPERIMENTAL)
9
+ else()
10
+ target_compile_definitions(nodejs PUBLIC NAPI_VERSION=${NAPI_VERSION})
7
11
  endif()
8
- target_compile_definitions(nodejs PUBLIC NAPI_VERSION=${NAPI_VERSION})
9
12
 
10
13
  # Architecture, for window linkage
11
14
  string(TOLOWER ${CMAKE_HOST_SYSTEM_PROCESSOR} NODE_ARCH)
@@ -49,6 +52,7 @@ endif()
49
52
  message(STATUS "Using Node.js headers from '${NODE_DIST_DIR}'")
50
53
 
51
54
  # Configuration
55
+ target_include_directories(nodejs SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
52
56
  target_include_directories(nodejs SYSTEM PUBLIC "${NODE_DIST_DIR}/include/node")
53
57
  if(WIN32)
54
58
  if(EXISTS "${NODE_DIST_DIR}/win-${NODE_ARCH}/node.lib")
@@ -65,6 +69,7 @@ target_sources(nodejs
65
69
  PUBLIC FILE_SET CXX_MODULES FILES
66
70
  js_native_api_types.cc
67
71
  js_native_api.cc
72
+ node_api_types.cc
68
73
  node_api.cc
69
74
  nodejs.cc
70
75
  uv.cc
package/js_native_api.cc CHANGED
@@ -1,5 +1,5 @@
1
1
  module;
2
- #include "version.h"
2
+ #include "napi_js/extern.h"
3
3
  // https://nodejs.org/api/n-api.html
4
4
  #include <js_native_api.h>
5
5
  export module nodejs:js_native_api;
@@ -48,6 +48,7 @@ export using ::napi_get_cb_info;
48
48
  export using ::napi_get_dataview_info;
49
49
  export using ::napi_get_date_value;
50
50
  export using ::napi_get_element;
51
+ export using ::napi_get_global;
51
52
  export using ::napi_get_instance_data;
52
53
  export using ::napi_get_null;
53
54
  export using ::napi_get_property_names;
@@ -92,10 +93,12 @@ export using ::napi_type_tag_object;
92
93
  export using ::napi_typeof;
93
94
  export using ::napi_unwrap;
94
95
  export using ::napi_wrap;
96
+ export using ::node_api_create_external_sharedarraybuffer;
95
97
  export using ::node_api_create_property_key_latin1;
96
98
  export using ::node_api_create_property_key_utf16;
97
99
  export using ::node_api_create_property_key_utf8;
98
100
  export using ::node_api_create_syntax_error;
101
+ export using ::node_api_is_sharedarraybuffer;
99
102
  export using ::node_api_throw_syntax_error;
100
103
 
101
104
  // NOLINTEND(misc-unused-using-decls)
@@ -1,5 +1,5 @@
1
1
  module;
2
- #include "version.h"
2
+ #include "napi_js/version.h"
3
3
  #include <js_native_api_types.h>
4
4
  export module nodejs:js_native_api_types;
5
5
  // NOLINTBEGIN(misc-unused-using-decls)
@@ -20,7 +20,6 @@ export using ::napi_finalize;
20
20
  export using ::napi_property_descriptor;
21
21
  export using ::napi_type_tag;
22
22
  export using ::node_api_basic_finalize;
23
- export using ::node_api_nogc_finalize;
24
23
 
25
24
  // napi_key_collection_mode
26
25
  export using ::napi_key_collection_mode;
@@ -0,0 +1,10 @@
1
+ #if __linux__
2
+ #define NAPI_EXTERN __attribute__((weak))
3
+ #elif __APPLE__
4
+ #define NAPI_EXTERN __attribute__((weak))
5
+ #elif _WIN64
6
+ #define NAPI_EXTERN __declspec(dllimport) __attribute__((weak))
7
+ #else
8
+ #define NAPI_EXTERN
9
+ #endif
10
+ #define UV_EXTERN NAPI_EXTERN
@@ -1,10 +1,14 @@
1
1
  #include "node_version.h"
2
+ #ifdef NAPI_VERSION
2
3
  static_assert(NAPI_VERSION <= NODE_API_SUPPORTED_VERSION_MAX, "NAPI version mismatch");
4
+ #endif
3
5
 
4
6
  // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
5
7
  #define NODE_EQ_VERSION_AT_LEAST(major, minor, patch) \
6
8
  (((major) == NODE_MAJOR_VERSION && (minor) < NODE_MINOR_VERSION) || \
7
9
  ((major) == NODE_MAJOR_VERSION && (minor) == NODE_MINOR_VERSION && (patch) <= NODE_PATCH_VERSION))
8
10
 
11
+ #ifdef NAPI_VERSION
9
12
  static_assert(NAPI_VERSION >= 10);
13
+ #endif
10
14
  static_assert(NODE_VERSION_AT_LEAST(23, 6, 0) || NODE_EQ_VERSION_AT_LEAST(22, 14, 0));
package/node_api.cc CHANGED
@@ -1,13 +1,23 @@
1
1
  module;
2
- #include "version.h"
2
+ #include "napi_js/extern.h"
3
3
  #include <node_api.h>
4
4
  export module nodejs:node_api;
5
5
  // NOLINTBEGIN(misc-unused-using-decls)
6
6
 
7
+ // functions
8
+ export using ::napi_acquire_threadsafe_function;
7
9
  export using ::napi_add_async_cleanup_hook;
8
10
  export using ::napi_add_env_cleanup_hook;
11
+ export using ::napi_add_env_cleanup_hook;
9
12
  export using ::napi_async_cleanup_hook_handle;
13
+ export using ::napi_call_threadsafe_function;
14
+ export using ::napi_create_threadsafe_function;
15
+ export using ::napi_get_threadsafe_function_context;
10
16
  export using ::napi_get_uv_event_loop;
17
+ export using ::napi_ref_threadsafe_function;
18
+ export using ::napi_release_threadsafe_function;
11
19
  export using ::napi_remove_async_cleanup_hook;
20
+ export using ::napi_threadsafe_function_call_js;
21
+ export using ::napi_unref_threadsafe_function;
12
22
 
13
23
  // NOLINTEND(misc-unused-using-decls)
@@ -0,0 +1,20 @@
1
+ module;
2
+ #include <node_api_types.h>
3
+ export module nodejs:node_api_types;
4
+ // NOLINTBEGIN(misc-unused-using-decls)
5
+
6
+ export using ::napi_async_cleanup_hook;
7
+ export using ::napi_cleanup_hook;
8
+ export using ::napi_threadsafe_function;
9
+
10
+ // napi_threadsafe_function_release_mode
11
+ export using ::napi_threadsafe_function_release_mode;
12
+ export using ::napi_tsfn_abort;
13
+ export using ::napi_tsfn_release;
14
+
15
+ // napi_threadsafe_function_call_mode
16
+ export using ::napi_threadsafe_function_call_mode;
17
+ export using ::napi_tsfn_blocking;
18
+ export using ::napi_tsfn_nonblocking;
19
+
20
+ // NOLINTEND(misc-unused-using-decls)
package/nodejs.cc CHANGED
@@ -1,5 +1,6 @@
1
1
  export module nodejs;
2
2
  export import :js_native_api_types;
3
3
  export import :js_native_api;
4
+ export import :node_api_types;
4
5
  export import :node_api;
5
6
  export import :uv;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auto_js/napi_exports",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "C++ module exports for nodejs & n-api",
5
5
  "author": "https://github.com/laverdet/",
6
6
  "homepage": "https://github.com/laverdet/isolated-vm/tree/experimental/packages/third_party/nodejs",
package/uv.cc CHANGED
@@ -1,5 +1,5 @@
1
1
  module;
2
- #include "version.h"
2
+ #include "napi_js/version.h"
3
3
  #include <uv.h>
4
4
  export module nodejs:uv;
5
5