@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,1132 +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
- #include "v8.h" // NOLINT(build/include_order)
64
-
65
- #include "v8-platform.h" // NOLINT(build/include_order)
66
- #include "node_version.h" // NODE_MODULE_VERSION
67
-
68
- #include <memory>
69
- #include <functional>
70
-
71
- // We cannot use __POSIX__ in this header because that's only defined when
72
- // building Node.js.
73
- #ifndef _WIN32
74
- #include <signal.h>
75
- #endif // _WIN32
76
-
77
- #define NODE_MAKE_VERSION(major, minor, patch) \
78
- ((major) * 0x1000 + (minor) * 0x100 + (patch))
79
-
80
- #ifdef __clang__
81
- # define NODE_CLANG_AT_LEAST(major, minor, patch) \
82
- (NODE_MAKE_VERSION(major, minor, patch) <= \
83
- NODE_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__))
84
- #else
85
- # define NODE_CLANG_AT_LEAST(major, minor, patch) (0)
86
- #endif
87
-
88
- #ifdef __GNUC__
89
- # define NODE_GNUC_AT_LEAST(major, minor, patch) \
90
- (NODE_MAKE_VERSION(major, minor, patch) <= \
91
- NODE_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__))
92
- #else
93
- # define NODE_GNUC_AT_LEAST(major, minor, patch) (0)
94
- #endif
95
-
96
- #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
97
- # define NODE_DEPRECATED(message, declarator) declarator
98
- #else // NODE_WANT_INTERNALS
99
- # if NODE_CLANG_AT_LEAST(2, 9, 0) || NODE_GNUC_AT_LEAST(4, 5, 0)
100
- # define NODE_DEPRECATED(message, declarator) \
101
- __attribute__((deprecated(message))) declarator
102
- # elif defined(_MSC_VER)
103
- # define NODE_DEPRECATED(message, declarator) \
104
- __declspec(deprecated) declarator
105
- # else
106
- # define NODE_DEPRECATED(message, declarator) declarator
107
- # endif
108
- #endif
109
-
110
- // Forward-declare libuv loop
111
- struct uv_loop_s;
112
-
113
- struct napi_module;
114
-
115
- // Forward-declare these functions now to stop MSVS from becoming
116
- // terminally confused when it's done in node_internals.h
117
- namespace node {
118
-
119
- namespace tracing {
120
-
121
- class TracingController;
122
-
123
- }
124
-
125
- NODE_EXTERN v8::Local<v8::Value> ErrnoException(v8::Isolate* isolate,
126
- int errorno,
127
- const char* syscall = nullptr,
128
- const char* message = nullptr,
129
- const char* path = nullptr);
130
- NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
131
- int errorno,
132
- const char* syscall = nullptr,
133
- const char* message = nullptr,
134
- const char* path = nullptr,
135
- const char* dest = nullptr);
136
-
137
- NODE_DEPRECATED("Use ErrnoException(isolate, ...)",
138
- inline v8::Local<v8::Value> ErrnoException(
139
- int errorno,
140
- const char* syscall = nullptr,
141
- const char* message = nullptr,
142
- const char* path = nullptr) {
143
- return ErrnoException(v8::Isolate::GetCurrent(),
144
- errorno,
145
- syscall,
146
- message,
147
- path);
148
- })
149
-
150
- NODE_DEPRECATED("Use UVException(isolate, ...)",
151
- inline v8::Local<v8::Value> UVException(int errorno,
152
- const char* syscall = nullptr,
153
- const char* message = nullptr,
154
- const char* path = nullptr) {
155
- return UVException(v8::Isolate::GetCurrent(),
156
- errorno,
157
- syscall,
158
- message,
159
- path);
160
- })
161
-
162
- /*
163
- * These methods need to be called in a HandleScope.
164
- *
165
- * It is preferred that you use the `MakeCallback` overloads taking
166
- * `async_context` arguments.
167
- */
168
-
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
- const char* method,
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::String> symbol,
181
- int argc,
182
- v8::Local<v8::Value>* argv));
183
- NODE_DEPRECATED("Use MakeCallback(..., async_context)",
184
- NODE_EXTERN v8::Local<v8::Value> MakeCallback(
185
- v8::Isolate* isolate,
186
- v8::Local<v8::Object> recv,
187
- v8::Local<v8::Function> callback,
188
- int argc,
189
- v8::Local<v8::Value>* argv));
190
-
191
- } // namespace node
192
-
193
- #include <cassert>
194
- #include <cstdint>
195
-
196
- #ifndef NODE_STRINGIFY
197
- # define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)
198
- # define NODE_STRINGIFY_HELPER(n) #n
199
- #endif
200
-
201
- #ifdef _WIN32
202
- #if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
203
- typedef intptr_t ssize_t;
204
- # define _SSIZE_T_
205
- # define _SSIZE_T_DEFINED
206
- #endif
207
- #else // !_WIN32
208
- # include <sys/types.h> // size_t, ssize_t
209
- #endif // _WIN32
210
-
211
-
212
- namespace node {
213
-
214
- class IsolateData;
215
- class Environment;
216
-
217
- // TODO(addaleax): Officially deprecate this and replace it with something
218
- // better suited for a public embedder API.
219
- NODE_EXTERN int Start(int argc, char* argv[]);
220
-
221
- // Tear down Node.js while it is running (there are active handles
222
- // in the loop and / or actively executing JavaScript code).
223
- NODE_EXTERN int Stop(Environment* env);
224
-
225
- // Set up per-process state needed to run Node.js. This will consume arguments
226
- // from argv, fill exec_argv, and possibly add errors resulting from parsing
227
- // the arguments to `errors`. The return value is a suggested exit code for the
228
- // program; If it is 0, then initializing Node.js succeeded.
229
- NODE_EXTERN int InitializeNodeWithArgs(std::vector<std::string>* argv,
230
- std::vector<std::string>* exec_argv,
231
- std::vector<std::string>* errors);
232
-
233
- enum OptionEnvvarSettings {
234
- kAllowedInEnvironment,
235
- kDisallowedInEnvironment
236
- };
237
-
238
- NODE_EXTERN int ProcessGlobalArgs(std::vector<std::string>* args,
239
- std::vector<std::string>* exec_args,
240
- std::vector<std::string>* errors,
241
- OptionEnvvarSettings settings);
242
-
243
- class NodeArrayBufferAllocator;
244
-
245
- // An ArrayBuffer::Allocator class with some Node.js-specific tweaks. If you do
246
- // not have to use another allocator, using this class is recommended:
247
- // - It supports Buffer.allocUnsafe() and Buffer.allocUnsafeSlow() with
248
- // uninitialized memory.
249
- // - It supports transferring, rather than copying, ArrayBuffers when using
250
- // MessagePorts.
251
- class NODE_EXTERN ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
252
- public:
253
- // If `always_debug` is true, create an ArrayBuffer::Allocator instance
254
- // that performs additional integrity checks (e.g. make sure that only memory
255
- // that was allocated by the it is also freed by it).
256
- // This can also be set using the --debug-arraybuffer-allocations flag.
257
- static std::unique_ptr<ArrayBufferAllocator> Create(
258
- bool always_debug = false);
259
-
260
- private:
261
- virtual NodeArrayBufferAllocator* GetImpl() = 0;
262
-
263
- friend class IsolateData;
264
- };
265
-
266
- // Legacy equivalents for ArrayBufferAllocator::Create().
267
- NODE_EXTERN ArrayBufferAllocator* CreateArrayBufferAllocator();
268
- NODE_EXTERN void FreeArrayBufferAllocator(ArrayBufferAllocator* allocator);
269
-
270
- class NODE_EXTERN IsolatePlatformDelegate {
271
- public:
272
- virtual std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner() = 0;
273
- virtual bool IdleTasksEnabled() = 0;
274
- };
275
-
276
- class NODE_EXTERN MultiIsolatePlatform : public v8::Platform {
277
- public:
278
- ~MultiIsolatePlatform() override = default;
279
- // Returns true if work was dispatched or executed. New tasks that are
280
- // posted during flushing of the queue are postponed until the next
281
- // flushing.
282
- virtual bool FlushForegroundTasks(v8::Isolate* isolate) = 0;
283
- virtual void DrainTasks(v8::Isolate* isolate) = 0;
284
-
285
- // This needs to be called between the calls to `Isolate::Allocate()` and
286
- // `Isolate::Initialize()`, so that initialization can already start
287
- // using the platform.
288
- // When using `NewIsolate()`, this is taken care of by that function.
289
- // This function may only be called once per `Isolate`.
290
- virtual void RegisterIsolate(v8::Isolate* isolate,
291
- struct uv_loop_s* loop) = 0;
292
- // This method can be used when an application handles task scheduling on its
293
- // own through `IsolatePlatformDelegate`. Upon registering an isolate with
294
- // this overload any other method in this class with the exception of
295
- // `UnregisterIsolate` *must not* be used on that isolate.
296
- virtual void RegisterIsolate(v8::Isolate* isolate,
297
- IsolatePlatformDelegate* delegate) = 0;
298
-
299
- // This function may only be called once per `Isolate`, and discard any
300
- // pending delayed tasks scheduled for that isolate.
301
- // This needs to be called right before calling `Isolate::Dispose()`.
302
- virtual void UnregisterIsolate(v8::Isolate* isolate) = 0;
303
-
304
- // The platform should call the passed function once all state associated
305
- // with the given isolate has been cleaned up. This can, but does not have to,
306
- // happen asynchronously.
307
- virtual void AddIsolateFinishedCallback(v8::Isolate* isolate,
308
- void (*callback)(void*),
309
- void* data) = 0;
310
-
311
- static std::unique_ptr<MultiIsolatePlatform> Create(
312
- int thread_pool_size,
313
- v8::TracingController* tracing_controller = nullptr);
314
- };
315
-
316
- enum IsolateSettingsFlags {
317
- MESSAGE_LISTENER_WITH_ERROR_LEVEL = 1 << 0,
318
- DETAILED_SOURCE_POSITIONS_FOR_PROFILING = 1 << 1,
319
- SHOULD_NOT_SET_PROMISE_REJECTION_CALLBACK = 1 << 2,
320
- SHOULD_NOT_SET_PREPARE_STACK_TRACE_CALLBACK = 1 << 3
321
- };
322
-
323
- struct IsolateSettings {
324
- uint64_t flags = MESSAGE_LISTENER_WITH_ERROR_LEVEL |
325
- DETAILED_SOURCE_POSITIONS_FOR_PROFILING;
326
- v8::MicrotasksPolicy policy = v8::MicrotasksPolicy::kExplicit;
327
-
328
- // Error handling callbacks
329
- v8::Isolate::AbortOnUncaughtExceptionCallback
330
- should_abort_on_uncaught_exception_callback = nullptr;
331
- v8::FatalErrorCallback fatal_error_callback = nullptr;
332
- v8::PrepareStackTraceCallback prepare_stack_trace_callback = nullptr;
333
-
334
- // Miscellaneous callbacks
335
- v8::PromiseRejectCallback promise_reject_callback = nullptr;
336
- v8::AllowWasmCodeGenerationCallback
337
- allow_wasm_code_generation_callback = nullptr;
338
- };
339
-
340
- // Overriding IsolateSettings may produce unexpected behavior
341
- // in Node.js core functionality, so proceed at your own risk.
342
- NODE_EXTERN void SetIsolateUpForNode(v8::Isolate* isolate,
343
- const IsolateSettings& settings);
344
-
345
- // Set a number of callbacks for the `isolate`, in particular the Node.js
346
- // uncaught exception listener.
347
- NODE_EXTERN void SetIsolateUpForNode(v8::Isolate* isolate);
348
-
349
- // Creates a new isolate with Node.js-specific settings.
350
- // This is a convenience method equivalent to using SetIsolateCreateParams(),
351
- // Isolate::Allocate(), MultiIsolatePlatform::RegisterIsolate(),
352
- // Isolate::Initialize(), and SetIsolateUpForNode().
353
- NODE_EXTERN v8::Isolate* NewIsolate(ArrayBufferAllocator* allocator,
354
- struct uv_loop_s* event_loop,
355
- MultiIsolatePlatform* platform = nullptr);
356
- NODE_EXTERN v8::Isolate* NewIsolate(
357
- std::shared_ptr<ArrayBufferAllocator> allocator,
358
- struct uv_loop_s* event_loop,
359
- MultiIsolatePlatform* platform);
360
-
361
- // Creates a new context with Node.js-specific tweaks.
362
- NODE_EXTERN v8::Local<v8::Context> NewContext(
363
- v8::Isolate* isolate,
364
- v8::Local<v8::ObjectTemplate> object_template =
365
- v8::Local<v8::ObjectTemplate>());
366
-
367
- // Runs Node.js-specific tweaks on an already constructed context
368
- // Return value indicates success of operation
369
- NODE_EXTERN bool InitializeContext(v8::Local<v8::Context> context);
370
-
371
- // If `platform` is passed, it will be used to register new Worker instances.
372
- // It can be `nullptr`, in which case creating new Workers inside of
373
- // Environments that use this `IsolateData` will not work.
374
- NODE_EXTERN IsolateData* CreateIsolateData(
375
- v8::Isolate* isolate,
376
- struct uv_loop_s* loop,
377
- MultiIsolatePlatform* platform = nullptr,
378
- ArrayBufferAllocator* allocator = nullptr);
379
- NODE_EXTERN void FreeIsolateData(IsolateData* isolate_data);
380
-
381
- struct ThreadId {
382
- uint64_t id = static_cast<uint64_t>(-1);
383
- };
384
- NODE_EXTERN ThreadId AllocateEnvironmentThreadId();
385
-
386
- namespace EnvironmentFlags {
387
- enum Flags : uint64_t {
388
- kNoFlags = 0,
389
- // Use the default behaviour for Node.js instances.
390
- kDefaultFlags = 1 << 0,
391
- // Controls whether this Environment is allowed to affect per-process state
392
- // (e.g. cwd, process title, uid, etc.).
393
- // This is set when using kDefaultFlags.
394
- kOwnsProcessState = 1 << 1,
395
- // Set if this Environment instance is associated with the global inspector
396
- // handling code (i.e. listening on SIGUSR1).
397
- // This is set when using kDefaultFlags.
398
- kOwnsInspector = 1 << 2,
399
- // Set if Node.js should not run its own esm loader. This is needed by some
400
- // embedders, because it's possible for the Node.js esm loader to conflict
401
- // with another one in an embedder environment, e.g. Blink's in Chromium.
402
- kNoRegisterESMLoader = 1 << 3,
403
- // Set this flag to make Node.js track "raw" file descriptors, i.e. managed
404
- // by fs.open() and fs.close(), and close them during FreeEnvironment().
405
- kTrackUnmanagedFds = 1 << 4,
406
- // Set this flag to force hiding console windows when spawning child
407
- // processes. This is usually used when embedding Node.js in GUI programs on
408
- // Windows.
409
- kHideConsoleWindows = 1 << 5,
410
- // Set this flag to disable loading native addons via `process.dlopen`.
411
- // This environment flag is especially important for worker threads
412
- // so that a worker thread can't load a native addon even if `execArgv`
413
- // is overwritten and `--no-addons` is not specified but was specified
414
- // for this Environment instance.
415
- kNoNativeAddons = 1 << 6,
416
- // Set this flag to disable searching modules from global paths like
417
- // $HOME/.node_modules and $NODE_PATH. This is used by standalone apps that
418
- // do not expect to have their behaviors changed because of globally
419
- // installed modules.
420
- kNoGlobalSearchPaths = 1 << 7
421
- };
422
- } // namespace EnvironmentFlags
423
-
424
- struct InspectorParentHandle {
425
- virtual ~InspectorParentHandle();
426
- };
427
-
428
- // TODO(addaleax): Maybe move per-Environment options parsing here.
429
- // Returns nullptr when the Environment cannot be created e.g. there are
430
- // pending JavaScript exceptions.
431
- NODE_EXTERN Environment* CreateEnvironment(
432
- IsolateData* isolate_data,
433
- v8::Local<v8::Context> context,
434
- const std::vector<std::string>& args,
435
- const std::vector<std::string>& exec_args,
436
- EnvironmentFlags::Flags flags = EnvironmentFlags::kDefaultFlags,
437
- ThreadId thread_id = {} /* allocates a thread id automatically */,
438
- std::unique_ptr<InspectorParentHandle> inspector_parent_handle = {});
439
-
440
- // Returns a handle that can be passed to `LoadEnvironment()`, making the
441
- // child Environment accessible to the inspector as if it were a Node.js Worker.
442
- // `child_thread_id` can be created using `AllocateEnvironmentThreadId()`
443
- // and then later passed on to `CreateEnvironment()` to create the child
444
- // Environment, together with the inspector handle.
445
- // This method should not be called while the parent Environment is active
446
- // on another thread.
447
- NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
448
- Environment* parent_env,
449
- ThreadId child_thread_id,
450
- const char* child_url);
451
-
452
- struct StartExecutionCallbackInfo {
453
- v8::Local<v8::Object> process_object;
454
- v8::Local<v8::Function> native_require;
455
- };
456
-
457
- using StartExecutionCallback =
458
- std::function<v8::MaybeLocal<v8::Value>(const StartExecutionCallbackInfo&)>;
459
-
460
- NODE_EXTERN v8::MaybeLocal<v8::Value> LoadEnvironment(
461
- Environment* env,
462
- StartExecutionCallback cb);
463
- NODE_EXTERN v8::MaybeLocal<v8::Value> LoadEnvironment(
464
- Environment* env,
465
- const char* main_script_source_utf8);
466
- NODE_EXTERN void FreeEnvironment(Environment* env);
467
-
468
- // Set a callback that is called when process.exit() is called from JS,
469
- // overriding the default handler.
470
- // It receives the Environment* instance and the exit code as arguments.
471
- // This could e.g. call Stop(env); in order to terminate execution and stop
472
- // the event loop.
473
- // The default handler disposes of the global V8 platform instance, if one is
474
- // being used, and calls exit().
475
- NODE_EXTERN void SetProcessExitHandler(
476
- Environment* env,
477
- std::function<void(Environment*, int)>&& handler);
478
- NODE_EXTERN void DefaultProcessExitHandler(Environment* env, int exit_code);
479
-
480
- // This may return nullptr if context is not associated with a Node instance.
481
- NODE_EXTERN Environment* GetCurrentEnvironment(v8::Local<v8::Context> context);
482
- NODE_EXTERN IsolateData* GetEnvironmentIsolateData(Environment* env);
483
- NODE_EXTERN ArrayBufferAllocator* GetArrayBufferAllocator(IsolateData* data);
484
-
485
- NODE_EXTERN void OnFatalError(const char* location, const char* message);
486
- NODE_EXTERN void PromiseRejectCallback(v8::PromiseRejectMessage message);
487
- NODE_EXTERN bool AllowWasmCodeGenerationCallback(v8::Local<v8::Context> context,
488
- v8::Local<v8::String>);
489
- NODE_EXTERN bool ShouldAbortOnUncaughtException(v8::Isolate* isolate);
490
- NODE_EXTERN v8::MaybeLocal<v8::Value> PrepareStackTraceCallback(
491
- v8::Local<v8::Context> context,
492
- v8::Local<v8::Value> exception,
493
- v8::Local<v8::Array> trace);
494
-
495
- // This returns the MultiIsolatePlatform used for an Environment or IsolateData
496
- // instance, if one exists.
497
- NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(Environment* env);
498
- NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env);
499
-
500
- NODE_DEPRECATED("Use MultiIsolatePlatform::Create() instead",
501
- NODE_EXTERN MultiIsolatePlatform* CreatePlatform(
502
- int thread_pool_size,
503
- v8::TracingController* tracing_controller));
504
- NODE_DEPRECATED("Use MultiIsolatePlatform::Create() instead",
505
- NODE_EXTERN void FreePlatform(MultiIsolatePlatform* platform));
506
-
507
- // Get/set the currently active tracing controller. Using CreatePlatform()
508
- // will implicitly set this by default. This is global and should be initialized
509
- // along with the v8::Platform instance that is being used. `controller`
510
- // is allowed to be `nullptr`.
511
- // This is used for tracing events from Node.js itself. V8 uses the tracing
512
- // controller returned from the active `v8::Platform` instance.
513
- NODE_EXTERN v8::TracingController* GetTracingController();
514
- NODE_EXTERN void SetTracingController(v8::TracingController* controller);
515
-
516
- // Run `process.emit('beforeExit')` as it would usually happen when Node.js is
517
- // run in standalone mode.
518
- NODE_EXTERN v8::Maybe<bool> EmitProcessBeforeExit(Environment* env);
519
- NODE_DEPRECATED("Use Maybe version (EmitProcessBeforeExit) instead",
520
- NODE_EXTERN void EmitBeforeExit(Environment* env));
521
- // Run `process.emit('exit')` as it would usually happen when Node.js is run
522
- // in standalone mode. The return value corresponds to the exit code.
523
- NODE_EXTERN v8::Maybe<int> EmitProcessExit(Environment* env);
524
- NODE_DEPRECATED("Use Maybe version (EmitProcessExit) instead",
525
- NODE_EXTERN int EmitExit(Environment* env));
526
-
527
- // Runs hooks added through `AtExit()`. This is part of `FreeEnvironment()`,
528
- // so calling it manually is typically not necessary.
529
- NODE_EXTERN void RunAtExit(Environment* env);
530
-
531
- // This may return nullptr if the current v8::Context is not associated
532
- // with a Node instance.
533
- NODE_EXTERN struct uv_loop_s* GetCurrentEventLoop(v8::Isolate* isolate);
534
-
535
- // Runs the main loop for a given Environment. This roughly performs the
536
- // following steps:
537
- // 1. Call uv_run() on the event loop until it is drained.
538
- // 2. Call platform->DrainTasks() on the associated platform/isolate.
539
- // 3. If the event loop is alive again, go to Step 1.
540
- // 4. Call EmitProcessBeforeExit().
541
- // 5. If the event loop is alive again, go to Step 1.
542
- // 6. Call EmitProcessExit() and forward the return value.
543
- // If at any point node::Stop() is called, the function will attempt to return
544
- // as soon as possible, returning an empty `Maybe`.
545
- // This function only works if `env` has an associated `MultiIsolatePlatform`.
546
- NODE_EXTERN v8::Maybe<int> SpinEventLoop(Environment* env);
547
-
548
- class NODE_EXTERN CommonEnvironmentSetup {
549
- public:
550
- ~CommonEnvironmentSetup();
551
-
552
- // Create a new CommonEnvironmentSetup, that is, a group of objects that
553
- // together form the typical setup for a single Node.js Environment instance.
554
- // If any error occurs, `*errors` will be populated and the returned pointer
555
- // will be empty.
556
- // env_args will be passed through as arguments to CreateEnvironment(), after
557
- // `isolate_data` and `context`.
558
- template <typename... EnvironmentArgs>
559
- static std::unique_ptr<CommonEnvironmentSetup> Create(
560
- MultiIsolatePlatform* platform,
561
- std::vector<std::string>* errors,
562
- EnvironmentArgs&&... env_args);
563
-
564
- struct uv_loop_s* event_loop() const;
565
- std::shared_ptr<ArrayBufferAllocator> array_buffer_allocator() const;
566
- v8::Isolate* isolate() const;
567
- IsolateData* isolate_data() const;
568
- Environment* env() const;
569
- v8::Local<v8::Context> context() const;
570
-
571
- CommonEnvironmentSetup(const CommonEnvironmentSetup&) = delete;
572
- CommonEnvironmentSetup& operator=(const CommonEnvironmentSetup&) = delete;
573
- CommonEnvironmentSetup(CommonEnvironmentSetup&&) = delete;
574
- CommonEnvironmentSetup& operator=(CommonEnvironmentSetup&&) = delete;
575
-
576
- private:
577
- struct Impl;
578
- Impl* impl_;
579
- CommonEnvironmentSetup(
580
- MultiIsolatePlatform*,
581
- std::vector<std::string>*,
582
- std::function<Environment*(const CommonEnvironmentSetup*)>);
583
- };
584
-
585
- // Implementation for CommonEnvironmentSetup::Create
586
- template <typename... EnvironmentArgs>
587
- std::unique_ptr<CommonEnvironmentSetup> CommonEnvironmentSetup::Create(
588
- MultiIsolatePlatform* platform,
589
- std::vector<std::string>* errors,
590
- EnvironmentArgs&&... env_args) {
591
- auto ret = std::unique_ptr<CommonEnvironmentSetup>(new CommonEnvironmentSetup(
592
- platform, errors,
593
- [&](const CommonEnvironmentSetup* setup) -> Environment* {
594
- return CreateEnvironment(
595
- setup->isolate_data(), setup->context(),
596
- std::forward<EnvironmentArgs>(env_args)...);
597
- }));
598
- if (!errors->empty()) ret.reset();
599
- return ret;
600
- }
601
-
602
- /* Converts a unixtime to V8 Date */
603
- NODE_DEPRECATED("Use v8::Date::New() directly",
604
- inline v8::Local<v8::Value> NODE_UNIXTIME_V8(double time) {
605
- return v8::Date::New(
606
- v8::Isolate::GetCurrent()->GetCurrentContext(),
607
- 1000 * time)
608
- .ToLocalChecked();
609
- })
610
- #define NODE_UNIXTIME_V8 node::NODE_UNIXTIME_V8
611
- NODE_DEPRECATED("Use v8::Date::ValueOf() directly",
612
- inline double NODE_V8_UNIXTIME(v8::Local<v8::Date> date) {
613
- return date->ValueOf() / 1000;
614
- })
615
- #define NODE_V8_UNIXTIME node::NODE_V8_UNIXTIME
616
-
617
- #define NODE_DEFINE_CONSTANT(target, constant) \
618
- do { \
619
- v8::Isolate* isolate = target->GetIsolate(); \
620
- v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
621
- v8::Local<v8::String> constant_name = \
622
- v8::String::NewFromUtf8(isolate, #constant, \
623
- v8::NewStringType::kInternalized).ToLocalChecked(); \
624
- v8::Local<v8::Number> constant_value = \
625
- v8::Number::New(isolate, static_cast<double>(constant)); \
626
- v8::PropertyAttribute constant_attributes = \
627
- static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \
628
- (target)->DefineOwnProperty(context, \
629
- constant_name, \
630
- constant_value, \
631
- constant_attributes).Check(); \
632
- } \
633
- while (0)
634
-
635
- #define NODE_DEFINE_HIDDEN_CONSTANT(target, constant) \
636
- do { \
637
- v8::Isolate* isolate = target->GetIsolate(); \
638
- v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
639
- v8::Local<v8::String> constant_name = \
640
- v8::String::NewFromUtf8(isolate, #constant, \
641
- v8::NewStringType::kInternalized) \
642
- .ToLocalChecked(); \
643
- v8::Local<v8::Number> constant_value = \
644
- v8::Number::New(isolate, static_cast<double>(constant)); \
645
- v8::PropertyAttribute constant_attributes = \
646
- static_cast<v8::PropertyAttribute>(v8::ReadOnly | \
647
- v8::DontDelete | \
648
- v8::DontEnum); \
649
- (target)->DefineOwnProperty(context, \
650
- constant_name, \
651
- constant_value, \
652
- constant_attributes).Check(); \
653
- } \
654
- while (0)
655
-
656
- // Used to be a macro, hence the uppercase name.
657
- inline void NODE_SET_METHOD(v8::Local<v8::Template> recv,
658
- const char* name,
659
- v8::FunctionCallback callback) {
660
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
661
- v8::HandleScope handle_scope(isolate);
662
- v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate,
663
- callback);
664
- v8::Local<v8::String> fn_name = v8::String::NewFromUtf8(isolate, name,
665
- v8::NewStringType::kInternalized).ToLocalChecked();
666
- t->SetClassName(fn_name);
667
- recv->Set(fn_name, t);
668
- }
669
-
670
- // Used to be a macro, hence the uppercase name.
671
- inline void NODE_SET_METHOD(v8::Local<v8::Object> recv,
672
- const char* name,
673
- v8::FunctionCallback callback) {
674
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
675
- v8::HandleScope handle_scope(isolate);
676
- v8::Local<v8::Context> context = isolate->GetCurrentContext();
677
- v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate,
678
- callback);
679
- v8::Local<v8::Function> fn = t->GetFunction(context).ToLocalChecked();
680
- v8::Local<v8::String> fn_name = v8::String::NewFromUtf8(isolate, name,
681
- v8::NewStringType::kInternalized).ToLocalChecked();
682
- fn->SetName(fn_name);
683
- recv->Set(context, fn_name, fn).Check();
684
- }
685
- #define NODE_SET_METHOD node::NODE_SET_METHOD
686
-
687
- // Used to be a macro, hence the uppercase name.
688
- // Not a template because it only makes sense for FunctionTemplates.
689
- inline void NODE_SET_PROTOTYPE_METHOD(v8::Local<v8::FunctionTemplate> recv,
690
- const char* name,
691
- v8::FunctionCallback callback) {
692
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
693
- v8::HandleScope handle_scope(isolate);
694
- v8::Local<v8::Signature> s = v8::Signature::New(isolate, recv);
695
- v8::Local<v8::FunctionTemplate> t =
696
- v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), s);
697
- v8::Local<v8::String> fn_name = v8::String::NewFromUtf8(isolate, name,
698
- v8::NewStringType::kInternalized).ToLocalChecked();
699
- t->SetClassName(fn_name);
700
- recv->PrototypeTemplate()->Set(fn_name, t);
701
- }
702
- #define NODE_SET_PROTOTYPE_METHOD node::NODE_SET_PROTOTYPE_METHOD
703
-
704
- // BINARY is a deprecated alias of LATIN1.
705
- // BASE64URL is not currently exposed to the JavaScript side.
706
- enum encoding {
707
- ASCII,
708
- UTF8,
709
- BASE64,
710
- UCS2,
711
- BINARY,
712
- HEX,
713
- BUFFER,
714
- BASE64URL,
715
- LATIN1 = BINARY
716
- };
717
-
718
- NODE_EXTERN enum encoding ParseEncoding(
719
- v8::Isolate* isolate,
720
- v8::Local<v8::Value> encoding_v,
721
- enum encoding default_encoding = LATIN1);
722
-
723
- NODE_EXTERN void FatalException(v8::Isolate* isolate,
724
- const v8::TryCatch& try_catch);
725
-
726
- NODE_EXTERN v8::Local<v8::Value> Encode(v8::Isolate* isolate,
727
- const char* buf,
728
- size_t len,
729
- enum encoding encoding = LATIN1);
730
-
731
- // Warning: This reverses endianness on Big Endian platforms, even though the
732
- // signature using uint16_t implies that it should not.
733
- NODE_EXTERN v8::Local<v8::Value> Encode(v8::Isolate* isolate,
734
- const uint16_t* buf,
735
- size_t len);
736
-
737
- // Returns -1 if the handle was not valid for decoding
738
- NODE_EXTERN ssize_t DecodeBytes(v8::Isolate* isolate,
739
- v8::Local<v8::Value>,
740
- enum encoding encoding = LATIN1);
741
- // returns bytes written.
742
- NODE_EXTERN ssize_t DecodeWrite(v8::Isolate* isolate,
743
- char* buf,
744
- size_t buflen,
745
- v8::Local<v8::Value>,
746
- enum encoding encoding = LATIN1);
747
- #ifdef _WIN32
748
- NODE_EXTERN v8::Local<v8::Value> WinapiErrnoException(
749
- v8::Isolate* isolate,
750
- int errorno,
751
- const char* syscall = nullptr,
752
- const char* msg = "",
753
- const char* path = nullptr);
754
- #endif
755
-
756
- const char* signo_string(int errorno);
757
-
758
-
759
- typedef void (*addon_register_func)(
760
- v8::Local<v8::Object> exports,
761
- v8::Local<v8::Value> module,
762
- void* priv);
763
-
764
- typedef void (*addon_context_register_func)(
765
- v8::Local<v8::Object> exports,
766
- v8::Local<v8::Value> module,
767
- v8::Local<v8::Context> context,
768
- void* priv);
769
-
770
- enum ModuleFlags {
771
- kLinked = 0x02
772
- };
773
-
774
- struct node_module {
775
- int nm_version;
776
- unsigned int nm_flags;
777
- void* nm_dso_handle;
778
- const char* nm_filename;
779
- node::addon_register_func nm_register_func;
780
- node::addon_context_register_func nm_context_register_func;
781
- const char* nm_modname;
782
- void* nm_priv;
783
- struct node_module* nm_link;
784
- };
785
-
786
- extern "C" NODE_EXTERN void node_module_register(void* mod);
787
-
788
- #ifdef _WIN32
789
- # define NODE_MODULE_EXPORT __declspec(dllexport)
790
- #else
791
- # define NODE_MODULE_EXPORT __attribute__((visibility("default")))
792
- #endif
793
-
794
- #ifdef NODE_SHARED_MODE
795
- # define NODE_CTOR_PREFIX
796
- #else
797
- # define NODE_CTOR_PREFIX static
798
- #endif
799
-
800
- #if defined(_MSC_VER)
801
- #pragma section(".CRT$XCU", read)
802
- #define NODE_C_CTOR(fn) \
803
- NODE_CTOR_PREFIX void __cdecl fn(void); \
804
- __declspec(dllexport, allocate(".CRT$XCU")) \
805
- void (__cdecl*fn ## _)(void) = fn; \
806
- NODE_CTOR_PREFIX void __cdecl fn(void)
807
- #else
808
- #define NODE_C_CTOR(fn) \
809
- NODE_CTOR_PREFIX void fn(void) __attribute__((constructor)); \
810
- NODE_CTOR_PREFIX void fn(void)
811
- #endif
812
-
813
- #define NODE_MODULE_X(modname, regfunc, priv, flags) \
814
- extern "C" { \
815
- static node::node_module _module = \
816
- { \
817
- NODE_MODULE_VERSION, \
818
- flags, \
819
- NULL, /* NOLINT (readability/null_usage) */ \
820
- __FILE__, \
821
- (node::addon_register_func) (regfunc), \
822
- NULL, /* NOLINT (readability/null_usage) */ \
823
- NODE_STRINGIFY(modname), \
824
- priv, \
825
- NULL /* NOLINT (readability/null_usage) */ \
826
- }; \
827
- NODE_C_CTOR(_register_ ## modname) { \
828
- node_module_register(&_module); \
829
- } \
830
- }
831
-
832
- #define NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, priv, flags) \
833
- extern "C" { \
834
- static node::node_module _module = \
835
- { \
836
- NODE_MODULE_VERSION, \
837
- flags, \
838
- NULL, /* NOLINT (readability/null_usage) */ \
839
- __FILE__, \
840
- NULL, /* NOLINT (readability/null_usage) */ \
841
- (node::addon_context_register_func) (regfunc), \
842
- NODE_STRINGIFY(modname), \
843
- priv, \
844
- NULL /* NOLINT (readability/null_usage) */ \
845
- }; \
846
- NODE_C_CTOR(_register_ ## modname) { \
847
- node_module_register(&_module); \
848
- } \
849
- }
850
-
851
- // Usage: `NODE_MODULE(NODE_GYP_MODULE_NAME, InitializerFunction)`
852
- // If no NODE_MODULE is declared, Node.js looks for the well-known
853
- // symbol `node_register_module_v${NODE_MODULE_VERSION}`.
854
- #define NODE_MODULE(modname, regfunc) \
855
- NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
856
-
857
- #define NODE_MODULE_CONTEXT_AWARE(modname, regfunc) \
858
- /* NOLINTNEXTLINE (readability/null_usage) */ \
859
- NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, 0)
860
-
861
- // Embedders can use this type of binding for statically linked native bindings.
862
- // It is used the same way addon bindings are used, except that linked bindings
863
- // can be accessed through `process._linkedBinding(modname)`.
864
- #define NODE_MODULE_LINKED(modname, regfunc) \
865
- /* NOLINTNEXTLINE (readability/null_usage) */ \
866
- NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, \
867
- node::ModuleFlags::kLinked)
868
-
869
- /*
870
- * For backward compatibility in add-on modules.
871
- */
872
- #define NODE_MODULE_DECL /* nothing */
873
-
874
- #define NODE_MODULE_INITIALIZER_BASE node_register_module_v
875
-
876
- #define NODE_MODULE_INITIALIZER_X(base, version) \
877
- NODE_MODULE_INITIALIZER_X_HELPER(base, version)
878
-
879
- #define NODE_MODULE_INITIALIZER_X_HELPER(base, version) base##version
880
-
881
- #define NODE_MODULE_INITIALIZER \
882
- NODE_MODULE_INITIALIZER_X(NODE_MODULE_INITIALIZER_BASE, \
883
- NODE_MODULE_VERSION)
884
-
885
- #define NODE_MODULE_INIT() \
886
- extern "C" NODE_MODULE_EXPORT void \
887
- NODE_MODULE_INITIALIZER(v8::Local<v8::Object> exports, \
888
- v8::Local<v8::Value> module, \
889
- v8::Local<v8::Context> context); \
890
- NODE_MODULE_CONTEXT_AWARE(NODE_GYP_MODULE_NAME, \
891
- NODE_MODULE_INITIALIZER) \
892
- void NODE_MODULE_INITIALIZER(v8::Local<v8::Object> exports, \
893
- v8::Local<v8::Value> module, \
894
- v8::Local<v8::Context> context)
895
-
896
- // Allows embedders to add a binding to the current Environment* that can be
897
- // accessed through process._linkedBinding() in the target Environment and all
898
- // Worker threads that it creates.
899
- // In each variant, the registration function needs to be usable at least for
900
- // the time during which the Environment exists.
901
- NODE_EXTERN void AddLinkedBinding(Environment* env, const node_module& mod);
902
- NODE_EXTERN void AddLinkedBinding(Environment* env,
903
- const struct napi_module& mod);
904
- NODE_EXTERN void AddLinkedBinding(Environment* env,
905
- const char* name,
906
- addon_context_register_func fn,
907
- void* priv);
908
-
909
- /* Registers a callback with the passed-in Environment instance. The callback
910
- * is called after the event loop exits, but before the VM is disposed.
911
- * Callbacks are run in reverse order of registration, i.e. newest first.
912
- */
913
- NODE_EXTERN void AtExit(Environment* env,
914
- void (*cb)(void* arg),
915
- void* arg);
916
-
917
- typedef double async_id;
918
- struct async_context {
919
- ::node::async_id async_id;
920
- ::node::async_id trigger_async_id;
921
- };
922
-
923
- /* This is a lot like node::AtExit, except that the hooks added via this
924
- * function are run before the AtExit ones and will always be registered
925
- * for the current Environment instance.
926
- * These functions are safe to use in an addon supporting multiple
927
- * threads/isolates. */
928
- NODE_EXTERN void AddEnvironmentCleanupHook(v8::Isolate* isolate,
929
- void (*fun)(void* arg),
930
- void* arg);
931
-
932
- NODE_EXTERN void RemoveEnvironmentCleanupHook(v8::Isolate* isolate,
933
- void (*fun)(void* arg),
934
- void* arg);
935
-
936
- /* These are async equivalents of the above. After the cleanup hook is invoked,
937
- * `cb(cbarg)` *must* be called, and attempting to remove the cleanup hook will
938
- * have no effect. */
939
- struct ACHHandle;
940
- struct NODE_EXTERN DeleteACHHandle { void operator()(ACHHandle*) const; };
941
- typedef std::unique_ptr<ACHHandle, DeleteACHHandle> AsyncCleanupHookHandle;
942
-
943
- /* This function is not intended to be used externally, it exists to aid in
944
- * keeping ABI compatibility between Node and Electron. */
945
- NODE_EXTERN ACHHandle* AddEnvironmentCleanupHookInternal(
946
- v8::Isolate* isolate,
947
- void (*fun)(void* arg, void (*cb)(void*), void* cbarg),
948
- void* arg);
949
- inline AsyncCleanupHookHandle AddEnvironmentCleanupHook(
950
- v8::Isolate* isolate,
951
- void (*fun)(void* arg, void (*cb)(void*), void* cbarg),
952
- void* arg) {
953
- return AsyncCleanupHookHandle(AddEnvironmentCleanupHookInternal(isolate, fun,
954
- arg));
955
- }
956
-
957
- /* This function is not intended to be used externally, it exists to aid in
958
- * keeping ABI compatibility between Node and Electron. */
959
- NODE_EXTERN void RemoveEnvironmentCleanupHookInternal(ACHHandle* holder);
960
- inline void RemoveEnvironmentCleanupHook(AsyncCleanupHookHandle holder) {
961
- RemoveEnvironmentCleanupHookInternal(holder.get());
962
- }
963
-
964
- /* Returns the id of the current execution context. If the return value is
965
- * zero then no execution has been set. This will happen if the user handles
966
- * I/O from native code. */
967
- NODE_EXTERN async_id AsyncHooksGetExecutionAsyncId(v8::Isolate* isolate);
968
-
969
- /* Return same value as async_hooks.triggerAsyncId(); */
970
- NODE_EXTERN async_id AsyncHooksGetTriggerAsyncId(v8::Isolate* isolate);
971
-
972
- /* If the native API doesn't inherit from the helper class then the callbacks
973
- * must be triggered manually. This triggers the init() callback. The return
974
- * value is the async id assigned to the resource.
975
- *
976
- * The `trigger_async_id` parameter should correspond to the resource which is
977
- * creating the new resource, which will usually be the return value of
978
- * `AsyncHooksGetTriggerAsyncId()`. */
979
- NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate,
980
- v8::Local<v8::Object> resource,
981
- const char* name,
982
- async_id trigger_async_id = -1);
983
-
984
- NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate,
985
- v8::Local<v8::Object> resource,
986
- v8::Local<v8::String> name,
987
- async_id trigger_async_id = -1);
988
-
989
- /* Emit the destroy() callback. The overload taking an `Environment*` argument
990
- * should be used when the Isolate’s current Context is not associated with
991
- * a Node.js Environment, or when there is no current Context, for example
992
- * when calling this function during garbage collection. In that case, the
993
- * `Environment*` value should have been acquired previously, e.g. through
994
- * `GetCurrentEnvironment()`. */
995
- NODE_EXTERN void EmitAsyncDestroy(v8::Isolate* isolate,
996
- async_context asyncContext);
997
- NODE_EXTERN void EmitAsyncDestroy(Environment* env,
998
- async_context asyncContext);
999
-
1000
- class InternalCallbackScope;
1001
-
1002
- /* This class works like `MakeCallback()` in that it sets up a specific
1003
- * asyncContext as the current one and informs the async_hooks and domains
1004
- * modules that this context is currently active.
1005
- *
1006
- * `MakeCallback()` is a wrapper around this class as well as
1007
- * `Function::Call()`. Either one of these mechanisms needs to be used for
1008
- * top-level calls into JavaScript (i.e. without any existing JS stack).
1009
- *
1010
- * This object should be stack-allocated to ensure that it is contained in a
1011
- * valid HandleScope.
1012
- *
1013
- * Exceptions happening within this scope will be treated like uncaught
1014
- * exceptions. If this behaviour is undesirable, a new `v8::TryCatch` scope
1015
- * needs to be created inside of this scope.
1016
- */
1017
- class NODE_EXTERN CallbackScope {
1018
- public:
1019
- CallbackScope(v8::Isolate* isolate,
1020
- v8::Local<v8::Object> resource,
1021
- async_context asyncContext);
1022
- CallbackScope(Environment* env,
1023
- v8::Local<v8::Object> resource,
1024
- async_context asyncContext);
1025
- ~CallbackScope();
1026
-
1027
- void operator=(const CallbackScope&) = delete;
1028
- void operator=(CallbackScope&&) = delete;
1029
- CallbackScope(const CallbackScope&) = delete;
1030
- CallbackScope(CallbackScope&&) = delete;
1031
-
1032
- private:
1033
- InternalCallbackScope* private_;
1034
- v8::TryCatch try_catch_;
1035
- };
1036
-
1037
- /* An API specific to emit before/after callbacks is unnecessary because
1038
- * MakeCallback will automatically call them for you.
1039
- *
1040
- * These methods may create handles on their own, so run them inside a
1041
- * HandleScope.
1042
- *
1043
- * `asyncId` and `triggerAsyncId` should correspond to the values returned by
1044
- * `EmitAsyncInit()` and `AsyncHooksGetTriggerAsyncId()`, respectively, when the
1045
- * invoking resource was created. If these values are unknown, 0 can be passed.
1046
- * */
1047
- NODE_EXTERN
1048
- v8::MaybeLocal<v8::Value> MakeCallback(v8::Isolate* isolate,
1049
- v8::Local<v8::Object> recv,
1050
- v8::Local<v8::Function> callback,
1051
- int argc,
1052
- v8::Local<v8::Value>* argv,
1053
- async_context asyncContext);
1054
- NODE_EXTERN
1055
- v8::MaybeLocal<v8::Value> MakeCallback(v8::Isolate* isolate,
1056
- v8::Local<v8::Object> recv,
1057
- const char* method,
1058
- int argc,
1059
- v8::Local<v8::Value>* argv,
1060
- async_context asyncContext);
1061
- NODE_EXTERN
1062
- v8::MaybeLocal<v8::Value> MakeCallback(v8::Isolate* isolate,
1063
- v8::Local<v8::Object> recv,
1064
- v8::Local<v8::String> symbol,
1065
- int argc,
1066
- v8::Local<v8::Value>* argv,
1067
- async_context asyncContext);
1068
-
1069
- /* Helper class users can optionally inherit from. If
1070
- * `AsyncResource::MakeCallback()` is used, then all four callbacks will be
1071
- * called automatically. */
1072
- class NODE_EXTERN AsyncResource {
1073
- public:
1074
- AsyncResource(v8::Isolate* isolate,
1075
- v8::Local<v8::Object> resource,
1076
- const char* name,
1077
- async_id trigger_async_id = -1);
1078
-
1079
- virtual ~AsyncResource();
1080
-
1081
- AsyncResource(const AsyncResource&) = delete;
1082
- void operator=(const AsyncResource&) = delete;
1083
-
1084
- v8::MaybeLocal<v8::Value> MakeCallback(
1085
- v8::Local<v8::Function> callback,
1086
- int argc,
1087
- v8::Local<v8::Value>* argv);
1088
-
1089
- v8::MaybeLocal<v8::Value> MakeCallback(
1090
- const char* method,
1091
- int argc,
1092
- v8::Local<v8::Value>* argv);
1093
-
1094
- v8::MaybeLocal<v8::Value> MakeCallback(
1095
- v8::Local<v8::String> symbol,
1096
- int argc,
1097
- v8::Local<v8::Value>* argv);
1098
-
1099
- v8::Local<v8::Object> get_resource();
1100
- async_id get_async_id() const;
1101
- async_id get_trigger_async_id() const;
1102
-
1103
- protected:
1104
- class NODE_EXTERN CallbackScope : public node::CallbackScope {
1105
- public:
1106
- explicit CallbackScope(AsyncResource* res);
1107
- };
1108
-
1109
- private:
1110
- Environment* env_;
1111
- v8::Global<v8::Object> resource_;
1112
- async_context async_context_;
1113
- };
1114
-
1115
- #ifndef _WIN32
1116
- // Register a signal handler without interrupting any handlers that node
1117
- // itself needs. This does override handlers registered through
1118
- // process.on('SIG...', function() { ... }). The `reset_handler` flag indicates
1119
- // whether the signal handler for the given signal should be reset to its
1120
- // default value before executing the handler (i.e. it works like SA_RESETHAND).
1121
- // The `reset_handler` flag is invalid when `signal` is SIGSEGV.
1122
- NODE_EXTERN
1123
- void RegisterSignalHandler(int signal,
1124
- void (*handler)(int signal,
1125
- siginfo_t* info,
1126
- void* ucontext),
1127
- bool reset_handler = false);
1128
- #endif // _WIN32
1129
-
1130
- } // namespace node
1131
-
1132
- #endif // SRC_NODE_H_