@encharm/cws 4.0.2 → 4.3.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 (410) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/LICENSE +3 -2
  3. package/README.md +9 -2
  4. package/binding.gyp +2 -2
  5. package/dist/bindings/cws_darwin_arm64_node108.node +0 -0
  6. package/dist/bindings/cws_darwin_arm64_node64.node +0 -0
  7. package/dist/bindings/cws_darwin_arm64_node72.node +0 -0
  8. package/dist/bindings/cws_darwin_arm64_node79.node +0 -0
  9. package/dist/bindings/cws_darwin_arm64_node83.node +0 -0
  10. package/dist/bindings/cws_darwin_arm64_node93.node +0 -0
  11. package/dist/bindings/cws_darwin_x64_node108.node +0 -0
  12. package/dist/bindings/cws_darwin_x64_node64.node +0 -0
  13. package/dist/bindings/cws_darwin_x64_node72.node +0 -0
  14. package/dist/bindings/cws_darwin_x64_node79.node +0 -0
  15. package/dist/bindings/cws_darwin_x64_node83.node +0 -0
  16. package/dist/bindings/cws_darwin_x64_node93.node +0 -0
  17. package/dist/bindings/cws_linux_x64_node108.node +0 -0
  18. package/dist/bindings/cws_linux_x64_node64.node +0 -0
  19. package/dist/bindings/cws_linux_x64_node72.node +0 -0
  20. package/dist/bindings/cws_linux_x64_node79.node +0 -0
  21. package/dist/bindings/cws_linux_x64_node83.node +0 -0
  22. package/dist/bindings/cws_linux_x64_node93.node +0 -0
  23. package/dist/bindings/cws_win32_x64_node108.node +0 -0
  24. package/dist/bindings/cws_win32_x64_node64.node +0 -0
  25. package/dist/bindings/cws_win32_x64_node72.node +0 -0
  26. package/dist/bindings/cws_win32_x64_node79.node +0 -0
  27. package/dist/bindings/cws_win32_x64_node83.node +0 -0
  28. package/dist/bindings/cws_win32_x64_node93.node +0 -0
  29. package/dist/client.d.ts +1 -0
  30. package/dist/client.js +4 -0
  31. package/dist/index.js +3 -2
  32. package/dist/server.js +1 -0
  33. package/dist/shared.js +2 -1
  34. package/package.json +1 -1
  35. package/src/Addon.cpp +1 -0
  36. package/src/Addon.h +35 -2
  37. package/src/HTTPSocket.cpp +1 -1
  38. package/src/LICENSE +4 -0
  39. package/src/Socket.h +12 -3
  40. package/src/headers/{13 → 18}/aliased_buffer.h +61 -9
  41. package/src/headers/18/aliased_struct-inl.h +54 -0
  42. package/src/headers/18/aliased_struct.h +63 -0
  43. package/src/headers/{12 → 18}/async_wrap-inl.h +0 -0
  44. package/src/headers/{12 → 18}/async_wrap.h +26 -2
  45. package/src/headers/{12/base64.h → 18/base64-inl.h} +78 -86
  46. package/src/headers/18/base64.h +69 -0
  47. package/src/headers/{12 → 18}/base_object-inl.h +46 -25
  48. package/src/headers/{12 → 18}/base_object.h +82 -17
  49. package/src/headers/{12 → 18}/callback_queue-inl.h +9 -9
  50. package/src/headers/{12 → 18}/callback_queue.h +13 -5
  51. package/src/headers/18/cares_wrap.h +523 -0
  52. package/src/headers/{12 → 18}/connect_wrap.h +0 -0
  53. package/src/headers/{12 → 18}/connection_wrap.h +0 -0
  54. package/src/headers/18/crypto/crypto_aes.h +89 -0
  55. package/src/headers/{13/node_crypto_bio.h → 18/crypto/crypto_bio.h} +3 -4
  56. package/src/headers/18/crypto/crypto_cipher.h +291 -0
  57. package/src/headers/{13/node_crypto_clienthello-inl.h → 18/crypto/crypto_clienthello-inl.h} +4 -5
  58. package/src/headers/{13/node_crypto_clienthello.h → 18/crypto/crypto_clienthello.h} +3 -4
  59. package/src/headers/{12/node_crypto_common.h → 18/crypto/crypto_common.h} +49 -36
  60. package/src/headers/18/crypto/crypto_context.h +147 -0
  61. package/src/headers/18/crypto/crypto_dh.h +156 -0
  62. package/src/headers/18/crypto/crypto_dsa.h +77 -0
  63. package/src/headers/18/crypto/crypto_ec.h +170 -0
  64. package/src/headers/{12/node_crypto_groups.h → 18/crypto/crypto_groups.h} +3 -3
  65. package/src/headers/18/crypto/crypto_hash.h +89 -0
  66. package/src/headers/18/crypto/crypto_hkdf.h +65 -0
  67. package/src/headers/18/crypto/crypto_hmac.h +94 -0
  68. package/src/headers/18/crypto/crypto_keygen.h +305 -0
  69. package/src/headers/18/crypto/crypto_keys.h +420 -0
  70. package/src/headers/18/crypto/crypto_pbkdf2.h +76 -0
  71. package/src/headers/18/crypto/crypto_random.h +130 -0
  72. package/src/headers/18/crypto/crypto_rsa.h +141 -0
  73. package/src/headers/18/crypto/crypto_scrypt.h +87 -0
  74. package/src/headers/18/crypto/crypto_sig.h +168 -0
  75. package/src/headers/18/crypto/crypto_spkac.h +21 -0
  76. package/src/headers/18/crypto/crypto_timing.h +20 -0
  77. package/src/headers/{12/tls_wrap.h → 18/crypto/crypto_tls.h} +137 -66
  78. package/src/headers/18/crypto/crypto_util.h +791 -0
  79. package/src/headers/18/crypto/crypto_x509.h +143 -0
  80. package/src/headers/{12 → 18}/debug_utils-inl.h +0 -0
  81. package/src/headers/{13 → 18}/debug_utils.h +7 -4
  82. package/src/headers/{12 → 18}/diagnosticfilename-inl.h +0 -0
  83. package/src/headers/{12 → 18}/env-inl.h +397 -304
  84. package/src/headers/{12 → 18}/env.h +397 -172
  85. package/src/headers/{12 → 18}/handle_wrap.h +7 -3
  86. package/src/headers/18/histogram-inl.h +107 -0
  87. package/src/headers/18/histogram.h +239 -0
  88. package/src/headers/{13 → 18}/inspector_agent.h +4 -7
  89. package/src/headers/{12 → 18}/inspector_io.h +0 -0
  90. package/src/headers/{13 → 18}/inspector_profiler.h +17 -5
  91. package/src/headers/{12 → 18}/inspector_socket.h +0 -0
  92. package/src/headers/{12 → 18}/inspector_socket_server.h +0 -0
  93. package/src/headers/18/js_native_api.h +571 -0
  94. package/src/headers/{13 → 18}/js_native_api_types.h +30 -7
  95. package/src/headers/{12 → 18}/js_native_api_v8.h +220 -83
  96. package/src/headers/{12 → 18}/js_native_api_v8_internals.h +6 -5
  97. package/src/headers/{12 → 18}/js_stream.h +0 -0
  98. package/src/headers/{12 → 18}/json_utils.h +0 -0
  99. package/src/headers/{13 → 18}/memory_tracker-inl.h +6 -5
  100. package/src/headers/{13 → 18}/memory_tracker.h +0 -7
  101. package/src/headers/{13 → 18}/module_wrap.h +24 -7
  102. package/src/headers/{13 → 18}/node.h +329 -68
  103. package/src/headers/18/node_api.h +288 -0
  104. package/src/headers/18/node_api_internals.h +38 -0
  105. package/src/headers/{12 → 18}/node_api_types.h +12 -9
  106. package/src/headers/{12 → 18}/node_binding.h +0 -0
  107. package/src/headers/18/node_blob.h +191 -0
  108. package/src/headers/18/node_bob-inl.h +37 -0
  109. package/src/headers/18/node_bob.h +111 -0
  110. package/src/headers/{13 → 18}/node_buffer.h +0 -0
  111. package/src/headers/{13 → 18}/node_constants.h +5 -1
  112. package/src/headers/{12 → 18}/node_context_data.h +5 -0
  113. package/src/headers/{12 → 18}/node_contextify.h +37 -2
  114. package/src/headers/{10/node_javascript.h → 18/node_crypto.h} +30 -14
  115. package/src/headers/{12 → 18}/node_dir.h +0 -0
  116. package/src/headers/{12 → 18}/node_dtrace.h +0 -0
  117. package/src/headers/{12 → 18}/node_errors.h +90 -24
  118. package/src/headers/18/node_external_reference.h +145 -0
  119. package/src/headers/{13 → 18}/node_file-inl.h +38 -21
  120. package/src/headers/{12 → 18}/node_file.h +74 -13
  121. package/src/headers/{13 → 18}/node_http2.h +365 -269
  122. package/src/headers/{12 → 18}/node_http2_state.h +40 -50
  123. package/src/headers/{13 → 18}/node_http_common-inl.h +25 -5
  124. package/src/headers/{13 → 18}/node_http_common.h +24 -20
  125. package/src/headers/{13 → 18}/node_i18n.h +2 -1
  126. package/src/headers/{12 → 18}/node_internals.h +39 -41
  127. package/src/headers/{12 → 18}/node_main_instance.h +15 -18
  128. package/src/headers/{12 → 18}/node_mem-inl.h +0 -0
  129. package/src/headers/{12 → 18}/node_mem.h +1 -1
  130. package/src/headers/{13 → 18}/node_messaging.h +170 -23
  131. package/src/headers/{12 → 18}/node_metadata.h +17 -4
  132. package/src/headers/{12 → 18}/node_mutex.h +77 -1
  133. package/src/headers/{12 → 18}/node_native_module.h +11 -1
  134. package/src/headers/{12 → 18}/node_native_module_env.h +14 -8
  135. package/src/headers/{12 → 18}/node_object_wrap.h +0 -0
  136. package/src/headers/{13 → 18}/node_options-inl.h +51 -21
  137. package/src/headers/{13 → 18}/node_options.h +46 -14
  138. package/src/headers/18/node_perf.h +168 -0
  139. package/src/headers/{12 → 18}/node_perf_common.h +16 -22
  140. package/src/headers/{12 → 18}/node_platform.h +21 -16
  141. package/src/headers/18/node_process-inl.h +26 -0
  142. package/src/headers/18/node_process.h +97 -0
  143. package/src/headers/{13 → 18}/node_report.h +2 -2
  144. package/src/headers/{13 → 18}/node_revert.h +10 -0
  145. package/src/headers/{12 → 18}/node_root_certs.h +439 -651
  146. package/src/headers/18/node_snapshot_builder.h +43 -0
  147. package/src/headers/18/node_snapshotable.h +130 -0
  148. package/src/headers/{12 → 18}/node_sockaddr-inl.h +100 -4
  149. package/src/headers/18/node_sockaddr.h +405 -0
  150. package/src/headers/{13 → 18}/node_stat_watcher.h +7 -1
  151. package/src/headers/{12 → 18}/node_union_bytes.h +0 -0
  152. package/src/headers/{13 → 18}/node_url.h +18 -1
  153. package/src/headers/18/node_v8.h +41 -0
  154. package/src/headers/{12 → 18}/node_v8_platform-inl.h +10 -0
  155. package/src/headers/{13 → 18}/node_version.h +7 -7
  156. package/src/headers/{12 → 18}/node_wasi.h +0 -0
  157. package/src/headers/18/node_wasm_web_api.h +55 -0
  158. package/src/headers/{13 → 18}/node_watchdog.h +0 -0
  159. package/src/headers/{10 → 18}/node_win32_etw_provider-inl.h +7 -6
  160. package/src/headers/{10 → 18}/node_win32_etw_provider.h +0 -0
  161. package/src/headers/{13 → 18}/node_worker.h +24 -17
  162. package/src/headers/{12 → 18}/pipe_wrap.h +2 -0
  163. package/src/headers/{12 → 18}/req_wrap-inl.h +0 -0
  164. package/src/headers/{13 → 18}/req_wrap.h +1 -1
  165. package/src/headers/{12 → 18}/spawn_sync.h +0 -0
  166. package/src/headers/{13 → 18}/stream_base-inl.h +58 -22
  167. package/src/headers/{13 → 18}/stream_base.h +29 -3
  168. package/src/headers/{13 → 18}/stream_pipe.h +8 -3
  169. package/src/headers/{12 → 18}/stream_wrap.h +4 -1
  170. package/src/headers/{13 → 18}/string_bytes.h +0 -7
  171. package/src/headers/{12 → 18}/string_decoder-inl.h +0 -0
  172. package/src/headers/{10 → 18}/string_decoder.h +0 -0
  173. package/src/headers/{13 → 18}/string_search.h +2 -2
  174. package/src/headers/{12 → 18}/tcp_wrap.h +4 -0
  175. package/src/headers/{12 → 18}/threadpoolwork-inl.h +0 -0
  176. package/src/headers/18/timer_wrap-inl.h +32 -0
  177. package/src/headers/18/timer_wrap.h +85 -0
  178. package/src/headers/{13 → 18}/tracing/agent.h +1 -1
  179. package/src/headers/{12 → 18}/tracing/node_trace_buffer.h +0 -0
  180. package/src/headers/{12 → 18}/tracing/node_trace_writer.h +0 -0
  181. package/src/headers/{13 → 18}/tracing/trace_event.h +23 -13
  182. package/src/headers/{12 → 18}/tracing/trace_event_common.h +0 -0
  183. package/src/headers/{12 → 18}/tracing/traced_value.h +0 -0
  184. package/src/headers/{13 → 18}/tty_wrap.h +2 -1
  185. package/src/headers/{13 → 18}/udp_wrap.h +5 -0
  186. package/src/headers/{13 → 18}/util-inl.h +69 -15
  187. package/src/headers/{13 → 18}/util.h +93 -31
  188. package/src/headers/18/v8-fast-api-calls.h +939 -0
  189. package/src/headers/{12 → 18}/v8abbr.h +2 -2
  190. package/dist/bindings/cws_darwin_64.node +0 -0
  191. package/dist/bindings/cws_darwin_72.node +0 -0
  192. package/dist/bindings/cws_darwin_79.node +0 -0
  193. package/dist/bindings/cws_darwin_83.node +0 -0
  194. package/dist/bindings/cws_darwin_93.node +0 -0
  195. package/dist/bindings/cws_linux_64.node +0 -0
  196. package/dist/bindings/cws_linux_72.node +0 -0
  197. package/dist/bindings/cws_linux_79.node +0 -0
  198. package/dist/bindings/cws_linux_83.node +0 -0
  199. package/dist/bindings/cws_linux_93.node +0 -0
  200. package/dist/bindings/cws_win32_64.node +0 -0
  201. package/dist/bindings/cws_win32_72.node +0 -0
  202. package/dist/bindings/cws_win32_79.node +0 -0
  203. package/dist/bindings/cws_win32_83.node +0 -0
  204. package/dist/bindings/cws_win32_93.node +0 -0
  205. package/src/headers/10/aliased_buffer.h +0 -241
  206. package/src/headers/10/async_wrap-inl.h +0 -106
  207. package/src/headers/10/async_wrap.h +0 -218
  208. package/src/headers/10/base64.h +0 -197
  209. package/src/headers/10/base_object-inl.h +0 -132
  210. package/src/headers/10/base_object.h +0 -115
  211. package/src/headers/10/connect_wrap.h +0 -28
  212. package/src/headers/10/connection_wrap.h +0 -30
  213. package/src/headers/10/debug_utils.h +0 -128
  214. package/src/headers/10/env-inl.h +0 -906
  215. package/src/headers/10/env.h +0 -1046
  216. package/src/headers/10/handle_wrap.h +0 -114
  217. package/src/headers/10/inspector_agent.h +0 -137
  218. package/src/headers/10/inspector_io.h +0 -97
  219. package/src/headers/10/inspector_socket.h +0 -59
  220. package/src/headers/10/inspector_socket_server.h +0 -104
  221. package/src/headers/10/js_stream.h +0 -57
  222. package/src/headers/10/memory_tracker-inl.h +0 -318
  223. package/src/headers/10/memory_tracker.h +0 -246
  224. package/src/headers/10/module_wrap.h +0 -100
  225. package/src/headers/10/node.h +0 -863
  226. package/src/headers/10/node_api.h +0 -752
  227. package/src/headers/10/node_api_types.h +0 -171
  228. package/src/headers/10/node_buffer.h +0 -90
  229. package/src/headers/10/node_code_cache.h +0 -17
  230. package/src/headers/10/node_constants.h +0 -74
  231. package/src/headers/10/node_context_data.h +0 -39
  232. package/src/headers/10/node_contextify.h +0 -141
  233. package/src/headers/10/node_counters.h +0 -59
  234. package/src/headers/10/node_crypto.h +0 -699
  235. package/src/headers/10/node_crypto_bio.h +0 -177
  236. package/src/headers/10/node_crypto_clienthello-inl.h +0 -92
  237. package/src/headers/10/node_crypto_clienthello.h +0 -131
  238. package/src/headers/10/node_crypto_groups.h +0 -416
  239. package/src/headers/10/node_dtrace.h +0 -84
  240. package/src/headers/10/node_errors.h +0 -118
  241. package/src/headers/10/node_file.h +0 -373
  242. package/src/headers/10/node_http2.h +0 -1304
  243. package/src/headers/10/node_http2_state.h +0 -158
  244. package/src/headers/10/node_i18n.h +0 -69
  245. package/src/headers/10/node_internals.h +0 -952
  246. package/src/headers/10/node_messaging.h +0 -219
  247. package/src/headers/10/node_mutex.h +0 -191
  248. package/src/headers/10/node_object_wrap.h +0 -130
  249. package/src/headers/10/node_options-inl.h +0 -444
  250. package/src/headers/10/node_options.h +0 -397
  251. package/src/headers/10/node_perf.h +0 -134
  252. package/src/headers/10/node_perf_common.h +0 -96
  253. package/src/headers/10/node_persistent.h +0 -30
  254. package/src/headers/10/node_platform.h +0 -170
  255. package/src/headers/10/node_revert.h +0 -75
  256. package/src/headers/10/node_root_certs.h +0 -3393
  257. package/src/headers/10/node_stat_watcher.h +0 -65
  258. package/src/headers/10/node_url.h +0 -193
  259. package/src/headers/10/node_version.h +0 -120
  260. package/src/headers/10/node_watchdog.h +0 -114
  261. package/src/headers/10/node_win32_perfctr_provider.h +0 -58
  262. package/src/headers/10/node_worker.h +0 -94
  263. package/src/headers/10/pipe_wrap.h +0 -76
  264. package/src/headers/10/req_wrap-inl.h +0 -166
  265. package/src/headers/10/req_wrap.h +0 -61
  266. package/src/headers/10/sharedarraybuffer_metadata.h +0 -67
  267. package/src/headers/10/spawn_sync.h +0 -240
  268. package/src/headers/10/stream_base-inl.h +0 -458
  269. package/src/headers/10/stream_base.h +0 -378
  270. package/src/headers/10/stream_pipe.h +0 -72
  271. package/src/headers/10/stream_wrap.h +0 -130
  272. package/src/headers/10/string_bytes.h +0 -126
  273. package/src/headers/10/string_decoder-inl.h +0 -38
  274. package/src/headers/10/string_search.h +0 -620
  275. package/src/headers/10/tcp_wrap.h +0 -99
  276. package/src/headers/10/tls_wrap.h +0 -195
  277. package/src/headers/10/tracing/agent.h +0 -178
  278. package/src/headers/10/tracing/node_trace_buffer.h +0 -83
  279. package/src/headers/10/tracing/node_trace_writer.h +0 -75
  280. package/src/headers/10/tracing/trace_event.h +0 -706
  281. package/src/headers/10/tracing/trace_event_common.h +0 -1102
  282. package/src/headers/10/tracing/traced_value.h +0 -68
  283. package/src/headers/10/tty_wrap.h +0 -63
  284. package/src/headers/10/udp_wrap.h +0 -102
  285. package/src/headers/10/util-inl.h +0 -459
  286. package/src/headers/10/util.h +0 -508
  287. package/src/headers/10/v8abbr.h +0 -121
  288. package/src/headers/12/aliased_buffer.h +0 -263
  289. package/src/headers/12/debug_utils.h +0 -181
  290. package/src/headers/12/histogram-inl.h +0 -83
  291. package/src/headers/12/histogram.h +0 -98
  292. package/src/headers/12/http_parser_adaptor.h +0 -24
  293. package/src/headers/12/inspector_agent.h +0 -147
  294. package/src/headers/12/inspector_profiler.h +0 -137
  295. package/src/headers/12/js_native_api.h +0 -541
  296. package/src/headers/12/js_native_api_types.h +0 -139
  297. package/src/headers/12/memory_tracker-inl.h +0 -339
  298. package/src/headers/12/memory_tracker.h +0 -283
  299. package/src/headers/12/module_wrap.h +0 -99
  300. package/src/headers/12/node.h +0 -887
  301. package/src/headers/12/node_api.h +0 -239
  302. package/src/headers/12/node_buffer.h +0 -92
  303. package/src/headers/12/node_constants.h +0 -80
  304. package/src/headers/12/node_crypto.h +0 -800
  305. package/src/headers/12/node_crypto_bio.h +0 -195
  306. package/src/headers/12/node_crypto_clienthello-inl.h +0 -91
  307. package/src/headers/12/node_crypto_clienthello.h +0 -132
  308. package/src/headers/12/node_file-inl.h +0 -289
  309. package/src/headers/12/node_http2.h +0 -1311
  310. package/src/headers/12/node_http_parser_impl.h +0 -994
  311. package/src/headers/12/node_i18n.h +0 -144
  312. package/src/headers/12/node_messaging.h +0 -227
  313. package/src/headers/12/node_options-inl.h +0 -447
  314. package/src/headers/12/node_options.h +0 -479
  315. package/src/headers/12/node_perf.h +0 -181
  316. package/src/headers/12/node_process.h +0 -41
  317. package/src/headers/12/node_report.h +0 -47
  318. package/src/headers/12/node_revert.h +0 -78
  319. package/src/headers/12/node_sockaddr.h +0 -123
  320. package/src/headers/12/node_stat_watcher.h +0 -66
  321. package/src/headers/12/node_url.h +0 -188
  322. package/src/headers/12/node_version.h +0 -98
  323. package/src/headers/12/node_watchdog.h +0 -152
  324. package/src/headers/12/node_win32_etw_provider-inl.h +0 -287
  325. package/src/headers/12/node_win32_etw_provider.h +0 -99
  326. package/src/headers/12/node_worker.h +0 -142
  327. package/src/headers/12/req_wrap.h +0 -77
  328. package/src/headers/12/sharedarraybuffer_metadata.h +0 -72
  329. package/src/headers/12/stream_base-inl.h +0 -323
  330. package/src/headers/12/stream_base.h +0 -431
  331. package/src/headers/12/stream_pipe.h +0 -72
  332. package/src/headers/12/string_bytes.h +0 -142
  333. package/src/headers/12/string_decoder.h +0 -50
  334. package/src/headers/12/string_search.h +0 -638
  335. package/src/headers/12/tracing/agent.h +0 -195
  336. package/src/headers/12/tracing/trace_event.h +0 -710
  337. package/src/headers/12/tty_wrap.h +0 -64
  338. package/src/headers/12/udp_wrap.h +0 -222
  339. package/src/headers/12/util-inl.h +0 -529
  340. package/src/headers/12/util.h +0 -765
  341. package/src/headers/13/async_wrap-inl.h +0 -94
  342. package/src/headers/13/async_wrap.h +0 -224
  343. package/src/headers/13/base64.h +0 -197
  344. package/src/headers/13/base_object-inl.h +0 -353
  345. package/src/headers/13/base_object.h +0 -229
  346. package/src/headers/13/connect_wrap.h +0 -26
  347. package/src/headers/13/connection_wrap.h +0 -30
  348. package/src/headers/13/debug_utils-inl.h +0 -223
  349. package/src/headers/13/diagnosticfilename-inl.h +0 -33
  350. package/src/headers/13/env-inl.h +0 -1293
  351. package/src/headers/13/env.h +0 -1469
  352. package/src/headers/13/handle_wrap.h +0 -117
  353. package/src/headers/13/histogram-inl.h +0 -83
  354. package/src/headers/13/histogram.h +0 -98
  355. package/src/headers/13/inspector_io.h +0 -78
  356. package/src/headers/13/inspector_socket.h +0 -60
  357. package/src/headers/13/inspector_socket_server.h +0 -110
  358. package/src/headers/13/js_native_api.h +0 -541
  359. package/src/headers/13/js_native_api_v8.h +0 -303
  360. package/src/headers/13/js_native_api_v8_internals.h +0 -38
  361. package/src/headers/13/js_stream.h +0 -52
  362. package/src/headers/13/json_utils.h +0 -160
  363. package/src/headers/13/node_api.h +0 -239
  364. package/src/headers/13/node_api_types.h +0 -44
  365. package/src/headers/13/node_binding.h +0 -99
  366. package/src/headers/13/node_context_data.h +0 -39
  367. package/src/headers/13/node_contextify.h +0 -161
  368. package/src/headers/13/node_crypto.h +0 -800
  369. package/src/headers/13/node_crypto_common.h +0 -138
  370. package/src/headers/13/node_crypto_groups.h +0 -415
  371. package/src/headers/13/node_dir.h +0 -52
  372. package/src/headers/13/node_dtrace.h +0 -86
  373. package/src/headers/13/node_errors.h +0 -210
  374. package/src/headers/13/node_file.h +0 -364
  375. package/src/headers/13/node_http2_state.h +0 -144
  376. package/src/headers/13/node_internals.h +0 -405
  377. package/src/headers/13/node_main_instance.h +0 -97
  378. package/src/headers/13/node_mem-inl.h +0 -112
  379. package/src/headers/13/node_mem.h +0 -41
  380. package/src/headers/13/node_metadata.h +0 -109
  381. package/src/headers/13/node_mutex.h +0 -247
  382. package/src/headers/13/node_native_module.h +0 -99
  383. package/src/headers/13/node_native_module_env.h +0 -65
  384. package/src/headers/13/node_object_wrap.h +0 -132
  385. package/src/headers/13/node_perf.h +0 -181
  386. package/src/headers/13/node_perf_common.h +0 -97
  387. package/src/headers/13/node_platform.h +0 -190
  388. package/src/headers/13/node_process.h +0 -41
  389. package/src/headers/13/node_root_certs.h +0 -3424
  390. package/src/headers/13/node_sockaddr-inl.h +0 -170
  391. package/src/headers/13/node_sockaddr.h +0 -123
  392. package/src/headers/13/node_union_bytes.h +0 -103
  393. package/src/headers/13/node_v8_platform-inl.h +0 -184
  394. package/src/headers/13/node_wasi.h +0 -108
  395. package/src/headers/13/node_win32_etw_provider-inl.h +0 -287
  396. package/src/headers/13/node_win32_etw_provider.h +0 -99
  397. package/src/headers/13/pipe_wrap.h +0 -78
  398. package/src/headers/13/req_wrap-inl.h +0 -170
  399. package/src/headers/13/spawn_sync.h +0 -242
  400. package/src/headers/13/stream_wrap.h +0 -130
  401. package/src/headers/13/string_decoder-inl.h +0 -37
  402. package/src/headers/13/string_decoder.h +0 -50
  403. package/src/headers/13/tcp_wrap.h +0 -101
  404. package/src/headers/13/threadpoolwork-inl.h +0 -57
  405. package/src/headers/13/tls_wrap.h +0 -221
  406. package/src/headers/13/tracing/node_trace_buffer.h +0 -83
  407. package/src/headers/13/tracing/node_trace_writer.h +0 -75
  408. package/src/headers/13/tracing/trace_event_common.h +0 -1109
  409. package/src/headers/13/tracing/traced_value.h +0 -70
  410. package/src/headers/13/v8abbr.h +0 -124
