@encharm/cws 4.5.3 → 4.8.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.
Files changed (305) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/CLAUDE.md +83 -0
  3. package/README.md +20 -4
  4. package/binding.gyp +8 -2
  5. package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
  6. package/dist/bindings/cws_darwin_arm64_node127.node +0 -0
  7. package/dist/bindings/cws_darwin_arm64_node137.node +0 -0
  8. package/dist/bindings/cws_darwin_arm64_node147.node +0 -0
  9. package/dist/bindings/cws_linux_arm64_node115.node +0 -0
  10. package/dist/bindings/cws_linux_arm64_node127.node +0 -0
  11. package/dist/bindings/cws_linux_arm64_node137.node +0 -0
  12. package/dist/bindings/cws_linux_arm64_node147.node +0 -0
  13. package/dist/bindings/cws_linux_x64_node115.node +0 -0
  14. package/dist/bindings/cws_linux_x64_node127.node +0 -0
  15. package/dist/bindings/cws_linux_x64_node137.node +0 -0
  16. package/dist/bindings/cws_linux_x64_node147.node +0 -0
  17. package/dist/bindings/cws_win32_x64_node115.node +0 -0
  18. package/dist/bindings/cws_win32_x64_node127.node +0 -0
  19. package/dist/bindings/cws_win32_x64_node137.node +0 -0
  20. package/dist/bindings/cws_win32_x64_node147.node +0 -0
  21. package/dist/client.d.ts +1 -0
  22. package/dist/client.js +15 -1
  23. package/dist/index.d.ts +6 -1
  24. package/dist/index.js +2 -0
  25. package/dist/server.d.ts +1 -0
  26. package/dist/server.js +16 -2
  27. package/dist/shared.d.ts +1 -0
  28. package/dist/shared.js +3 -2
  29. package/package.json +1 -1
  30. package/src/Addon.cpp +4 -1
  31. package/src/Addon.h +80 -15
  32. package/src/Extensions.cpp +7 -1
  33. package/src/Extensions.h +2 -1
  34. package/src/Group.cpp +1 -1
  35. package/src/Group.h +4 -1
  36. package/src/HTTPSocket.cpp +1 -1
  37. package/src/Hub.cpp +11 -76
  38. package/src/Hub.h +12 -10
  39. package/src/Networking.h +11 -0
  40. package/src/Socket.h +201 -6
  41. package/src/WebSocket.cpp +8 -5
  42. package/src/Zlib.cpp +138 -0
  43. package/src/Zlib.h +38 -0
  44. package/src/cSNode.cpp +2 -0
  45. package/src/cSNode.h +4 -0
  46. package/src/headers/26/acorn_version.h +6 -0
  47. package/src/headers/26/aliased_buffer-inl.h +264 -0
  48. package/src/headers/26/aliased_buffer.h +205 -0
  49. package/src/headers/26/aliased_struct-inl.h +143 -0
  50. package/src/headers/26/aliased_struct.h +248 -0
  51. package/src/headers/26/amaro_version.h +6 -0
  52. package/src/headers/26/async_context_frame.h +33 -0
  53. package/src/headers/26/async_wrap-inl.h +123 -0
  54. package/src/headers/26/async_wrap.h +254 -0
  55. package/src/headers/26/base_object-inl.h +333 -0
  56. package/src/headers/26/base_object.h +339 -0
  57. package/src/headers/26/base_object_types.h +76 -0
  58. package/src/headers/26/blob_serializer_deserializer-inl.h +385 -0
  59. package/src/headers/26/blob_serializer_deserializer.h +142 -0
  60. package/src/headers/26/builtin_info.h +57 -0
  61. package/src/headers/26/callback_queue-inl.h +97 -0
  62. package/src/headers/26/callback_queue.h +79 -0
  63. package/src/headers/26/cares_wrap.h +475 -0
  64. package/src/headers/26/cleanup_queue-inl.h +36 -0
  65. package/src/headers/26/cleanup_queue.h +79 -0
  66. package/src/headers/26/compile_cache.h +134 -0
  67. package/src/headers/26/connect_wrap.h +26 -0
  68. package/src/headers/26/connection_wrap.h +30 -0
  69. package/src/headers/26/cppgc_helpers-inl.h +69 -0
  70. package/src/headers/26/cppgc_helpers.h +162 -0
  71. package/src/headers/26/crypto/crypto_aes.h +107 -0
  72. package/src/headers/26/crypto/crypto_argon2.h +88 -0
  73. package/src/headers/26/crypto/crypto_bio.h +193 -0
  74. package/src/headers/26/crypto/crypto_chacha20_poly1305.h +62 -0
  75. package/src/headers/26/crypto/crypto_cipher.h +291 -0
  76. package/src/headers/26/crypto/crypto_common.h +48 -0
  77. package/src/headers/26/crypto/crypto_context.h +219 -0
  78. package/src/headers/26/crypto/crypto_dh.h +104 -0
  79. package/src/headers/26/crypto/crypto_dsa.h +50 -0
  80. package/src/headers/26/crypto/crypto_ec.h +102 -0
  81. package/src/headers/26/crypto/crypto_hash.h +157 -0
  82. package/src/headers/26/crypto/crypto_hkdf.h +62 -0
  83. package/src/headers/26/crypto/crypto_hmac.h +92 -0
  84. package/src/headers/26/crypto/crypto_kem.h +131 -0
  85. package/src/headers/26/crypto/crypto_keygen.h +382 -0
  86. package/src/headers/26/crypto/crypto_keys.h +366 -0
  87. package/src/headers/26/crypto/crypto_kmac.h +79 -0
  88. package/src/headers/26/crypto/crypto_pbkdf2.h +76 -0
  89. package/src/headers/26/crypto/crypto_pqc.h +39 -0
  90. package/src/headers/26/crypto/crypto_random.h +127 -0
  91. package/src/headers/26/crypto/crypto_rsa.h +108 -0
  92. package/src/headers/26/crypto/crypto_scrypt.h +85 -0
  93. package/src/headers/26/crypto/crypto_sig.h +159 -0
  94. package/src/headers/26/crypto/crypto_spkac.h +21 -0
  95. package/src/headers/26/crypto/crypto_timing.h +20 -0
  96. package/src/headers/26/crypto/crypto_tls.h +342 -0
  97. package/src/headers/26/crypto/crypto_turboshake.h +105 -0
  98. package/src/headers/26/crypto/crypto_util.h +775 -0
  99. package/src/headers/26/crypto/crypto_x509.h +140 -0
  100. package/src/headers/26/dataqueue/queue.h +311 -0
  101. package/src/headers/26/debug_utils-inl.h +291 -0
  102. package/src/headers/26/debug_utils.h +200 -0
  103. package/src/headers/26/diagnosticfilename-inl.h +33 -0
  104. package/src/headers/26/embedded_data.h +17 -0
  105. package/src/headers/26/encoding_binding.h +59 -0
  106. package/src/headers/26/env-inl.h +956 -0
  107. package/src/headers/26/env.h +1294 -0
  108. package/src/headers/26/env_properties.h +562 -0
  109. package/src/headers/26/ffi/data.h +30 -0
  110. package/src/headers/26/ffi/fast.h +96 -0
  111. package/src/headers/26/ffi/jit_memory.h +26 -0
  112. package/src/headers/26/ffi/types.h +99 -0
  113. package/src/headers/26/handle_wrap.h +123 -0
  114. package/src/headers/26/histogram-inl.h +211 -0
  115. package/src/headers/26/histogram.h +474 -0
  116. package/src/headers/26/inspector/dom_storage_agent.h +68 -0
  117. package/src/headers/26/inspector/inspector_object_utils.h +38 -0
  118. package/src/headers/26/inspector/io_agent.h +30 -0
  119. package/src/headers/26/inspector/main_thread_interface.h +116 -0
  120. package/src/headers/26/inspector/network_agent.h +110 -0
  121. package/src/headers/26/inspector/network_inspector.h +45 -0
  122. package/src/headers/26/inspector/network_requests_buffer.h +195 -0
  123. package/src/headers/26/inspector/network_resource_manager.h +29 -0
  124. package/src/headers/26/inspector/node_json.h +24 -0
  125. package/src/headers/26/inspector/node_string.h +101 -0
  126. package/src/headers/26/inspector/notification_emitter.h +38 -0
  127. package/src/headers/26/inspector/protocol_helper.h +27 -0
  128. package/src/headers/26/inspector/runtime_agent.h +41 -0
  129. package/src/headers/26/inspector/storage_agent.h +33 -0
  130. package/src/headers/26/inspector/target_agent.h +59 -0
  131. package/src/headers/26/inspector/target_manager.h +70 -0
  132. package/src/headers/26/inspector/tracing_agent.h +43 -0
  133. package/src/headers/26/inspector/worker_agent.h +40 -0
  134. package/src/headers/26/inspector/worker_inspector.h +124 -0
  135. package/src/headers/26/inspector_agent.h +168 -0
  136. package/src/headers/26/inspector_io.h +78 -0
  137. package/src/headers/26/inspector_profiler.h +149 -0
  138. package/src/headers/26/inspector_socket.h +60 -0
  139. package/src/headers/26/inspector_socket_server.h +110 -0
  140. package/src/headers/26/js_native_api.h +634 -0
  141. package/src/headers/26/js_native_api_types.h +244 -0
  142. package/src/headers/26/js_native_api_v8.h +485 -0
  143. package/src/headers/26/js_native_api_v8_internals.h +45 -0
  144. package/src/headers/26/js_stream.h +57 -0
  145. package/src/headers/26/json_utils.h +172 -0
  146. package/src/headers/26/large_pages/node_large_page.h +34 -0
  147. package/src/headers/26/lru_cache-inl.h +69 -0
  148. package/src/headers/26/memory_tracker-inl.h +461 -0
  149. package/src/headers/26/memory_tracker.h +341 -0
  150. package/src/headers/26/module_wrap.h +231 -0
  151. package/src/headers/26/ncrypto.h +2008 -0
  152. package/src/headers/26/node.h +1693 -0
  153. package/src/headers/26/node_api.h +265 -0
  154. package/src/headers/26/node_api_internals.h +48 -0
  155. package/src/headers/26/node_api_types.h +58 -0
  156. package/src/headers/26/node_binding.h +170 -0
  157. package/src/headers/26/node_blob.h +160 -0
  158. package/src/headers/26/node_bob-inl.h +36 -0
  159. package/src/headers/26/node_bob.h +107 -0
  160. package/src/headers/26/node_buffer.h +92 -0
  161. package/src/headers/26/node_builtins.h +239 -0
  162. package/src/headers/26/node_concepts.h +46 -0
  163. package/src/headers/26/node_config_file.h +77 -0
  164. package/src/headers/26/node_constants.h +82 -0
  165. package/src/headers/26/node_context_data.h +171 -0
  166. package/src/headers/26/node_contextify.h +261 -0
  167. package/src/headers/26/node_crypto.h +66 -0
  168. package/src/headers/26/node_debug.h +30 -0
  169. package/src/headers/26/node_diagnostics_channel.h +121 -0
  170. package/src/headers/26/node_dir.h +52 -0
  171. package/src/headers/26/node_dotenv.h +45 -0
  172. package/src/headers/26/node_errors.h +378 -0
  173. package/src/headers/26/node_exit_code.h +54 -0
  174. package/src/headers/26/node_external_reference.h +171 -0
  175. package/src/headers/26/node_ffi.h +212 -0
  176. package/src/headers/26/node_file-inl.h +421 -0
  177. package/src/headers/26/node_file.h +561 -0
  178. package/src/headers/26/node_file_utils.h +39 -0
  179. package/src/headers/26/node_hash.h +212 -0
  180. package/src/headers/26/node_http2.h +1202 -0
  181. package/src/headers/26/node_http2_state.h +159 -0
  182. package/src/headers/26/node_http_common-inl.h +199 -0
  183. package/src/headers/26/node_http_common.h +535 -0
  184. package/src/headers/26/node_i18n.h +132 -0
  185. package/src/headers/26/node_internals.h +485 -0
  186. package/src/headers/26/node_locks.h +184 -0
  187. package/src/headers/26/node_main_instance.h +67 -0
  188. package/src/headers/26/node_mem-inl.h +113 -0
  189. package/src/headers/26/node_mem.h +45 -0
  190. package/src/headers/26/node_messaging.h +389 -0
  191. package/src/headers/26/node_metadata.h +172 -0
  192. package/src/headers/26/node_modules.h +102 -0
  193. package/src/headers/26/node_mutex.h +323 -0
  194. package/src/headers/26/node_object_wrap.h +145 -0
  195. package/src/headers/26/node_options-inl.h +524 -0
  196. package/src/headers/26/node_options.h +710 -0
  197. package/src/headers/26/node_perf.h +167 -0
  198. package/src/headers/26/node_perf_common.h +103 -0
  199. package/src/headers/26/node_platform.h +290 -0
  200. package/src/headers/26/node_process-inl.h +26 -0
  201. package/src/headers/26/node_process.h +112 -0
  202. package/src/headers/26/node_profiling.h +38 -0
  203. package/src/headers/26/node_realm-inl.h +156 -0
  204. package/src/headers/26/node_realm.h +236 -0
  205. package/src/headers/26/node_report.h +43 -0
  206. package/src/headers/26/node_revert.h +82 -0
  207. package/src/headers/26/node_root_certs.h +2937 -0
  208. package/src/headers/26/node_sea.h +101 -0
  209. package/src/headers/26/node_shadow_realm.h +46 -0
  210. package/src/headers/26/node_snapshot_builder.h +57 -0
  211. package/src/headers/26/node_snapshotable.h +167 -0
  212. package/src/headers/26/node_sockaddr-inl.h +248 -0
  213. package/src/headers/26/node_sockaddr.h +459 -0
  214. package/src/headers/26/node_sqlite.h +607 -0
  215. package/src/headers/26/node_stat_watcher.h +73 -0
  216. package/src/headers/26/node_task_runner.h +92 -0
  217. package/src/headers/26/node_threadsafe_cow-inl.h +54 -0
  218. package/src/headers/26/node_threadsafe_cow.h +105 -0
  219. package/src/headers/26/node_union_bytes.h +81 -0
  220. package/src/headers/26/node_url.h +101 -0
  221. package/src/headers/26/node_url_pattern.h +118 -0
  222. package/src/headers/26/node_v8.h +78 -0
  223. package/src/headers/26/node_v8_embedder.h +26 -0
  224. package/src/headers/26/node_v8_platform-inl.h +96 -0
  225. package/src/headers/26/node_version.h +116 -0
  226. package/src/headers/26/node_wasi.h +184 -0
  227. package/src/headers/26/node_wasm_web_api.h +55 -0
  228. package/src/headers/26/node_watchdog.h +164 -0
  229. package/src/headers/26/node_webstorage.h +62 -0
  230. package/src/headers/26/node_worker.h +162 -0
  231. package/src/headers/26/path.h +36 -0
  232. package/src/headers/26/permission/boolean_permission.h +50 -0
  233. package/src/headers/26/permission/fs_permission.h +192 -0
  234. package/src/headers/26/permission/permission.h +155 -0
  235. package/src/headers/26/permission/permission_base.h +79 -0
  236. package/src/headers/26/pipe_wrap.h +80 -0
  237. package/src/headers/26/quic/application.h +279 -0
  238. package/src/headers/26/quic/arena.h +373 -0
  239. package/src/headers/26/quic/bindingdata.h +440 -0
  240. package/src/headers/26/quic/cid.h +127 -0
  241. package/src/headers/26/quic/data.h +358 -0
  242. package/src/headers/26/quic/defs.h +417 -0
  243. package/src/headers/26/quic/endpoint.h +519 -0
  244. package/src/headers/26/quic/guard.h +5 -0
  245. package/src/headers/26/quic/http3.h +25 -0
  246. package/src/headers/26/quic/packet.h +166 -0
  247. package/src/headers/26/quic/preferredaddress.h +72 -0
  248. package/src/headers/26/quic/session.h +770 -0
  249. package/src/headers/26/quic/session_manager.h +107 -0
  250. package/src/headers/26/quic/sessionticket.h +110 -0
  251. package/src/headers/26/quic/streams.h +518 -0
  252. package/src/headers/26/quic/tlscontext.h +353 -0
  253. package/src/headers/26/quic/tokens.h +263 -0
  254. package/src/headers/26/quic/transportparams.h +184 -0
  255. package/src/headers/26/req_wrap-inl.h +175 -0
  256. package/src/headers/26/req_wrap.h +79 -0
  257. package/src/headers/26/spawn_sync.h +243 -0
  258. package/src/headers/26/stream_base-inl.h +170 -0
  259. package/src/headers/26/stream_base.h +487 -0
  260. package/src/headers/26/stream_pipe.h +76 -0
  261. package/src/headers/26/stream_wrap.h +137 -0
  262. package/src/headers/26/string_bytes.h +114 -0
  263. package/src/headers/26/string_decoder-inl.h +31 -0
  264. package/src/headers/26/string_decoder.h +49 -0
  265. package/src/headers/26/tcp_wrap.h +138 -0
  266. package/src/headers/26/threadpoolwork-inl.h +70 -0
  267. package/src/headers/26/timer_wrap-inl.h +32 -0
  268. package/src/headers/26/timer_wrap.h +87 -0
  269. package/src/headers/26/timers.h +70 -0
  270. package/src/headers/26/tracing/agent.h +125 -0
  271. package/src/headers/26/tracing/agent_legacy.h +146 -0
  272. package/src/headers/26/tracing/agent_perfetto.h +145 -0
  273. package/src/headers/26/tracing/node_trace_buffer.h +91 -0
  274. package/src/headers/26/tracing/node_trace_writer.h +79 -0
  275. package/src/headers/26/tracing/trace_event.h +27 -0
  276. package/src/headers/26/tracing/trace_event_helper.h +40 -0
  277. package/src/headers/26/tracing/trace_event_legacy.h +1113 -0
  278. package/src/headers/26/tracing/trace_event_legacy_inl.h +711 -0
  279. package/src/headers/26/tracing/trace_event_perfetto.h +47 -0
  280. package/src/headers/26/tracing/traced_value.h +167 -0
  281. package/src/headers/26/tty_wrap.h +65 -0
  282. package/src/headers/26/udp_wrap.h +231 -0
  283. package/src/headers/26/undici_version.h +6 -0
  284. package/src/headers/26/util-inl.h +788 -0
  285. package/src/headers/26/util.h +1207 -0
  286. package/src/headers/26/v8-cpp-heap-external.h +56 -0
  287. package/src/headers/26/v8-external-memory-accounter.h +60 -0
  288. package/src/headers/26/v8-fast-api-calls.h +784 -0
  289. package/src/headers/26/v8-inspector-protocol.h +13 -0
  290. package/src/headers/26/v8-inspector.h +458 -0
  291. package/src/headers/26/v8-metrics.h +273 -0
  292. package/src/headers/26/v8-trace-categories.h +28 -0
  293. package/src/headers/26/v8-unwinder-state.h +30 -0
  294. package/src/headers/26/v8-util.h +549 -0
  295. package/src/headers/26/v8-value-serializer-version.h +24 -0
  296. package/src/headers/26/v8-version-string.h +38 -0
  297. package/src/headers/26/v8-wasm-trap-handler-posix.h +31 -0
  298. package/src/headers/26/v8-wasm-trap-handler-win.h +28 -0
  299. package/src/headers/26/zlib_version.h +6 -0
  300. package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Info.plist +0 -20
  301. package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Resources/DWARF/cws_darwin_arm64_node115.node +0 -0
  302. package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Resources/Relocations/aarch64/cws_darwin_arm64_node115.node.yml +0 -931
  303. package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Info.plist +0 -20
  304. package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Resources/DWARF/cws_darwin_arm64_node127.node +0 -0
  305. package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Resources/Relocations/aarch64/cws_darwin_arm64_node127.node.yml +0 -931
