emnapi 1.2.0 → 1.3.1

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.
Files changed (44) hide show
  1. package/CMakeLists.txt +13 -3
  2. package/README.md +7 -18
  3. package/common.gypi +1 -0
  4. package/dist/library_napi.js +130 -41
  5. package/emnapi.gyp +4 -0
  6. package/include/node/emnapi.h +2 -2
  7. package/include/node/js_native_api.h +30 -25
  8. package/include/node/js_native_api_types.h +13 -9
  9. package/include/node/node_api.h +25 -13
  10. package/include/node/uv/threadpool.h +1 -1
  11. package/include/node/uv/unix.h +4 -0
  12. package/include/node/uv.h +49 -6
  13. package/index.js +1 -0
  14. package/lib/wasm32/libemnapi.a +0 -0
  15. package/lib/wasm32-emscripten/libemnapi-mt.a +0 -0
  16. package/lib/wasm32-emscripten/libemnapi.a +0 -0
  17. package/lib/wasm32-wasi/libemnapi.a +0 -0
  18. package/lib/wasm32-wasi-threads/libemnapi-basic-mt.a +0 -0
  19. package/lib/wasm32-wasi-threads/libemnapi-basic.a +0 -0
  20. package/lib/wasm32-wasi-threads/libemnapi-mt.a +0 -0
  21. package/lib/wasm32-wasi-threads/libemnapi.a +0 -0
  22. package/lib/wasm32-wasip1/libemnapi.a +0 -0
  23. package/lib/wasm32-wasip1-threads/libemnapi-basic-mt.a +0 -0
  24. package/lib/wasm32-wasip1-threads/libemnapi-basic.a +0 -0
  25. package/lib/wasm32-wasip1-threads/libemnapi-mt.a +0 -0
  26. package/lib/wasm32-wasip1-threads/libemnapi.a +0 -0
  27. package/lib/wasm64-emscripten/libemnapi-mt.a +0 -0
  28. package/lib/wasm64-emscripten/libemnapi.a +0 -0
  29. package/package.json +1 -1
  30. package/src/async_cleanup_hook.c +1 -1
  31. package/src/async_work.c +2 -2
  32. package/src/emnapi_internal.h +2 -2
  33. package/src/js_native_api.c +2 -1
  34. package/src/node_api.c +5 -5
  35. package/src/threadsafe_function.c +20 -21
  36. package/src/uv/queue.h +68 -86
  37. package/src/uv/threadpool.c +58 -40
  38. package/src/uv/unix/async.c +67 -64
  39. package/src/uv/unix/core.c +36 -1
  40. package/src/uv/unix/internal.h +54 -0
  41. package/src/uv/unix/loop.c +40 -4
  42. package/src/uv/unix/posix-hrtime.c +40 -0
  43. package/src/uv/uv-common.c +123 -7
  44. package/src/uv/uv-common.h +137 -9
@@ -56,7 +56,7 @@
56
56
  EXTERN_C_START
57
57
 
58
58
  NAPI_EXTERN napi_status NAPI_CDECL napi_get_last_error_info(
59
- node_api_nogc_env env, const napi_extended_error_info** result);
59
+ node_api_basic_env env, const napi_extended_error_info** result);
60
60
 
61
61
  // Getters for defined singletons
