@encharm/cws 4.4.1 → 4.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (485) hide show
  1. package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
  2. package/dist/bindings/cws_darwin_arm64_node127.node +0 -0
  3. package/dist/bindings/cws_linux_arm64_node115.node +0 -0
  4. package/dist/bindings/cws_linux_arm64_node127.node +0 -0
  5. package/dist/bindings/cws_linux_x64_node115.node +0 -0
  6. package/dist/bindings/cws_linux_x64_node127.node +0 -0
  7. package/dist/bindings/cws_win32_x64_node108.node +0 -0
  8. package/dist/bindings/cws_win32_x64_node115.node +0 -0
  9. package/dist/bindings/cws_win32_x64_node127.node +0 -0
  10. package/dist/bindings/cws_win32_x64_node83.node +0 -0
  11. package/dist/bindings/cws_win32_x64_node93.node +0 -0
  12. package/package.json +1 -1
  13. package/src/Addon.h +8 -23
  14. package/src/Socket.h +0 -1
  15. package/src/headers/22/acorn_version.h +6 -0
  16. package/src/headers/22/aliased_buffer-inl.h +243 -0
  17. package/src/headers/22/aliased_buffer.h +206 -0
  18. package/src/headers/{18 → 22}/async_wrap-inl.h +8 -6
  19. package/src/headers/{18 → 22}/async_wrap.h +65 -59
  20. package/src/headers/{16 → 22}/base_object-inl.h +57 -117
  21. package/src/headers/{18 → 22}/base_object.h +58 -30
  22. package/src/headers/22/base_object_types.h +74 -0
  23. package/src/headers/22/blob_serializer_deserializer-inl.h +385 -0
  24. package/src/headers/22/blob_serializer_deserializer.h +132 -0
  25. package/src/headers/{16 → 22}/callback_queue.h +1 -0
  26. package/src/headers/{16 → 22}/cares_wrap.h +27 -20
  27. package/src/headers/22/cjs_module_lexer_version.h +6 -0
  28. package/src/headers/22/cleanup_queue-inl.h +62 -0
  29. package/src/headers/22/cleanup_queue.h +85 -0
  30. package/src/headers/22/compile_cache.h +104 -0
  31. package/src/headers/{18 → 22}/crypto/crypto_clienthello.h +1 -1
  32. package/src/headers/{18 → 22}/crypto/crypto_context.h +31 -7
  33. package/src/headers/{18 → 22}/crypto/crypto_keys.h +118 -148
  34. package/src/headers/{18 → 22}/crypto/crypto_tls.h +20 -5
  35. package/src/headers/{18 → 22}/crypto/crypto_util.h +219 -263
  36. package/src/headers/22/crypto/ncrypto.h +752 -0
  37. package/src/headers/{16 → 22}/debug_utils-inl.h +15 -7
  38. package/src/headers/{18 → 22}/debug_utils.h +25 -19
  39. package/src/headers/22/encoding_binding.h +59 -0
  40. package/src/headers/{14 → 22}/env-inl.h +276 -409
  41. package/src/headers/22/env.h +1266 -0
  42. package/src/headers/22/env_properties.h +497 -0
  43. package/src/headers/{18 → 22}/handle_wrap.h +2 -0
  44. package/src/headers/{18 → 22}/histogram.h +88 -48
  45. package/src/headers/{16 → 22}/inspector_agent.h +17 -1
  46. package/src/headers/{16 → 22}/inspector_profiler.h +15 -13
  47. package/src/headers/{18 → 22}/js_native_api.h +78 -30
  48. package/src/headers/{18 → 22}/js_native_api_types.h +46 -1
  49. package/src/headers/{18 → 22}/js_native_api_v8.h +206 -161
  50. package/src/headers/{18 → 22}/js_native_api_v8_internals.h +6 -0
  51. package/src/headers/22/json_parser.h +40 -0
  52. package/src/headers/{16 → 22}/json_utils.h +19 -8
  53. package/src/headers/{18 → 22}/memory_tracker-inl.h +16 -13
  54. package/src/headers/{14 → 22}/memory_tracker.h +13 -8
  55. package/src/headers/{16 → 22}/module_wrap.h +49 -19
  56. package/src/headers/22/ncrypto/ncrypto.h +752 -0
  57. package/src/headers/{18 → 22}/node.h +465 -68
  58. package/src/headers/{18 → 22}/node_api.h +66 -81
  59. package/src/headers/{18 → 22}/node_api_internals.h +8 -4
  60. package/src/headers/{18 → 22}/node_api_types.h +5 -0
  61. package/src/headers/22/node_binding.h +154 -0
  62. package/src/headers/{18 → 22}/node_blob.h +46 -78
  63. package/src/headers/{18 → 22}/node_bob-inl.h +1 -2
  64. package/src/headers/{18 → 22}/node_bob.h +2 -6
  65. package/src/headers/{18 → 22}/node_buffer.h +1 -1
  66. package/src/headers/22/node_builtins.h +220 -0
  67. package/src/headers/{18 → 22}/node_constants.h +3 -5
  68. package/src/headers/22/node_context_data.h +168 -0
  69. package/src/headers/22/node_contextify.h +199 -0
  70. package/src/headers/{16 → 22}/node_crypto.h +1 -2
  71. package/src/headers/22/node_dotenv.h +45 -0
  72. package/src/headers/{18 → 22}/node_errors.h +86 -27
  73. package/src/headers/22/node_exit_code.h +54 -0
  74. package/src/headers/22/node_external_reference.h +249 -0
  75. package/src/headers/{18 → 22}/node_file-inl.h +127 -30
  76. package/src/headers/{16 → 22}/node_file.h +122 -11
  77. package/src/headers/{18 → 22}/node_http2.h +28 -11
  78. package/src/headers/{16 → 22}/node_http2_state.h +34 -25
  79. package/src/headers/{18 → 22}/node_http_common-inl.h +2 -1
  80. package/src/headers/{18 → 22}/node_http_common.h +56 -55
  81. package/src/headers/{16 → 22}/node_i18n.h +5 -18
  82. package/src/headers/{18 → 22}/node_internals.h +121 -59
  83. package/src/headers/{18 → 22}/node_main_instance.h +4 -31
  84. package/src/headers/{18 → 22}/node_messaging.h +27 -10
  85. package/src/headers/{18 → 22}/node_metadata.h +23 -1
  86. package/src/headers/{18 → 22}/node_options-inl.h +24 -11
  87. package/src/headers/{18 → 22}/node_options.h +124 -39
  88. package/src/headers/{18 → 22}/node_perf.h +0 -2
  89. package/src/headers/{18 → 22}/node_perf_common.h +20 -9
  90. package/src/headers/{18 → 22}/node_platform.h +11 -5
  91. package/src/headers/{18 → 22}/node_process.h +26 -14
  92. package/src/headers/22/node_realm-inl.h +145 -0
  93. package/src/headers/22/node_realm.h +184 -0
  94. package/src/headers/{16 → 22}/node_report.h +13 -17
  95. package/src/headers/{16 → 22}/node_revert.h +3 -3
  96. package/src/headers/{16 → 22}/node_root_certs.h +902 -461
  97. package/src/headers/22/node_sea.h +64 -0
  98. package/src/headers/22/node_shadow_realm.h +46 -0
  99. package/src/headers/22/node_snapshot_builder.h +57 -0
  100. package/src/headers/22/node_snapshotable.h +174 -0
  101. package/src/headers/{18 → 22}/node_sockaddr.h +2 -2
  102. package/src/headers/{16 → 22}/node_stat_watcher.h +2 -1
  103. package/src/headers/22/node_threadsafe_cow-inl.h +54 -0
  104. package/src/headers/22/node_threadsafe_cow.h +105 -0
  105. package/src/headers/22/node_union_bytes.h +81 -0
  106. package/src/headers/22/node_url.h +96 -0
  107. package/src/headers/22/node_v8.h +77 -0
  108. package/src/headers/{14 → 22}/node_v8_platform-inl.h +17 -6
  109. package/src/headers/{18 → 22}/node_version.h +20 -8
  110. package/src/headers/22/node_wasi.h +185 -0
  111. package/src/headers/{14 → 22}/node_watchdog.h +2 -0
  112. package/src/headers/{18 → 22}/node_worker.h +7 -2
  113. package/src/headers/22/permission/child_process_permission.h +31 -0
  114. package/src/headers/22/permission/fs_permission.h +167 -0
  115. package/src/headers/22/permission/inspector_permission.h +31 -0
  116. package/src/headers/22/permission/permission.h +99 -0
  117. package/src/headers/22/permission/permission_base.h +60 -0
  118. package/src/headers/22/permission/wasi_permission.h +31 -0
  119. package/src/headers/22/permission/worker_permission.h +31 -0
  120. package/src/headers/{16 → 22}/req_wrap-inl.h +7 -6
  121. package/src/headers/{14 → 22}/spawn_sync.h +3 -3
  122. package/src/headers/{18 → 22}/stream_base-inl.h +0 -135
  123. package/src/headers/{18 → 22}/stream_base.h +35 -16
  124. package/src/headers/{18 → 22}/stream_pipe.h +3 -4
  125. package/src/headers/{16 → 22}/stream_wrap.h +2 -1
  126. package/src/headers/{18 → 22}/string_bytes.h +5 -14
  127. package/src/headers/{14 → 22}/string_decoder-inl.h +0 -6
  128. package/src/headers/{16 → 22}/string_decoder.h +0 -1
  129. package/src/headers/{18 → 22}/tcp_wrap.h +1 -1
  130. package/src/headers/{18 → 22}/threadpoolwork-inl.h +14 -1
  131. package/src/headers/22/timers.h +76 -0
  132. package/src/headers/{18 → 22}/tracing/trace_event.h +7 -5
  133. package/src/headers/{16 → 22}/udp_wrap.h +8 -5
  134. package/src/headers/22/undici_version.h +6 -0
  135. package/src/headers/{18 → 22}/util-inl.h +97 -127
  136. package/src/headers/{18 → 22}/util.h +293 -106
  137. package/src/headers/{18 → 22}/v8-fast-api-calls.h +103 -58
  138. package/dist/bindings/cws_darwin_arm64_node83.node +0 -0
  139. package/dist/bindings/cws_darwin_arm64_node93.node +0 -0
  140. package/dist/bindings/cws_darwin_x64_node83.node +0 -0
  141. package/dist/bindings/cws_darwin_x64_node93.node +0 -0
  142. package/dist/bindings/cws_linux_arm64_node83.node +0 -0
  143. package/dist/bindings/cws_linux_arm64_node93.node +0 -0
  144. package/dist/bindings/cws_linux_x64_node83.node +0 -0
  145. package/dist/bindings/cws_linux_x64_node93.node +0 -0
  146. package/src/headers/14/aliased_buffer.h +0 -263
  147. package/src/headers/14/allocated_buffer-inl.h +0 -110
  148. package/src/headers/14/allocated_buffer.h +0 -73
  149. package/src/headers/14/async_wrap-inl.h +0 -94
  150. package/src/headers/14/async_wrap.h +0 -230
  151. package/src/headers/14/base64.h +0 -183
  152. package/src/headers/14/base_object-inl.h +0 -371
  153. package/src/headers/14/base_object.h +0 -281
  154. package/src/headers/14/callback_queue-inl.h +0 -97
  155. package/src/headers/14/callback_queue.h +0 -78
  156. package/src/headers/14/debug_utils-inl.h +0 -223
  157. package/src/headers/14/debug_utils.h +0 -181
  158. package/src/headers/14/env.h +0 -1388
  159. package/src/headers/14/handle_wrap.h +0 -117
  160. package/src/headers/14/histogram-inl.h +0 -83
  161. package/src/headers/14/histogram.h +0 -98
  162. package/src/headers/14/inspector_agent.h +0 -149
  163. package/src/headers/14/inspector_profiler.h +0 -137
  164. package/src/headers/14/js_native_api.h +0 -544
  165. package/src/headers/14/js_native_api_types.h +0 -143
  166. package/src/headers/14/js_native_api_v8.h +0 -301
  167. package/src/headers/14/js_native_api_v8_internals.h +0 -38
  168. package/src/headers/14/json_utils.h +0 -161
  169. package/src/headers/14/memory_tracker-inl.h +0 -355
  170. package/src/headers/14/module_wrap.h +0 -99
  171. package/src/headers/14/node.h +0 -1032
  172. package/src/headers/14/node_api.h +0 -255
  173. package/src/headers/14/node_api_types.h +0 -44
  174. package/src/headers/14/node_binding.h +0 -99
  175. package/src/headers/14/node_buffer.h +0 -92
  176. package/src/headers/14/node_constants.h +0 -84
  177. package/src/headers/14/node_context_data.h +0 -44
  178. package/src/headers/14/node_contextify.h +0 -161
  179. package/src/headers/14/node_crypto.h +0 -865
  180. package/src/headers/14/node_crypto_bio.h +0 -195
  181. package/src/headers/14/node_crypto_clienthello-inl.h +0 -91
  182. package/src/headers/14/node_crypto_clienthello.h +0 -132
  183. package/src/headers/14/node_crypto_common.h +0 -138
  184. package/src/headers/14/node_crypto_groups.h +0 -415
  185. package/src/headers/14/node_dtrace.h +0 -86
  186. package/src/headers/14/node_errors.h +0 -214
  187. package/src/headers/14/node_file-inl.h +0 -306
  188. package/src/headers/14/node_file.h +0 -417
  189. package/src/headers/14/node_http2.h +0 -1191
  190. package/src/headers/14/node_http2_state.h +0 -149
  191. package/src/headers/14/node_http_common-inl.h +0 -194
  192. package/src/headers/14/node_http_common.h +0 -529
  193. package/src/headers/14/node_i18n.h +0 -144
  194. package/src/headers/14/node_internals.h +0 -405
  195. package/src/headers/14/node_main_instance.h +0 -96
  196. package/src/headers/14/node_mem.h +0 -45
  197. package/src/headers/14/node_messaging.h +0 -303
  198. package/src/headers/14/node_metadata.h +0 -109
  199. package/src/headers/14/node_mutex.h +0 -247
  200. package/src/headers/14/node_native_module.h +0 -101
  201. package/src/headers/14/node_native_module_env.h +0 -66
  202. package/src/headers/14/node_options-inl.h +0 -451
  203. package/src/headers/14/node_options.h +0 -481
  204. package/src/headers/14/node_perf.h +0 -181
  205. package/src/headers/14/node_perf_common.h +0 -97
  206. package/src/headers/14/node_platform.h +0 -189
  207. package/src/headers/14/node_process.h +0 -40
  208. package/src/headers/14/node_report.h +0 -47
  209. package/src/headers/14/node_revert.h +0 -72
  210. package/src/headers/14/node_root_certs.h +0 -3458
  211. package/src/headers/14/node_sockaddr-inl.h +0 -170
  212. package/src/headers/14/node_sockaddr.h +0 -123
  213. package/src/headers/14/node_stat_watcher.h +0 -70
  214. package/src/headers/14/node_union_bytes.h +0 -103
  215. package/src/headers/14/node_url.h +0 -188
  216. package/src/headers/14/node_version.h +0 -98
  217. package/src/headers/14/node_wasi.h +0 -108
  218. package/src/headers/14/node_win32_etw_provider-inl.h +0 -287
  219. package/src/headers/14/node_win32_etw_provider.h +0 -99
  220. package/src/headers/14/node_worker.h +0 -141
  221. package/src/headers/14/pipe_wrap.h +0 -78
  222. package/src/headers/14/req_wrap-inl.h +0 -170
  223. package/src/headers/14/req_wrap.h +0 -77
  224. package/src/headers/14/stream_base-inl.h +0 -275
  225. package/src/headers/14/stream_base.h +0 -434
  226. package/src/headers/14/stream_pipe.h +0 -73
  227. package/src/headers/14/stream_wrap.h +0 -130
  228. package/src/headers/14/string_bytes.h +0 -129
  229. package/src/headers/14/string_decoder.h +0 -50
  230. package/src/headers/14/string_search.h +0 -638
  231. package/src/headers/14/tcp_wrap.h +0 -101
  232. package/src/headers/14/threadpoolwork-inl.h +0 -57
  233. package/src/headers/14/tls_wrap.h +0 -222
  234. package/src/headers/14/tracing/agent.h +0 -195
  235. package/src/headers/14/tracing/node_trace_buffer.h +0 -83
  236. package/src/headers/14/tracing/node_trace_writer.h +0 -75
  237. package/src/headers/14/tracing/trace_event.h +0 -720
  238. package/src/headers/14/tracing/traced_value.h +0 -70
  239. package/src/headers/14/tty_wrap.h +0 -64
  240. package/src/headers/14/udp_wrap.h +0 -227
  241. package/src/headers/14/util-inl.h +0 -566
  242. package/src/headers/14/util.h +0 -804
  243. package/src/headers/14/v8abbr.h +0 -124
  244. package/src/headers/16/aliased_buffer.h +0 -315
  245. package/src/headers/16/aliased_struct-inl.h +0 -54
  246. package/src/headers/16/aliased_struct.h +0 -63
  247. package/src/headers/16/allocated_buffer-inl.h +0 -110
  248. package/src/headers/16/allocated_buffer.h +0 -73
  249. package/src/headers/16/async_wrap-inl.h +0 -94
  250. package/src/headers/16/async_wrap.h +0 -246
  251. package/src/headers/16/base64-inl.h +0 -189
  252. package/src/headers/16/base64.h +0 -69
  253. package/src/headers/16/base_object.h +0 -294
  254. package/src/headers/16/connect_wrap.h +0 -26
  255. package/src/headers/16/connection_wrap.h +0 -30
  256. package/src/headers/16/crypto/crypto_aes.h +0 -89
  257. package/src/headers/16/crypto/crypto_bio.h +0 -194
  258. package/src/headers/16/crypto/crypto_cipher.h +0 -286
  259. package/src/headers/16/crypto/crypto_clienthello-inl.h +0 -90
  260. package/src/headers/16/crypto/crypto_clienthello.h +0 -131
  261. package/src/headers/16/crypto/crypto_common.h +0 -187
  262. package/src/headers/16/crypto/crypto_context.h +0 -147
  263. package/src/headers/16/crypto/crypto_dh.h +0 -157
  264. package/src/headers/16/crypto/crypto_dsa.h +0 -76
  265. package/src/headers/16/crypto/crypto_ec.h +0 -169
  266. package/src/headers/16/crypto/crypto_groups.h +0 -415
  267. package/src/headers/16/crypto/crypto_hash.h +0 -89
  268. package/src/headers/16/crypto/crypto_hkdf.h +0 -66
  269. package/src/headers/16/crypto/crypto_hmac.h +0 -94
  270. package/src/headers/16/crypto/crypto_keygen.h +0 -301
  271. package/src/headers/16/crypto/crypto_keys.h +0 -412
  272. package/src/headers/16/crypto/crypto_pbkdf2.h +0 -76
  273. package/src/headers/16/crypto/crypto_random.h +0 -130
  274. package/src/headers/16/crypto/crypto_rsa.h +0 -141
  275. package/src/headers/16/crypto/crypto_scrypt.h +0 -87
  276. package/src/headers/16/crypto/crypto_sig.h +0 -167
  277. package/src/headers/16/crypto/crypto_spkac.h +0 -20
  278. package/src/headers/16/crypto/crypto_timing.h +0 -20
  279. package/src/headers/16/crypto/crypto_tls.h +0 -292
  280. package/src/headers/16/crypto/crypto_util.h +0 -736
  281. package/src/headers/16/crypto/crypto_x509.h +0 -141
  282. package/src/headers/16/debug_utils.h +0 -184
  283. package/src/headers/16/diagnosticfilename-inl.h +0 -33
  284. package/src/headers/16/env-inl.h +0 -1277
  285. package/src/headers/16/env.h +0 -1629
  286. package/src/headers/16/handle_wrap.h +0 -121
  287. package/src/headers/16/histogram-inl.h +0 -88
  288. package/src/headers/16/histogram.h +0 -216
  289. package/src/headers/16/inspector_io.h +0 -78
  290. package/src/headers/16/inspector_socket.h +0 -60
  291. package/src/headers/16/inspector_socket_server.h +0 -110
  292. package/src/headers/16/js_native_api.h +0 -561
  293. package/src/headers/16/js_native_api_types.h +0 -160
  294. package/src/headers/16/js_native_api_v8.h +0 -451
  295. package/src/headers/16/js_native_api_v8_internals.h +0 -39
  296. package/src/headers/16/js_stream.h +0 -52
  297. package/src/headers/16/memory_tracker-inl.h +0 -356
  298. package/src/headers/16/memory_tracker.h +0 -284
  299. package/src/headers/16/node.d +0 -315
  300. package/src/headers/16/node.h +0 -1132
  301. package/src/headers/16/node.stp +0 -146
  302. package/src/headers/16/node_api.h +0 -275
  303. package/src/headers/16/node_api_internals.h +0 -30
  304. package/src/headers/16/node_api_types.h +0 -50
  305. package/src/headers/16/node_binding.h +0 -99
  306. package/src/headers/16/node_blob.h +0 -191
  307. package/src/headers/16/node_bob-inl.h +0 -37
  308. package/src/headers/16/node_bob.h +0 -111
  309. package/src/headers/16/node_buffer.h +0 -92
  310. package/src/headers/16/node_constants.h +0 -84
  311. package/src/headers/16/node_context_data.h +0 -44
  312. package/src/headers/16/node_contextify.h +0 -196
  313. package/src/headers/16/node_dir.h +0 -52
  314. package/src/headers/16/node_dtrace.h +0 -86
  315. package/src/headers/16/node_errors.h +0 -277
  316. package/src/headers/16/node_external_reference.h +0 -129
  317. package/src/headers/16/node_file-inl.h +0 -306
  318. package/src/headers/16/node_http2.h +0 -1140
  319. package/src/headers/16/node_http_common-inl.h +0 -200
  320. package/src/headers/16/node_http_common.h +0 -531
  321. package/src/headers/16/node_internals.h +0 -421
  322. package/src/headers/16/node_main_instance.h +0 -103
  323. package/src/headers/16/node_mem-inl.h +0 -112
  324. package/src/headers/16/node_messaging.h +0 -373
  325. package/src/headers/16/node_metadata.h +0 -122
  326. package/src/headers/16/node_native_module.h +0 -101
  327. package/src/headers/16/node_native_module_env.h +0 -68
  328. package/src/headers/16/node_object_wrap.h +0 -132
  329. package/src/headers/16/node_options-inl.h +0 -477
  330. package/src/headers/16/node_options.h +0 -494
  331. package/src/headers/16/node_perf.h +0 -185
  332. package/src/headers/16/node_perf_common.h +0 -89
  333. package/src/headers/16/node_platform.h +0 -192
  334. package/src/headers/16/node_process.h +0 -43
  335. package/src/headers/16/node_provider.d +0 -80
  336. package/src/headers/16/node_snapshotable.h +0 -137
  337. package/src/headers/16/node_sockaddr-inl.h +0 -266
  338. package/src/headers/16/node_sockaddr.h +0 -405
  339. package/src/headers/16/node_union_bytes.h +0 -103
  340. package/src/headers/16/node_url.h +0 -205
  341. package/src/headers/16/node_v8.h +0 -41
  342. package/src/headers/16/node_v8_platform-inl.h +0 -194
  343. package/src/headers/16/node_version.h +0 -98
  344. package/src/headers/16/node_wasi.h +0 -108
  345. package/src/headers/16/node_watchdog.h +0 -152
  346. package/src/headers/16/node_win32_etw_provider-inl.h +0 -288
  347. package/src/headers/16/node_win32_etw_provider.h +0 -99
  348. package/src/headers/16/node_worker.h +0 -145
  349. package/src/headers/16/req_wrap.h +0 -77
  350. package/src/headers/16/spawn_sync.h +0 -242
  351. package/src/headers/16/stream_base-inl.h +0 -303
  352. package/src/headers/16/stream_base.h +0 -454
  353. package/src/headers/16/stream_pipe.h +0 -73
  354. package/src/headers/16/string_bytes.h +0 -122
  355. package/src/headers/16/string_decoder-inl.h +0 -37
  356. package/src/headers/16/string_search.h +0 -638
  357. package/src/headers/16/tcp_wrap.h +0 -103
  358. package/src/headers/16/threadpoolwork-inl.h +0 -57
  359. package/src/headers/16/timer_wrap.h +0 -84
  360. package/src/headers/16/tracing/agent.h +0 -195
  361. package/src/headers/16/tracing/node_trace_buffer.h +0 -83
  362. package/src/headers/16/tracing/node_trace_writer.h +0 -75
  363. package/src/headers/16/tracing/trace_event.h +0 -720
  364. package/src/headers/16/tracing/trace_event_common.h +0 -1109
  365. package/src/headers/16/tracing/traced_value.h +0 -70
  366. package/src/headers/16/tty_wrap.h +0 -66
  367. package/src/headers/16/util-inl.h +0 -575
  368. package/src/headers/16/util.h +0 -824
  369. package/src/headers/16/v8abbr.h +0 -123
  370. package/src/headers/16/v8ustack.d +0 -695
  371. package/src/headers/18/aliased_buffer.h +0 -315
  372. package/src/headers/18/aliased_struct-inl.h +0 -54
  373. package/src/headers/18/aliased_struct.h +0 -63
  374. package/src/headers/18/base64-inl.h +0 -189
  375. package/src/headers/18/base64.h +0 -69
  376. package/src/headers/18/base_object-inl.h +0 -374
  377. package/src/headers/18/callback_queue-inl.h +0 -97
  378. package/src/headers/18/callback_queue.h +0 -78
  379. package/src/headers/18/cares_wrap.h +0 -523
  380. package/src/headers/18/connect_wrap.h +0 -26
  381. package/src/headers/18/connection_wrap.h +0 -30
  382. package/src/headers/18/crypto/crypto_aes.h +0 -89
  383. package/src/headers/18/crypto/crypto_bio.h +0 -194
  384. package/src/headers/18/crypto/crypto_cipher.h +0 -291
  385. package/src/headers/18/crypto/crypto_clienthello-inl.h +0 -90
  386. package/src/headers/18/crypto/crypto_common.h +0 -151
  387. package/src/headers/18/crypto/crypto_dh.h +0 -156
  388. package/src/headers/18/crypto/crypto_dsa.h +0 -77
  389. package/src/headers/18/crypto/crypto_ec.h +0 -170
  390. package/src/headers/18/crypto/crypto_groups.h +0 -415
  391. package/src/headers/18/crypto/crypto_hash.h +0 -89
  392. package/src/headers/18/crypto/crypto_hkdf.h +0 -65
  393. package/src/headers/18/crypto/crypto_hmac.h +0 -94
  394. package/src/headers/18/crypto/crypto_keygen.h +0 -305
  395. package/src/headers/18/crypto/crypto_pbkdf2.h +0 -76
  396. package/src/headers/18/crypto/crypto_random.h +0 -130
  397. package/src/headers/18/crypto/crypto_rsa.h +0 -141
  398. package/src/headers/18/crypto/crypto_scrypt.h +0 -87
  399. package/src/headers/18/crypto/crypto_sig.h +0 -168
  400. package/src/headers/18/crypto/crypto_spkac.h +0 -21
  401. package/src/headers/18/crypto/crypto_timing.h +0 -20
  402. package/src/headers/18/crypto/crypto_x509.h +0 -143
  403. package/src/headers/18/debug_utils-inl.h +0 -223
  404. package/src/headers/18/diagnosticfilename-inl.h +0 -33
  405. package/src/headers/18/env-inl.h +0 -1308
  406. package/src/headers/18/env.h +0 -1667
  407. package/src/headers/18/inspector_agent.h +0 -144
  408. package/src/headers/18/inspector_io.h +0 -78
  409. package/src/headers/18/inspector_profiler.h +0 -149
  410. package/src/headers/18/inspector_socket.h +0 -60
  411. package/src/headers/18/inspector_socket_server.h +0 -110
  412. package/src/headers/18/js_stream.h +0 -52
  413. package/src/headers/18/json_utils.h +0 -161
  414. package/src/headers/18/memory_tracker.h +0 -284
  415. package/src/headers/18/module_wrap.h +0 -116
  416. package/src/headers/18/node_binding.h +0 -99
  417. package/src/headers/18/node_context_data.h +0 -44
  418. package/src/headers/18/node_contextify.h +0 -196
  419. package/src/headers/18/node_crypto.h +0 -57
  420. package/src/headers/18/node_dir.h +0 -52
  421. package/src/headers/18/node_dtrace.h +0 -86
  422. package/src/headers/18/node_external_reference.h +0 -145
  423. package/src/headers/18/node_file.h +0 -426
  424. package/src/headers/18/node_http2_state.h +0 -149
  425. package/src/headers/18/node_i18n.h +0 -145
  426. package/src/headers/18/node_mem-inl.h +0 -112
  427. package/src/headers/18/node_mem.h +0 -45
  428. package/src/headers/18/node_mutex.h +0 -323
  429. package/src/headers/18/node_native_module.h +0 -109
  430. package/src/headers/18/node_native_module_env.h +0 -71
  431. package/src/headers/18/node_object_wrap.h +0 -132
  432. package/src/headers/18/node_process-inl.h +0 -26
  433. package/src/headers/18/node_report.h +0 -47
  434. package/src/headers/18/node_revert.h +0 -82
  435. package/src/headers/18/node_root_certs.h +0 -3246
  436. package/src/headers/18/node_snapshot_builder.h +0 -43
  437. package/src/headers/18/node_snapshotable.h +0 -130
  438. package/src/headers/18/node_stat_watcher.h +0 -72
  439. package/src/headers/18/node_union_bytes.h +0 -103
  440. package/src/headers/18/node_url.h +0 -205
  441. package/src/headers/18/node_v8.h +0 -41
  442. package/src/headers/18/node_v8_platform-inl.h +0 -194
  443. package/src/headers/18/node_wasi.h +0 -108
  444. package/src/headers/18/node_watchdog.h +0 -152
  445. package/src/headers/18/node_win32_etw_provider-inl.h +0 -288
  446. package/src/headers/18/node_win32_etw_provider.h +0 -99
  447. package/src/headers/18/pipe_wrap.h +0 -80
  448. package/src/headers/18/req_wrap-inl.h +0 -170
  449. package/src/headers/18/spawn_sync.h +0 -242
  450. package/src/headers/18/stream_wrap.h +0 -133
  451. package/src/headers/18/string_decoder-inl.h +0 -37
  452. package/src/headers/18/string_decoder.h +0 -50
  453. package/src/headers/18/string_search.h +0 -638
  454. package/src/headers/18/tracing/node_trace_buffer.h +0 -83
  455. package/src/headers/18/tracing/node_trace_writer.h +0 -75
  456. package/src/headers/18/tracing/trace_event_common.h +0 -1109
  457. package/src/headers/18/tracing/traced_value.h +0 -70
  458. package/src/headers/18/udp_wrap.h +0 -227
  459. package/src/headers/18/v8abbr.h +0 -123
  460. /package/src/headers/{14 → 22}/aliased_struct-inl.h +0 -0
  461. /package/src/headers/{14 → 22}/aliased_struct.h +0 -0
  462. /package/src/headers/{16 → 22}/callback_queue-inl.h +0 -0
  463. /package/src/headers/{14 → 22}/connect_wrap.h +0 -0
  464. /package/src/headers/{14 → 22}/connection_wrap.h +0 -0
  465. /package/src/headers/{14 → 22}/diagnosticfilename-inl.h +0 -0
  466. /package/src/headers/{18 → 22}/histogram-inl.h +0 -0
  467. /package/src/headers/{14 → 22}/inspector_io.h +0 -0
  468. /package/src/headers/{14 → 22}/inspector_socket.h +0 -0
  469. /package/src/headers/{14 → 22}/inspector_socket_server.h +0 -0
  470. /package/src/headers/{14 → 22}/js_stream.h +0 -0
  471. /package/src/headers/{14 → 22}/node_dir.h +0 -0
  472. /package/src/headers/{14 → 22}/node_mem-inl.h +0 -0
  473. /package/src/headers/{16 → 22}/node_mem.h +0 -0
  474. /package/src/headers/{16 → 22}/node_mutex.h +0 -0
  475. /package/src/headers/{14 → 22}/node_object_wrap.h +0 -0
  476. /package/src/headers/{16 → 22}/node_process-inl.h +0 -0
  477. /package/src/headers/{18 → 22}/node_sockaddr-inl.h +0 -0
  478. /package/src/headers/{18 → 22}/node_wasm_web_api.h +0 -0
  479. /package/src/headers/{16 → 22}/pipe_wrap.h +0 -0
  480. /package/src/headers/{18 → 22}/req_wrap.h +0 -0
  481. /package/src/headers/{18 → 22}/timer_wrap-inl.h +0 -0
  482. /package/src/headers/{18 → 22}/timer_wrap.h +0 -0
  483. /package/src/headers/{18 → 22}/tracing/agent.h +0 -0
  484. /package/src/headers/{14 → 22}/tracing/trace_event_common.h +0 -0
  485. /package/src/headers/{18 → 22}/tty_wrap.h +0 -0