@@ -0,0 +1,76 @@
1
+ #ifndef SRC_STREAM_PIPE_H_
2
+ #define SRC_STREAM_PIPE_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "stream_base.h"
7
+
8
+ namespace node {
9
+
10
+ class StreamPipe : public AsyncWrap {
11
+ public:
12
+ ~StreamPipe() override;
13
+
14
+ void Unpipe(bool is_in_deletion = false);
15
+
16
+ static v8::Maybe<StreamPipe*> New(StreamBase* source,
17
+ StreamBase* sink,
18
+ v8::Local<v8::Object> obj);
19
+ static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
20
+ static void Start(const v8::FunctionCallbackInfo<v8::Value>& args);
21
+ static void Unpipe(const v8::FunctionCallbackInfo<v8::Value>& args);
22
+ static void IsClosed(const v8::FunctionCallbackInfo<v8::Value>& args);
23
+ static void PendingWrites(const v8::FunctionCallbackInfo<v8::Value>& args);
24
+
25
+ SET_NO_MEMORY_INFO()
26
+ SET_MEMORY_INFO_NAME(StreamPipe)
27
+ SET_SELF_SIZE(StreamPipe)
28
+
29
+ private:
30
+ StreamPipe(StreamBase* source, StreamBase* sink, v8::Local<v8::Object> obj);
31
+
32
+ inline StreamBase* source();
33
+ inline StreamBase* sink();
34
+
35
+ int pending_writes_ = 0;
36
+ bool is_reading_ = false;
37
+ bool is_eof_ = false;
38
+ bool is_closed_ = true;
39
+ bool sink_destroyed_ = false;
40
+ bool source_destroyed_ = false;
41
+ bool uses_wants_write_ = false;
42
+
43
+ // Set a default value so that when we’re coming from Start(), we know
44
+ // that we don’t want to read just yet.
45
+ // This will likely need to be changed when supporting streams without
46
+ // `OnStreamWantsWrite()` support.
47
+ size_t wanted_data_ = 0;
48
+
49
+ void ProcessData(size_t nread, std::unique_ptr<v8::BackingStore> bs);
50
+
51
+ class ReadableListener : public StreamListener {
52
+ public:
53
+ uv_buf_t OnStreamAlloc(size_t suggested_size) override;
54
+ void OnStreamRead(ssize_t nread, const uv_buf_t& buf) override;
55
+ void OnStreamDestroy() override;
56
+ };
57
+
58
+ class WritableListener : public StreamListener {
59
+ public:
60
+ uv_buf_t OnStreamAlloc(size_t suggested_size) override;
61
+ void OnStreamRead(ssize_t nread, const uv_buf_t& buf) override;
62
+ void OnStreamAfterWrite(WriteWrap* w, int status) override;
63
+ void OnStreamAfterShutdown(ShutdownWrap* w, int status) override;
64
+ void OnStreamWantsWrite(size_t suggested_size) override;
65
+ void OnStreamDestroy() override;
66
+ };
67
+
68
+ ReadableListener readable_listener_;
69
+ WritableListener writable_listener_;
70
+ };
71
+
72
+ } // namespace node
73
+
74
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
75
+
76
+ #endif // SRC_STREAM_PIPE_H_
@@ -0,0 +1,137 @@
1
+ // Copyright Joyent, Inc. and other Node contributors.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a
4
+ // copy of this software and associated documentation files (the
5
+ // "Software"), to deal in the Software without restriction, including
6
+ // without limitation the rights to use, copy, modify, merge, publish,
7
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ // persons to whom the Software is furnished to do so, subject to the
9
+ // following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included
12
+ // in all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ #ifndef SRC_STREAM_WRAP_H_
23
+ #define SRC_STREAM_WRAP_H_
24
+
25
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
+
27
+ #include "stream_base.h"
28
+ #include "handle_wrap.h"
29
+ #include "v8.h"
30
+
31
+ namespace node {
32
+
33
+ class Environment;
34
+ class ExternalReferenceRegistry;
35
+
36
+ class LibuvStreamWrap : public HandleWrap, public StreamBase {
37
+ public:
38
+ enum InternalFields {
39
+ kInternalFieldCount = std::max<uint32_t>(HandleWrap::kInternalFieldCount,
40
+ StreamBase::kInternalFieldCount),
41
+ };
42
+
43
+ static void Initialize(v8::Local<v8::Object> target,
44
+ v8::Local<v8::Value> unused,
45
+ v8::Local<v8::Context> context,
46
+ void* priv);
47
+ static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
48
+ int GetFD() override;
49
+ bool IsAlive() override;
50
+ bool IsClosing() override;
51
+ bool IsIPCPipe() override;
52
+
53
+ // JavaScript functions
54
+ int ReadStart() override;
55
+ int ReadStop() override;
56
+
57
+ // Resource implementation
58
+ int DoShutdown(ShutdownWrap* req_wrap) override;
59
+ int DoTryWrite(uv_buf_t** bufs, size_t* count) override;
60
+ inline bool HasDoTryWrite() const override { return true; }
61
+ int DoWrite(WriteWrap* w,
62
+ uv_buf_t* bufs,
63
+ size_t count,
64
+ uv_stream_t* send_handle) override;
65
+
66
+ inline uv_stream_t* stream() const {
67
+ return stream_;
68
+ }
69
+
70
+ inline bool is_named_pipe() const {
71
+ return stream()->type == UV_NAMED_PIPE;
72
+ }
73
+
74
+ inline bool is_named_pipe_ipc() const {
75
+ return is_named_pipe() &&
76
+ reinterpret_cast<const uv_pipe_t*>(stream())->ipc != 0;
77
+ }
78
+
79
+ inline bool is_tcp() const {
80
+ return stream()->type == UV_TCP;
81
+ }
82
+
83
+ ShutdownWrap* CreateShutdownWrap(v8::Local<v8::Object> object) override;
84
+ WriteWrap* CreateWriteWrap(v8::Local<v8::Object> object) override;
85
+
86
+ static LibuvStreamWrap* From(Environment* env, v8::Local<v8::Object> object);
87
+
88
+ protected:
89
+ LibuvStreamWrap(Environment* env,
90
+ v8::Local<v8::Object> object,
91
+ uv_stream_t* stream,
92
+ AsyncWrap::ProviderType provider);
93
+
94
+ AsyncWrap* GetAsyncWrap() override;
95
+
96
+ static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
97
+ Environment* env);
98
+
99
+ protected:
100
+ inline void set_fd(int fd) {
101
+ #ifdef _WIN32
102
+ fd_ = fd;
103
+ #endif
104
+ }
105
+
106
+
107
+ private:
108
+ static void GetWriteQueueSize(
109
+ const v8::FunctionCallbackInfo<v8::Value>& info);
110
+ static void SetBlocking(const v8::FunctionCallbackInfo<v8::Value>& args);
111
+
112
+ // Callbacks for libuv
113
+ void OnUvAlloc(size_t suggested_size, uv_buf_t* buf);
114
+ v8::Maybe<void> OnUvRead(ssize_t nread, const uv_buf_t* buf);
115
+
116
+ static void AfterUvWrite(uv_write_t* req, int status);
117
+ static void AfterUvShutdown(uv_shutdown_t* req, int status);
118
+
119
+ uv_stream_t* const stream_;
120
+
121
+ #ifdef _WIN32
122
+ // We don't always have an FD that we could look up on the stream_
123
+ // object itself on Windows. However, for some cases, we open handles
124
+ // using FDs; In that case, we can store and provide the value.
125
+ // This became necessary because it allows to detect situations
126
+ // where multiple handles refer to the same stdio FDs (in particular,
127
+ // a possible IPC channel and a regular process.std??? stream).
128
+ int fd_ = -1;
129
+ #endif
130
+ };
131
+
132
+
133
+ } // namespace node
134
+
135
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
136
+
137
+ #endif // SRC_STREAM_WRAP_H_
@@ -0,0 +1,114 @@
1
+ // Copyright Joyent, Inc. and other Node contributors.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a
4
+ // copy of this software and associated documentation files (the
5
+ // "Software"), to deal in the Software without restriction, including
6
+ // without limitation the rights to use, copy, modify, merge, publish,
7
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ // persons to whom the Software is furnished to do so, subject to the
9
+ // following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included
12
+ // in all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ #ifndef SRC_STRING_BYTES_H_
23
+ #define SRC_STRING_BYTES_H_
24
+
25
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
+
27
+ // Decodes a v8::Local<v8::String> or Buffer to a raw char*
28
+
29
+ #include "v8.h"
30
+ #include "env-inl.h"
31
+
32
+ #include <string>
33
+
34
+ namespace node {
35
+
36
+ class StringBytes {
37
+ public:
38
+ class InlineDecoder : public MaybeStackBuffer<char> {
39
+ public:
40
+ inline v8::Maybe<void> Decode(Environment* env,
41
+ v8::Local<v8::String> string,
42
+ enum encoding enc) {
43
+ size_t storage;
44
+ if (!StringBytes::StorageSize(env->isolate(), string, enc).To(&storage))
45
+ return v8::Nothing<void>();
46
+ AllocateSufficientStorage(storage);
47
+ const size_t length =
48
+ StringBytes::Write(env->isolate(), out(), storage, string, enc);
49
+
50
+ // No zero terminator is included when using this method.
51
+ SetLength(length);
52
+ return v8::JustVoid();
53
+ }
54
+
55
+ inline size_t size() const { return length(); }
56
+ };
57
+
58
+ // Fast, but can be 2 bytes oversized for Base64, and
59
+ // as much as triple UTF-8 strings <= 65536 chars in length
60
+ static v8::Maybe<size_t> StorageSize(v8::Isolate* isolate,
61
+ v8::Local<v8::Value> val,
62
+ enum encoding enc);
63
+
64
+ // Precise byte count, but slightly slower for Base64 and
65
+ // very much slower for UTF-8
66
+ static v8::Maybe<size_t> Size(v8::Isolate* isolate,
67
+ v8::Local<v8::Value> val,
68
+ enum encoding enc);
69
+
70
+ // Write the bytes from the string or buffer into the char*
71
+ // returns the number of bytes written, which will always be
72
+ // <= buflen. Use StorageSize/Size first to know how much
73
+ // memory to allocate.
74
+ static size_t Write(v8::Isolate* isolate,
75
+ char* buf,
76
+ size_t buflen,
77
+ v8::Local<v8::Value> val,
78
+ enum encoding enc);
79
+
80
+ // Take the bytes in the src, and turn it into a Buffer or String.
81
+ static v8::MaybeLocal<v8::Value> Encode(v8::Isolate* isolate,
82
+ const char* buf,
83
+ size_t buflen,
84
+ enum encoding encoding);
85
+
86
+ // Like Encode(..., UTF8) but does not re-validate. Input must be valid UTF-8.
87
+ static v8::MaybeLocal<v8::Value> EncodeValidUtf8(v8::Isolate* isolate,
88
+ const char* buf,
89
+ size_t buflen);
90
+
91
+ // Warning: This reverses endianness on BE platforms, even though the
92
+ // signature using uint16_t implies that it should not.
93
+ // However, the brokenness is already public API and can't therefore
94
+ // be changed easily.
95
+ static v8::MaybeLocal<v8::Value> Encode(v8::Isolate* isolate,
96
+ const uint16_t* buf,
97
+ size_t buflen);
98
+
99
+ static v8::MaybeLocal<v8::Value> Encode(v8::Isolate* isolate,
100
+ const char* buf,
101
+ enum encoding encoding);
102
+
103
+ private:
104
+ static size_t WriteUCS2(v8::Isolate* isolate,
105
+ char* buf,
106
+ size_t buflen,
107
+ v8::Local<v8::String> str);
108
+ };
109
+
110
+ } // namespace node
111
+
112
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
113
+
114
+ #endif // SRC_STRING_BYTES_H_
@@ -0,0 +1,31 @@
1
+ #ifndef SRC_STRING_DECODER_INL_H_
2
+ #define SRC_STRING_DECODER_INL_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "string_decoder.h"
7
+
8
+ namespace node {
9
+
10
+ enum encoding StringDecoder::Encoding() const {
11
+ return static_cast<enum encoding>(state_[kEncodingField]);
12
+ }
13
+
14
+ unsigned StringDecoder::BufferedBytes() const {
15
+ return state_[kBufferedBytes];
16
+ }
17
+
18
+ unsigned StringDecoder::MissingBytes() const {
19
+ return state_[kMissingBytes];
20
+ }
21
+
22
+ char* StringDecoder::IncompleteCharacterBuffer() {
23
+ return reinterpret_cast<char*>(state_ + kIncompleteCharactersStart);
24
+ }
25
+
26
+
27
+ } // namespace node
28
+
29
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
30
+
31
+ #endif // SRC_STRING_DECODER_INL_H_
@@ -0,0 +1,49 @@
1
+ #ifndef SRC_STRING_DECODER_H_
2
+ #define SRC_STRING_DECODER_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "node.h"
7
+
8
+ namespace node {
9
+
10
+ class StringDecoder {
11
+ public:
12
+ StringDecoder() { state_[kEncodingField] = BUFFER; }
13
+ inline enum encoding Encoding() const;
14
+
15
+ inline char* IncompleteCharacterBuffer();
16
+ inline unsigned MissingBytes() const;
17
+ inline unsigned BufferedBytes() const;
18
+
19
+ // Decode a string from the specified encoding.
20
+ // The value pointed to by `nread` will be modified to reflect that
21
+ // less data may have been read because it ended on an incomplete character
22
+ // and more data may have been read because a previously incomplete character
23
+ // was finished.
24
+ v8::MaybeLocal<v8::String> DecodeData(v8::Isolate* isolate,
25
+ const char* data,
26
+ size_t* nread);
27
+ // Flush an incomplete character. For character encodings like UTF8 this
28
+ // means printing replacement characters, buf for e.g. Base64 the returned
29
+ // string contains more data.
30
+ v8::MaybeLocal<v8::String> FlushData(v8::Isolate* isolate);
31
+
32
+ enum Fields {
33
+ kIncompleteCharactersStart = 0,
34
+ kIncompleteCharactersEnd = 4,
35
+ kMissingBytes = 4,
36
+ kBufferedBytes = 5,
37
+ kEncodingField = 6,
38
+ kNumFields = 7
39
+ };
40
+
41
+ private:
42
+ uint8_t state_[kNumFields] = {};
43
+ };
44
+
45
+ } // namespace node
46
+
47
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
48
+
49
+ #endif // SRC_STRING_DECODER_H_
@@ -0,0 +1,138 @@
1
+ // Copyright Joyent, Inc. and other Node contributors.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a
4
+ // copy of this software and associated documentation files (the
5
+ // "Software"), to deal in the Software without restriction, including
6
+ // without limitation the rights to use, copy, modify, merge, publish,
7
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ // persons to whom the Software is furnished to do so, subject to the
9
+ // following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included
12
+ // in all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ #ifndef SRC_TCP_WRAP_H_
23
+ #define SRC_TCP_WRAP_H_
24
+
25
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
+
27
+ #include "async_wrap.h"
28
+ #include "connection_wrap.h"
29
+ #include "node_messaging.h"
30
+
31
+ namespace node {
32
+
33
+ class ExternalReferenceRegistry;
34
+ class Environment;
35
+
36
+ class TCPWrap : public ConnectionWrap<TCPWrap, uv_tcp_t> {
37
+ public:
38
+ enum SocketType {
39
+ SOCKET,
40
+ SERVER
41
+ };
42
+
43
+ static v8::MaybeLocal<v8::Object> Instantiate(Environment* env,
44
+ AsyncWrap* parent,
45
+ SocketType type);
46
+ static void Initialize(v8::Local<v8::Object> target,
47
+ v8::Local<v8::Value> unused,
48
+ v8::Local<v8::Context> context,
49
+ void* priv);
50
+ static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
51
+
52
+ SET_NO_MEMORY_INFO()
53
+ SET_SELF_SIZE(TCPWrap)
54
+ const char* MemoryInfoName() const override {
55
+ switch (provider_type()) {
56
+ case ProviderType::PROVIDER_TCPWRAP:
57
+ return "TCPSocketWrap";
58
+ case ProviderType::PROVIDER_TCPSERVERWRAP:
59
+ return "TCPServerWrap";
60
+ default:
61
+ UNREACHABLE();
62
+ }
63
+ }
64
+
65
+ // Transfer the underlying socket to another thread via .postMessage(). The
66
+ // transfer duplicates the socket and re-adopts it (uv_tcp_open) in the
67
+ // receiving event loop. This is the building block for distributing
68
+ // listening sockets and accepted connections across worker_threads.
69
+ BaseObject::TransferMode GetTransferMode() const override;
70
+ std::unique_ptr<worker::TransferData> TransferForMessaging() override;
71
+
72
+ private:
73
+ typedef uv_tcp_t HandleType;
74
+
75
+ class TransferData : public worker::TransferData {
76
+ public:
77
+ explicit TransferData(uv_os_sock_t socket, SocketType type)
78
+ : socket_(socket), type_(type) {}
79
+ ~TransferData() override;
80
+
81
+ BaseObjectPtr<BaseObject> Deserialize(
82
+ Environment* env,
83
+ v8::Local<v8::Context> context,
84
+ std::unique_ptr<worker::TransferData> self) override;
85
+
86
+ SET_NO_MEMORY_INFO()
87
+ SET_MEMORY_INFO_NAME(TCPWrapTransferData)
88
+ SET_SELF_SIZE(TransferData)
89
+
90
+ private:
91
+ uv_os_sock_t socket_;
92
+ SocketType type_;
93
+ };
94
+
95
+ template <typename T,
96
+ int (*F)(const typename T::HandleType*, sockaddr*, int*)>
97
+ friend void GetSockOrPeerName(const v8::FunctionCallbackInfo<v8::Value>&);
98
+
99
+ TCPWrap(Environment* env, v8::Local<v8::Object> object,
100
+ ProviderType provider);
101
+
102
+ static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
103
+ static void SetNoDelay(const v8::FunctionCallbackInfo<v8::Value>& args);
104
+ static void SetKeepAlive(const v8::FunctionCallbackInfo<v8::Value>& args);
105
+ static void SetTypeOfService(const v8::FunctionCallbackInfo<v8::Value>& args);
106
+ static void GetTypeOfService(const v8::FunctionCallbackInfo<v8::Value>& args);
107
+ static void Bind(const v8::FunctionCallbackInfo<v8::Value>& args);
108
+ static void Bind6(const v8::FunctionCallbackInfo<v8::Value>& args);
109
+ static void Listen(const v8::FunctionCallbackInfo<v8::Value>& args);
110
+ static void Connect(const v8::FunctionCallbackInfo<v8::Value>& args);
111
+ static void Connect6(const v8::FunctionCallbackInfo<v8::Value>& args);
112
+ template <typename T>
113
+ static void Connect(const v8::FunctionCallbackInfo<v8::Value>& args,
114
+ int (*uv_ip_addr)(const char* ip_address,
115
+ int port,
116
+ T* addr));
117
+ static void Open(const v8::FunctionCallbackInfo<v8::Value>& args);
118
+ template <typename T>
119
+ static void Bind(const v8::FunctionCallbackInfo<v8::Value>& args,
120
+ int family,
121
+ int (*uv_ip_addr)(const char* ip_address,
122
+ int port,
123
+ T* addr));
124
+ static void Reset(const v8::FunctionCallbackInfo<v8::Value>& args);
125
+ int Reset(v8::Local<v8::Value> close_callback = v8::Local<v8::Value>());
126
+
127
+ #ifdef _WIN32
128
+ static void SetSimultaneousAccepts(
129
+ const v8::FunctionCallbackInfo<v8::Value>& args);
130
+ #endif
131
+ };
132
+
133
+
134
+ } // namespace node
135
+
136
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
137
+
138
+ #endif // SRC_TCP_WRAP_H_
@@ -0,0 +1,70 @@
1
+ // Copyright Joyent, Inc. and other Node contributors.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a
4
+ // copy of this software and associated documentation files (the
5
+ // "Software"), to deal in the Software without restriction, including
6
+ // without limitation the rights to use, copy, modify, merge, publish,
7
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ // persons to whom the Software is furnished to do so, subject to the
9
+ // following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included
12
+ // in all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ #ifndef SRC_THREADPOOLWORK_INL_H_
23
+ #define SRC_THREADPOOLWORK_INL_H_
24
+
25
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
+
27
+ #include "node_internals.h"
28
+ #include "tracing/trace_event.h"
29
+ #include "util-inl.h"
30
+
31
+ namespace node {
32
+
33
+ void ThreadPoolWork::ScheduleWork() {
34
+ env_->IncreaseWaitingRequestCounter();
35
+ TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(
36
+ TRACING_CATEGORY_NODE2(threadpoolwork, async), type_, this);
37
+ int status = uv_queue_work(
38
+ env_->event_loop(),
39
+ &work_req_,
40
+ [](uv_work_t* req) {
41
+ ThreadPoolWork* self = ContainerOf(&ThreadPoolWork::work_req_, req);
42
+ TRACE_EVENT_BEGIN0(TRACING_CATEGORY_NODE2(threadpoolwork, sync),
43
+ self->type_);
44
+ self->DoThreadPoolWork();
45
+ TRACE_EVENT_END0(TRACING_CATEGORY_NODE2(threadpoolwork, sync),
46
+ self->type_);
47
+ },
48
+ [](uv_work_t* req, int status) {
49
+ ThreadPoolWork* self = ContainerOf(&ThreadPoolWork::work_req_, req);
50
+ self->env_->DecreaseWaitingRequestCounter();
51
+ TRACE_EVENT_NESTABLE_ASYNC_END1(
52
+ TRACING_CATEGORY_NODE2(threadpoolwork, async),
53
+ self->type_,
54
+ self,
55
+ "result",
56
+ status);
57
+ self->AfterThreadPoolWork(status);
58
+ });
59
+ CHECK_EQ(status, 0);
60
+ }
61
+
62
+ int ThreadPoolWork::CancelWork() {
63
+ return uv_cancel(reinterpret_cast<uv_req_t*>(&work_req_));
64
+ }
65
+
66
+ } // namespace node
67
+
68
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
69
+
70
+ #endif // SRC_THREADPOOLWORK_INL_H_
@@ -0,0 +1,32 @@
1
+ #ifndef SRC_TIMER_WRAP_INL_H_
2
+ #define SRC_TIMER_WRAP_INL_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "timer_wrap.h"
7
+
8
+ #include <utility>
9
+
10
+ #include "env.h"
11
+ #include "uv.h"
12
+
13
+ namespace node {
14
+
15
+ template <typename... Args>
16
+ inline TimerWrap::TimerWrap(Environment* env, Args&&... args)
17
+ : env_(env), fn_(std::forward<Args>(args)...) {
18
+ uv_timer_init(env->event_loop(), &timer_);
19
+ timer_.data = this;
20
+ }
21
+
22
+ template <typename... Args>
23
+ inline TimerWrapHandle::TimerWrapHandle(Environment* env, Args&&... args) {
24
+ timer_ = new TimerWrap(env, std::forward<Args>(args)...);
25
+ env->AddCleanupHook(CleanupHook, this);
26
+ }
27
+
28
+ } // namespace node
29
+
30
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
31
+
32
+ #endif // SRC_TIMER_WRAP_INL_H_