@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
@@ -75,8 +75,13 @@
75
75
  #include "v8-platform.h" // NOLINT(build/include_order)
76
76
  #include "node_version.h" // NODE_MODULE_VERSION
77
77
 
78
- #include <memory>
78
+ #define NAPI_EXPERIMENTAL
79
+ #include "node_api.h"
80
+
79
81
  #include <functional>
82
+ #include <memory>
83
+ #include <optional>
84
+ #include <ostream>
80
85
 
81
86
  // We cannot use __POSIX__ in this header because that's only defined when
82
87
  // building Node.js.
@@ -120,12 +125,12 @@
120
125
  // Forward-declare libuv loop
121
126
  struct uv_loop_s;
122
127
 
123
- struct napi_module;
124
-
125
128
  // Forward-declare these functions now to stop MSVS from becoming
126
129
  // terminally confused when it's done in node_internals.h
127
130
  namespace node {
128
131
 
132
+ struct SnapshotData;
133
+
129
134
  namespace tracing {
130
135
 
131
136
  class TracingController;
@@ -223,11 +228,14 @@ namespace node {
223
228
 
224
229
  class IsolateData;
225
230
  class Environment;
231
+ class MultiIsolatePlatform;
232
+ class InitializationResultImpl;
226
233
 
227
- namespace ProcessFlags {
228
- enum Flags : uint64_t {
234
+ namespace ProcessInitializationFlags {
235
+ enum Flags : uint32_t {
229
236
  kNoFlags = 0,
230
237
  // Enable stdio inheritance, which is disabled by default.
238
+ // This flag is also implied by kNoStdioInitialization.
231
239
  kEnableStdioInheritance = 1 << 0,
232
240
  // Disable reading the NODE_OPTIONS environment variable.
233
241
  kDisableNodeOptionsEnv = 1 << 1,
@@ -235,8 +243,81 @@ enum Flags : uint64_t {
235
243
  kDisableCLIOptions = 1 << 2,
236
244
  // Do not initialize ICU.
237
245
  kNoICU = 1 << 3,
246
+ // Do not modify stdio file descriptor or TTY state.
247
+ kNoStdioInitialization = 1 << 4,
248
+ // Do not register Node.js-specific signal handlers
249
+ // and reset other signal handlers to default state.
250
+ kNoDefaultSignalHandling = 1 << 5,
251
+ // Do not perform V8 initialization.
252
+ kNoInitializeV8 = 1 << 6,
253
+ // Do not initialize a default Node.js-provided V8 platform instance.
254
+ kNoInitializeNodeV8Platform = 1 << 7,
255
+ // Do not initialize OpenSSL config.
256
+ kNoInitOpenSSL = 1 << 8,
257
+ // Do not initialize Node.js debugging based on environment variables.
258
+ kNoParseGlobalDebugVariables = 1 << 9,
259
+ // Do not adjust OS resource limits for this process.
260
+ kNoAdjustResourceLimits = 1 << 10,
261
+ // Do not map code segments into large pages for this process.
262
+ kNoUseLargePages = 1 << 11,
263
+ // Skip printing output for --help, --version, --v8-options.
264
+ kNoPrintHelpOrVersionOutput = 1 << 12,
265
+ // Do not perform cppgc initialization. If set, the embedder must call
266
+ // cppgc::InitializeProcess() before creating a Node.js environment
267
+ // and call cppgc::ShutdownProcess() before process shutdown.
268
+ kNoInitializeCppgc = 1 << 13,
269
+ // Initialize the process for predictable snapshot generation.
270
+ kGeneratePredictableSnapshot = 1 << 14,
271
+
272
+ // Emulate the behavior of InitializeNodeWithArgs() when passing
273
+ // a flags argument to the InitializeOncePerProcess() replacement
274
+ // function.
275
+ kLegacyInitializeNodeWithArgsBehavior =
276
+ kNoStdioInitialization | kNoDefaultSignalHandling | kNoInitializeV8 |
277
+ kNoInitializeNodeV8Platform | kNoInitOpenSSL |
278
+ kNoParseGlobalDebugVariables | kNoAdjustResourceLimits |
279
+ kNoUseLargePages | kNoPrintHelpOrVersionOutput | kNoInitializeCppgc,
280
+ };
281
+ } // namespace ProcessInitializationFlags
282
+ namespace ProcessFlags = ProcessInitializationFlags; // Legacy alias.
283
+
284
+ namespace StopFlags {
285
+ enum Flags : uint32_t {
286
+ kNoFlags = 0,
287
+ // Do not explicitly terminate the Isolate
288
+ // when exiting the Environment.
289
+ kDoNotTerminateIsolate = 1 << 0,
290
+ };
291
+ } // namespace StopFlags
292
+
293
+ class NODE_EXTERN InitializationResult {
294
+ public:
295
+ virtual ~InitializationResult() = default;
296
+
297
+ // Returns a suggested process exit code.
298
+ virtual int exit_code() const = 0;
299
+
300
+ // Returns 'true' if initialization was aborted early due to errors.
301
+ virtual bool early_return() const = 0;
302
+
303
+ // Returns the parsed list of non-Node.js arguments.
304
+ virtual const std::vector<std::string>& args() const = 0;
305
+
306
+ // Returns the parsed list of Node.js arguments.
307
+ virtual const std::vector<std::string>& exec_args() const = 0;
308
+
309
+ // Returns an array of errors. Note that these may be warnings
310
+ // whose existence does not imply a non-zero exit code.
311
+ virtual const std::vector<std::string>& errors() const = 0;
312
+
313
+ // If kNoInitializeNodeV8Platform was not specified, the global Node.js
314
+ // platform instance.
315
+ virtual MultiIsolatePlatform* platform() const = 0;
316
+
317
+ private:
318
+ InitializationResult() = default;
319
+ friend class InitializationResultImpl;
238
320
  };
239
- } // namespace ProcessFlags
240
321
 
241
322
  // TODO(addaleax): Officially deprecate this and replace it with something
242
323
  // better suited for a public embedder API.
@@ -244,28 +325,68 @@ NODE_EXTERN int Start(int argc, char* argv[]);
244
325
 
245
326
  // Tear down Node.js while it is running (there are active handles
246
327
  // in the loop and / or actively executing JavaScript code).
247
- NODE_EXTERN int Stop(Environment* env);
328
+ NODE_EXTERN int Stop(Environment* env,
329
+ StopFlags::Flags flags = StopFlags::kNoFlags);
248
330
 
249
331
  // Set up per-process state needed to run Node.js. This will consume arguments
250
332
  // from argv, fill exec_argv, and possibly add errors resulting from parsing
251
333
  // the arguments to `errors`. The return value is a suggested exit code for the
252
334
  // program; If it is 0, then initializing Node.js succeeded.
253
- NODE_EXTERN int InitializeNodeWithArgs(
254
- std::vector<std::string>* argv,
255
- std::vector<std::string>* exec_argv,
256
- std::vector<std::string>* errors);
257
- // TODO(zcbenz): Turn above overloaded version into below's default argument.
258
- NODE_EXTERN int InitializeNodeWithArgs(
259
- std::vector<std::string>* argv,
260
- std::vector<std::string>* exec_argv,
261
- std::vector<std::string>* errors,
262
- ProcessFlags::Flags flags);
335
+ // This runs a subset of the initialization performed by
336
+ // InitializeOncePerProcess(), which supersedes this function.
337
+ // The subset is roughly equivalent to the one given by
338
+ // `ProcessInitializationFlags::kLegacyInitializeNodeWithArgsBehavior`.
339
+ NODE_DEPRECATED("Use InitializeOncePerProcess() instead",
340
+ NODE_EXTERN int InitializeNodeWithArgs(
341
+ std::vector<std::string>* argv,
342
+ std::vector<std::string>* exec_argv,
343
+ std::vector<std::string>* errors,
344
+ ProcessInitializationFlags::Flags flags =
345
+ ProcessInitializationFlags::kNoFlags));
346
+
347
+ // Set up per-process state needed to run Node.js. This will consume arguments
348
+ // from args, and return information about the initialization success,
349
+ // including the arguments split into argv/exec_argv, a list of potential
350
+ // errors encountered during initialization, and a potential suggested
351
+ // exit code.
352
+ NODE_EXTERN std::shared_ptr<InitializationResult> InitializeOncePerProcess(
353
+ const std::vector<std::string>& args,
354
+ ProcessInitializationFlags::Flags flags =
355
+ ProcessInitializationFlags::kNoFlags);
356
+ // Undoes the initialization performed by InitializeOncePerProcess(),
357
+ // where cleanup is necessary.
358
+ NODE_EXTERN void TearDownOncePerProcess();
359
+ // Convenience overload for specifying multiple flags without having
360
+ // to worry about casts.
361
+ inline std::shared_ptr<InitializationResult> InitializeOncePerProcess(
362
+ const std::vector<std::string>& args,
363
+ std::initializer_list<ProcessInitializationFlags::Flags> list) {
364
+ uint64_t flags_accum = ProcessInitializationFlags::kNoFlags;
365
+ for (const auto flag : list) flags_accum |= static_cast<uint64_t>(flag);
366
+ return InitializeOncePerProcess(
367
+ args, static_cast<ProcessInitializationFlags::Flags>(flags_accum));
368
+ }
263
369
 
264
370
  enum OptionEnvvarSettings {
265
- kAllowedInEnvironment,
266
- kDisallowedInEnvironment
371
+ // Allow the options to be set via the environment variable, like
372
+ // `NODE_OPTIONS`.
373
+ kAllowedInEnvvar = 0,
374
+ // Disallow the options to be set via the environment variable, like
375
+ // `NODE_OPTIONS`.
376
+ kDisallowedInEnvvar = 1,
377
+ // Deprecated, use kAllowedInEnvvar instead.
378
+ kAllowedInEnvironment = kAllowedInEnvvar,
379
+ // Deprecated, use kDisallowedInEnvvar instead.
380
+ kDisallowedInEnvironment = kDisallowedInEnvvar,
267
381
  };
268
382
 
383
+ // Process the arguments and set up the per-process options.
384
+ // If the `settings` is set as OptionEnvvarSettings::kAllowedInEnvvar, the
385
+ // options that are allowed in the environment variable are processed. Options
386
+ // that are disallowed to be set via environment variable are processed as
387
+ // errors.
388
+ // Otherwise all the options that are disallowed (and those are allowed) to be
389
+ // set via environment variable are processed.
269
390
  NODE_EXTERN int ProcessGlobalArgs(std::vector<std::string>* args,
270
391
  std::vector<std::string>* exec_args,
271
392
  std::vector<std::string>* errors,
@@ -349,7 +470,8 @@ enum IsolateSettingsFlags {
349
470
  MESSAGE_LISTENER_WITH_ERROR_LEVEL = 1 << 0,
350
471
  DETAILED_SOURCE_POSITIONS_FOR_PROFILING = 1 << 1,
351
472
  SHOULD_NOT_SET_PROMISE_REJECTION_CALLBACK = 1 << 2,
352
- SHOULD_NOT_SET_PREPARE_STACK_TRACE_CALLBACK = 1 << 3
473
+ SHOULD_NOT_SET_PREPARE_STACK_TRACE_CALLBACK = 1 << 3,
474
+ ALLOW_MODIFY_CODE_GENERATION_FROM_STRINGS_CALLBACK = 0, /* legacy no-op */
353
475
  };
354
476
 
355
477
  struct IsolateSettings {
@@ -367,6 +489,79 @@ struct IsolateSettings {
367
489
  v8::PromiseRejectCallback promise_reject_callback = nullptr;
368
490
  v8::AllowWasmCodeGenerationCallback
369
491
  allow_wasm_code_generation_callback = nullptr;
492
+ v8::ModifyCodeGenerationFromStringsCallback2
493
+ modify_code_generation_from_strings_callback = nullptr;
494
+ };
495
+
496
+ // Represents a startup snapshot blob, e.g. created by passing
497
+ // --node-snapshot-main=entry.js to the configure script at build time,
498
+ // or by running Node.js with the --build-snapshot option.
499
+ //
500
+ // If used, the snapshot *must* have been built with the same Node.js
501
+ // version and V8 flags as the version that is currently running, and will
502
+ // be rejected otherwise.
503
+ // The same EmbedderSnapshotData instance *must* be passed to both
504
+ // `NewIsolate()` and `CreateIsolateData()`. The first `Environment` instance
505
+ // should be created with an empty `context` argument and will then
506
+ // use the main context included in the snapshot blob. It can be retrieved
507
+ // using `GetMainContext()`. `LoadEnvironment` can receive an empty
508
+ // `StartExecutionCallback` in this case.
509
+ // If V8 was configured with the shared-readonly-heap option, it requires
510
+ // all snapshots used to create `Isolate` instances to be identical.
511
+ // This option *must* be unset by embedders who wish to use the startup
512
+ // feature during the build step by passing the --disable-shared-readonly-heap
513
+ // flag to the configure script.
514
+ //
515
+ // The snapshot *must* be kept alive during the execution of the Isolate
516
+ // that was created using it.
517
+ //
518
+ // Snapshots are an *experimental* feature. In particular, the embedder API
519
+ // exposed through this class is subject to change or removal between Node.js
520
+ // versions, including possible API and ABI breakage.
521
+ class EmbedderSnapshotData {
522
+ public:
523
+ struct DeleteSnapshotData {
524
+ void operator()(const EmbedderSnapshotData*) const;
525
+ };
526
+ using Pointer =
527
+ std::unique_ptr<const EmbedderSnapshotData, DeleteSnapshotData>;
528
+
529
+ // Return an EmbedderSnapshotData object that refers to the built-in
530
+ // snapshot of Node.js. This can have been configured through e.g.
531
+ // --node-snapshot-main=entry.js.
532
+ static Pointer BuiltinSnapshotData();
533
+
534
+ // Return an EmbedderSnapshotData object that is based on an input file.
535
+ // Calling this method will consume but not close the FILE* handle.
536
+ // The FILE* handle can be closed immediately following this call.
537
+ // If the snapshot is invalid, this returns an empty pointer.
538
+ static Pointer FromFile(FILE* in);
539
+ static Pointer FromBlob(const std::vector<char>& in);
540
+ static Pointer FromBlob(std::string_view in);
541
+
542
+ // Write this EmbedderSnapshotData object to an output file.
543
+ // Calling this method will not close the FILE* handle.
544
+ // The FILE* handle can be closed immediately following this call.
545
+ void ToFile(FILE* out) const;
546
+ std::vector<char> ToBlob() const;
547
+
548
+ // Returns whether custom snapshots can be used. Currently, this means
549
+ // that V8 was configured without the shared-readonly-heap feature.
550
+ static bool CanUseCustomSnapshotPerIsolate();
551
+
552
+ EmbedderSnapshotData(const EmbedderSnapshotData&) = delete;
553
+ EmbedderSnapshotData& operator=(const EmbedderSnapshotData&) = delete;
554
+ EmbedderSnapshotData(EmbedderSnapshotData&&) = delete;
555
+ EmbedderSnapshotData& operator=(EmbedderSnapshotData&&) = delete;
556
+
557
+ protected:
558
+ EmbedderSnapshotData(const SnapshotData* impl, bool owns_impl);
559
+
560
+ private:
561
+ const SnapshotData* impl_;
562
+ bool owns_impl_;
563
+ friend struct SnapshotData;
564
+ friend class CommonEnvironmentSetup;
370
565
  };
371
566
 
372
567
  // Overriding IsolateSettings may produce unexpected behavior
@@ -382,13 +577,18 @@ NODE_EXTERN void SetIsolateUpForNode(v8::Isolate* isolate);
382
577
  // This is a convenience method equivalent to using SetIsolateCreateParams(),
383
578
  // Isolate::Allocate(), MultiIsolatePlatform::RegisterIsolate(),
384
579
  // Isolate::Initialize(), and SetIsolateUpForNode().
385
- NODE_EXTERN v8::Isolate* NewIsolate(ArrayBufferAllocator* allocator,
386
- struct uv_loop_s* event_loop,
387
- MultiIsolatePlatform* platform = nullptr);
580
+ NODE_EXTERN v8::Isolate* NewIsolate(
581
+ ArrayBufferAllocator* allocator,
582
+ struct uv_loop_s* event_loop,
583
+ MultiIsolatePlatform* platform,
584
+ const EmbedderSnapshotData* snapshot_data = nullptr,
585
+ const IsolateSettings& settings = {});
388
586
  NODE_EXTERN v8::Isolate* NewIsolate(
389
587
  std::shared_ptr<ArrayBufferAllocator> allocator,
390
588
  struct uv_loop_s* event_loop,
391
- MultiIsolatePlatform* platform);
589
+ MultiIsolatePlatform* platform,
590
+ const EmbedderSnapshotData* snapshot_data = nullptr,
591
+ const IsolateSettings& settings = {});
392
592
 
393
593
  // Creates a new context with Node.js-specific tweaks.
394
594
  NODE_EXTERN v8::Local<v8::Context> NewContext(
@@ -407,7 +607,8 @@ NODE_EXTERN IsolateData* CreateIsolateData(
407
607
  v8::Isolate* isolate,
408
608
  struct uv_loop_s* loop,
409
609
  MultiIsolatePlatform* platform = nullptr,
410
- ArrayBufferAllocator* allocator = nullptr);
610
+ ArrayBufferAllocator* allocator = nullptr,
611
+ const EmbedderSnapshotData* snapshot_data = nullptr);
411
612
  NODE_EXTERN void FreeIsolateData(IsolateData* isolate_data);
412
613
 
413
614
  struct ThreadId {
@@ -456,17 +657,54 @@ enum Flags : uint64_t {
456
657
  // This control is needed by embedders who may not want to initialize the V8
457
658
  // inspector in situations where one has already been created,
458
659
  // e.g. Blink's in Chromium.
459
- kNoCreateInspector = 1 << 9
660
+ kNoCreateInspector = 1 << 9,
661
+ // Controls whether or not the InspectorAgent for this Environment should
662
+ // call StartDebugSignalHandler. This control is needed by embedders who may
663
+ // not want to allow other processes to start the V8 inspector.
664
+ kNoStartDebugSignalHandler = 1 << 10,
665
+ // Controls whether the InspectorAgent created for this Environment waits for
666
+ // Inspector frontend events during the Environment creation. It's used to
667
+ // call node::Stop(env) on a Worker thread that is waiting for the events.
668
+ kNoWaitForInspectorFrontend = 1 << 11
460
669
  };
461
670
  } // namespace EnvironmentFlags
462
671
 
672
+ enum class SnapshotFlags : uint32_t {
673
+ kDefault = 0,
674
+ // Whether code cache should be generated as part of the snapshot.
675
+ // Code cache reduces the time spent on compiling functions included
676
+ // in the snapshot at the expense of a bigger snapshot size and
677
+ // potentially breaking portability of the snapshot.
678
+ kWithoutCodeCache = 1 << 0,
679
+ };
680
+
681
+ struct SnapshotConfig {
682
+ SnapshotFlags flags = SnapshotFlags::kDefault;
683
+
684
+ // When builder_script_path is std::nullopt, the snapshot is generated as a
685
+ // built-in snapshot instead of a custom one, and it's expected that the
686
+ // built-in snapshot only contains states that reproduce in every run of the
687
+ // application. The event loop won't be run when generating a built-in
688
+ // snapshot, so asynchronous operations should be avoided.
689
+ //
690
+ // When builder_script_path is an std::string, it should match args[1]
691
+ // passed to CreateForSnapshotting(). The embedder is also expected to use
692
+ // LoadEnvironment() to run a script matching this path. In that case the
693
+ // snapshot is generated as a custom snapshot and the event loop is run, so
694
+ // the snapshot builder can execute asynchronous operations as long as they
695
+ // are run to completion when the snapshot is taken.
696
+ std::optional<std::string> builder_script_path;
697
+ };
698
+
463
699
  struct InspectorParentHandle {
464
- virtual ~InspectorParentHandle();
700
+ virtual ~InspectorParentHandle() = default;
465
701
  };
466
702
 
467
703
  // TODO(addaleax): Maybe move per-Environment options parsing here.
468
704
  // Returns nullptr when the Environment cannot be created e.g. there are
469
705
  // pending JavaScript exceptions.
706
+ // `context` may be empty if an `EmbedderSnapshotData` instance was provided
707
+ // to `NewIsolate()` and `CreateIsolateData()`.
470
708
  NODE_EXTERN Environment* CreateEnvironment(
471
709
  IsolateData* isolate_data,
472
710
  v8::Local<v8::Context> context,
@@ -488,20 +726,47 @@ NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
488
726
  ThreadId child_thread_id,
489
727
  const char* child_url);
490
728
 
729
+ NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
730
+ Environment* parent_env,
731
+ ThreadId child_thread_id,
732
+ const char* child_url,
733
+ const char* name);
734
+
491
735
  struct StartExecutionCallbackInfo {
492
736
  v8::Local<v8::Object> process_object;
493
737
  v8::Local<v8::Function> native_require;
738
+ v8::Local<v8::Function> run_cjs;
494
739
  };
495
740
 
496
741
  using StartExecutionCallback =
497
742
  std::function<v8::MaybeLocal<v8::Value>(const StartExecutionCallbackInfo&)>;
743
+ using EmbedderPreloadCallback =
744
+ std::function<void(Environment* env,
745
+ v8::Local<v8::Value> process,
746
+ v8::Local<v8::Value> require)>;
498
747
 
748
+ // Run initialization for the environment.
749
+ //
750
+ // The |preload| function, usually used by embedders to inject scripts,
751
+ // will be run by Node.js before Node.js executes the entry point.
752
+ // The function is guaranteed to run before the user land module loader running
753
+ // any user code, so it is safe to assume that at this point, no user code has
754
+ // been run yet.
755
+ // The function will be executed with preload(process, require), and the passed
756
+ // require function has access to internal Node.js modules. There is no
757
+ // stability guarantee about the internals exposed to the internal require
758
+ // function. Expect breakages when updating Node.js versions if the embedder
759
+ // imports internal modules with the internal require function.
760
+ // Worker threads created in the environment will also respect The |preload|
761
+ // function, so make sure the function is thread-safe.
499
762
  NODE_EXTERN v8::MaybeLocal<v8::Value> LoadEnvironment(
500
763
  Environment* env,
501
- StartExecutionCallback cb);
764
+ StartExecutionCallback cb,
765
+ EmbedderPreloadCallback preload = nullptr);
502
766
  NODE_EXTERN v8::MaybeLocal<v8::Value> LoadEnvironment(
503
767
  Environment* env,
504
- const char* main_script_source_utf8);
768
+ std::string_view main_script_source_utf8,
769
+ EmbedderPreloadCallback preload = nullptr);
505
770
  NODE_EXTERN void FreeEnvironment(Environment* env);
506
771
 
507
772
  // Set a callback that is called when process.exit() is called from JS,
@@ -520,8 +785,12 @@ NODE_EXTERN void DefaultProcessExitHandler(Environment* env, int exit_code);
520
785
  NODE_EXTERN Environment* GetCurrentEnvironment(v8::Local<v8::Context> context);
521
786
  NODE_EXTERN IsolateData* GetEnvironmentIsolateData(Environment* env);
522
787
  NODE_EXTERN ArrayBufferAllocator* GetArrayBufferAllocator(IsolateData* data);
788
+ // This is mostly useful for Environment* instances that were created through
789
+ // a snapshot and have a main context that was read from that snapshot.
790
+ NODE_EXTERN v8::Local<v8::Context> GetMainContext(Environment* env);
523
791
 
524
- NODE_EXTERN void OnFatalError(const char* location, const char* message);
792
+ [[noreturn]] NODE_EXTERN void OnFatalError(const char* location,
793
+ const char* message);
525
794
  NODE_EXTERN void PromiseRejectCallback(v8::PromiseRejectMessage message);
526
795
  NODE_EXTERN bool AllowWasmCodeGenerationCallback(v8::Local<v8::Context> context,
527
796
  v8::Local<v8::String>);
@@ -531,6 +800,33 @@ NODE_EXTERN v8::MaybeLocal<v8::Value> PrepareStackTraceCallback(
531
800
  v8::Local<v8::Value> exception,
532
801
  v8::Local<v8::Array> trace);
533
802
 
803
+ // Writes a diagnostic report to a file. If filename is not provided, the
804
+ // default filename includes the date, time, PID, and a sequence number.
805
+ // The report's JavaScript stack trace is taken from err, if present.
806
+ // If isolate is nullptr, no information about the JavaScript environment
807
+ // is included in the report.
808
+ // Returns the filename of the written report.
809
+ NODE_EXTERN std::string TriggerNodeReport(v8::Isolate* isolate,
810
+ const char* message,
811
+ const char* trigger,
812
+ const std::string& filename,
813
+ v8::Local<v8::Value> error);
814
+ NODE_EXTERN std::string TriggerNodeReport(Environment* env,
815
+ const char* message,
816
+ const char* trigger,
817
+ const std::string& filename,
818
+ v8::Local<v8::Value> error);
819
+ NODE_EXTERN void GetNodeReport(v8::Isolate* isolate,
820
+ const char* message,
821
+ const char* trigger,
822
+ v8::Local<v8::Value> error,
823
+ std::ostream& out);
824
+ NODE_EXTERN void GetNodeReport(Environment* env,
825
+ const char* message,
826
+ const char* trigger,
827
+ v8::Local<v8::Value> error,
828
+ std::ostream& out);
829
+
534
830
  // This returns the MultiIsolatePlatform used for an Environment or IsolateData
535
831
  // instance, if one exists.
536
832
  NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(Environment* env);
@@ -584,6 +880,8 @@ NODE_EXTERN struct uv_loop_s* GetCurrentEventLoop(v8::Isolate* isolate);
584
880
  // This function only works if `env` has an associated `MultiIsolatePlatform`.
585
881
  NODE_EXTERN v8::Maybe<int> SpinEventLoop(Environment* env);
586
882
 
883
+ NODE_EXTERN std::string GetAnonymousMainPath();
884
+
587
885
  class NODE_EXTERN CommonEnvironmentSetup {
588
886
  public:
589
887
  ~CommonEnvironmentSetup();
@@ -599,8 +897,44 @@ class NODE_EXTERN CommonEnvironmentSetup {
599
897
  MultiIsolatePlatform* platform,
600
898
  std::vector<std::string>* errors,
601
899
  EnvironmentArgs&&... env_args);
900
+ template <typename... EnvironmentArgs>
901
+ static std::unique_ptr<CommonEnvironmentSetup> CreateFromSnapshot(
902
+ MultiIsolatePlatform* platform,
903
+ std::vector<std::string>* errors,
904
+ const EmbedderSnapshotData* snapshot_data,
905
+ EnvironmentArgs&&... env_args);
906
+
907
+ // Create an embedding setup which will be used for creating a snapshot
908
+ // using CreateSnapshot().
909
+ //
910
+ // This will create and attach a v8::SnapshotCreator to this instance,
911
+ // and the same restrictions apply to this instance that also apply to
912
+ // other V8 snapshotting environments.
913
+ // Not all Node.js APIs are supported in this case. Currently, there is
914
+ // no support for native/host objects other than Node.js builtins
915
+ // in the snapshot.
916
+ //
917
+ // If the embedder wants to use LoadEnvironment() later to run a snapshot
918
+ // builder script they should make sure args[1] contains the path of the
919
+ // snapshot script, which will be used to create __filename and __dirname
920
+ // in the context where the builder script is run. If they do not want to
921
+ // include the build-time paths into the snapshot, use the string returned
922
+ // by GetAnonymousMainPath() as args[1] to anonymize the script.
923
+ //
924
+ // Snapshots are an *experimental* feature. In particular, the embedder API
925
+ // exposed through this class is subject to change or removal between Node.js
926
+ // versions, including possible API and ABI breakage.
927
+ static std::unique_ptr<CommonEnvironmentSetup> CreateForSnapshotting(
928
+ MultiIsolatePlatform* platform,
929
+ std::vector<std::string>* errors,
930
+ const std::vector<std::string>& args = {},
931
+ const std::vector<std::string>& exec_args = {},
932
+ const SnapshotConfig& snapshot_config = {});
933
+ EmbedderSnapshotData::Pointer CreateSnapshot();
602
934
 
603
935
  struct uv_loop_s* event_loop() const;
936
+ v8::SnapshotCreator* snapshot_creator();
937
+ // Empty for snapshotting environments.
604
938
  std::shared_ptr<ArrayBufferAllocator> array_buffer_allocator() const;
605
939
  v8::Isolate* isolate() const;
606
940
  IsolateData* isolate_data() const;
@@ -613,12 +947,25 @@ class NODE_EXTERN CommonEnvironmentSetup {
613
947
  CommonEnvironmentSetup& operator=(CommonEnvironmentSetup&&) = delete;
614
948
 
615
949
  private:
950
+ enum Flags : uint32_t {
951
+ kNoFlags = 0,
952
+ kIsForSnapshotting = 1,
953
+ };
954
+
616
955
  struct Impl;
617
956
  Impl* impl_;
957
+
618
958
  CommonEnvironmentSetup(
619
959
  MultiIsolatePlatform*,
620
960
  std::vector<std::string>*,
621
961
  std::function<Environment*(const CommonEnvironmentSetup*)>);
962
+ CommonEnvironmentSetup(
963
+ MultiIsolatePlatform*,
964
+ std::vector<std::string>*,
965
+ const EmbedderSnapshotData*,
966
+ uint32_t flags,
967
+ std::function<Environment*(const CommonEnvironmentSetup*)>,
968
+ const SnapshotConfig* config = nullptr);
622
969
  };
623
970
 
624
971
  // Implementation for CommonEnvironmentSetup::Create
@@ -638,6 +985,29 @@ std::unique_ptr<CommonEnvironmentSetup> CommonEnvironmentSetup::Create(
638
985
  return ret;
639
986
  }
640
987
 
988
+ // Implementation for ::CreateFromSnapshot -- the ::Create() method
989
+ // could call this with a nullptr snapshot_data in a major version.
990
+ template <typename... EnvironmentArgs>
991
+ std::unique_ptr<CommonEnvironmentSetup>
992
+ CommonEnvironmentSetup::CreateFromSnapshot(
993
+ MultiIsolatePlatform* platform,
994
+ std::vector<std::string>* errors,
995
+ const EmbedderSnapshotData* snapshot_data,
996
+ EnvironmentArgs&&... env_args) {
997
+ auto ret = std::unique_ptr<CommonEnvironmentSetup>(new CommonEnvironmentSetup(
998
+ platform,
999
+ errors,
1000
+ snapshot_data,
1001
+ Flags::kNoFlags,
1002
+ [&](const CommonEnvironmentSetup* setup) -> Environment* {
1003
+ return CreateEnvironment(setup->isolate_data(),
1004
+ setup->context(),
1005
+ std::forward<EnvironmentArgs>(env_args)...);
1006
+ }));
1007
+ if (!errors->empty()) ret.reset();
1008
+ return ret;
1009
+ }
1010
+
641
1011
  /* Converts a unixtime to V8 Date */
642
1012
  NODE_DEPRECATED("Use v8::Date::New() directly",
643
1013
  inline v8::Local<v8::Value> NODE_UNIXTIME_V8(double time) {
@@ -653,44 +1023,38 @@ NODE_DEPRECATED("Use v8::Date::ValueOf() directly",
653
1023
  })
654
1024
  #define NODE_V8_UNIXTIME node::NODE_V8_UNIXTIME
655
1025
 
656
- #define NODE_DEFINE_CONSTANT(target, constant) \
657
- do { \
658
- v8::Isolate* isolate = target->GetIsolate(); \
659
- v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
660
- v8::Local<v8::String> constant_name = \
661
- v8::String::NewFromUtf8(isolate, #constant, \
662
- v8::NewStringType::kInternalized).ToLocalChecked(); \
663
- v8::Local<v8::Number> constant_value = \
664
- v8::Number::New(isolate, static_cast<double>(constant)); \
665
- v8::PropertyAttribute constant_attributes = \
666
- static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \
667
- (target)->DefineOwnProperty(context, \
668
- constant_name, \
669
- constant_value, \
670
- constant_attributes).Check(); \
671
- } \
672
- while (0)
673
-
674
- #define NODE_DEFINE_HIDDEN_CONSTANT(target, constant) \
675
- do { \
676
- v8::Isolate* isolate = target->GetIsolate(); \
677
- v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
678
- v8::Local<v8::String> constant_name = \
679
- v8::String::NewFromUtf8(isolate, #constant, \
680
- v8::NewStringType::kInternalized) \
681
- .ToLocalChecked(); \
682
- v8::Local<v8::Number> constant_value = \
683
- v8::Number::New(isolate, static_cast<double>(constant)); \
684
- v8::PropertyAttribute constant_attributes = \
685
- static_cast<v8::PropertyAttribute>(v8::ReadOnly | \
686
- v8::DontDelete | \
687
- v8::DontEnum); \
688
- (target)->DefineOwnProperty(context, \
689
- constant_name, \
690
- constant_value, \
691
- constant_attributes).Check(); \
692
- } \
693
- while (0)
1026
+ #define NODE_DEFINE_CONSTANT(target, constant) \
1027
+ do { \
1028
+ v8::Isolate* isolate = target->GetIsolate(); \
1029
+ v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
1030
+ v8::Local<v8::String> constant_name = v8::String::NewFromUtf8Literal( \
1031
+ isolate, #constant, v8::NewStringType::kInternalized); \
1032
+ v8::Local<v8::Number> constant_value = \
1033
+ v8::Number::New(isolate, static_cast<double>(constant)); \
1034
+ v8::PropertyAttribute constant_attributes = \
1035
+ static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \
1036
+ (target) \
1037
+ ->DefineOwnProperty( \
1038
+ context, constant_name, constant_value, constant_attributes) \
1039
+ .Check(); \
1040
+ } while (0)
1041
+
1042
+ #define NODE_DEFINE_HIDDEN_CONSTANT(target, constant) \
1043
+ do { \
1044
+ v8::Isolate* isolate = target->GetIsolate(); \
1045
+ v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
1046
+ v8::Local<v8::String> constant_name = v8::String::NewFromUtf8Literal( \
1047
+ isolate, #constant, v8::NewStringType::kInternalized); \
1048
+ v8::Local<v8::Number> constant_value = \
1049
+ v8::Number::New(isolate, static_cast<double>(constant)); \
1050
+ v8::PropertyAttribute constant_attributes = \
1051
+ static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete | \
1052
+ v8::DontEnum); \
1053
+ (target) \
1054
+ ->DefineOwnProperty( \
1055
+ context, constant_name, constant_value, constant_attributes) \
1056
+ .Check(); \
1057
+ } while (0)
694
1058
 
695
1059
  // Used to be a macro, hence the uppercase name.
696
1060
  inline void NODE_SET_METHOD(v8::Local<v8::Template> recv,
@@ -946,6 +1310,11 @@ NODE_EXTERN void AddLinkedBinding(Environment* env,
946
1310
  const char* name,
947
1311
  addon_context_register_func fn,
948
1312
  void* priv);
1313
+ NODE_EXTERN void AddLinkedBinding(
1314
+ Environment* env,
1315
+ const char* name,
1316
+ napi_addon_register_func fn,
1317
+ int32_t module_api_version = NODE_API_DEFAULT_MODULE_API_VERSION);
949
1318
 
950
1319
  /* Registers a callback with the passed-in Environment instance. The callback
951
1320
  * is called after the event loop exits, but before the VM is disposed.
@@ -1002,6 +1371,15 @@ inline void RemoveEnvironmentCleanupHook(AsyncCleanupHookHandle holder) {
1002
1371
  RemoveEnvironmentCleanupHookInternal(holder.get());
1003
1372
  }
1004
1373
 
1374
+ // This behaves like V8's Isolate::RequestInterrupt(), but also wakes up
1375
+ // the event loop if it is currently idle. Interrupt requests are drained
1376
+ // in `FreeEnvironment()`. The passed callback can not call back into
1377
+ // JavaScript.
1378
+ // This function can be called from any thread.
1379
+ NODE_EXTERN void RequestInterrupt(Environment* env,
1380
+ void (*fun)(void* arg),
1381
+ void* arg);
1382
+
1005
1383
  /* Returns the id of the current execution context. If the return value is
1006
1384
  * zero then no execution has been set. This will happen if the user handles
1007
1385
  * I/O from native code. */
@@ -1168,6 +1546,25 @@ void RegisterSignalHandler(int signal,
1168
1546
  bool reset_handler = false);
1169
1547
  #endif // _WIN32
1170
1548
 
1549
+ // Configure the layout of the JavaScript object with a cppgc::GarbageCollected
1550
+ // instance so that when the JavaScript object is reachable, the garbage
1551
+ // collected instance would have its Trace() method invoked per the cppgc
1552
+ // contract. To make it work, the process must have called
1553
+ // cppgc::InitializeProcess() before, which is usually the case for addons
1554
+ // loaded by the stand-alone Node.js executable. Embedders of Node.js can use
1555
+ // either need to call it themselves or make sure that
1556
+ // ProcessInitializationFlags::kNoInitializeCppgc is *not* set for cppgc to
1557
+ // work.
1558
+ // If the CppHeap is owned by Node.js, which is usually the case for addon,
1559
+ // the object must be created with at least two internal fields available,
1560
+ // and the first two internal fields would be configured by Node.js.
1561
+ // This may be superseded by a V8 API in the future, see
1562
+ // https://bugs.chromium.org/p/v8/issues/detail?id=13960. Until then this
1563
+ // serves as a helper for Node.js isolates.
1564
+ NODE_EXTERN void SetCppgcReference(v8::Isolate* isolate,
1565
+ v8::Local<v8::Object> object,
1566
+ void* wrappable);
1567
+
1171
1568
  } // namespace node
1172
1569
 
1173
1570
  #endif // SRC_NODE_H_