62
62
  NAPI_EXTERN napi_status NAPI_CDECL napi_get_undefined(napi_env env,
@@ -100,19 +100,19 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_create_string_utf16(napi_env env,
100
100
  napi_value* result);
101
101
  #ifdef NAPI_EXPERIMENTAL
102
102
  #define NODE_API_EXPERIMENTAL_HAS_EXTERNAL_STRINGS
103
- NAPI_EXTERN napi_status NAPI_CDECL
104
- node_api_create_external_string_latin1(napi_env env,
105
- char* str,
106
- size_t length,
107
- node_api_nogc_finalize finalize_callback,
108
- void* finalize_hint,
109
- napi_value* result,
110
- bool* copied);
103
+ NAPI_EXTERN napi_status NAPI_CDECL node_api_create_external_string_latin1(
104
+ napi_env env,
105
+ char* str,
106
+ size_t length,
107
+ node_api_basic_finalize finalize_callback,
108
+ void* finalize_hint,
109
+ napi_value* result,
110
+ bool* copied);
111
111
  NAPI_EXTERN napi_status NAPI_CDECL
112
112
  node_api_create_external_string_utf16(napi_env env,
113
113
  char16_t* str,
114
114
  size_t length,
115
- node_api_nogc_finalize finalize_callback,
115
+ node_api_basic_finalize finalize_callback,
116
116
  void* finalize_hint,
117
117
  napi_value* result,
118
118
  bool* copied);
@@ -120,6 +120,10 @@ node_api_create_external_string_utf16(napi_env env,
120
120
 
121
121
  #ifdef NAPI_EXPERIMENTAL
122
122
  #define NODE_API_EXPERIMENTAL_HAS_PROPERTY_KEYS
123
+ NAPI_EXTERN napi_status NAPI_CDECL node_api_create_property_key_latin1(
124
+ napi_env env, const char* str, size_t length, napi_value* result);
125
+ NAPI_EXTERN napi_status NAPI_CDECL node_api_create_property_key_utf8(
126
+ napi_env env, const char* str, size_t length, napi_value* result);
123
127
  NAPI_EXTERN napi_status NAPI_CDECL node_api_create_property_key_utf16(
124
128
  napi_env env, const char16_t* str, size_t length, napi_value* result);
125
129
  #endif // NAPI_EXPERIMENTAL
@@ -324,12 +328,13 @@ napi_define_class(napi_env env,
324
328
  napi_value* result);
325
329
 
326
330
  // Methods to work with external data objects
327
- NAPI_EXTERN napi_status NAPI_CDECL napi_wrap(napi_env env,
328
- napi_value js_object,
329
- void* native_object,
330
- node_api_nogc_finalize finalize_cb,
331
- void* finalize_hint,
332
- napi_ref* result);
331
+ NAPI_EXTERN napi_status NAPI_CDECL
332
+ napi_wrap(napi_env env,
333
+ napi_value js_object,
334
+ void* native_object,
335
+ node_api_basic_finalize finalize_cb,
336
+ void* finalize_hint,
337
+ napi_ref* result);
333
338
  NAPI_EXTERN napi_status NAPI_CDECL napi_unwrap(napi_env env,
334
339
  napi_value js_object,
335
340
  void** result);
@@ -339,7 +344,7 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_remove_wrap(napi_env env,
339
344
  NAPI_EXTERN napi_status NAPI_CDECL
340
345
  napi_create_external(napi_env env,
341
346
  void* data,
342
- node_api_nogc_finalize finalize_cb,
347
+ node_api_basic_finalize finalize_cb,
343
348
  void* finalize_hint,
344
349
  napi_value* result);
345
350
  NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_external(napi_env env,
@@ -438,7 +443,7 @@ NAPI_EXTERN napi_status NAPI_CDECL
438
443
  napi_create_external_arraybuffer(napi_env env,
439
444
  void* external_data,
440
445
  size_t byte_length,
441
- node_api_nogc_finalize finalize_cb,
446
+ node_api_basic_finalize finalize_cb,
442
447
  void* finalize_hint,
443
448
  napi_value* result);
444
449
  #endif // NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED
@@ -480,7 +485,7 @@ napi_get_dataview_info(napi_env env,
480
485
  size_t* byte_offset);
481
486
 
482
487
  // version management
483
- NAPI_EXTERN napi_status NAPI_CDECL napi_get_version(node_api_nogc_env env,
488
+ NAPI_EXTERN napi_status NAPI_CDECL napi_get_version(node_api_basic_env env,
484
489
  uint32_t* result);
485
490
 
486
491
  // Promises
@@ -504,7 +509,7 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_run_script(napi_env env,
504
509
 
505
510
  // Memory management
506
511
  NAPI_EXTERN napi_status NAPI_CDECL napi_adjust_external_memory(
507
- node_api_nogc_env env, int64_t change_in_bytes, int64_t* adjusted_value);
512
+ node_api_basic_env env, int64_t change_in_bytes, int64_t* adjusted_value);
508
513
 
509
514
  #if NAPI_VERSION >= 5
510
515
 
@@ -526,7 +531,7 @@ NAPI_EXTERN napi_status NAPI_CDECL
526
531
  napi_add_finalizer(napi_env env,
527
532
  napi_value js_object,
528
533
  void* finalize_data,
529
- node_api_nogc_finalize finalize_cb,
534
+ node_api_basic_finalize finalize_cb,
530
535
  void* finalize_hint,
531
536
  napi_ref* result);
532
537
 
@@ -536,7 +541,7 @@ napi_add_finalizer(napi_env env,
536
541
  #define NODE_API_EXPERIMENTAL_HAS_POST_FINALIZER
537
542
 
538
543
  NAPI_EXTERN napi_status NAPI_CDECL
539
- node_api_post_finalizer(node_api_nogc_env env,
544
+ node_api_post_finalizer(node_api_basic_env env,
540
545
  napi_finalize finalize_cb,
541
546
  void* finalize_data,
542
547
  void* finalize_hint);
@@ -581,13 +586,13 @@ napi_get_all_property_names(napi_env env,
581
586
 
582
587
  // Instance data
583
588
  NAPI_EXTERN napi_status NAPI_CDECL
584
- napi_set_instance_data(node_api_nogc_env env,
589
+ napi_set_instance_data(node_api_basic_env env,
585
590
  void* data,
586
591
  napi_finalize finalize_cb,
587
592
  void* finalize_hint);
588
593
 
589
- NAPI_EXTERN napi_status NAPI_CDECL napi_get_instance_data(node_api_nogc_env env,
590
- void** data);
594
+ NAPI_EXTERN napi_status NAPI_CDECL
595
+ napi_get_instance_data(node_api_basic_env env, void** data);
591
596
  #endif // NAPI_VERSION >= 6
592
597
 
593
598
  #if NAPI_VERSION >= 7
@@ -27,7 +27,7 @@ typedef struct napi_env__* napi_env;
27
27
  // meaning that they do not affect the state of the JS engine, and can
28
28
  // therefore be called synchronously from a finalizer that itself runs
29
29
  // synchronously during GC. Such APIs can receive either a `napi_env` or a
30
- // `node_api_nogc_env` as their first parameter, because we should be able to
30
+ // `node_api_basic_env` as their first parameter, because we should be able to
31
31
  // also call them during normal, non-garbage-collecting operations, whereas
32
32
  // APIs that affect the state of the JS engine can only receive a `napi_env` as
33
33
  // their first parameter, because we must not call them during GC. In lieu of
@@ -37,19 +37,21 @@ typedef struct napi_env__* napi_env;
37
37
  // expecting a non-const value.
38
38
  //
39
39
  // In conjunction with appropriate CFLAGS to warn us if we're passing a const
40
- // (nogc) environment into an API that expects a non-const environment, and the
41
- // definition of nogc finalizer function pointer types below, which receive a
42
- // nogc environment as their first parameter, and can thus only call nogc APIs
43
- // (unless the user explicitly casts the environment), we achieve the ability
44
- // to ensure at compile time that we do not call APIs that affect the state of
45
- // the JS engine from a synchronous (nogc) finalizer.
40
+ // (basic) environment into an API that expects a non-const environment, and
41
+ // the definition of basic finalizer function pointer types below, which
42
+ // receive a basic environment as their first parameter, and can thus only call
43
+ // basic APIs (unless the user explicitly casts the environment), we achieve
44
+ // the ability to ensure at compile time that we do not call APIs that affect
45
+ // the state of the JS engine from a synchronous (basic) finalizer.
46
46
  #if !defined(NAPI_EXPERIMENTAL) || \
47
47
  (defined(NAPI_EXPERIMENTAL) && \
48
- defined(NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT))
48
+ (defined(NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT) || \
49
+ defined(NODE_API_EXPERIMENTAL_BASIC_ENV_OPT_OUT)))
49
50
  typedef struct napi_env__* node_api_nogc_env;
50
51
  #else
51
52
  typedef const struct napi_env__* node_api_nogc_env;
52
53
  #endif
54
+ typedef node_api_nogc_env node_api_basic_env;
53
55
 
54
56
  typedef struct napi_value__* napi_value;
55
57
  typedef struct napi_ref__* napi_ref;
@@ -147,13 +149,15 @@ typedef void(NAPI_CDECL* napi_finalize)(napi_env env,
147
149
 
148
150
  #if !defined(NAPI_EXPERIMENTAL) || \
149
151
  (defined(NAPI_EXPERIMENTAL) && \
150
- defined(NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT))
152
+ (defined(NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT) || \
153
+ defined(NODE_API_EXPERIMENTAL_BASIC_ENV_OPT_OUT)))
151
154
  typedef napi_finalize node_api_nogc_finalize;
152
155
  #else
153
156
  typedef void(NAPI_CDECL* node_api_nogc_finalize)(node_api_nogc_env env,
154
157
  void* finalize_data,
155
158
  void* finalize_hint);
156
159
  #endif
160
+ typedef node_api_nogc_finalize node_api_basic_finalize;
157
161
 
158
162
  typedef struct {
159
163
  // One of utf8name or name should be NULL.
@@ -141,10 +141,22 @@ NAPI_EXTERN napi_status NAPI_CDECL
141
141
  napi_create_external_buffer(napi_env env,
142
142
  size_t length,
143
143
  void* data,
144
- node_api_nogc_finalize finalize_cb,
144
+ node_api_basic_finalize finalize_cb,
145
145
  void* finalize_hint,
146
146
  napi_value* result);
147
147
  #endif // NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED
148
+
149
+ #ifdef NAPI_EXPERIMENTAL
150
+ #define NODE_API_EXPERIMENTAL_HAS_CREATE_BUFFER_FROM_ARRAYBUFFER
151
+
152
+ NAPI_EXTERN napi_status NAPI_CDECL
153
+ node_api_create_buffer_from_arraybuffer(napi_env env,
154
+ napi_value arraybuffer,
155
+ size_t byte_offset,
156
+ size_t byte_length,
157
+ napi_value* result);
158
+ #endif // NAPI_EXPERIMENTAL
159
+
148
160
  NAPI_EXTERN napi_status NAPI_CDECL napi_create_buffer_copy(napi_env env,
149
161
  size_t length,
150
162
  const void* data,
@@ -169,20 +181,20 @@ napi_create_async_work(napi_env env,
169
181
  napi_async_work* result);
170
182
  NAPI_EXTERN napi_status NAPI_CDECL napi_delete_async_work(napi_env env,
171
183
  napi_async_work work);
172
- NAPI_EXTERN napi_status NAPI_CDECL napi_queue_async_work(node_api_nogc_env env,
184
+ NAPI_EXTERN napi_status NAPI_CDECL napi_queue_async_work(node_api_basic_env env,
173
185
  napi_async_work work);
174
- NAPI_EXTERN napi_status NAPI_CDECL napi_cancel_async_work(node_api_nogc_env env,
175
- napi_async_work work);
186
+ NAPI_EXTERN napi_status NAPI_CDECL
187
+ napi_cancel_async_work(node_api_basic_env env, napi_async_work work);
176
188
 
177
189
  // version management
178
- NAPI_EXTERN napi_status NAPI_CDECL
179
- napi_get_node_version(node_api_nogc_env env, const napi_node_version** version);
190
+ NAPI_EXTERN napi_status NAPI_CDECL napi_get_node_version(
191
+ node_api_basic_env env, const napi_node_version** version);
180
192
 
181
193
  #if NAPI_VERSION >= 2
182
194
 
183
195
  // Return the current libuv event loop for a given environment
184
196
  NAPI_EXTERN napi_status NAPI_CDECL
185
- napi_get_uv_event_loop(node_api_nogc_env env, struct uv_loop_s** loop);
197
+ napi_get_uv_event_loop(node_api_basic_env env, struct uv_loop_s** loop);
186
198
 
187
199
  #endif // NAPI_VERSION >= 2
188
200
 
@@ -192,10 +204,10 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_fatal_exception(napi_env env,
192
204
  napi_value err);
193
205
 
194
206
  NAPI_EXTERN napi_status NAPI_CDECL napi_add_env_cleanup_hook(
195
- node_api_nogc_env env, napi_cleanup_hook fun, void* arg);
207
+ node_api_basic_env env, napi_cleanup_hook fun, void* arg);
196
208
 
197
209
  NAPI_EXTERN napi_status NAPI_CDECL napi_remove_env_cleanup_hook(
198
- node_api_nogc_env env, napi_cleanup_hook fun, void* arg);
210
+ node_api_basic_env env, napi_cleanup_hook fun, void* arg);
199
211
 
200
212
  NAPI_EXTERN napi_status NAPI_CDECL
201
213
  napi_open_callback_scope(napi_env env,
@@ -239,17 +251,17 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_release_threadsafe_function(
239
251
  napi_threadsafe_function func, napi_threadsafe_function_release_mode mode);
240
252
 
241
253
  NAPI_EXTERN napi_status NAPI_CDECL napi_unref_threadsafe_function(
242
- node_api_nogc_env env, napi_threadsafe_function func);
254
+ node_api_basic_env env, napi_threadsafe_function func);
243
255
 
244
256
  NAPI_EXTERN napi_status NAPI_CDECL napi_ref_threadsafe_function(
245
- node_api_nogc_env env, napi_threadsafe_function func);
257
+ node_api_basic_env env, napi_threadsafe_function func);
246
258
 
247
259
  #endif // NAPI_VERSION >= 4
248
260
 
249
261
  #if NAPI_VERSION >= 8
250
262
 
251
263
  NAPI_EXTERN napi_status NAPI_CDECL
252
- napi_add_async_cleanup_hook(node_api_nogc_env env,
264
+ napi_add_async_cleanup_hook(node_api_basic_env env,
253
265
  napi_async_cleanup_hook hook,
254
266
  void* arg,
255
267
  napi_async_cleanup_hook_handle* remove_handle);
@@ -262,7 +274,7 @@ napi_remove_async_cleanup_hook(napi_async_cleanup_hook_handle remove_handle);
262
274
  #if NAPI_VERSION >= 9
263
275
 
264
276
  NAPI_EXTERN napi_status NAPI_CDECL
265
- node_api_get_module_file_name(node_api_nogc_env env, const char** result);
277
+ node_api_get_module_file_name(node_api_basic_env env, const char** result);
266
278
 
267
279
  #endif // NAPI_VERSION >= 9
268
280
 
@@ -33,7 +33,7 @@ struct uv__work {
33
33
  void (*work)(struct uv__work *w);
34
34
  void (*done)(struct uv__work *w, int status);
35
35
  struct uv_loop_s* loop;
36
- void* wq[2];
36
+ struct uv__queue wq;
37
37
  };
38
38
 
39
39
  #endif
@@ -18,4 +18,8 @@ typedef pthread_cond_t uv_cond_t;
18
18
 
19
19
  #endif
20
20
 
21
+ #define UV_HANDLE_PRIVATE_FIELDS \
22
+ uv_handle_t* next_closing; \
23
+ unsigned int flags; \
24
+
21
25
  #endif /* UV_UNIX_H */
package/include/node/uv.h CHANGED
@@ -3,13 +3,21 @@
3
3
 
4
4
  #if defined(__EMSCRIPTEN_PTHREADS__) || defined(_REENTRANT)
5
5
 
6
- #include <stddef.h>
7
- #include "uv/unix.h"
8
-
9
6
  #ifdef __cplusplus
10
7
  extern "C" {
11
8
  #endif
12
9
 
10
+ #include <stddef.h>
11
+ #include <stdint.h>
12
+
13
+ /* Internal type, do not use. */
14
+ struct uv__queue {
15
+ struct uv__queue* next;
16
+ struct uv__queue* prev;
17
+ };
18
+
19
+ #include "uv/unix.h"
20
+
13
21
  #define UV_EXTERN /* nothing */
14
22
 
15
23
  typedef enum {
@@ -29,6 +37,8 @@ typedef struct uv_work_s uv_work_t;
29
37
  typedef struct uv_handle_s uv_handle_t;
30
38
  typedef struct uv_async_s uv_async_t;
31
39
 
40
+ typedef struct uv_metrics_s uv_metrics_t;
41
+
32
42
  typedef void (*uv_work_cb)(uv_work_t* req);
33
43
  typedef void (*uv_after_work_cb)(uv_work_t* req, int status);
34
44
 
@@ -40,10 +50,22 @@ struct uv_req_s {
40
50
  UV_REQ_FIELDS
41
51
  };
42
52
 
53
+ typedef void* (*uv_malloc_func)(size_t size);
54
+ typedef void* (*uv_realloc_func)(void* ptr, size_t size);
55
+ typedef void* (*uv_calloc_func)(size_t count, size_t size);
56
+ typedef void (*uv_free_func)(void* ptr);
57
+
43
58
  UV_EXTERN void uv_library_shutdown(void);
59
+
60
+ UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func,
61
+ uv_realloc_func realloc_func,
62
+ uv_calloc_func calloc_func,
63
+ uv_free_func free_func);
64
+
44
65
  UV_EXTERN uv_loop_t* uv_default_loop(void);
45
66
  UV_EXTERN int uv_loop_init(uv_loop_t* loop);
46
67
  UV_EXTERN int uv_loop_close(uv_loop_t* loop);
68
+ UV_EXTERN uint64_t uv_hrtime(void);
47
69
  UV_EXTERN void uv_sleep(unsigned int msec);
48
70
 
49
71
  UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value);
@@ -111,6 +133,12 @@ typedef void (*uv_async_cb)(uv_async_t* handle);
111
133
  uv_loop_t* loop; \
112
134
  uv_handle_type type; \
113
135
  uv_close_cb close_cb; \
136
+ struct uv__queue handle_queue; \
137
+ union { \
138
+ int fd; \
139
+ void* reserved[4]; \
140
+ } u; \
141
+ UV_HANDLE_PRIVATE_FIELDS \
114
142
 
115
143
  struct uv_handle_s {
116
144
  UV_HANDLE_FIELDS
@@ -119,7 +147,7 @@ struct uv_handle_s {
119
147
  struct uv_async_s {
120
148
  UV_HANDLE_FIELDS
121
149
  uv_async_cb async_cb;
122
- void* queue[2];
150
+ struct uv__queue queue;
123
151
  int pending;
124
152
  };
125
153
 
@@ -129,18 +157,33 @@ UV_EXTERN int uv_async_init(uv_loop_t*,
129
157
  UV_EXTERN int uv_async_send(uv_async_t* async);
130
158
 
131
159
  UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb);
160
+ UV_EXTERN int uv_is_closing(const uv_handle_t* handle);
161
+
162
+ struct uv_metrics_s {
163
+ uint64_t loop_count;
164
+ uint64_t events;
165
+ uint64_t events_waiting;
166
+ /* private */
167
+ uint64_t* reserved[13];
168
+ };
169
+
170
+ UV_EXTERN int uv_metrics_info(uv_loop_t* loop, uv_metrics_t* metrics);
171
+ UV_EXTERN uint64_t uv_metrics_idle_time(uv_loop_t* loop);
132
172
 
133
173
  struct uv_loop_s {
134
174
  void* data;
175
+ unsigned int active_handles;
176
+ struct uv__queue handle_queue;
135
177
  union {
136
178
  void* unused;
137
179
  unsigned int count;
138
180
  } active_reqs;
139
- void* wq[2];
181
+ void* internal_fields;
140
182
 
183
+ struct uv__queue wq;
141
184
  uv_mutex_t wq_mutex;
142
185
  uv_async_t wq_async;
143
- void* async_handles[2];
186
+ struct uv__queue async_handles;
144
187
  void* em_queue;
145
188
  };
146
189
 
package/index.js CHANGED
@@ -16,6 +16,7 @@ const sources = [
16
16
  path.join(__dirname, './src/uv/uv-common.c'),
17
17
  path.join(__dirname, './src/uv/threadpool.c'),
18
18
  path.join(__dirname, './src/uv/unix/loop.c'),
19
+ path.join(__dirname, './src/uv/unix/posix-hrtime.c'),
19
20
  path.join(__dirname, './src/uv/unix/thread.c'),
20
21
  path.join(__dirname, './src/uv/unix/async.c'),
21
22
  path.join(__dirname, './src/uv/unix/core.c')
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emnapi",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Node-API implementation for Emscripten",
5
5
  "main": "index.js",
6
6
  "gypfile": false,
@@ -101,7 +101,7 @@ _emnapi_ach_handle_delete(napi_async_cleanup_hook_handle handle) {
101
101
  }
102
102
 
103
103
  napi_status
104
- napi_add_async_cleanup_hook(napi_env env,
104
+ napi_add_async_cleanup_hook(node_api_basic_env env,
105
105
  napi_async_cleanup_hook hook,
106
106
  void* arg,
107
107
  napi_async_cleanup_hook_handle* remove_handle) {
package/src/async_work.c CHANGED
@@ -198,7 +198,7 @@ napi_status napi_delete_async_work(napi_env env, napi_async_work work) {
198
198
  #endif
199
199
  }
200
200
 
201
- napi_status napi_queue_async_work(napi_env env, napi_async_work work) {
201
+ napi_status napi_queue_async_work(node_api_basic_env env, napi_async_work work) {
202
202
  #if EMNAPI_HAVE_THREADS
203
203
  CHECK_ENV(env);
204
204
  CHECK_ARG(env, work);
@@ -220,7 +220,7 @@ napi_status napi_queue_async_work(napi_env env, napi_async_work work) {
220
220
  } \
221
221
  } while (0)
222
222
 
223
- napi_status napi_cancel_async_work(napi_env env, napi_async_work work) {
223
+ napi_status napi_cancel_async_work(node_api_basic_env env, napi_async_work work) {
224
224
  #if EMNAPI_HAVE_THREADS
225
225
  CHECK_ENV(env);
226
226
  CHECK_ARG(env, work);
@@ -72,11 +72,11 @@ EXTERN_C_END
72
72
 
73
73
  EXTERN_C_START
74
74
 
75
- EMNAPI_INTERNAL_EXTERN napi_status napi_set_last_error(node_api_nogc_env env,
75
+ EMNAPI_INTERNAL_EXTERN napi_status napi_set_last_error(node_api_basic_env env,
76
76
  napi_status error_code,
77
77
  uint32_t engine_error_code,
78
78
  void* engine_reserved);
79
- EMNAPI_INTERNAL_EXTERN napi_status napi_clear_last_error(node_api_nogc_env env);
79
+ EMNAPI_INTERNAL_EXTERN napi_status napi_clear_last_error(node_api_basic_env env);
80
80
 
81
81
  #ifdef __EMSCRIPTEN__
82
82
  #if __EMSCRIPTEN_major__ * 10000 + __EMSCRIPTEN_minor__ * 100 + __EMSCRIPTEN_tiny__ >= 30114 // NOLINT
@@ -35,8 +35,9 @@ EMNAPI_INTERNAL_EXTERN void _emnapi_get_last_error_info(napi_env env,
35
35
  void** engine_reserved);
36
36
 
37
37
  napi_status napi_get_last_error_info(
38
- napi_env env, const napi_extended_error_info** result) {
38
+ node_api_basic_env basic_env, const napi_extended_error_info** result) {
39
39
  static napi_extended_error_info last_error;
40
+ napi_env env = (napi_env) basic_env;
40
41
  CHECK_ENV(env);
41
42
  CHECK_ARG(env, result);
42
43
 
package/src/node_api.c CHANGED
@@ -1,7 +1,7 @@
1
1
  #include "node_api.h"
2
2
  #include "emnapi_internal.h"
3
3
 
4
- #if EMNAPI_HAVE_THREADS
4
+ #if EMNAPI_HAVE_THREADS && !defined(EMNAPI_DISABLE_UV)
5
5
  #include "uv.h"
6
6
  #endif
7
7
 
@@ -12,7 +12,7 @@ EMNAPI_INTERNAL_EXTERN void _emnapi_get_node_version(uint32_t* major,
12
12
  uint32_t* patch);
13
13
 
14
14
  napi_status
15
- napi_get_node_version(napi_env env,
15
+ napi_get_node_version(node_api_basic_env env,
16
16
  const napi_node_version** version) {
17
17
  CHECK_ENV(env);
18
18
  CHECK_ARG(env, version);
@@ -29,9 +29,9 @@ napi_get_node_version(napi_env env,
29
29
  return napi_clear_last_error(env);
30
30
  }
31
31
 
32
- napi_status napi_get_uv_event_loop(napi_env env,
32
+ napi_status napi_get_uv_event_loop(node_api_basic_env env,
33
33
  struct uv_loop_s** loop) {
34
- #if EMNAPI_HAVE_THREADS
34
+ #if EMNAPI_HAVE_THREADS && !defined(EMNAPI_DISABLE_UV)
35
35
  CHECK_ENV(env);
36
36
  CHECK_ARG(env, loop);
37
37
  // Though this is fake libuv loop
@@ -44,7 +44,7 @@ napi_status napi_get_uv_event_loop(napi_env env,
44
44
 
45
45
  EMNAPI_INTERNAL_EXTERN int _emnapi_get_filename(napi_env env, char* buf, int len);
46
46
 
47
- napi_status node_api_get_module_file_name(napi_env env,
47
+ napi_status node_api_get_module_file_name(node_api_basic_env env,
48
48
  const char** result) {
49
49
  CHECK_ENV(env);
50
50
  CHECK_ARG(env, result);