@auto_js/napi_exports 0.0.1 → 0.0.3
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 +36 -5
- package/LICENSE +13 -0
- package/js_native_api.cc +14 -0
- package/js_native_api_types.cc +57 -33
- package/node_api.cc +5 -0
- package/package.json +2 -2
- package/uv.cc +6 -0
- package/version.h +10 -0
package/CMakeLists.txt
CHANGED
|
@@ -7,6 +7,12 @@ if(NOT DEFINED NAPI_VERSION)
|
|
|
7
7
|
endif()
|
|
8
8
|
target_compile_definitions(nodejs PUBLIC "NAPI_VERSION=${NAPI_VERSION}")
|
|
9
9
|
|
|
10
|
+
# Architecture, for window linkage
|
|
11
|
+
string(TOLOWER ${CMAKE_HOST_SYSTEM_PROCESSOR} NODE_ARCH)
|
|
12
|
+
if(NODE_ARCH STREQUAL amd64)
|
|
13
|
+
set(NODE_ARCH x64)
|
|
14
|
+
endif()
|
|
15
|
+
|
|
10
16
|
# Acquire or locate nodejs headers
|
|
11
17
|
if(NOT DEFINED NODE_DIST_DIR)
|
|
12
18
|
if(DEFINED ENV{NODE_DIST_DIR})
|
|
@@ -16,20 +22,45 @@ if(NOT DEFINED NODE_DIST_DIR)
|
|
|
16
22
|
endif()
|
|
17
23
|
endif()
|
|
18
24
|
if(NOT DEFINED NODE_DIST_DIR)
|
|
25
|
+
if(DEFINED NODE_VERSION)
|
|
26
|
+
message(STATUS "Using Node.js version '${NODE_VERSION}'")
|
|
27
|
+
else()
|
|
28
|
+
execute_process(COMMAND sh -c "node -v | cut -c2-" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE NODE_VERSION RESULT_VARIABLE RESULT)
|
|
29
|
+
if(NOT RESULT STREQUAL 0)
|
|
30
|
+
message(FATAL_ERROR "nodejs version not set" )
|
|
31
|
+
endif()
|
|
32
|
+
message(STATUS "Detected Node.js version '${NODE_VERSION}'")
|
|
33
|
+
endif()
|
|
34
|
+
set(NODE_HEADERS_URL "https://nodejs.org/download/release/v${NODE_VERSION}/node-v${NODE_VERSION}-headers.tar.gz")
|
|
35
|
+
message(STATUS "Downloading Node.js headers from '${NODE_HEADERS_URL}'")
|
|
19
36
|
include(FetchContent)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
)
|
|
37
|
+
# So much searching to find this 'DOWNLOAD_NO_PROGRESS' option. It's not documented under
|
|
38
|
+
# FetchContent, oh no this is actually an ExternalProject option, you see.
|
|
39
|
+
FetchContent_Declare(node_headers URL "${NODE_HEADERS_URL}" DOWNLOAD_NO_PROGRESS TRUE)
|
|
24
40
|
FetchContent_MakeAvailable(node_headers)
|
|
25
41
|
set(NODE_DIST_DIR "${node_headers_SOURCE_DIR}" CACHE STRING "")
|
|
42
|
+
if(WIN32)
|
|
43
|
+
file(DOWNLOAD "https://nodejs.org/download/release/v${NODE_VERSION}/win-${NODE_ARCH}/node.lib" "${NODE_DIST_DIR}/win-${NODE_ARCH}/node.lib")
|
|
44
|
+
endif()
|
|
26
45
|
endif()
|
|
27
46
|
if(NOT EXISTS "${NODE_DIST_DIR}/include/node/node.h")
|
|
28
|
-
message(FATAL_ERROR "Missing ${NODE_DIST_DIR}/include/node/node.h")
|
|
47
|
+
message(FATAL_ERROR "Missing '${NODE_DIST_DIR}/include/node/node.h'")
|
|
29
48
|
endif()
|
|
30
49
|
message(STATUS "Using Node.js headers from '${NODE_DIST_DIR}'")
|
|
50
|
+
|
|
51
|
+
# Configuration
|
|
31
52
|
target_include_directories(nodejs SYSTEM PUBLIC "${NODE_DIST_DIR}/include/node")
|
|
53
|
+
if(WIN32)
|
|
54
|
+
if(EXISTS "${NODE_DIST_DIR}/win-${NODE_ARCH}/node.lib")
|
|
55
|
+
target_link_directories(nodejs PUBLIC "${NODE_DIST_DIR}/win-${NODE_ARCH}")
|
|
56
|
+
else()
|
|
57
|
+
message(WARNING "Missing '${NODE_DIST_DIR}/win-${NODE_ARCH}/node.lib'")
|
|
58
|
+
endif()
|
|
59
|
+
# nb: `winmm` for `js_clock::now()`
|
|
60
|
+
target_link_libraries(nodejs PUBLIC node winmm)
|
|
61
|
+
endif()
|
|
32
62
|
|
|
63
|
+
# Sources
|
|
33
64
|
target_sources(nodejs
|
|
34
65
|
PUBLIC FILE_SET CXX_MODULES FILES
|
|
35
66
|
js_native_api_types.cc
|
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2017 Marcel Laverdet
|
|
2
|
+
|
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
5
|
+
copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
9
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
package/js_native_api.cc
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
module;
|
|
2
|
+
#include "version.h"
|
|
3
|
+
// https://nodejs.org/api/n-api.html
|
|
2
4
|
#include <js_native_api.h>
|
|
3
5
|
export module nodejs:js_native_api;
|
|
4
6
|
// NOLINTBEGIN(misc-unused-using-decls)
|
|
@@ -9,11 +11,14 @@ export using ::napi_check_object_type_tag;
|
|
|
9
11
|
export using ::napi_close_handle_scope;
|
|
10
12
|
export using ::napi_coerce_to_bool;
|
|
11
13
|
export using ::napi_coerce_to_object;
|
|
14
|
+
export using ::napi_coerce_to_string;
|
|
12
15
|
export using ::napi_create_array_with_length;
|
|
13
16
|
export using ::napi_create_array;
|
|
17
|
+
export using ::napi_create_arraybuffer;
|
|
14
18
|
export using ::napi_create_bigint_int64;
|
|
15
19
|
export using ::napi_create_bigint_uint64;
|
|
16
20
|
export using ::napi_create_bigint_words;
|
|
21
|
+
export using ::napi_create_dataview;
|
|
17
22
|
export using ::napi_create_date;
|
|
18
23
|
export using ::napi_create_double;
|
|
19
24
|
export using ::napi_create_error;
|
|
@@ -29,14 +34,18 @@ export using ::napi_create_string_latin1;
|
|
|
29
34
|
export using ::napi_create_string_utf16;
|
|
30
35
|
export using ::napi_create_string_utf8;
|
|
31
36
|
export using ::napi_create_type_error;
|
|
37
|
+
export using ::napi_create_typedarray;
|
|
32
38
|
export using ::napi_create_uint32;
|
|
33
39
|
export using ::napi_define_class;
|
|
34
40
|
export using ::napi_define_properties;
|
|
35
41
|
export using ::napi_delete_reference;
|
|
42
|
+
export using ::napi_get_all_property_names;
|
|
36
43
|
export using ::napi_get_and_clear_last_exception;
|
|
37
44
|
export using ::napi_get_array_length;
|
|
45
|
+
export using ::napi_get_arraybuffer_info;
|
|
38
46
|
export using ::napi_get_boolean;
|
|
39
47
|
export using ::napi_get_cb_info;
|
|
48
|
+
export using ::napi_get_dataview_info;
|
|
40
49
|
export using ::napi_get_date_value;
|
|
41
50
|
export using ::napi_get_element;
|
|
42
51
|
export using ::napi_get_instance_data;
|
|
@@ -44,6 +53,7 @@ export using ::napi_get_null;
|
|
|
44
53
|
export using ::napi_get_property_names;
|
|
45
54
|
export using ::napi_get_property;
|
|
46
55
|
export using ::napi_get_reference_value;
|
|
56
|
+
export using ::napi_get_typedarray_info;
|
|
47
57
|
export using ::napi_get_undefined;
|
|
48
58
|
export using ::napi_get_value_bigint_int64;
|
|
49
59
|
export using ::napi_get_value_bigint_uint64;
|
|
@@ -59,8 +69,11 @@ export using ::napi_get_value_string_utf8;
|
|
|
59
69
|
export using ::napi_get_value_uint32;
|
|
60
70
|
export using ::napi_has_own_property;
|
|
61
71
|
export using ::napi_is_array;
|
|
72
|
+
export using ::napi_is_arraybuffer;
|
|
73
|
+
export using ::napi_is_dataview;
|
|
62
74
|
export using ::napi_is_date;
|
|
63
75
|
export using ::napi_is_promise;
|
|
76
|
+
export using ::napi_is_typedarray;
|
|
64
77
|
export using ::napi_new_instance;
|
|
65
78
|
export using ::napi_open_handle_scope;
|
|
66
79
|
export using ::napi_reference_ref;
|
|
@@ -69,6 +82,7 @@ export using ::napi_reject_deferred;
|
|
|
69
82
|
export using ::napi_resolve_deferred;
|
|
70
83
|
export using ::napi_set_element;
|
|
71
84
|
export using ::napi_set_instance_data;
|
|
85
|
+
export using ::napi_set_named_property;
|
|
72
86
|
export using ::napi_set_property;
|
|
73
87
|
export using ::napi_throw_type_error;
|
|
74
88
|
export using ::napi_throw;
|
package/js_native_api_types.cc
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
module;
|
|
2
|
+
#include "version.h"
|
|
2
3
|
#include <js_native_api_types.h>
|
|
3
4
|
export module nodejs:js_native_api_types;
|
|
4
5
|
// NOLINTBEGIN(misc-unused-using-decls)
|
|
@@ -21,33 +22,32 @@ export using ::napi_type_tag;
|
|
|
21
22
|
export using ::node_api_basic_finalize;
|
|
22
23
|
export using ::node_api_nogc_finalize;
|
|
23
24
|
|
|
24
|
-
//
|
|
25
|
-
export using ::
|
|
26
|
-
export using ::
|
|
27
|
-
export using ::
|
|
28
|
-
export using ::napi_external;
|
|
29
|
-
export using ::napi_function;
|
|
30
|
-
export using ::napi_null;
|
|
31
|
-
export using ::napi_number;
|
|
32
|
-
export using ::napi_object;
|
|
33
|
-
export using ::napi_string;
|
|
34
|
-
export using ::napi_symbol;
|
|
35
|
-
export using ::napi_undefined;
|
|
25
|
+
// napi_key_collection_mode
|
|
26
|
+
export using ::napi_key_collection_mode;
|
|
27
|
+
export using ::napi_key_include_prototypes;
|
|
28
|
+
export using ::napi_key_own_only;
|
|
36
29
|
|
|
37
|
-
//
|
|
38
|
-
export using ::
|
|
39
|
-
export using ::
|
|
40
|
-
export using ::
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export using ::
|
|
44
|
-
export using ::
|
|
45
|
-
export using ::
|
|
46
|
-
export using ::
|
|
47
|
-
export using ::
|
|
48
|
-
export using ::
|
|
49
|
-
export using ::
|
|
50
|
-
|
|
30
|
+
// napi_key_conversion
|
|
31
|
+
export using ::napi_key_conversion;
|
|
32
|
+
export using ::napi_key_keep_numbers;
|
|
33
|
+
export using ::napi_key_numbers_to_strings;
|
|
34
|
+
|
|
35
|
+
// napi_key_filter
|
|
36
|
+
export using ::napi_key_filter;
|
|
37
|
+
export using ::napi_key_all_properties;
|
|
38
|
+
export using ::napi_key_configurable;
|
|
39
|
+
export using ::napi_key_enumerable;
|
|
40
|
+
export using ::napi_key_skip_strings;
|
|
41
|
+
export using ::napi_key_skip_symbols;
|
|
42
|
+
export using ::napi_key_writable;
|
|
43
|
+
|
|
44
|
+
// napi_property_attributes
|
|
45
|
+
export using ::napi_property_attributes;
|
|
46
|
+
export using ::napi_default;
|
|
47
|
+
export using ::napi_writable;
|
|
48
|
+
export using ::napi_enumerable;
|
|
49
|
+
export using ::napi_configurable;
|
|
50
|
+
export using ::napi_static;
|
|
51
51
|
|
|
52
52
|
// napi_status
|
|
53
53
|
export using ::napi_status;
|
|
@@ -76,12 +76,36 @@ export using ::napi_queue_full;
|
|
|
76
76
|
export using ::napi_string_expected;
|
|
77
77
|
export using ::napi_would_deadlock;
|
|
78
78
|
|
|
79
|
-
//
|
|
80
|
-
export using ::
|
|
81
|
-
export using ::
|
|
82
|
-
export using ::
|
|
83
|
-
export using ::
|
|
84
|
-
export using ::
|
|
85
|
-
export using ::
|
|
79
|
+
// napi_typedarray_type
|
|
80
|
+
export using ::napi_typedarray_type;
|
|
81
|
+
export using ::napi_bigint64_array;
|
|
82
|
+
export using ::napi_biguint64_array;
|
|
83
|
+
export using ::napi_float32_array;
|
|
84
|
+
export using ::napi_float64_array;
|
|
85
|
+
export using ::napi_int16_array;
|
|
86
|
+
export using ::napi_int32_array;
|
|
87
|
+
export using ::napi_int8_array;
|
|
88
|
+
export using ::napi_uint16_array;
|
|
89
|
+
export using ::napi_uint32_array;
|
|
90
|
+
export using ::napi_uint8_array;
|
|
91
|
+
export using ::napi_uint8_clamped_array;
|
|
92
|
+
#if NODE_VERSION_AT_LEAST(25, 5, 0) || NODE_EQ_VERSION_AT_LEAST(24, 13, 1)
|
|
93
|
+
export using ::napi_float16_array;
|
|
94
|
+
#else
|
|
95
|
+
export constexpr auto napi_float16_array = static_cast<napi_typedarray_type>(napi_biguint64_array + 1);
|
|
96
|
+
#endif
|
|
97
|
+
|
|
98
|
+
// napi_valuetype
|
|
99
|
+
export using ::napi_valuetype;
|
|
100
|
+
export using ::napi_bigint;
|
|
101
|
+
export using ::napi_boolean;
|
|
102
|
+
export using ::napi_external;
|
|
103
|
+
export using ::napi_function;
|
|
104
|
+
export using ::napi_null;
|
|
105
|
+
export using ::napi_number;
|
|
106
|
+
export using ::napi_object;
|
|
107
|
+
export using ::napi_string;
|
|
108
|
+
export using ::napi_symbol;
|
|
109
|
+
export using ::napi_undefined;
|
|
86
110
|
|
|
87
111
|
// NOLINTEND(misc-unused-using-decls)
|
package/node_api.cc
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
module;
|
|
2
|
+
#include "version.h"
|
|
2
3
|
#include <node_api.h>
|
|
3
4
|
export module nodejs:node_api;
|
|
4
5
|
// NOLINTBEGIN(misc-unused-using-decls)
|
|
5
6
|
|
|
7
|
+
export using ::napi_add_async_cleanup_hook;
|
|
8
|
+
export using ::napi_add_env_cleanup_hook;
|
|
9
|
+
export using ::napi_async_cleanup_hook_handle;
|
|
6
10
|
export using ::napi_get_uv_event_loop;
|
|
11
|
+
export using ::napi_remove_async_cleanup_hook;
|
|
7
12
|
|
|
8
13
|
// NOLINTEND(misc-unused-using-decls)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auto_js/napi_exports",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
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",
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/laverdet/isolated-vm.git"
|
|
11
11
|
}
|
|
12
|
-
}
|
|
12
|
+
}
|
package/uv.cc
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
module;
|
|
2
|
+
#include "version.h"
|
|
2
3
|
#include <uv.h>
|
|
3
4
|
export module nodejs:uv;
|
|
4
5
|
|
|
@@ -7,11 +8,16 @@ export module nodejs:uv;
|
|
|
7
8
|
export using ::uv_async_t;
|
|
8
9
|
export using ::uv_handle_t;
|
|
9
10
|
export using ::uv_handle_type;
|
|
11
|
+
export using ::uv_lib_t;
|
|
10
12
|
export using ::uv_loop_t;
|
|
11
13
|
|
|
12
14
|
export using ::uv_async_init;
|
|
13
15
|
export using ::uv_async_send;
|
|
14
16
|
export using ::uv_close;
|
|
17
|
+
export using ::uv_dlclose;
|
|
18
|
+
export using ::uv_dlerror;
|
|
19
|
+
export using ::uv_dlopen;
|
|
20
|
+
export using ::uv_dlsym;
|
|
15
21
|
export using ::uv_is_active;
|
|
16
22
|
export using ::uv_ref;
|
|
17
23
|
export using ::uv_unref;
|
package/version.h
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#include "node_version.h"
|
|
2
|
+
static_assert(NAPI_VERSION <= NODE_API_SUPPORTED_VERSION_MAX, "NAPI version mismatch");
|
|
3
|
+
|
|
4
|
+
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
|
5
|
+
#define NODE_EQ_VERSION_AT_LEAST(major, minor, patch) \
|
|
6
|
+
(((major) == NODE_MAJOR_VERSION && (minor) < NODE_MINOR_VERSION) || \
|
|
7
|
+
((major) == NODE_MAJOR_VERSION && (minor) == NODE_MINOR_VERSION && (patch) <= NODE_PATCH_VERSION))
|
|
8
|
+
|
|
9
|
+
static_assert(NAPI_VERSION >= 10);
|
|
10
|
+
static_assert(NODE_VERSION_AT_LEAST(23, 6, 0) || NODE_EQ_VERSION_AT_LEAST(22, 14, 0));
|