@@ -1,863 +0,0 @@
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_NODE_H_
23
- #define SRC_NODE_H_
24
-
25
- #ifdef _WIN32
26
- # ifndef BUILDING_NODE_EXTENSION
27
- # define NODE_EXTERN __declspec(dllexport)
28
- # else
29
- # define NODE_EXTERN __declspec(dllimport)
30
- # endif
31
- #else
32
- # define NODE_EXTERN /* nothing */
33
- #endif
34
-
35
- #ifdef BUILDING_NODE_EXTENSION
36
- # undef BUILDING_V8_SHARED
37
- # undef BUILDING_UV_SHARED
38
- # define USING_V8_SHARED 1
39
- # define USING_UV_SHARED 1
40
- #endif
41
-
42
- // This should be defined in make system.
43
- // See issue https://github.com/nodejs/node-v0.x-archive/issues/1236
44
- #if defined(__MINGW32__) || defined(_MSC_VER)
45
- #ifndef _WIN32_WINNT
46
- # define _WIN32_WINNT 0x0600 // Windows Server 2008
47
- #endif
48
-
49
- #ifndef NOMINMAX
50
- # define NOMINMAX
51
- #endif
52
-
53
- #endif
54
-
55
- #if defined(_MSC_VER)
56
- #define PATH_MAX MAX_PATH
57
- #endif
58
-
59
- #ifdef _WIN32
60
- # define SIGKILL 9
61
- #endif
62
-
63
- #include "v8.h" // NOLINT(build/include_order)
64
- #include "v8-platform.h" // NOLINT(build/include_order)
65
- #include "node_version.h" // NODE_MODULE_VERSION
66
-
67
- #define NODE_MAKE_VERSION(major, minor, patch) \
68
- ((major) * 0x1000 + (minor) * 0x100 + (patch))
69
-
70
- #ifdef __clang__
71
- # define NODE_CLANG_AT_LEAST(major, minor, patch) \
72
- (NODE_MAKE_VERSION(major, minor, patch) <= \
73
- NODE_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__))
74
- #else
75
- # define NODE_CLANG_AT_LEAST(major, minor, patch) (0)
76
- #endif
77
-
78
- #ifdef __GNUC__
79
- # define NODE_GNUC_AT_LEAST(major, minor, patch) \
80
- (NODE_MAKE_VERSION(major, minor, patch) <= \
81
- NODE_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__))
82
- #else
83
- # define NODE_GNUC_AT_LEAST(major, minor, patch) (0)
84
- #endif
85
-
86
- #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
87
- # define NODE_DEPRECATED(message, declarator) declarator
88
- #else // NODE_WANT_INTERNALS
89
- # if NODE_CLANG_AT_LEAST(2, 9, 0) || NODE_GNUC_AT_LEAST(4, 5, 0)
90
- # define NODE_DEPRECATED(message, declarator) \
91
- __attribute__((deprecated(message))) declarator
92
- # elif defined(_MSC_VER)
93
- # define NODE_DEPRECATED(message, declarator) \
94
- __declspec(deprecated) declarator
95
- # else
96
- # define NODE_DEPRECATED(message, declarator) declarator
97
- # endif
98
- #endif
99
-
100
- // Forward-declare libuv loop
101
- struct uv_loop_s;
102
-
103
- // Forward-declare these functions now to stop MSVS from becoming
104
- // terminally confused when it's done in node_internals.h
105
- namespace node {
106
-
107
- namespace tracing {
108
-
109
- class TracingController;
110
-
111
- }
112
-
113
- NODE_EXTERN v8::Local<v8::Value> ErrnoException(v8::Isolate* isolate,
114
- int errorno,
115
- const char* syscall = nullptr,
116
- const char* message = nullptr,
117
- const char* path = nullptr);
118
- NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
119
- int errorno,
120
- const char* syscall = nullptr,
121
- const char* message = nullptr,
122
- const char* path = nullptr);
123
- NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
124
- int errorno,
125
- const char* syscall,
126
- const char* message,
127
- const char* path,
128
- const char* dest);
129
-
130
- NODE_DEPRECATED("Use ErrnoException(isolate, ...)",
131
- inline v8::Local<v8::Value> ErrnoException(
132
- int errorno,
133
- const char* syscall = nullptr,
134
- const char* message = nullptr,
135
- const char* path = nullptr) {
136
- return ErrnoException(v8::Isolate::GetCurrent(),
137
- errorno,
138
- syscall,
139
- message,
140
- path);
141
- })
142
-
143
- NODE_DEPRECATED("Use UVException(isolate, ...)",
144
- inline v8::Local<v8::Value> UVException(int errorno,
145
- const char* syscall = nullptr,
146
- const char* message = nullptr,
147
- const char* path = nullptr) {
148
- return UVException(v8::Isolate::GetCurrent(),
149
- errorno,
150
- syscall,
151
- message,
152
- path);
153
- })
154
-
155
- /*
156
- * These methods need to be called in a HandleScope.
157
- *
158
- * It is preferred that you use the `MakeCallback` overloads taking
159
- * `async_context` arguments.
160
- */
161
-
162
- NODE_DEPRECATED("Use MakeCallback(..., async_context)",
163
- NODE_EXTERN v8::Local<v8::Value> MakeCallback(
164
- v8::Isolate* isolate,
165
- v8::Local<v8::Object> recv,
166
- const char* method,
167
- int argc,
168
- v8::Local<v8::Value>* argv));
169
- NODE_DEPRECATED("Use MakeCallback(..., async_context)",
170
- NODE_EXTERN v8::Local<v8::Value> MakeCallback(
171
- v8::Isolate* isolate,
172
- v8::Local<v8::Object> recv,
173
- v8::Local<v8::String> symbol,
174
- int argc,
175
- v8::Local<v8::Value>* argv));
176
- NODE_DEPRECATED("Use MakeCallback(..., async_context)",
177
- NODE_EXTERN v8::Local<v8::Value> MakeCallback(
178
- v8::Isolate* isolate,
179
- v8::Local<v8::Object> recv,
180
- v8::Local<v8::Function> callback,
181
- int argc,
182
- v8::Local<v8::Value>* argv));
183
-
184
- } // namespace node
185
-
186
- #include <assert.h>
187
- #include <stdint.h>
188
-
189
- #ifndef NODE_STRINGIFY
190
- #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)
191
- #define NODE_STRINGIFY_HELPER(n) #n
192
- #endif
193
-
194
- #ifdef _WIN32
195
- #if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
196
- typedef intptr_t ssize_t;
197
- # define _SSIZE_T_
198
- # define _SSIZE_T_DEFINED
199
- #endif
200
- #else // !_WIN32
201
- # include <sys/types.h> // size_t, ssize_t
202
- #endif // _WIN32
203
-
204
-
205
- namespace node {
206
-
207
- // TODO(addaleax): Remove all of these.
208
- NODE_DEPRECATED("use command-line flags",
209
- NODE_EXTERN extern bool no_deprecation);
210
- #if HAVE_OPENSSL
211
- NODE_DEPRECATED("use command-line flags",
212
- NODE_EXTERN extern bool ssl_openssl_cert_store);
213
- # if NODE_FIPS_MODE
214
- NODE_DEPRECATED("use command-line flags",
215
- NODE_EXTERN extern bool enable_fips_crypto);
216
- NODE_DEPRECATED("user command-line flags",
217
- NODE_EXTERN extern bool force_fips_crypto);
218
- # endif
219
- #endif
220
-
221
- // TODO(addaleax): Officially deprecate this and replace it with something
222
- // better suited for a public embedder API.
223
- NODE_EXTERN int Start(int argc, char* argv[]);
224
-
225
- // TODO(addaleax): Officially deprecate this and replace it with something
226
- // better suited for a public embedder API.
227
- NODE_EXTERN void Init(int* argc,
228
- const char** argv,
229
- int* exec_argc,
230
- const char*** exec_argv);
231
-
232
- class ArrayBufferAllocator;
233
-
234
- NODE_EXTERN ArrayBufferAllocator* CreateArrayBufferAllocator();
235
- NODE_EXTERN void FreeArrayBufferAllocator(ArrayBufferAllocator* allocator);
236
-
237
- class IsolateData;
238
- class Environment;
239
-
240
- class NODE_EXTERN MultiIsolatePlatform : public v8::Platform {
241
- public:
242
- virtual ~MultiIsolatePlatform() { }
243
- // Returns true if work was dispatched or executed. New tasks that are
244
- // posted during flushing of the queue are postponed until the next
245
- // flushing.
246
- virtual bool FlushForegroundTasks(v8::Isolate* isolate) = 0;
247
- virtual void DrainBackgroundTasks(v8::Isolate* isolate) = 0;
248
- virtual void CancelPendingDelayedTasks(v8::Isolate* isolate) = 0;
249
-
250
- // These will be called by the `IsolateData` creation/destruction functions.
251
- virtual void RegisterIsolate(IsolateData* isolate_data,
252
- struct uv_loop_s* loop) = 0;
253
- virtual void UnregisterIsolate(IsolateData* isolate_data) = 0;
254
- };
255
-
256
- // Creates a new isolate with Node.js-specific settings.
257
- NODE_EXTERN v8::Isolate* NewIsolate(ArrayBufferAllocator* allocator);
258
-
259
- // Creates a new context with Node.js-specific tweaks.
260
- NODE_EXTERN v8::Local<v8::Context> NewContext(
261
- v8::Isolate* isolate,
262
- v8::Local<v8::ObjectTemplate> object_template =
263
- v8::Local<v8::ObjectTemplate>());
264
-
265
- // If `platform` is passed, it will be used to register new Worker instances.
266
- // It can be `nullptr`, in which case creating new Workers inside of
267
- // Environments that use this `IsolateData` will not work.
268
- // TODO(helloshuangzi): switch to default parameters.
269
- NODE_EXTERN IsolateData* CreateIsolateData(
270
- v8::Isolate* isolate,
271
- struct uv_loop_s* loop);
272
- NODE_EXTERN IsolateData* CreateIsolateData(
273
- v8::Isolate* isolate,
274
- struct uv_loop_s* loop,
275
- MultiIsolatePlatform* platform);
276
- NODE_EXTERN IsolateData* CreateIsolateData(
277
- v8::Isolate* isolate,
278
- struct uv_loop_s* loop,
279
- MultiIsolatePlatform* platform,
280
- ArrayBufferAllocator* allocator);
281
- NODE_EXTERN void FreeIsolateData(IsolateData* isolate_data);
282
-
283
- // TODO(addaleax): Add an official variant using STL containers, and move
284
- // per-Environment options parsing here.
285
- NODE_EXTERN Environment* CreateEnvironment(IsolateData* isolate_data,
286
- v8::Local<v8::Context> context,
287
- int argc,
288
- const char* const* argv,
289
- int exec_argc,
290
- const char* const* exec_argv);
291
-
292
- NODE_EXTERN void LoadEnvironment(Environment* env);
293
- NODE_EXTERN void FreeEnvironment(Environment* env);
294
-
295
- // This may return nullptr if context is not associated with a Node instance.
296
- NODE_EXTERN Environment* GetCurrentEnvironment(v8::Local<v8::Context> context);
297
-
298
- // This returns the MultiIsolatePlatform used in the main thread of Node.js.
299
- // If NODE_USE_V8_PLATFORM haven't been defined when Node.js was built,
300
- // it returns nullptr.
301
- NODE_EXTERN MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform();
302
-
303
- NODE_EXTERN MultiIsolatePlatform* CreatePlatform(
304
- int thread_pool_size,
305
- node::tracing::TracingController* tracing_controller);
306
- MultiIsolatePlatform* InitializeV8Platform(int thread_pool_size);
307
- NODE_EXTERN void FreePlatform(MultiIsolatePlatform* platform);
308
-
309
- NODE_EXTERN void EmitBeforeExit(Environment* env);
310
- NODE_EXTERN int EmitExit(Environment* env);
311
- NODE_EXTERN void RunAtExit(Environment* env);
312
-
313
- // This may return nullptr if the current v8::Context is not associated
314
- // with a Node instance.
315
- NODE_EXTERN struct uv_loop_s* GetCurrentEventLoop(v8::Isolate* isolate);
316
-
317
- /* Converts a unixtime to V8 Date */
318
- NODE_DEPRECATED("Use v8::Date::New() directly",
319
- inline v8::Local<v8::Value> NODE_UNIXTIME_V8(double time) {
320
- return v8::Date::New(
321
- v8::Isolate::GetCurrent()->GetCurrentContext(),
322
- 1000 * time)
323
- .ToLocalChecked();
324
- })
325
- #define NODE_UNIXTIME_V8 node::NODE_UNIXTIME_V8
326
- NODE_DEPRECATED("Use v8::Date::ValueOf() directly",
327
- inline double NODE_V8_UNIXTIME(v8::Local<v8::Date> date) {
328
- return date->ValueOf() / 1000;
329
- })
330
- #define NODE_V8_UNIXTIME node::NODE_V8_UNIXTIME
331
-
332
- #define NODE_DEFINE_CONSTANT(target, constant) \
333
- do { \
334
- v8::Isolate* isolate = target->GetIsolate(); \
335
- v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
336
- v8::Local<v8::String> constant_name = \
337
- v8::String::NewFromUtf8(isolate, #constant, \
338
- v8::NewStringType::kInternalized).ToLocalChecked(); \
339
- v8::Local<v8::Number> constant_value = \
340
- v8::Number::New(isolate, static_cast<double>(constant)); \
341
- v8::PropertyAttribute constant_attributes = \
342
- static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \
343
- (target)->DefineOwnProperty(context, \
344
- constant_name, \
345
- constant_value, \
346
- constant_attributes).FromJust(); \
347
- } \
348
- while (0)
349
-
350
- #define NODE_DEFINE_HIDDEN_CONSTANT(target, constant) \
351
- do { \
352
- v8::Isolate* isolate = target->GetIsolate(); \
353
- v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
354
- v8::Local<v8::String> constant_name = \
355
- v8::String::NewFromUtf8(isolate, #constant, \
356
- v8::NewStringType::kInternalized) \
357
- .ToLocalChecked(); \
358
- v8::Local<v8::Number> constant_value = \
359
- v8::Number::New(isolate, static_cast<double>(constant)); \
360
- v8::PropertyAttribute constant_attributes = \
361
- static_cast<v8::PropertyAttribute>(v8::ReadOnly | \
362
- v8::DontDelete | \
363
- v8::DontEnum); \
364
- (target)->DefineOwnProperty(context, \
365
- constant_name, \
366
- constant_value, \
367
- constant_attributes).FromJust(); \
368
- } \
369
- while (0)
370
-
371
- // Used to be a macro, hence the uppercase name.
372
- inline void NODE_SET_METHOD(v8::Local<v8::Template> recv,
373
- const char* name,
374
- v8::FunctionCallback callback) {
375
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
376
- v8::HandleScope handle_scope(isolate);
377
- v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate,
378
- callback);
379
- v8::Local<v8::String> fn_name = v8::String::NewFromUtf8(isolate, name,
380
- v8::NewStringType::kInternalized).ToLocalChecked();
381
- t->SetClassName(fn_name);
382
- recv->Set(fn_name, t);
383
- }
384
-
385
- // Used to be a macro, hence the uppercase name.
386
- inline void NODE_SET_METHOD(v8::Local<v8::Object> recv,
387
- const char* name,
388
- v8::FunctionCallback callback) {
389
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
390
- v8::HandleScope handle_scope(isolate);
391
- v8::Local<v8::Context> context = isolate->GetCurrentContext();
392
- v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate,
393
- callback);
394
- v8::Local<v8::Function> fn = t->GetFunction(context).ToLocalChecked();
395
- v8::Local<v8::String> fn_name = v8::String::NewFromUtf8(isolate, name,
396
- v8::NewStringType::kInternalized).ToLocalChecked();
397
- fn->SetName(fn_name);
398
- recv->Set(fn_name, fn);
399
- }
400
- #define NODE_SET_METHOD node::NODE_SET_METHOD
401
-
402
- // Used to be a macro, hence the uppercase name.
403
- // Not a template because it only makes sense for FunctionTemplates.
404
- inline void NODE_SET_PROTOTYPE_METHOD(v8::Local<v8::FunctionTemplate> recv,
405
- const char* name,
406
- v8::FunctionCallback callback) {
407
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
408
- v8::HandleScope handle_scope(isolate);
409
- v8::Local<v8::Signature> s = v8::Signature::New(isolate, recv);
410
- v8::Local<v8::FunctionTemplate> t =
411
- v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), s);
412
- v8::Local<v8::String> fn_name = v8::String::NewFromUtf8(isolate, name,
413
- v8::NewStringType::kInternalized).ToLocalChecked();
414
- t->SetClassName(fn_name);
415
- recv->PrototypeTemplate()->Set(fn_name, t);
416
- }
417
- #define NODE_SET_PROTOTYPE_METHOD node::NODE_SET_PROTOTYPE_METHOD
418
-
419
- // BINARY is a deprecated alias of LATIN1.
420
- enum encoding {ASCII, UTF8, BASE64, UCS2, BINARY, HEX, BUFFER, LATIN1 = BINARY};
421
-
422
- NODE_EXTERN enum encoding ParseEncoding(
423
- v8::Isolate* isolate,
424
- v8::Local<v8::Value> encoding_v,
425
- enum encoding default_encoding = LATIN1);
426
- NODE_DEPRECATED("Use ParseEncoding(isolate, ...)",
427
- inline enum encoding ParseEncoding(
428
- v8::Local<v8::Value> encoding_v,
429
- enum encoding default_encoding = LATIN1) {
430
- return ParseEncoding(v8::Isolate::GetCurrent(), encoding_v, default_encoding);
431
- })
432
-
433
- NODE_EXTERN void FatalException(v8::Isolate* isolate,
434
- const v8::TryCatch& try_catch);
435
-
436
- NODE_DEPRECATED("Use FatalException(isolate, ...)",
437
- inline void FatalException(const v8::TryCatch& try_catch) {
438
- return FatalException(v8::Isolate::GetCurrent(), try_catch);
439
- })
440
-
441
- NODE_EXTERN v8::Local<v8::Value> Encode(v8::Isolate* isolate,
442
- const char* buf,
443
- size_t len,
444
- enum encoding encoding = LATIN1);
445
-
446
- // Warning: This reverses endianness on Big Endian platforms, even though the
447
- // signature using uint16_t implies that it should not.
448
- NODE_EXTERN v8::Local<v8::Value> Encode(v8::Isolate* isolate,
449
- const uint16_t* buf,
450
- size_t len);
451
-
452
- NODE_DEPRECATED("Use Encode(isolate, ...)",
453
- inline v8::Local<v8::Value> Encode(
454
- const void* buf,
455
- size_t len,
456
- enum encoding encoding = LATIN1) {
457
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
458
- if (encoding == UCS2) {
459
- assert(reinterpret_cast<uintptr_t>(buf) % sizeof(uint16_t) == 0 &&
460
- "UCS2 buffer must be aligned on two-byte boundary.");
461
- const uint16_t* that = static_cast<const uint16_t*>(buf);
462
- return Encode(isolate, that, len / sizeof(*that));
463
- }
464
- return Encode(isolate, static_cast<const char*>(buf), len, encoding);
465
- })
466
-
467
- // Returns -1 if the handle was not valid for decoding
468
- NODE_EXTERN ssize_t DecodeBytes(v8::Isolate* isolate,
469
- v8::Local<v8::Value>,
470
- enum encoding encoding = LATIN1);
471
- NODE_DEPRECATED("Use DecodeBytes(isolate, ...)",
472
- inline ssize_t DecodeBytes(
473
- v8::Local<v8::Value> val,
474
- enum encoding encoding = LATIN1) {
475
- return DecodeBytes(v8::Isolate::GetCurrent(), val, encoding);
476
- })
477
-
478
- // returns bytes written.
479
- NODE_EXTERN ssize_t DecodeWrite(v8::Isolate* isolate,
480
- char* buf,
481
- size_t buflen,
482
- v8::Local<v8::Value>,
483
- enum encoding encoding = LATIN1);
484
- NODE_DEPRECATED("Use DecodeWrite(isolate, ...)",
485
- inline ssize_t DecodeWrite(char* buf,
486
- size_t buflen,
487
- v8::Local<v8::Value> val,
488
- enum encoding encoding = LATIN1) {
489
- return DecodeWrite(v8::Isolate::GetCurrent(), buf, buflen, val, encoding);
490
- })
491
-
492
- #ifdef _WIN32
493
- NODE_EXTERN v8::Local<v8::Value> WinapiErrnoException(
494
- v8::Isolate* isolate,
495
- int errorno,
496
- const char* syscall = nullptr,
497
- const char* msg = "",
498
- const char* path = nullptr);
499
-
500
- NODE_DEPRECATED("Use WinapiErrnoException(isolate, ...)",
501
- inline v8::Local<v8::Value> WinapiErrnoException(int errorno,
502
- const char* syscall = nullptr, const char* msg = "",
503
- const char* path = nullptr) {
504
- return WinapiErrnoException(v8::Isolate::GetCurrent(),
505
- errorno,
506
- syscall,
507
- msg,
508
- path);
509
- })
510
- #endif
511
-
512
- const char* signo_string(int errorno);
513
-
514
-
515
- typedef void (*addon_register_func)(
516
- v8::Local<v8::Object> exports,
517
- v8::Local<v8::Value> module,
518
- void* priv);
519
-
520
- typedef void (*addon_context_register_func)(
521
- v8::Local<v8::Object> exports,
522
- v8::Local<v8::Value> module,
523
- v8::Local<v8::Context> context,
524
- void* priv);
525
-
526
- struct node_module {
527
- int nm_version;
528
- unsigned int nm_flags;
529
- void* nm_dso_handle;
530
- const char* nm_filename;
531
- node::addon_register_func nm_register_func;
532
- node::addon_context_register_func nm_context_register_func;
533
- const char* nm_modname;
534
- void* nm_priv;
535
- struct node_module* nm_link;
536
- };
537
-
538
- extern "C" NODE_EXTERN void node_module_register(void* mod);
539
-
540
- #ifdef _WIN32
541
- # define NODE_MODULE_EXPORT __declspec(dllexport)
542
- #else
543
- # define NODE_MODULE_EXPORT __attribute__((visibility("default")))
544
- #endif
545
-
546
- #ifdef NODE_SHARED_MODE
547
- # define NODE_CTOR_PREFIX
548
- #else
549
- # define NODE_CTOR_PREFIX static
550
- #endif
551
-
552
- #if defined(_MSC_VER)
553
- #pragma section(".CRT$XCU", read)
554
- #define NODE_C_CTOR(fn) \
555
- NODE_CTOR_PREFIX void __cdecl fn(void); \
556
- __declspec(dllexport, allocate(".CRT$XCU")) \
557
- void (__cdecl*fn ## _)(void) = fn; \
558
- NODE_CTOR_PREFIX void __cdecl fn(void)
559
- #else
560
- #define NODE_C_CTOR(fn) \
561
- NODE_CTOR_PREFIX void fn(void) __attribute__((constructor)); \
562
- NODE_CTOR_PREFIX void fn(void)
563
- #endif
564
-
565
- #define NODE_MODULE_X(modname, regfunc, priv, flags) \
566
- extern "C" { \
567
- static node::node_module _module = \
568
- { \
569
- NODE_MODULE_VERSION, \
570
- flags, \
571
- NULL, /* NOLINT (readability/null_usage) */ \
572
- __FILE__, \
573
- (node::addon_register_func) (regfunc), \
574
- NULL, /* NOLINT (readability/null_usage) */ \
575
- NODE_STRINGIFY(modname), \
576
- priv, \
577
- NULL /* NOLINT (readability/null_usage) */ \
578
- }; \
579
- NODE_C_CTOR(_register_ ## modname) { \
580
- node_module_register(&_module); \
581
- } \
582
- }
583
-
584
- #define NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, priv, flags) \
585
- extern "C" { \
586
- static node::node_module _module = \
587
- { \
588
- NODE_MODULE_VERSION, \
589
- flags, \
590
- NULL, /* NOLINT (readability/null_usage) */ \
591
- __FILE__, \
592
- NULL, /* NOLINT (readability/null_usage) */ \
593
- (node::addon_context_register_func) (regfunc), \
594
- NODE_STRINGIFY(modname), \
595
- priv, \
596
- NULL /* NOLINT (readability/null_usage) */ \
597
- }; \
598
- NODE_C_CTOR(_register_ ## modname) { \
599
- node_module_register(&_module); \
600
- } \
601
- }
602
-
603
- // Usage: `NODE_MODULE(NODE_GYP_MODULE_NAME, InitializerFunction)`
604
- // If no NODE_MODULE is declared, Node.js looks for the well-known
605
- // symbol `node_register_module_v${NODE_MODULE_VERSION}`.
606
- #define NODE_MODULE(modname, regfunc) \
607
- NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
608
-
609
- #define NODE_MODULE_CONTEXT_AWARE(modname, regfunc) \
610
- /* NOLINTNEXTLINE (readability/null_usage) */ \
611
- NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, 0)
612
-
613
- /*
614
- * For backward compatibility in add-on modules.
615
- */
616
- #define NODE_MODULE_DECL /* nothing */
617
-
618
- #define NODE_MODULE_INITIALIZER_BASE node_register_module_v
619
-
620
- #define NODE_MODULE_INITIALIZER_X(base, version) \
621
- NODE_MODULE_INITIALIZER_X_HELPER(base, version)
622
-
623
- #define NODE_MODULE_INITIALIZER_X_HELPER(base, version) base##version
624
-
625
- #define NODE_MODULE_INITIALIZER \
626
- NODE_MODULE_INITIALIZER_X(NODE_MODULE_INITIALIZER_BASE, \
627
- NODE_MODULE_VERSION)
628
-
629
- #define NODE_MODULE_INIT() \
630
- extern "C" NODE_MODULE_EXPORT void \
631
- NODE_MODULE_INITIALIZER(v8::Local<v8::Object> exports, \
632
- v8::Local<v8::Value> module, \
633
- v8::Local<v8::Context> context); \
634
- NODE_MODULE_CONTEXT_AWARE(NODE_GYP_MODULE_NAME, \
635
- NODE_MODULE_INITIALIZER) \
636
- void NODE_MODULE_INITIALIZER(v8::Local<v8::Object> exports, \
637
- v8::Local<v8::Value> module, \
638
- v8::Local<v8::Context> context)
639
-
640
- /* Called after the event loop exits but before the VM is disposed.
641
- * Callbacks are run in reverse order of registration, i.e. newest first.
642
- */
643
- NODE_EXTERN void AtExit(void (*cb)(void* arg), void* arg = 0);
644
-
645
- /* Registers a callback with the passed-in Environment instance. The callback
646
- * is called after the event loop exits, but before the VM is disposed.
647
- * Callbacks are run in reverse order of registration, i.e. newest first.
648
- */
649
- NODE_EXTERN void AtExit(Environment* env, void (*cb)(void* arg), void* arg = 0);
650
-
651
- typedef void (*promise_hook_func) (v8::PromiseHookType type,
652
- v8::Local<v8::Promise> promise,
653
- v8::Local<v8::Value> parent,
654
- void* arg);
655
-
656
- typedef double async_id;
657
- struct async_context {
658
- ::node::async_id async_id;
659
- ::node::async_id trigger_async_id;
660
- };
661
-
662
- /* Registers an additional v8::PromiseHook wrapper. This API exists because V8
663
- * itself supports only a single PromiseHook. */
664
- NODE_DEPRECATED("Use async_hooks directly instead",
665
- NODE_EXTERN void AddPromiseHook(v8::Isolate* isolate,
666
- promise_hook_func fn,
667
- void* arg));
668
-
669
- /* This is a lot like node::AtExit, except that the hooks added via this
670
- * function are run before the AtExit ones and will always be registered
671
- * for the current Environment instance.
672
- * These functions are safe to use in an addon supporting multiple
673
- * threads/isolates. */
674
- NODE_EXTERN void AddEnvironmentCleanupHook(v8::Isolate* isolate,
675
- void (*fun)(void* arg),
676
- void* arg);
677
-
678
- NODE_EXTERN void RemoveEnvironmentCleanupHook(v8::Isolate* isolate,
679
- void (*fun)(void* arg),
680
- void* arg);
681
-
682
- /* Returns the id of the current execution context. If the return value is
683
- * zero then no execution has been set. This will happen if the user handles
684
- * I/O from native code. */
685
- NODE_EXTERN async_id AsyncHooksGetExecutionAsyncId(v8::Isolate* isolate);
686
-
687
- /* Return same value as async_hooks.triggerAsyncId(); */
688
- NODE_EXTERN async_id AsyncHooksGetTriggerAsyncId(v8::Isolate* isolate);
689
-
690
- /* If the native API doesn't inherit from the helper class then the callbacks
691
- * must be triggered manually. This triggers the init() callback. The return
692
- * value is the async id assigned to the resource.
693
- *
694
- * The `trigger_async_id` parameter should correspond to the resource which is
695
- * creating the new resource, which will usually be the return value of
696
- * `AsyncHooksGetTriggerAsyncId()`. */
697
- NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate,
698
- v8::Local<v8::Object> resource,
699
- const char* name,
700
- async_id trigger_async_id = -1);
701
-
702
- NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate,
703
- v8::Local<v8::Object> resource,
704
- v8::Local<v8::String> name,
705
- async_id trigger_async_id = -1);
706
-
707
- /* Emit the destroy() callback. */
708
- NODE_EXTERN void EmitAsyncDestroy(v8::Isolate* isolate,
709
- async_context asyncContext);
710
-
711
- class InternalCallbackScope;
712
-
713
- /* This class works like `MakeCallback()` in that it sets up a specific
714
- * asyncContext as the current one and informs the async_hooks and domains
715
- * modules that this context is currently active.
716
- *
717
- * `MakeCallback()` is a wrapper around this class as well as
718
- * `Function::Call()`. Either one of these mechanisms needs to be used for
719
- * top-level calls into JavaScript (i.e. without any existing JS stack).
720
- *
721
- * This object should be stack-allocated to ensure that it is contained in a
722
- * valid HandleScope.
723
- *
724
- * Exceptions happening within this scope will be treated like uncaught
725
- * exceptions. If this behaviour is undesirable, a new `v8::TryCatch` scope
726
- * needs to be created inside of this scope.
727
- */
728
- class NODE_EXTERN CallbackScope {
729
- public:
730
- CallbackScope(v8::Isolate* isolate,
731
- v8::Local<v8::Object> resource,
732
- async_context asyncContext);
733
- ~CallbackScope();
734
-
735
- private:
736
- InternalCallbackScope* private_;
737
- v8::TryCatch try_catch_;
738
-
739
- void operator=(const CallbackScope&) = delete;
740
- void operator=(CallbackScope&&) = delete;
741
- CallbackScope(const CallbackScope&) = delete;
742
- CallbackScope(CallbackScope&&) = delete;
743
- };
744
-
745
- /* An API specific to emit before/after callbacks is unnecessary because
746
- * MakeCallback will automatically call them for you.
747
- *
748
- * These methods may create handles on their own, so run them inside a
749
- * HandleScope.
750
- *
751
- * `asyncId` and `triggerAsyncId` should correspond to the values returned by
752
- * `EmitAsyncInit()` and `AsyncHooksGetTriggerAsyncId()`, respectively, when the
753
- * invoking resource was created. If these values are unknown, 0 can be passed.
754
- * */
755
- NODE_EXTERN
756
- v8::MaybeLocal<v8::Value> MakeCallback(v8::Isolate* isolate,
757
- v8::Local<v8::Object> recv,
758
- v8::Local<v8::Function> callback,
759
- int argc,
760
- v8::Local<v8::Value>* argv,
761
- async_context asyncContext);
762
- NODE_EXTERN
763
- v8::MaybeLocal<v8::Value> MakeCallback(v8::Isolate* isolate,
764
- v8::Local<v8::Object> recv,
765
- const char* method,
766
- int argc,
767
- v8::Local<v8::Value>* argv,
768
- async_context asyncContext);
769
- NODE_EXTERN
770
- v8::MaybeLocal<v8::Value> MakeCallback(v8::Isolate* isolate,
771
- v8::Local<v8::Object> recv,
772
- v8::Local<v8::String> symbol,
773
- int argc,
774
- v8::Local<v8::Value>* argv,
775
- async_context asyncContext);
776
-
777
- /* Helper class users can optionally inherit from. If
778
- * `AsyncResource::MakeCallback()` is used, then all four callbacks will be
779
- * called automatically. */
780
- class AsyncResource {
781
- public:
782
- AsyncResource(v8::Isolate* isolate,
783
- v8::Local<v8::Object> resource,
784
- const char* name,
785
- async_id trigger_async_id = -1)
786
- : isolate_(isolate),
787
- resource_(isolate, resource) {
788
- async_context_ = EmitAsyncInit(isolate, resource, name,
789
- trigger_async_id);
790
- }
791
-
792
- AsyncResource(v8::Isolate* isolate,
793
- v8::Local<v8::Object> resource,
794
- v8::Local<v8::String> name,
795
- async_id trigger_async_id = -1)
796
- : isolate_(isolate),
797
- resource_(isolate, resource) {
798
- async_context_ = EmitAsyncInit(isolate, resource, name,
799
- trigger_async_id);
800
- }
801
-
802
- virtual ~AsyncResource() {
803
- EmitAsyncDestroy(isolate_, async_context_);
804
- resource_.Reset();
805
- }
806
-
807
- v8::MaybeLocal<v8::Value> MakeCallback(
808
- v8::Local<v8::Function> callback,
809
- int argc,
810
- v8::Local<v8::Value>* argv) {
811
- return node::MakeCallback(isolate_, get_resource(),
812
- callback, argc, argv,
813
- async_context_);
814
- }
815
-
816
- v8::MaybeLocal<v8::Value> MakeCallback(
817
- const char* method,
818
- int argc,
819
- v8::Local<v8::Value>* argv) {
820
- return node::MakeCallback(isolate_, get_resource(),
821
- method, argc, argv,
822
- async_context_);
823
- }
824
-
825
- v8::MaybeLocal<v8::Value> MakeCallback(
826
- v8::Local<v8::String> symbol,
827
- int argc,
828
- v8::Local<v8::Value>* argv) {
829
- return node::MakeCallback(isolate_, get_resource(),
830
- symbol, argc, argv,
831
- async_context_);
832
- }
833
-
834
- v8::Local<v8::Object> get_resource() {
835
- return resource_.Get(isolate_);
836
- }
837
-
838
- async_id get_async_id() const {
839
- return async_context_.async_id;
840
- }
841
-
842
- async_id get_trigger_async_id() const {
843
- return async_context_.trigger_async_id;
844
- }
845
-
846
- protected:
847
- class CallbackScope : public node::CallbackScope {
848
- public:
849
- explicit CallbackScope(AsyncResource* res)
850
- : node::CallbackScope(res->isolate_,
851
- res->resource_.Get(res->isolate_),
852
- res->async_context_) {}
853
- };
854
-
855
- private:
856
- v8::Isolate* isolate_;
857
- v8::Persistent<v8::Object> resource_;
858
- async_context async_context_;
859
- };
860
-
861
- } // namespace node
862
-
863
- #endif // SRC_NODE_H_