emnapi 0.31.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/CMakeLists.txt +160 -0
- package/LICENSE +21 -0
- package/README.md +875 -0
- package/cmake/wasm32.cmake +32 -0
- package/dist/library_napi.js +4784 -0
- package/include/common.h +26 -0
- package/include/emnapi.h +81 -0
- package/include/js_native_api.h +560 -0
- package/include/js_native_api_types.h +159 -0
- package/include/napi-inl.deprecated.h +186 -0
- package/include/napi-inl.h +6299 -0
- package/include/napi.h +3127 -0
- package/include/node_api.h +226 -0
- package/include/node_api_types.h +56 -0
- package/include/uv/threadpool.h +41 -0
- package/include/uv/unix.h +21 -0
- package/include/uv.h +134 -0
- package/index.d.ts +4 -0
- package/index.js +22 -0
- package/lib/wasm32/libdlmalloc.a +0 -0
- package/lib/wasm32/libemmalloc.a +0 -0
- package/lib/wasm32/libemnapi.a +0 -0
- package/lib/wasm32-emscripten/libemnapi-mt.a +0 -0
- package/lib/wasm32-emscripten/libemnapi.a +0 -0
- package/lib/wasm32-emscripten.txt +5 -0
- package/lib/wasm32-wasi/libemnapi.a +0 -0
- package/lib/wasm32-wasi.txt +4 -0
- package/lib/wasm32.txt +4 -0
- package/package.json +43 -0
- package/src/emnapi.c +1344 -0
- package/src/malloc/dlmalloc/dlmalloc.c +92 -0
- package/src/malloc/dlmalloc/malloc.c +6395 -0
- package/src/malloc/emmalloc/emmalloc.c +1551 -0
- package/src/malloc/memcpy.c +136 -0
- package/src/malloc/memset.c +98 -0
- package/src/malloc/sbrk.c +29 -0
- package/src/uv/queue.h +108 -0
- package/src/uv/threadpool.c +408 -0
- package/src/uv/unix/async.c +206 -0
- package/src/uv/unix/core.c +35 -0
- package/src/uv/unix/loop.c +36 -0
- package/src/uv/unix/thread.c +118 -0
- package/src/uv/uv-common.c +51 -0
- package/src/uv/uv-common.h +68 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
#ifndef SRC_NODE_API_H_
|
|
2
|
+
#define SRC_NODE_API_H_
|
|
3
|
+
|
|
4
|
+
#if defined(__EMSCRIPTEN__) || defined(__wasi__)
|
|
5
|
+
#include <stdlib.h>
|
|
6
|
+
#endif
|
|
7
|
+
#include "js_native_api.h"
|
|
8
|
+
#include "node_api_types.h"
|
|
9
|
+
|
|
10
|
+
struct uv_loop_s;
|
|
11
|
+
|
|
12
|
+
#ifdef __EMSCRIPTEN__
|
|
13
|
+
#define NAPI_MODULE_EXPORT __attribute__((used))
|
|
14
|
+
#else
|
|
15
|
+
#define NAPI_MODULE_EXPORT __attribute__((visibility("default")))
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
#define NAPI_NO_RETURN __attribute__((__noreturn__))
|
|
19
|
+
|
|
20
|
+
typedef napi_value (*napi_addon_register_func)(napi_env env,
|
|
21
|
+
napi_value exports);
|
|
22
|
+
|
|
23
|
+
#define NAPI_MODULE_VERSION 1
|
|
24
|
+
|
|
25
|
+
#define NAPI_MODULE_INITIALIZER_X(base, version) \
|
|
26
|
+
NAPI_MODULE_INITIALIZER_X_HELPER(base, version)
|
|
27
|
+
#define NAPI_MODULE_INITIALIZER_X_HELPER(base, version) base##version
|
|
28
|
+
|
|
29
|
+
#define NAPI_WASM_INITIALIZER \
|
|
30
|
+
NAPI_MODULE_INITIALIZER_X(napi_register_wasm_v, NAPI_MODULE_VERSION)
|
|
31
|
+
#define NAPI_MODULE(modname, regfunc) \
|
|
32
|
+
EXTERN_C_START \
|
|
33
|
+
NAPI_MODULE_EXPORT napi_value NAPI_WASM_INITIALIZER(napi_env env, \
|
|
34
|
+
napi_value exports) { \
|
|
35
|
+
return regfunc(env, exports); \
|
|
36
|
+
} \
|
|
37
|
+
EXTERN_C_END
|
|
38
|
+
|
|
39
|
+
#define NAPI_MODULE_INITIALIZER_BASE napi_register_module_v
|
|
40
|
+
|
|
41
|
+
#define NAPI_MODULE_INITIALIZER \
|
|
42
|
+
NAPI_MODULE_INITIALIZER_X(NAPI_MODULE_INITIALIZER_BASE, \
|
|
43
|
+
NAPI_MODULE_VERSION)
|
|
44
|
+
|
|
45
|
+
#define NAPI_MODULE_INIT() \
|
|
46
|
+
EXTERN_C_START \
|
|
47
|
+
NAPI_MODULE_EXPORT napi_value \
|
|
48
|
+
NAPI_MODULE_INITIALIZER(napi_env env, napi_value exports); \
|
|
49
|
+
EXTERN_C_END \
|
|
50
|
+
NAPI_MODULE(NODE_GYP_MODULE_NAME, NAPI_MODULE_INITIALIZER) \
|
|
51
|
+
napi_value NAPI_MODULE_INITIALIZER(napi_env env, \
|
|
52
|
+
napi_value exports)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
EXTERN_C_START
|
|
56
|
+
|
|
57
|
+
NAPI_EXTERN
|
|
58
|
+
napi_status napi_create_async_work(napi_env env,
|
|
59
|
+
napi_value async_resource,
|
|
60
|
+
napi_value async_resource_name,
|
|
61
|
+
napi_async_execute_callback execute,
|
|
62
|
+
napi_async_complete_callback complete,
|
|
63
|
+
void* data,
|
|
64
|
+
napi_async_work* result);
|
|
65
|
+
NAPI_EXTERN napi_status napi_delete_async_work(napi_env env,
|
|
66
|
+
napi_async_work work);
|
|
67
|
+
NAPI_EXTERN napi_status napi_queue_async_work(napi_env env,
|
|
68
|
+
napi_async_work work);
|
|
69
|
+
NAPI_EXTERN napi_status napi_cancel_async_work(napi_env env,
|
|
70
|
+
napi_async_work work);
|
|
71
|
+
|
|
72
|
+
NAPI_EXTERN NAPI_NO_RETURN void napi_fatal_error(const char* location,
|
|
73
|
+
size_t location_len,
|
|
74
|
+
const char* message,
|
|
75
|
+
size_t message_len);
|
|
76
|
+
|
|
77
|
+
// Methods for custom handling of async operations
|
|
78
|
+
NAPI_EXTERN napi_status
|
|
79
|
+
napi_async_init(napi_env env,
|
|
80
|
+
napi_value async_resource,
|
|
81
|
+
napi_value async_resource_name,
|
|
82
|
+
napi_async_context* result);
|
|
83
|
+
|
|
84
|
+
NAPI_EXTERN napi_status
|
|
85
|
+
napi_async_destroy(napi_env env, napi_async_context async_context);
|
|
86
|
+
|
|
87
|
+
NAPI_EXTERN napi_status
|
|
88
|
+
napi_make_callback(napi_env env,
|
|
89
|
+
napi_async_context async_context,
|
|
90
|
+
napi_value recv,
|
|
91
|
+
napi_value func,
|
|
92
|
+
size_t argc,
|
|
93
|
+
const napi_value* argv,
|
|
94
|
+
napi_value* result);
|
|
95
|
+
|
|
96
|
+
// Methods to provide node::Buffer functionality with napi types
|
|
97
|
+
NAPI_EXTERN napi_status
|
|
98
|
+
napi_create_buffer(napi_env env,
|
|
99
|
+
size_t length,
|
|
100
|
+
void** data,
|
|
101
|
+
napi_value* result);
|
|
102
|
+
|
|
103
|
+
#ifndef NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED
|
|
104
|
+
NAPI_EXTERN napi_status
|
|
105
|
+
napi_create_external_buffer(napi_env env,
|
|
106
|
+
size_t length,
|
|
107
|
+
void* data,
|
|
108
|
+
napi_finalize finalize_cb,
|
|
109
|
+
void* finalize_hint,
|
|
110
|
+
napi_value* result);
|
|
111
|
+
#endif // NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED
|
|
112
|
+
|
|
113
|
+
NAPI_EXTERN napi_status
|
|
114
|
+
napi_create_buffer_copy(napi_env env,
|
|
115
|
+
size_t length,
|
|
116
|
+
const void* data,
|
|
117
|
+
void** result_data,
|
|
118
|
+
napi_value* result);
|
|
119
|
+
|
|
120
|
+
NAPI_EXTERN napi_status
|
|
121
|
+
napi_is_buffer(napi_env env,
|
|
122
|
+
napi_value value,
|
|
123
|
+
bool* result);
|
|
124
|
+
|
|
125
|
+
NAPI_EXTERN napi_status
|
|
126
|
+
napi_get_buffer_info(napi_env env,
|
|
127
|
+
napi_value value,
|
|
128
|
+
void** data,
|
|
129
|
+
size_t* length);
|
|
130
|
+
|
|
131
|
+
NAPI_EXTERN
|
|
132
|
+
napi_status napi_get_node_version(napi_env env,
|
|
133
|
+
const napi_node_version** version);
|
|
134
|
+
|
|
135
|
+
#if NAPI_VERSION >= 2
|
|
136
|
+
|
|
137
|
+
NAPI_EXTERN napi_status napi_get_uv_event_loop(napi_env env,
|
|
138
|
+
struct uv_loop_s** loop);
|
|
139
|
+
|
|
140
|
+
#endif // NAPI_VERSION >= 2
|
|
141
|
+
|
|
142
|
+
#if NAPI_VERSION >= 3
|
|
143
|
+
|
|
144
|
+
NAPI_EXTERN napi_status napi_fatal_exception(napi_env env,
|
|
145
|
+
napi_value err);
|
|
146
|
+
|
|
147
|
+
NAPI_EXTERN napi_status
|
|
148
|
+
napi_add_env_cleanup_hook(napi_env env, napi_cleanup_hook fun, void* arg);
|
|
149
|
+
|
|
150
|
+
NAPI_EXTERN napi_status
|
|
151
|
+
napi_remove_env_cleanup_hook(napi_env env, napi_cleanup_hook fun, void* arg);
|
|
152
|
+
|
|
153
|
+
NAPI_EXTERN napi_status
|
|
154
|
+
napi_open_callback_scope(napi_env env,
|
|
155
|
+
napi_value resource_object,
|
|
156
|
+
napi_async_context context,
|
|
157
|
+
napi_callback_scope* result);
|
|
158
|
+
|
|
159
|
+
NAPI_EXTERN napi_status
|
|
160
|
+
napi_close_callback_scope(napi_env env, napi_callback_scope scope);
|
|
161
|
+
|
|
162
|
+
#endif // NAPI_VERSION >= 3
|
|
163
|
+
|
|
164
|
+
#if NAPI_VERSION >= 4
|
|
165
|
+
|
|
166
|
+
// Calling into JS from other threads
|
|
167
|
+
NAPI_EXTERN napi_status
|
|
168
|
+
napi_create_threadsafe_function(napi_env env,
|
|
169
|
+
napi_value func,
|
|
170
|
+
napi_value async_resource,
|
|
171
|
+
napi_value async_resource_name,
|
|
172
|
+
size_t max_queue_size,
|
|
173
|
+
size_t initial_thread_count,
|
|
174
|
+
void* thread_finalize_data,
|
|
175
|
+
napi_finalize thread_finalize_cb,
|
|
176
|
+
void* context,
|
|
177
|
+
napi_threadsafe_function_call_js call_js_cb,
|
|
178
|
+
napi_threadsafe_function* result);
|
|
179
|
+
|
|
180
|
+
NAPI_EXTERN napi_status
|
|
181
|
+
napi_get_threadsafe_function_context(napi_threadsafe_function func,
|
|
182
|
+
void** result);
|
|
183
|
+
|
|
184
|
+
NAPI_EXTERN napi_status
|
|
185
|
+
napi_call_threadsafe_function(napi_threadsafe_function func,
|
|
186
|
+
void* data,
|
|
187
|
+
napi_threadsafe_function_call_mode is_blocking);
|
|
188
|
+
|
|
189
|
+
NAPI_EXTERN napi_status
|
|
190
|
+
napi_acquire_threadsafe_function(napi_threadsafe_function func);
|
|
191
|
+
|
|
192
|
+
NAPI_EXTERN napi_status
|
|
193
|
+
napi_release_threadsafe_function(napi_threadsafe_function func,
|
|
194
|
+
napi_threadsafe_function_release_mode mode);
|
|
195
|
+
|
|
196
|
+
NAPI_EXTERN napi_status
|
|
197
|
+
napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func);
|
|
198
|
+
|
|
199
|
+
NAPI_EXTERN napi_status
|
|
200
|
+
napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func);
|
|
201
|
+
|
|
202
|
+
#endif
|
|
203
|
+
|
|
204
|
+
#if NAPI_VERSION >= 8
|
|
205
|
+
|
|
206
|
+
NAPI_EXTERN napi_status
|
|
207
|
+
napi_add_async_cleanup_hook(napi_env env,
|
|
208
|
+
napi_async_cleanup_hook hook,
|
|
209
|
+
void* arg,
|
|
210
|
+
napi_async_cleanup_hook_handle* remove_handle);
|
|
211
|
+
|
|
212
|
+
NAPI_EXTERN napi_status
|
|
213
|
+
napi_remove_async_cleanup_hook(napi_async_cleanup_hook_handle remove_handle);
|
|
214
|
+
|
|
215
|
+
#endif // NAPI_VERSION >= 8
|
|
216
|
+
|
|
217
|
+
#ifdef NAPI_EXPERIMENTAL
|
|
218
|
+
|
|
219
|
+
NAPI_EXTERN napi_status
|
|
220
|
+
node_api_get_module_file_name(napi_env env, const char** result);
|
|
221
|
+
|
|
222
|
+
#endif // NAPI_EXPERIMENTAL
|
|
223
|
+
|
|
224
|
+
EXTERN_C_END
|
|
225
|
+
|
|
226
|
+
#endif
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#ifndef SRC_NODE_API_TYPES_H_
|
|
2
|
+
#define SRC_NODE_API_TYPES_H_
|
|
3
|
+
|
|
4
|
+
#include "js_native_api_types.h"
|
|
5
|
+
|
|
6
|
+
typedef struct napi_callback_scope__* napi_callback_scope;
|
|
7
|
+
typedef struct napi_async_context__* napi_async_context;
|
|
8
|
+
typedef struct napi_async_work__* napi_async_work;
|
|
9
|
+
|
|
10
|
+
#if NAPI_VERSION >= 3
|
|
11
|
+
typedef void(*napi_cleanup_hook)(void* arg);
|
|
12
|
+
#endif // NAPI_VERSION >= 3
|
|
13
|
+
|
|
14
|
+
#if NAPI_VERSION >= 4
|
|
15
|
+
typedef struct napi_threadsafe_function__* napi_threadsafe_function;
|
|
16
|
+
#endif // NAPI_VERSION >= 4
|
|
17
|
+
|
|
18
|
+
#if NAPI_VERSION >= 4
|
|
19
|
+
typedef enum {
|
|
20
|
+
napi_tsfn_release,
|
|
21
|
+
napi_tsfn_abort
|
|
22
|
+
} napi_threadsafe_function_release_mode;
|
|
23
|
+
|
|
24
|
+
typedef enum {
|
|
25
|
+
napi_tsfn_nonblocking,
|
|
26
|
+
napi_tsfn_blocking
|
|
27
|
+
} napi_threadsafe_function_call_mode;
|
|
28
|
+
#endif // NAPI_VERSION >= 4
|
|
29
|
+
|
|
30
|
+
typedef void (*napi_async_execute_callback)(napi_env env,
|
|
31
|
+
void* data);
|
|
32
|
+
typedef void (*napi_async_complete_callback)(napi_env env,
|
|
33
|
+
napi_status status,
|
|
34
|
+
void* data);
|
|
35
|
+
|
|
36
|
+
#if NAPI_VERSION >= 4
|
|
37
|
+
typedef void (*napi_threadsafe_function_call_js)(napi_env env,
|
|
38
|
+
napi_value js_callback,
|
|
39
|
+
void* context,
|
|
40
|
+
void* data);
|
|
41
|
+
#endif // NAPI_VERSION >= 4
|
|
42
|
+
|
|
43
|
+
typedef struct {
|
|
44
|
+
uint32_t major;
|
|
45
|
+
uint32_t minor;
|
|
46
|
+
uint32_t patch;
|
|
47
|
+
const char* release;
|
|
48
|
+
} napi_node_version;
|
|
49
|
+
|
|
50
|
+
#if NAPI_VERSION >= 8
|
|
51
|
+
typedef struct napi_async_cleanup_hook_handle__* napi_async_cleanup_hook_handle;
|
|
52
|
+
typedef void(*napi_async_cleanup_hook)(
|
|
53
|
+
napi_async_cleanup_hook_handle handle, void* data);
|
|
54
|
+
#endif // NAPI_VERSION >= 8
|
|
55
|
+
|
|
56
|
+
#endif // SRC_NODE_API_TYPES_H_
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
* of this software and associated documentation files (the "Software"), to
|
|
5
|
+
* deal in the Software without restriction, including without limitation the
|
|
6
|
+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
7
|
+
* sell copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
* furnished to do so, subject to the following conditions:
|
|
9
|
+
*
|
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
|
11
|
+
* all copies or substantial portions of the Software.
|
|
12
|
+
*
|
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
18
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
19
|
+
* IN THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* This file is private to libuv. It provides common functionality to both
|
|
24
|
+
* Windows and Unix backends.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
#ifndef UV_THREADPOOL_H_
|
|
28
|
+
#define UV_THREADPOOL_H_
|
|
29
|
+
|
|
30
|
+
#if defined(__EMSCRIPTEN_PTHREADS__) || defined(_REENTRANT)
|
|
31
|
+
|
|
32
|
+
struct uv__work {
|
|
33
|
+
void (*work)(struct uv__work *w);
|
|
34
|
+
void (*done)(struct uv__work *w, int status);
|
|
35
|
+
struct uv_loop_s* loop;
|
|
36
|
+
void* wq[2];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
#endif /* UV_THREADPOOL_H_ */
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#ifndef UV_UNIX_H
|
|
2
|
+
#define UV_UNIX_H
|
|
3
|
+
|
|
4
|
+
#if defined(__EMSCRIPTEN_PTHREADS__) || defined(_REENTRANT)
|
|
5
|
+
|
|
6
|
+
#include <semaphore.h>
|
|
7
|
+
#include <pthread.h>
|
|
8
|
+
|
|
9
|
+
#include "threadpool.h"
|
|
10
|
+
|
|
11
|
+
#define UV_ONCE_INIT PTHREAD_ONCE_INIT
|
|
12
|
+
|
|
13
|
+
typedef pthread_once_t uv_once_t;
|
|
14
|
+
typedef pthread_t uv_thread_t;
|
|
15
|
+
typedef pthread_mutex_t uv_mutex_t;
|
|
16
|
+
typedef sem_t uv_sem_t;
|
|
17
|
+
typedef pthread_cond_t uv_cond_t;
|
|
18
|
+
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
#endif /* UV_UNIX_H */
|
package/include/uv.h
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
#ifndef UV_H
|
|
2
|
+
#define UV_H
|
|
3
|
+
|
|
4
|
+
#if defined(__EMSCRIPTEN_PTHREADS__) || defined(_REENTRANT)
|
|
5
|
+
|
|
6
|
+
#include <stddef.h>
|
|
7
|
+
#include "uv/unix.h"
|
|
8
|
+
|
|
9
|
+
#ifdef __cplusplus
|
|
10
|
+
extern "C" {
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
#define UV_EXTERN /* nothing */
|
|
14
|
+
|
|
15
|
+
typedef enum {
|
|
16
|
+
UV_UNKNOWN_REQ = 0,
|
|
17
|
+
UV_WORK = 7,
|
|
18
|
+
UV_REQ_TYPE_MAX = 19
|
|
19
|
+
} uv_req_type;
|
|
20
|
+
|
|
21
|
+
typedef enum {
|
|
22
|
+
UV_UNKNOWN_HANDLE = 0,
|
|
23
|
+
UV_ASYNC = 1
|
|
24
|
+
} uv_handle_type;
|
|
25
|
+
|
|
26
|
+
typedef struct uv_loop_s uv_loop_t;
|
|
27
|
+
typedef struct uv_req_s uv_req_t;
|
|
28
|
+
typedef struct uv_work_s uv_work_t;
|
|
29
|
+
typedef struct uv_handle_s uv_handle_t;
|
|
30
|
+
typedef struct uv_async_s uv_async_t;
|
|
31
|
+
|
|
32
|
+
typedef void (*uv_work_cb)(uv_work_t* req);
|
|
33
|
+
typedef void (*uv_after_work_cb)(uv_work_t* req, int status);
|
|
34
|
+
|
|
35
|
+
#define UV_REQ_FIELDS \
|
|
36
|
+
void* data; \
|
|
37
|
+
uv_req_type type; \
|
|
38
|
+
|
|
39
|
+
struct uv_req_s {
|
|
40
|
+
UV_REQ_FIELDS
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
UV_EXTERN uv_loop_t* uv_default_loop(void);
|
|
44
|
+
UV_EXTERN int uv_loop_init(uv_loop_t* loop);
|
|
45
|
+
UV_EXTERN int uv_loop_close(uv_loop_t* loop);
|
|
46
|
+
UV_EXTERN void uv_sleep(unsigned int msec);
|
|
47
|
+
|
|
48
|
+
UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value);
|
|
49
|
+
UV_EXTERN void uv_sem_destroy(uv_sem_t* sem);
|
|
50
|
+
UV_EXTERN void uv_sem_post(uv_sem_t* sem);
|
|
51
|
+
UV_EXTERN void uv_sem_wait(uv_sem_t* sem);
|
|
52
|
+
|
|
53
|
+
UV_EXTERN int uv_cond_init(uv_cond_t* cond);
|
|
54
|
+
UV_EXTERN void uv_cond_signal(uv_cond_t* cond);
|
|
55
|
+
UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex);
|
|
56
|
+
|
|
57
|
+
UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void));
|
|
58
|
+
|
|
59
|
+
struct uv_work_s {
|
|
60
|
+
UV_REQ_FIELDS
|
|
61
|
+
uv_loop_t* loop;
|
|
62
|
+
uv_work_cb work_cb;
|
|
63
|
+
uv_after_work_cb after_work_cb;
|
|
64
|
+
struct uv__work work_req;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
UV_EXTERN int uv_queue_work(uv_loop_t* loop,
|
|
68
|
+
uv_work_t* req,
|
|
69
|
+
uv_work_cb work_cb,
|
|
70
|
+
uv_after_work_cb after_work_cb);
|
|
71
|
+
|
|
72
|
+
UV_EXTERN int uv_cancel(uv_req_t* req);
|
|
73
|
+
|
|
74
|
+
UV_EXTERN int uv_mutex_init(uv_mutex_t* mutex);
|
|
75
|
+
UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle);
|
|
76
|
+
UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle);
|
|
77
|
+
UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle);
|
|
78
|
+
|
|
79
|
+
typedef void (*uv_thread_cb)(void* arg);
|
|
80
|
+
|
|
81
|
+
UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg);
|
|
82
|
+
UV_EXTERN int uv_thread_join(uv_thread_t *tid);
|
|
83
|
+
|
|
84
|
+
typedef void (*uv_close_cb)(uv_handle_t* handle);
|
|
85
|
+
typedef void (*uv_async_cb)(uv_async_t* handle);
|
|
86
|
+
|
|
87
|
+
#define UV_HANDLE_FIELDS \
|
|
88
|
+
/* public */ \
|
|
89
|
+
void* data; \
|
|
90
|
+
/* read-only */ \
|
|
91
|
+
uv_loop_t* loop; \
|
|
92
|
+
uv_handle_type type; \
|
|
93
|
+
uv_close_cb close_cb; \
|
|
94
|
+
|
|
95
|
+
struct uv_handle_s {
|
|
96
|
+
UV_HANDLE_FIELDS
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
struct uv_async_s {
|
|
100
|
+
UV_HANDLE_FIELDS
|
|
101
|
+
uv_async_cb async_cb;
|
|
102
|
+
void* queue[2];
|
|
103
|
+
int pending;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
UV_EXTERN int uv_async_init(uv_loop_t*,
|
|
107
|
+
uv_async_t* async,
|
|
108
|
+
uv_async_cb async_cb);
|
|
109
|
+
UV_EXTERN int uv_async_send(uv_async_t* async);
|
|
110
|
+
|
|
111
|
+
UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb);
|
|
112
|
+
|
|
113
|
+
struct uv_loop_s {
|
|
114
|
+
void* data;
|
|
115
|
+
union {
|
|
116
|
+
void* unused;
|
|
117
|
+
unsigned int count;
|
|
118
|
+
} active_reqs;
|
|
119
|
+
void* wq[2];
|
|
120
|
+
|
|
121
|
+
uv_mutex_t wq_mutex;
|
|
122
|
+
uv_async_t wq_async;
|
|
123
|
+
void* async_handles[2];
|
|
124
|
+
void* em_queue;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
#undef UV_REQ_FIELDS
|
|
128
|
+
|
|
129
|
+
#ifdef __cplusplus
|
|
130
|
+
}
|
|
131
|
+
#endif
|
|
132
|
+
|
|
133
|
+
#endif
|
|
134
|
+
#endif /* UV_H */
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
+
|
|
4
|
+
const path = require('path')
|
|
5
|
+
|
|
6
|
+
const include = path.join(__dirname, 'include')
|
|
7
|
+
const includeDir = path.relative(process.cwd(), include)
|
|
8
|
+
const jsLibrary = path.join(__dirname, './dist/library_napi.js')
|
|
9
|
+
const sources = [
|
|
10
|
+
path.join(__dirname, './src/emnapi.c'),
|
|
11
|
+
path.join(__dirname, './src/uv/uv-common.c'),
|
|
12
|
+
path.join(__dirname, './src/uv/threadpool.c'),
|
|
13
|
+
path.join(__dirname, './src/uv/unix/loop.c'),
|
|
14
|
+
path.join(__dirname, './src/uv/unix/thread.c'),
|
|
15
|
+
path.join(__dirname, './src/uv/unix/async.c'),
|
|
16
|
+
path.join(__dirname, './src/uv/unix/core.c')
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
exports.include = include
|
|
20
|
+
exports.include_dir = includeDir
|
|
21
|
+
exports.js_library = jsLibrary
|
|
22
|
+
exports.sources = sources
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.29 (43074846f216abad2a1c35b5a631f2a9481d9e07)
|
|
2
|
+
clang version 16.0.0 (https://github.com/llvm/llvm-project 947d529e4194e0567cfbbea99127066f76c87269)
|
|
3
|
+
Target: wasm32-unknown-emscripten
|
|
4
|
+
Thread model: posix
|
|
5
|
+
InstalledDir: /home/runner/work/emnapi/emnapi/emsdk-cache/emsdk-main/upstream/bin
|
|
Binary file
|
package/lib/wasm32.txt
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "emnapi",
|
|
3
|
+
"version": "0.31.0",
|
|
4
|
+
"description": "Node-API implementation for Emscripten",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"ts-macros": "2.0.1"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "node ./script/build.js"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/toyobayashi/emnapi.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"emscripten",
|
|
18
|
+
"wasm",
|
|
19
|
+
"emcc",
|
|
20
|
+
"webassembly",
|
|
21
|
+
"binding",
|
|
22
|
+
"clang",
|
|
23
|
+
"c",
|
|
24
|
+
"c++",
|
|
25
|
+
"cpp",
|
|
26
|
+
"n-api",
|
|
27
|
+
"napi",
|
|
28
|
+
"node-addon-api",
|
|
29
|
+
"napi-rs",
|
|
30
|
+
"rust",
|
|
31
|
+
"wasi-sdk",
|
|
32
|
+
"wasi"
|
|
33
|
+
],
|
|
34
|
+
"author": "toyobayashi",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/toyobayashi/emnapi/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/toyobayashi/emnapi#readme",
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
}
|
|
43
|
+
}
|