@@ -1,1032 +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 __attribute__((visibility("default")))
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
- #if (__GNUC__ >= 8) && !defined(__clang__)
64
- #pragma GCC diagnostic push
65
- #pragma GCC diagnostic ignored "-Wcast-function-type"
66
- #endif
67
- #include "v8.h" // NOLINT(build/include_order)
68
- #if (__GNUC__ >= 8) && !defined(__clang__)
69
- #pragma GCC diagnostic pop
70
- #endif
71
-
72
- #include "v8-platform.h" // NOLINT(build/include_order)
73
- #include "node_version.h" // NODE_MODULE_VERSION
74
-
75
- #include <memory>
76
- #include <functional>
77
-
78
- // We cannot use __POSIX__ in this header because that's only defined when
79
- // building Node.js.
80
- #ifndef _WIN32
81
- #include <signal.h>
82
- #endif // _WIN32
83
-
84
- #define NODE_MAKE_VERSION(major, minor, patch) \
85
- ((major) * 0x1000 + (minor) * 0x100 + (patch))
86
-
87
- #ifdef __clang__
88
- # define NODE_CLANG_AT_LEAST(major, minor, patch) \
89
- (NODE_MAKE_VERSION(major, minor, patch) <= \
90
- NODE_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__))
91
- #else
92
- # define NODE_CLANG_AT_LEAST(major, minor, patch) (0)
93
- #endif
94
-
95
- #ifdef __GNUC__
96
- # define NODE_GNUC_AT_LEAST(major, minor, patch) \
97
- (NODE_MAKE_VERSION(major, minor, patch) <= \
98
- NODE_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__))
99
- #else
100
- # define NODE_GNUC_AT_LEAST(major, minor, patch) (0)
101
- #endif
102
-
103
- #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
104
- # define NODE_DEPRECATED(message, declarator) declarator
105
- #else // NODE_WANT_INTERNALS
106
- # if NODE_CLANG_AT_LEAST(2, 9, 0) || NODE_GNUC_AT_LEAST(4, 5, 0)
107
- # define NODE_DEPRECATED(message, declarator) \
108
- __attribute__((deprecated(message))) declarator
109
- # elif defined(_MSC_VER)
110
- # define NODE_DEPRECATED(message, declarator) \
111
- __declspec(deprecated) declarator
112
- # else
113
- # define NODE_DEPRECATED(message, declarator) declarator
114
- # endif
115
- #endif
116
-
117
- // Forward-declare libuv loop
118
- struct uv_loop_s;
119
-
120
- // Forward-declare these functions now to stop MSVS from becoming
121
- // terminally confused when it's done in node_internals.h
122
- namespace node {
123
-
124
- namespace tracing {
125
-
126
- class TracingController;
127
-
128
- }
129
-
130
- NODE_EXTERN v8::Local<v8::Value> ErrnoException(v8::Isolate* isolate,
131
- int errorno,
132
- const char* syscall = nullptr,
133
- const char* message = nullptr,
134
- const char* path = nullptr);
135
- NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
136
- int errorno,
137
- const char* syscall = nullptr,
138
- const char* message = nullptr,
139
- const char* path = nullptr,
140
- const char* dest = nullptr);
141
-
142
- NODE_DEPRECATED("Use ErrnoException(isolate, ...)",
143
- inline v8::Local<v8::Value> ErrnoException(
144
- int errorno,
145
- const char* syscall = nullptr,
146
- const char* message = nullptr,
147
- const char* path = nullptr) {
148
- return ErrnoException(v8::Isolate::GetCurrent(),
149
- errorno,
150
- syscall,
151
- message,
152
- path);
153
- })
154
-
155
- NODE_DEPRECATED("Use UVException(isolate, ...)",
156
- inline v8::Local<v8::Value> UVException(int errorno,
157
- const char* syscall = nullptr,
158
- const char* message = nullptr,
159
- const char* path = nullptr) {
160
- return UVException(v8::Isolate::GetCurrent(),
161
- errorno,
162
- syscall,
163
- message,
164
- path);
165
- })
166
-
167
- /*
168
- * These methods need to be called in a HandleScope.
169
- *
170
- * It is preferred that you use the `MakeCallback` overloads taking
171
- * `async_context` arguments.
172
- */
173
-
174
- NODE_DEPRECATED("Use MakeCallback(..., async_context)",
175
- NODE_EXTERN v8::Local<v8::Value> MakeCallback(
176
- v8::Isolate* isolate,
177
- v8::Local<v8::Object> recv,
178
- const char* method,
179
- int argc,
180
- v8::Local<v8::Value>* argv));
181
- NODE_DEPRECATED("Use MakeCallback(..., async_context)",
182
- NODE_EXTERN v8::Local<v8::Value> MakeCallback(
183
- v8::Isolate* isolate,
184
- v8::Local<v8::Object> recv,
185
- v8::Local<v8::String> symbol,
186
- int argc,
187
- v8::Local<v8::Value>* argv));
188
- NODE_DEPRECATED("Use MakeCallback(..., async_context)",
189
- NODE_EXTERN v8::Local<v8::Value> MakeCallback(
190
- v8::Isolate* isolate,
191
- v8::Local<v8::Object> recv,
192
- v8::Local<v8::Function> callback,
193
- int argc,
194
- v8::Local<v8::Value>* argv));
195
-
196
- } // namespace node
197
-
198
- #include <cassert>
199
- #include <cstdint>
200
-
201
- #ifndef NODE_STRINGIFY
202
- # define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)
203
- # define NODE_STRINGIFY_HELPER(n) #n
204
- #endif
205
-
206
- #ifdef _WIN32
207
- #if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
208
- typedef intptr_t ssize_t;
209
- # define _SSIZE_T_
210
- # define _SSIZE_T_DEFINED
211
- #endif
212
- #else // !_WIN32
213
- # include <sys/types.h> // size_t, ssize_t
214
- #endif // _WIN32
215
-
216
-
217
- namespace node {
218
-
219
- class IsolateData;
220
- class Environment;
221
-
222
- // TODO(addaleax): Officially deprecate this and replace it with something
223
- // better suited for a public embedder API.
224
- NODE_EXTERN int Start(int argc, char* argv[]);
225
-
226
- // Tear down Node.js while it is running (there are active handles
227
- // in the loop and / or actively executing JavaScript code).
228
- NODE_EXTERN int Stop(Environment* env);
229
-
230
- // It is recommended to use InitializeNodeWithArgs() instead as an embedder.
231
- // Init() calls InitializeNodeWithArgs() and exits the process with the exit
232
- // code returned from it.
233
- NODE_DEPRECATED("Use InitializeNodeWithArgs() instead",
234
- NODE_EXTERN void Init(int* argc,
235
- const char** argv,
236
- int* exec_argc,
237
- const char*** exec_argv));
238
- // Set up per-process state needed to run Node.js. This will consume arguments
239
- // from argv, fill exec_argv, and possibly add errors resulting from parsing
240
- // the arguments to `errors`. The return value is a suggested exit code for the
241
- // program; If it is 0, then initializing Node.js succeeded.
242
- NODE_EXTERN int InitializeNodeWithArgs(std::vector<std::string>* argv,
243
- std::vector<std::string>* exec_argv,
244
- std::vector<std::string>* errors);
245
-
246
- enum OptionEnvvarSettings {
247
- kAllowedInEnvironment,
248
- kDisallowedInEnvironment
249
- };
250
-
251
- NODE_EXTERN int ProcessGlobalArgs(std::vector<std::string>* args,
252
- std::vector<std::string>* exec_args,
253
- std::vector<std::string>* errors,
254
- OptionEnvvarSettings settings);
255
-
256
- class NodeArrayBufferAllocator;
257
-
258
- // An ArrayBuffer::Allocator class with some Node.js-specific tweaks. If you do
259
- // not have to use another allocator, using this class is recommended:
260
- // - It supports Buffer.allocUnsafe() and Buffer.allocUnsafeSlow() with
261
- // uninitialized memory.
262
- // - It supports transferring, rather than copying, ArrayBuffers when using
263
- // MessagePorts.
264
- class NODE_EXTERN ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
265
- public:
266
- // If `always_debug` is true, create an ArrayBuffer::Allocator instance
267
- // that performs additional integrity checks (e.g. make sure that only memory
268
- // that was allocated by the it is also freed by it).
269
- // This can also be set using the --debug-arraybuffer-allocations flag.
270
- static std::unique_ptr<ArrayBufferAllocator> Create(
271
- bool always_debug = false);
272
-
273
- private:
274
- virtual NodeArrayBufferAllocator* GetImpl() = 0;
275
-
276
- friend class IsolateData;
277
- };
278
-
279
- // Legacy equivalents for ArrayBufferAllocator::Create().
280
- NODE_EXTERN ArrayBufferAllocator* CreateArrayBufferAllocator();
281
- NODE_EXTERN void FreeArrayBufferAllocator(ArrayBufferAllocator* allocator);
282
-
283
- class NODE_EXTERN IsolatePlatformDelegate {
284
- public:
285
- virtual std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner() = 0;
286
- virtual bool IdleTasksEnabled() = 0;
287
- };
288
-
289
- class NODE_EXTERN MultiIsolatePlatform : public v8::Platform {
290
- public:
291
- ~MultiIsolatePlatform() override = default;
292
- // Returns true if work was dispatched or executed. New tasks that are
293
- // posted during flushing of the queue are postponed until the next
294
- // flushing.
295
- virtual bool FlushForegroundTasks(v8::Isolate* isolate) = 0;
296
- virtual void DrainTasks(v8::Isolate* isolate) = 0;
297
-
298
- // TODO(addaleax): Remove this, it is unnecessary.
299
- // This would currently be called before `UnregisterIsolate()` but will be
300
- // folded into it in the future.
301
- virtual void CancelPendingDelayedTasks(v8::Isolate* isolate);
302
-
303
- // This needs to be called between the calls to `Isolate::Allocate()` and
304
- // `Isolate::Initialize()`, so that initialization can already start
305
- // using the platform.
306
- // When using `NewIsolate()`, this is taken care of by that function.
307
- // This function may only be called once per `Isolate`.
308
- virtual void RegisterIsolate(v8::Isolate* isolate,
309
- struct uv_loop_s* loop) = 0;
310
- // This method can be used when an application handles task scheduling on its
311
- // own through `IsolatePlatformDelegate`. Upon registering an isolate with
312
- // this overload any other method in this class with the exception of
313
- // `UnregisterIsolate` *must not* be used on that isolate.
314
- virtual void RegisterIsolate(v8::Isolate* isolate,
315
- IsolatePlatformDelegate* delegate) = 0;
316
-
317
- // This function may only be called once per `Isolate`, and discard any
318
- // pending delayed tasks scheduled for that isolate.
319
- // This needs to be called right before calling `Isolate::Dispose()`.
320
- virtual void UnregisterIsolate(v8::Isolate* isolate) = 0;
321
-
322
- // The platform should call the passed function once all state associated
323
- // with the given isolate has been cleaned up. This can, but does not have to,
324
- // happen asynchronously.
325
- virtual void AddIsolateFinishedCallback(v8::Isolate* isolate,
326
- void (*callback)(void*),
327
- void* data) = 0;
328
-
329
- static std::unique_ptr<MultiIsolatePlatform> Create(
330
- int thread_pool_size,
331
- v8::TracingController* tracing_controller = nullptr);
332
- };
333
-
334
- enum IsolateSettingsFlags {
335
- MESSAGE_LISTENER_WITH_ERROR_LEVEL = 1 << 0,
336
- DETAILED_SOURCE_POSITIONS_FOR_PROFILING = 1 << 1
337
- };
338
-
339
- struct IsolateSettings {
340
- uint64_t flags = MESSAGE_LISTENER_WITH_ERROR_LEVEL |
341
- DETAILED_SOURCE_POSITIONS_FOR_PROFILING;
342
- v8::MicrotasksPolicy policy = v8::MicrotasksPolicy::kExplicit;
343
-
344
- // Error handling callbacks
345
- v8::Isolate::AbortOnUncaughtExceptionCallback
346
- should_abort_on_uncaught_exception_callback = nullptr;
347
- v8::FatalErrorCallback fatal_error_callback = nullptr;
348
- v8::PrepareStackTraceCallback prepare_stack_trace_callback = nullptr;
349
-
350
- // Miscellaneous callbacks
351
- v8::PromiseRejectCallback promise_reject_callback = nullptr;
352
- v8::AllowWasmCodeGenerationCallback
353
- allow_wasm_code_generation_callback = nullptr;
354
- };
355
-
356
- // Overriding IsolateSettings may produce unexpected behavior
357
- // in Node.js core functionality, so proceed at your own risk.
358
- NODE_EXTERN void SetIsolateUpForNode(v8::Isolate* isolate,
359
- const IsolateSettings& settings);
360
-
361
- // Set a number of callbacks for the `isolate`, in particular the Node.js
362
- // uncaught exception listener.
363
- NODE_EXTERN void SetIsolateUpForNode(v8::Isolate* isolate);
364
-
365
- // Creates a new isolate with Node.js-specific settings.
366
- // This is a convenience method equivalent to using SetIsolateCreateParams(),
367
- // Isolate::Allocate(), MultiIsolatePlatform::RegisterIsolate(),
368
- // Isolate::Initialize(), and SetIsolateUpForNode().
369
- NODE_EXTERN v8::Isolate* NewIsolate(ArrayBufferAllocator* allocator,
370
- struct uv_loop_s* event_loop);
371
- NODE_EXTERN v8::Isolate* NewIsolate(ArrayBufferAllocator* allocator,
372
- struct uv_loop_s* event_loop,
373
- MultiIsolatePlatform* platform);
374
- NODE_EXTERN v8::Isolate* NewIsolate(
375
- std::shared_ptr<ArrayBufferAllocator> allocator,
376
- struct uv_loop_s* event_loop,
377
- MultiIsolatePlatform* platform);
378
-
379
- // Creates a new context with Node.js-specific tweaks.
380
- NODE_EXTERN v8::Local<v8::Context> NewContext(
381
- v8::Isolate* isolate,
382
- v8::Local<v8::ObjectTemplate> object_template =
383
- v8::Local<v8::ObjectTemplate>());
384
-
385
- // Runs Node.js-specific tweaks on an already constructed context
386
- // Return value indicates success of operation
387
- NODE_EXTERN bool InitializeContext(v8::Local<v8::Context> context);
388
-
389
- // If `platform` is passed, it will be used to register new Worker instances.
390
- // It can be `nullptr`, in which case creating new Workers inside of
391
- // Environments that use this `IsolateData` will not work.
392
- NODE_EXTERN IsolateData* CreateIsolateData(
393
- v8::Isolate* isolate,
394
- struct uv_loop_s* loop,
395
- MultiIsolatePlatform* platform = nullptr,
396
- ArrayBufferAllocator* allocator = nullptr);
397
- NODE_EXTERN void FreeIsolateData(IsolateData* isolate_data);
398
-
399
- struct ThreadId {
400
- uint64_t id = static_cast<uint64_t>(-1);
401
- };
402
- NODE_EXTERN ThreadId AllocateEnvironmentThreadId();
403
-
404
- namespace EnvironmentFlags {
405
- enum Flags : uint64_t {
406
- kNoFlags = 0,
407
- // Use the default behaviour for Node.js instances.
408
- kDefaultFlags = 1 << 0,
409
- // Controls whether this Environment is allowed to affect per-process state
410
- // (e.g. cwd, process title, uid, etc.).
411
- // This is set when using kDefaultFlags.
412
- kOwnsProcessState = 1 << 1,
413
- // Set if this Environment instance is associated with the global inspector
414
- // handling code (i.e. listening on SIGUSR1).
415
- // This is set when using kDefaultFlags.
416
- kOwnsInspector = 1 << 2
417
- };
418
- } // namespace EnvironmentFlags
419
-
420
- struct InspectorParentHandle {
421
- virtual ~InspectorParentHandle();
422
- };
423
-
424
- // TODO(addaleax): Maybe move per-Environment options parsing here.
425
- // Returns nullptr when the Environment cannot be created e.g. there are
426
- // pending JavaScript exceptions.
427
- // It is recommended to use the second variant taking a flags argument.
428
- NODE_DEPRECATED("Use overload taking a flags argument",
429
- NODE_EXTERN Environment* CreateEnvironment(IsolateData* isolate_data,
430
- v8::Local<v8::Context> context,
431
- int argc,
432
- const char* const* argv,
433
- int exec_argc,
434
- const char* const* exec_argv));
435
- NODE_EXTERN Environment* CreateEnvironment(
436
- IsolateData* isolate_data,
437
- v8::Local<v8::Context> context,
438
- const std::vector<std::string>& args,
439
- const std::vector<std::string>& exec_args,
440
- EnvironmentFlags::Flags flags = EnvironmentFlags::kDefaultFlags,
441
- ThreadId thread_id = {} /* allocates a thread id automatically */,
442
- std::unique_ptr<InspectorParentHandle> inspector_parent_handle = {});
443
-
444
- // Returns a handle that can be passed to `LoadEnvironment()`, making the
445
- // child Environment accessible to the inspector as if it were a Node.js Worker.
446
- // `child_thread_id` can be created using `AllocateEnvironmentThreadId()`
447
- // and then later passed on to `CreateEnvironment()` to create the child
448
- // Environment, together with the inspector handle.
449
- // This method should not be called while the parent Environment is active
450
- // on another thread.
451
- NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
452
- Environment* parent_env,
453
- ThreadId child_thread_id,
454
- const char* child_url);
455
-
456
- struct StartExecutionCallbackInfo {
457
- v8::Local<v8::Object> process_object;
458
- v8::Local<v8::Function> native_require;
459
- };
460
-
461
- using StartExecutionCallback =
462
- std::function<v8::MaybeLocal<v8::Value>(const StartExecutionCallbackInfo&)>;
463
-
464
- NODE_DEPRECATED("Use variants returning MaybeLocal<> instead",
465
- NODE_EXTERN void LoadEnvironment(Environment* env));
466
- // The `InspectorParentHandle` arguments here are ignored and not used.
467
- // For passing `InspectorParentHandle`, use `CreateEnvironment()`.
468
- NODE_EXTERN v8::MaybeLocal<v8::Value> LoadEnvironment(
469
- Environment* env,
470
- StartExecutionCallback cb,
471
- std::unique_ptr<InspectorParentHandle> ignored_donotuse_removeme = {});
472
- NODE_EXTERN v8::MaybeLocal<v8::Value> LoadEnvironment(
473
- Environment* env,
474
- const char* main_script_source_utf8,
475
- std::unique_ptr<InspectorParentHandle> ignored_donotuse_removeme = {});
476
- NODE_EXTERN void FreeEnvironment(Environment* env);
477
-
478
- // Set a callback that is called when process.exit() is called from JS,
479
- // overriding the default handler.
480
- // It receives the Environment* instance and the exit code as arguments.
481
- // This could e.g. call Stop(env); in order to terminate execution and stop
482
- // the event loop.
483
- // The default handler disposes of the global V8 platform instance, if one is
484
- // being used, and calls exit().
485
- NODE_EXTERN void SetProcessExitHandler(
486
- Environment* env,
487
- std::function<void(Environment*, int)>&& handler);
488
- NODE_EXTERN void DefaultProcessExitHandler(Environment* env, int exit_code);
489
-
490
- // This may return nullptr if context is not associated with a Node instance.
491
- NODE_EXTERN Environment* GetCurrentEnvironment(v8::Local<v8::Context> context);
492
-
493
- // This returns the MultiIsolatePlatform used in the main thread of Node.js.
494
- // If NODE_USE_V8_PLATFORM has not been defined when Node.js was built,
495
- // it returns nullptr.
496
- NODE_DEPRECATED("Use GetMultiIsolatePlatform(env) instead",
497
- NODE_EXTERN MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform());
498
- // This returns the MultiIsolatePlatform used for an Environment or IsolateData
499
- // instance, if one exists.
500
- NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(Environment* env);
501
- NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env);
502
-
503
- // Legacy variants of MultiIsolatePlatform::Create().
504
- NODE_DEPRECATED("Use variant taking a v8::TracingController* pointer instead",
505
- NODE_EXTERN MultiIsolatePlatform* CreatePlatform(
506
- int thread_pool_size,
507
- node::tracing::TracingController* tracing_controller));
508
- NODE_EXTERN MultiIsolatePlatform* CreatePlatform(
509
- int thread_pool_size,
510
- v8::TracingController* tracing_controller);
511
- NODE_EXTERN void FreePlatform(MultiIsolatePlatform* platform);
512
-
513
- // Get/set the currently active tracing controller. Using CreatePlatform()
514
- // will implicitly set this by default. This is global and should be initialized
515
- // along with the v8::Platform instance that is being used. `controller`
516
- // is allowed to be `nullptr`.
517
- // This is used for tracing events from Node.js itself. V8 uses the tracing
518
- // controller returned from the active `v8::Platform` instance.
519
- NODE_EXTERN v8::TracingController* GetTracingController();
520
- NODE_EXTERN void SetTracingController(v8::TracingController* controller);
521
-
522
- NODE_EXTERN void EmitBeforeExit(Environment* env);
523
- NODE_EXTERN int EmitExit(Environment* env);
524
- NODE_EXTERN void RunAtExit(Environment* env);
525
-
526
- // This may return nullptr if the current v8::Context is not associated
527
- // with a Node instance.
528
- NODE_EXTERN struct uv_loop_s* GetCurrentEventLoop(v8::Isolate* isolate);
529
-
530
- /* Converts a unixtime to V8 Date */
531
- NODE_DEPRECATED("Use v8::Date::New() directly",
532
- inline v8::Local<v8::Value> NODE_UNIXTIME_V8(double time) {
533
- return v8::Date::New(
534
- v8::Isolate::GetCurrent()->GetCurrentContext(),
535
- 1000 * time)
536
- .ToLocalChecked();
537
- })
538
- #define NODE_UNIXTIME_V8 node::NODE_UNIXTIME_V8
539
- NODE_DEPRECATED("Use v8::Date::ValueOf() directly",
540
- inline double NODE_V8_UNIXTIME(v8::Local<v8::Date> date) {
541
- return date->ValueOf() / 1000;
542
- })
543
- #define NODE_V8_UNIXTIME node::NODE_V8_UNIXTIME
544
-
545
- #define NODE_DEFINE_CONSTANT(target, constant) \
546
- do { \
547
- v8::Isolate* isolate = target->GetIsolate(); \
548
- v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
549
- v8::Local<v8::String> constant_name = \
550
- v8::String::NewFromUtf8(isolate, #constant, \
551
- v8::NewStringType::kInternalized).ToLocalChecked(); \
552
- v8::Local<v8::Number> constant_value = \
553
- v8::Number::New(isolate, static_cast<double>(constant)); \
554
- v8::PropertyAttribute constant_attributes = \
555
- static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \
556
- (target)->DefineOwnProperty(context, \
557
- constant_name, \
558
- constant_value, \
559
- constant_attributes).Check(); \
560
- } \
561
- while (0)
562
-
563
- #define NODE_DEFINE_HIDDEN_CONSTANT(target, constant) \
564
- do { \
565
- v8::Isolate* isolate = target->GetIsolate(); \
566
- v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
567
- v8::Local<v8::String> constant_name = \
568
- v8::String::NewFromUtf8(isolate, #constant, \
569
- v8::NewStringType::kInternalized) \
570
- .ToLocalChecked(); \
571
- v8::Local<v8::Number> constant_value = \
572
- v8::Number::New(isolate, static_cast<double>(constant)); \
573
- v8::PropertyAttribute constant_attributes = \
574
- static_cast<v8::PropertyAttribute>(v8::ReadOnly | \
575
- v8::DontDelete | \
576
- v8::DontEnum); \
577
- (target)->DefineOwnProperty(context, \
578
- constant_name, \
579
- constant_value, \
580
- constant_attributes).Check(); \
581
- } \
582
- while (0)
583
-
584
- // Used to be a macro, hence the uppercase name.
585
- inline void NODE_SET_METHOD(v8::Local<v8::Template> recv,
586
- const char* name,
587
- v8::FunctionCallback callback) {
588
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
589
- v8::HandleScope handle_scope(isolate);
590
- v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate,
591
- callback);
592
- v8::Local<v8::String> fn_name = v8::String::NewFromUtf8(isolate, name,
593
- v8::NewStringType::kInternalized).ToLocalChecked();
594
- t->SetClassName(fn_name);
595
- recv->Set(fn_name, t);
596
- }
597
-
598
- // Used to be a macro, hence the uppercase name.
599
- inline void NODE_SET_METHOD(v8::Local<v8::Object> recv,
600
- const char* name,
601
- v8::FunctionCallback callback) {
602
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
603
- v8::HandleScope handle_scope(isolate);
604
- v8::Local<v8::Context> context = isolate->GetCurrentContext();
605
- v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate,
606
- callback);
607
- v8::Local<v8::Function> fn = t->GetFunction(context).ToLocalChecked();
608
- v8::Local<v8::String> fn_name = v8::String::NewFromUtf8(isolate, name,
609
- v8::NewStringType::kInternalized).ToLocalChecked();
610
- fn->SetName(fn_name);
611
- recv->Set(context, fn_name, fn).Check();
612
- }
613
- #define NODE_SET_METHOD node::NODE_SET_METHOD
614
-
615
- // Used to be a macro, hence the uppercase name.
616
- // Not a template because it only makes sense for FunctionTemplates.
617
- inline void NODE_SET_PROTOTYPE_METHOD(v8::Local<v8::FunctionTemplate> recv,
618
- const char* name,
619
- v8::FunctionCallback callback) {
620
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
621
- v8::HandleScope handle_scope(isolate);
622
- v8::Local<v8::Signature> s = v8::Signature::New(isolate, recv);
623
- v8::Local<v8::FunctionTemplate> t =
624
- v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), s);
625
- v8::Local<v8::String> fn_name = v8::String::NewFromUtf8(isolate, name,
626
- v8::NewStringType::kInternalized).ToLocalChecked();
627
- t->SetClassName(fn_name);
628
- recv->PrototypeTemplate()->Set(fn_name, t);
629
- }
630
- #define NODE_SET_PROTOTYPE_METHOD node::NODE_SET_PROTOTYPE_METHOD
631
-
632
- // BINARY is a deprecated alias of LATIN1.
633
- enum encoding {ASCII, UTF8, BASE64, UCS2, BINARY, HEX, BUFFER, LATIN1 = BINARY};
634
-
635
- NODE_EXTERN enum encoding ParseEncoding(
636
- v8::Isolate* isolate,
637
- v8::Local<v8::Value> encoding_v,
638
- enum encoding default_encoding = LATIN1);
639
-
640
- NODE_EXTERN void FatalException(v8::Isolate* isolate,
641
- const v8::TryCatch& try_catch);
642
-
643
- NODE_EXTERN v8::Local<v8::Value> Encode(v8::Isolate* isolate,
644
- const char* buf,
645
- size_t len,
646
- enum encoding encoding = LATIN1);
647
-
648
- // Warning: This reverses endianness on Big Endian platforms, even though the
649
- // signature using uint16_t implies that it should not.
650
- NODE_EXTERN v8::Local<v8::Value> Encode(v8::Isolate* isolate,
651
- const uint16_t* buf,
652
- size_t len);
653
-
654
- // Returns -1 if the handle was not valid for decoding
655
- NODE_EXTERN ssize_t DecodeBytes(v8::Isolate* isolate,
656
- v8::Local<v8::Value>,
657
- enum encoding encoding = LATIN1);
658
- // returns bytes written.
659
- NODE_EXTERN ssize_t DecodeWrite(v8::Isolate* isolate,
660
- char* buf,
661
- size_t buflen,
662
- v8::Local<v8::Value>,
663
- enum encoding encoding = LATIN1);
664
- #ifdef _WIN32
665
- NODE_EXTERN v8::Local<v8::Value> WinapiErrnoException(
666
- v8::Isolate* isolate,
667
- int errorno,
668
- const char* syscall = nullptr,
669
- const char* msg = "",
670
- const char* path = nullptr);
671
- #endif
672
-
673
- const char* signo_string(int errorno);
674
-
675
-
676
- typedef void (*addon_register_func)(
677
- v8::Local<v8::Object> exports,
678
- v8::Local<v8::Value> module,
679
- void* priv);
680
-
681
- typedef void (*addon_context_register_func)(
682
- v8::Local<v8::Object> exports,
683
- v8::Local<v8::Value> module,
684
- v8::Local<v8::Context> context,
685
- void* priv);
686
-
687
- enum ModuleFlags {
688
- kLinked = 0x02
689
- };
690
-
691
- struct node_module {
692
- int nm_version;
693
- unsigned int nm_flags;
694
- void* nm_dso_handle;
695
- const char* nm_filename;
696
- node::addon_register_func nm_register_func;
697
- node::addon_context_register_func nm_context_register_func;
698
- const char* nm_modname;
699
- void* nm_priv;
700
- struct node_module* nm_link;
701
- };
702
-
703
- extern "C" NODE_EXTERN void node_module_register(void* mod);
704
-
705
- #ifdef _WIN32
706
- # define NODE_MODULE_EXPORT __declspec(dllexport)
707
- #else
708
- # define NODE_MODULE_EXPORT __attribute__((visibility("default")))
709
- #endif
710
-
711
- #ifdef NODE_SHARED_MODE
712
- # define NODE_CTOR_PREFIX
713
- #else
714
- # define NODE_CTOR_PREFIX static
715
- #endif
716
-
717
- #if defined(_MSC_VER)
718
- #pragma section(".CRT$XCU", read)
719
- #define NODE_C_CTOR(fn) \
720
- NODE_CTOR_PREFIX void __cdecl fn(void); \
721
- __declspec(dllexport, allocate(".CRT$XCU")) \
722
- void (__cdecl*fn ## _)(void) = fn; \
723
- NODE_CTOR_PREFIX void __cdecl fn(void)
724
- #else
725
- #define NODE_C_CTOR(fn) \
726
- NODE_CTOR_PREFIX void fn(void) __attribute__((constructor)); \
727
- NODE_CTOR_PREFIX void fn(void)
728
- #endif
729
-
730
- #define NODE_MODULE_X(modname, regfunc, priv, flags) \
731
- extern "C" { \
732
- static node::node_module _module = \
733
- { \
734
- NODE_MODULE_VERSION, \
735
- flags, \
736
- NULL, /* NOLINT (readability/null_usage) */ \
737
- __FILE__, \
738
- (node::addon_register_func) (regfunc), \
739
- NULL, /* NOLINT (readability/null_usage) */ \
740
- NODE_STRINGIFY(modname), \
741
- priv, \
742
- NULL /* NOLINT (readability/null_usage) */ \
743
- }; \
744
- NODE_C_CTOR(_register_ ## modname) { \
745
- node_module_register(&_module); \
746
- } \
747
- }
748
-
749
- #define NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, priv, flags) \
750
- extern "C" { \
751
- static node::node_module _module = \
752
- { \
753
- NODE_MODULE_VERSION, \
754
- flags, \
755
- NULL, /* NOLINT (readability/null_usage) */ \
756
- __FILE__, \
757
- NULL, /* NOLINT (readability/null_usage) */ \
758
- (node::addon_context_register_func) (regfunc), \
759
- NODE_STRINGIFY(modname), \
760
- priv, \
761
- NULL /* NOLINT (readability/null_usage) */ \
762
- }; \
763
- NODE_C_CTOR(_register_ ## modname) { \
764
- node_module_register(&_module); \
765
- } \
766
- }
767
-
768
- // Usage: `NODE_MODULE(NODE_GYP_MODULE_NAME, InitializerFunction)`
769
- // If no NODE_MODULE is declared, Node.js looks for the well-known
770
- // symbol `node_register_module_v${NODE_MODULE_VERSION}`.
771
- #define NODE_MODULE(modname, regfunc) \
772
- NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
773
-
774
- #define NODE_MODULE_CONTEXT_AWARE(modname, regfunc) \
775
- /* NOLINTNEXTLINE (readability/null_usage) */ \
776
- NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, 0)
777
-
778
- // Embedders can use this type of binding for statically linked native bindings.
779
- // It is used the same way addon bindings are used, except that linked bindings
780
- // can be accessed through `process._linkedBinding(modname)`.
781
- #define NODE_MODULE_LINKED(modname, regfunc) \
782
- /* NOLINTNEXTLINE (readability/null_usage) */ \
783
- NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, \
784
- node::ModuleFlags::kLinked)
785
-
786
- /*
787
- * For backward compatibility in add-on modules.
788
- */
789
- #define NODE_MODULE_DECL /* nothing */
790
-
791
- #define NODE_MODULE_INITIALIZER_BASE node_register_module_v
792
-
793
- #define NODE_MODULE_INITIALIZER_X(base, version) \
794
- NODE_MODULE_INITIALIZER_X_HELPER(base, version)
795
-
796
- #define NODE_MODULE_INITIALIZER_X_HELPER(base, version) base##version
797
-
798
- #define NODE_MODULE_INITIALIZER \
799
- NODE_MODULE_INITIALIZER_X(NODE_MODULE_INITIALIZER_BASE, \
800
- NODE_MODULE_VERSION)
801
-
802
- #define NODE_MODULE_INIT() \
803
- extern "C" NODE_MODULE_EXPORT void \
804
- NODE_MODULE_INITIALIZER(v8::Local<v8::Object> exports, \
805
- v8::Local<v8::Value> module, \
806
- v8::Local<v8::Context> context); \
807
- NODE_MODULE_CONTEXT_AWARE(NODE_GYP_MODULE_NAME, \
808
- NODE_MODULE_INITIALIZER) \
809
- void NODE_MODULE_INITIALIZER(v8::Local<v8::Object> exports, \
810
- v8::Local<v8::Value> module, \
811
- v8::Local<v8::Context> context)
812
-
813
- // Allows embedders to add a binding to the current Environment* that can be
814
- // accessed through process._linkedBinding() in the target Environment and all
815
- // Worker threads that it creates.
816
- // In each variant, the registration function needs to be usable at least for
817
- // the time during which the Environment exists.
818
- NODE_EXTERN void AddLinkedBinding(Environment* env, const node_module& mod);
819
- NODE_EXTERN void AddLinkedBinding(Environment* env,
820
- const char* name,
821
- addon_context_register_func fn,
822
- void* priv);
823
-
824
- /* Called after the event loop exits but before the VM is disposed.
825
- * Callbacks are run in reverse order of registration, i.e. newest first.
826
- *
827
- * You should always use the three-argument variant (or, for addons,
828
- * AddEnvironmentCleanupHook) in order to avoid relying on global state.
829
- */
830
- NODE_DEPRECATED(
831
- "Use the three-argument variant of AtExit() or AddEnvironmentCleanupHook()",
832
- NODE_EXTERN void AtExit(void (*cb)(void* arg), void* arg = nullptr));
833
-
834
- /* Registers a callback with the passed-in Environment instance. The callback
835
- * is called after the event loop exits, but before the VM is disposed.
836
- * Callbacks are run in reverse order of registration, i.e. newest first.
837
- */
838
- NODE_EXTERN void AtExit(Environment* env,
839
- void (*cb)(void* arg),
840
- void* arg);
841
- NODE_DEPRECATED(
842
- "Use the three-argument variant of AtExit() or AddEnvironmentCleanupHook()",
843
- inline void AtExit(Environment* env,
844
- void (*cb)(void* arg)) {
845
- AtExit(env, cb, nullptr);
846
- })
847
-
848
- typedef double async_id;
849
- struct async_context {
850
- ::node::async_id async_id;
851
- ::node::async_id trigger_async_id;
852
- };
853
-
854
- /* This is a lot like node::AtExit, except that the hooks added via this
855
- * function are run before the AtExit ones and will always be registered
856
- * for the current Environment instance.
857
- * These functions are safe to use in an addon supporting multiple
858
- * threads/isolates. */
859
- NODE_EXTERN void AddEnvironmentCleanupHook(v8::Isolate* isolate,
860
- void (*fun)(void* arg),
861
- void* arg);
862
-
863
- NODE_EXTERN void RemoveEnvironmentCleanupHook(v8::Isolate* isolate,
864
- void (*fun)(void* arg),
865
- void* arg);
866
-
867
- /* Returns the id of the current execution context. If the return value is
868
- * zero then no execution has been set. This will happen if the user handles
869
- * I/O from native code. */
870
- NODE_EXTERN async_id AsyncHooksGetExecutionAsyncId(v8::Isolate* isolate);
871
-
872
- /* Return same value as async_hooks.triggerAsyncId(); */
873
- NODE_EXTERN async_id AsyncHooksGetTriggerAsyncId(v8::Isolate* isolate);
874
-
875
- /* If the native API doesn't inherit from the helper class then the callbacks
876
- * must be triggered manually. This triggers the init() callback. The return
877
- * value is the async id assigned to the resource.
878
- *
879
- * The `trigger_async_id` parameter should correspond to the resource which is
880
- * creating the new resource, which will usually be the return value of
881
- * `AsyncHooksGetTriggerAsyncId()`. */
882
- NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate,
883
- v8::Local<v8::Object> resource,
884
- const char* name,
885
- async_id trigger_async_id = -1);
886
-
887
- NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate,
888
- v8::Local<v8::Object> resource,
889
- v8::Local<v8::String> name,
890
- async_id trigger_async_id = -1);
891
-
892
- /* Emit the destroy() callback. The overload taking an `Environment*` argument
893
- * should be used when the Isolate’s current Context is not associated with
894
- * a Node.js Environment, or when there is no current Context, for example
895
- * when calling this function during garbage collection. In that case, the
896
- * `Environment*` value should have been acquired previously, e.g. through
897
- * `GetCurrentEnvironment()`. */
898
- NODE_EXTERN void EmitAsyncDestroy(v8::Isolate* isolate,
899
- async_context asyncContext);
900
- NODE_EXTERN void EmitAsyncDestroy(Environment* env,
901
- async_context asyncContext);
902
-
903
- class InternalCallbackScope;
904
-
905
- /* This class works like `MakeCallback()` in that it sets up a specific
906
- * asyncContext as the current one and informs the async_hooks and domains
907
- * modules that this context is currently active.
908
- *
909
- * `MakeCallback()` is a wrapper around this class as well as
910
- * `Function::Call()`. Either one of these mechanisms needs to be used for
911
- * top-level calls into JavaScript (i.e. without any existing JS stack).
912
- *
913
- * This object should be stack-allocated to ensure that it is contained in a
914
- * valid HandleScope.
915
- *
916
- * Exceptions happening within this scope will be treated like uncaught
917
- * exceptions. If this behaviour is undesirable, a new `v8::TryCatch` scope
918
- * needs to be created inside of this scope.
919
- */
920
- class NODE_EXTERN CallbackScope {
921
- public:
922
- CallbackScope(v8::Isolate* isolate,
923
- v8::Local<v8::Object> resource,
924
- async_context asyncContext);
925
- ~CallbackScope();
926
-
927
- void operator=(const CallbackScope&) = delete;
928
- void operator=(CallbackScope&&) = delete;
929
- CallbackScope(const CallbackScope&) = delete;
930
- CallbackScope(CallbackScope&&) = delete;
931
-
932
- private:
933
- InternalCallbackScope* private_;
934
- v8::TryCatch try_catch_;
935
- };
936
-
937
- /* An API specific to emit before/after callbacks is unnecessary because
938
- * MakeCallback will automatically call them for you.
939
- *
940
- * These methods may create handles on their own, so run them inside a
941
- * HandleScope.
942
- *
943
- * `asyncId` and `triggerAsyncId` should correspond to the values returned by
944
- * `EmitAsyncInit()` and `AsyncHooksGetTriggerAsyncId()`, respectively, when the
945
- * invoking resource was created. If these values are unknown, 0 can be passed.
946
- * */
947
- NODE_EXTERN
948
- v8::MaybeLocal<v8::Value> MakeCallback(v8::Isolate* isolate,
949
- v8::Local<v8::Object> recv,
950
- v8::Local<v8::Function> callback,
951
- int argc,
952
- v8::Local<v8::Value>* argv,
953
- async_context asyncContext);
954
- NODE_EXTERN
955
- v8::MaybeLocal<v8::Value> MakeCallback(v8::Isolate* isolate,
956
- v8::Local<v8::Object> recv,
957
- const char* method,
958
- int argc,
959
- v8::Local<v8::Value>* argv,
960
- async_context asyncContext);
961
- NODE_EXTERN
962
- v8::MaybeLocal<v8::Value> MakeCallback(v8::Isolate* isolate,
963
- v8::Local<v8::Object> recv,
964
- v8::Local<v8::String> symbol,
965
- int argc,
966
- v8::Local<v8::Value>* argv,
967
- async_context asyncContext);
968
-
969
- /* Helper class users can optionally inherit from. If
970
- * `AsyncResource::MakeCallback()` is used, then all four callbacks will be
971
- * called automatically. */
972
- class NODE_EXTERN AsyncResource {
973
- public:
974
- AsyncResource(v8::Isolate* isolate,
975
- v8::Local<v8::Object> resource,
976
- const char* name,
977
- async_id trigger_async_id = -1);
978
-
979
- virtual ~AsyncResource();
980
-
981
- AsyncResource(const AsyncResource&) = delete;
982
- void operator=(const AsyncResource&) = delete;
983
-
984
- v8::MaybeLocal<v8::Value> MakeCallback(
985
- v8::Local<v8::Function> callback,
986
- int argc,
987
- v8::Local<v8::Value>* argv);
988
-
989
- v8::MaybeLocal<v8::Value> MakeCallback(
990
- const char* method,
991
- int argc,
992
- v8::Local<v8::Value>* argv);
993
-
994
- v8::MaybeLocal<v8::Value> MakeCallback(
995
- v8::Local<v8::String> symbol,
996
- int argc,
997
- v8::Local<v8::Value>* argv);
998
-
999
- v8::Local<v8::Object> get_resource();
1000
- async_id get_async_id() const;
1001
- async_id get_trigger_async_id() const;
1002
-
1003
- protected:
1004
- class NODE_EXTERN CallbackScope : public node::CallbackScope {
1005
- public:
1006
- explicit CallbackScope(AsyncResource* res);
1007
- };
1008
-
1009
- private:
1010
- Environment* env_;
1011
- v8::Global<v8::Object> resource_;
1012
- async_context async_context_;
1013
- };
1014
-
1015
- #ifndef _WIN32
1016
- // Register a signal handler without interrupting any handlers that node
1017
- // itself needs. This does override handlers registered through
1018
- // process.on('SIG...', function() { ... }). The `reset_handler` flag indicates
1019
- // whether the signal handler for the given signal should be reset to its
1020
- // default value before executing the handler (i.e. it works like SA_RESETHAND).
1021
- // The `reset_handler` flag is invalid when `signal` is SIGSEGV.
1022
- NODE_EXTERN
1023
- void RegisterSignalHandler(int signal,
1024
- void (*handler)(int signal,
1025
- siginfo_t* info,
1026
- void* ucontext),
1027
- bool reset_handler = false);
1028
- #endif // _WIN32
1029
-
1030
- } // namespace node
1031
-
1032
- #endif // SRC_NODE_H_