@encharm/cws 4.5.3 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/CLAUDE.md +83 -0
  3. package/README.md +20 -4
  4. package/binding.gyp +8 -2
  5. package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
  6. package/dist/bindings/cws_darwin_arm64_node127.node +0 -0
  7. package/dist/bindings/cws_darwin_arm64_node137.node +0 -0
  8. package/dist/bindings/cws_darwin_arm64_node147.node +0 -0
  9. package/dist/bindings/cws_linux_arm64_node115.node +0 -0
  10. package/dist/bindings/cws_linux_arm64_node127.node +0 -0
  11. package/dist/bindings/cws_linux_arm64_node137.node +0 -0
  12. package/dist/bindings/cws_linux_arm64_node147.node +0 -0
  13. package/dist/bindings/cws_linux_x64_node115.node +0 -0
  14. package/dist/bindings/cws_linux_x64_node127.node +0 -0
  15. package/dist/bindings/cws_linux_x64_node137.node +0 -0
  16. package/dist/bindings/cws_linux_x64_node147.node +0 -0
  17. package/dist/bindings/cws_win32_x64_node115.node +0 -0
  18. package/dist/bindings/cws_win32_x64_node127.node +0 -0
  19. package/dist/bindings/cws_win32_x64_node137.node +0 -0
  20. package/dist/bindings/cws_win32_x64_node147.node +0 -0
  21. package/dist/client.d.ts +1 -0
  22. package/dist/client.js +15 -1
  23. package/dist/index.d.ts +6 -1
  24. package/dist/index.js +2 -0
  25. package/dist/server.d.ts +1 -0
  26. package/dist/server.js +16 -2
  27. package/dist/shared.d.ts +1 -0
  28. package/dist/shared.js +3 -2
  29. package/package.json +1 -1
  30. package/src/Addon.cpp +4 -1
  31. package/src/Addon.h +80 -15
  32. package/src/Extensions.cpp +7 -1
  33. package/src/Extensions.h +2 -1
  34. package/src/Group.cpp +1 -1
  35. package/src/Group.h +4 -1
  36. package/src/HTTPSocket.cpp +1 -1
  37. package/src/Hub.cpp +11 -76
  38. package/src/Hub.h +12 -10
  39. package/src/Networking.h +11 -0
  40. package/src/Socket.h +201 -6
  41. package/src/WebSocket.cpp +8 -5
  42. package/src/Zlib.cpp +138 -0
  43. package/src/Zlib.h +38 -0
  44. package/src/cSNode.cpp +2 -0
  45. package/src/cSNode.h +4 -0
  46. package/src/headers/26/acorn_version.h +6 -0
  47. package/src/headers/26/aliased_buffer-inl.h +264 -0
  48. package/src/headers/26/aliased_buffer.h +205 -0
  49. package/src/headers/26/aliased_struct-inl.h +143 -0
  50. package/src/headers/26/aliased_struct.h +248 -0
  51. package/src/headers/26/amaro_version.h +6 -0
  52. package/src/headers/26/async_context_frame.h +33 -0
  53. package/src/headers/26/async_wrap-inl.h +123 -0
  54. package/src/headers/26/async_wrap.h +254 -0
  55. package/src/headers/26/base_object-inl.h +333 -0
  56. package/src/headers/26/base_object.h +339 -0
  57. package/src/headers/26/base_object_types.h +76 -0
  58. package/src/headers/26/blob_serializer_deserializer-inl.h +385 -0
  59. package/src/headers/26/blob_serializer_deserializer.h +142 -0
  60. package/src/headers/26/builtin_info.h +57 -0
  61. package/src/headers/26/callback_queue-inl.h +97 -0
  62. package/src/headers/26/callback_queue.h +79 -0
  63. package/src/headers/26/cares_wrap.h +475 -0
  64. package/src/headers/26/cleanup_queue-inl.h +36 -0
  65. package/src/headers/26/cleanup_queue.h +79 -0
  66. package/src/headers/26/compile_cache.h +134 -0
  67. package/src/headers/26/connect_wrap.h +26 -0
  68. package/src/headers/26/connection_wrap.h +30 -0
  69. package/src/headers/26/cppgc_helpers-inl.h +69 -0
  70. package/src/headers/26/cppgc_helpers.h +162 -0
  71. package/src/headers/26/crypto/crypto_aes.h +107 -0
  72. package/src/headers/26/crypto/crypto_argon2.h +88 -0
  73. package/src/headers/26/crypto/crypto_bio.h +193 -0
  74. package/src/headers/26/crypto/crypto_chacha20_poly1305.h +62 -0
  75. package/src/headers/26/crypto/crypto_cipher.h +291 -0
  76. package/src/headers/26/crypto/crypto_common.h +48 -0
  77. package/src/headers/26/crypto/crypto_context.h +219 -0
  78. package/src/headers/26/crypto/crypto_dh.h +104 -0
  79. package/src/headers/26/crypto/crypto_dsa.h +50 -0
  80. package/src/headers/26/crypto/crypto_ec.h +102 -0
  81. package/src/headers/26/crypto/crypto_hash.h +157 -0
  82. package/src/headers/26/crypto/crypto_hkdf.h +62 -0
  83. package/src/headers/26/crypto/crypto_hmac.h +92 -0
  84. package/src/headers/26/crypto/crypto_kem.h +131 -0
  85. package/src/headers/26/crypto/crypto_keygen.h +382 -0
  86. package/src/headers/26/crypto/crypto_keys.h +366 -0
  87. package/src/headers/26/crypto/crypto_kmac.h +79 -0
  88. package/src/headers/26/crypto/crypto_pbkdf2.h +76 -0
  89. package/src/headers/26/crypto/crypto_pqc.h +39 -0
  90. package/src/headers/26/crypto/crypto_random.h +127 -0
  91. package/src/headers/26/crypto/crypto_rsa.h +108 -0
  92. package/src/headers/26/crypto/crypto_scrypt.h +85 -0
  93. package/src/headers/26/crypto/crypto_sig.h +159 -0
  94. package/src/headers/26/crypto/crypto_spkac.h +21 -0
  95. package/src/headers/26/crypto/crypto_timing.h +20 -0
  96. package/src/headers/26/crypto/crypto_tls.h +342 -0
  97. package/src/headers/26/crypto/crypto_turboshake.h +105 -0
  98. package/src/headers/26/crypto/crypto_util.h +775 -0
  99. package/src/headers/26/crypto/crypto_x509.h +140 -0
  100. package/src/headers/26/dataqueue/queue.h +311 -0
  101. package/src/headers/26/debug_utils-inl.h +291 -0
  102. package/src/headers/26/debug_utils.h +200 -0
  103. package/src/headers/26/diagnosticfilename-inl.h +33 -0
  104. package/src/headers/26/embedded_data.h +17 -0
  105. package/src/headers/26/encoding_binding.h +59 -0
  106. package/src/headers/26/env-inl.h +956 -0
  107. package/src/headers/26/env.h +1294 -0
  108. package/src/headers/26/env_properties.h +562 -0
  109. package/src/headers/26/ffi/data.h +30 -0
  110. package/src/headers/26/ffi/fast.h +96 -0
  111. package/src/headers/26/ffi/jit_memory.h +26 -0
  112. package/src/headers/26/ffi/types.h +99 -0
  113. package/src/headers/26/handle_wrap.h +123 -0
  114. package/src/headers/26/histogram-inl.h +211 -0
  115. package/src/headers/26/histogram.h +474 -0
  116. package/src/headers/26/inspector/dom_storage_agent.h +68 -0
  117. package/src/headers/26/inspector/inspector_object_utils.h +38 -0
  118. package/src/headers/26/inspector/io_agent.h +30 -0
  119. package/src/headers/26/inspector/main_thread_interface.h +116 -0
  120. package/src/headers/26/inspector/network_agent.h +110 -0
  121. package/src/headers/26/inspector/network_inspector.h +45 -0
  122. package/src/headers/26/inspector/network_requests_buffer.h +195 -0
  123. package/src/headers/26/inspector/network_resource_manager.h +29 -0
  124. package/src/headers/26/inspector/node_json.h +24 -0
  125. package/src/headers/26/inspector/node_string.h +101 -0
  126. package/src/headers/26/inspector/notification_emitter.h +38 -0
  127. package/src/headers/26/inspector/protocol_helper.h +27 -0
  128. package/src/headers/26/inspector/runtime_agent.h +41 -0
  129. package/src/headers/26/inspector/storage_agent.h +33 -0
  130. package/src/headers/26/inspector/target_agent.h +59 -0
  131. package/src/headers/26/inspector/target_manager.h +70 -0
  132. package/src/headers/26/inspector/tracing_agent.h +43 -0
  133. package/src/headers/26/inspector/worker_agent.h +40 -0
  134. package/src/headers/26/inspector/worker_inspector.h +124 -0
  135. package/src/headers/26/inspector_agent.h +168 -0
  136. package/src/headers/26/inspector_io.h +78 -0
  137. package/src/headers/26/inspector_profiler.h +149 -0
  138. package/src/headers/26/inspector_socket.h +60 -0
  139. package/src/headers/26/inspector_socket_server.h +110 -0
  140. package/src/headers/26/js_native_api.h +634 -0
  141. package/src/headers/26/js_native_api_types.h +244 -0
  142. package/src/headers/26/js_native_api_v8.h +485 -0
  143. package/src/headers/26/js_native_api_v8_internals.h +45 -0
  144. package/src/headers/26/js_stream.h +57 -0
  145. package/src/headers/26/json_utils.h +172 -0
  146. package/src/headers/26/large_pages/node_large_page.h +34 -0
  147. package/src/headers/26/lru_cache-inl.h +69 -0
  148. package/src/headers/26/memory_tracker-inl.h +461 -0
  149. package/src/headers/26/memory_tracker.h +341 -0
  150. package/src/headers/26/module_wrap.h +231 -0
  151. package/src/headers/26/ncrypto.h +2008 -0
  152. package/src/headers/26/node.h +1693 -0
  153. package/src/headers/26/node_api.h +265 -0
  154. package/src/headers/26/node_api_internals.h +48 -0
  155. package/src/headers/26/node_api_types.h +58 -0
  156. package/src/headers/26/node_binding.h +170 -0
  157. package/src/headers/26/node_blob.h +160 -0
  158. package/src/headers/26/node_bob-inl.h +36 -0
  159. package/src/headers/26/node_bob.h +107 -0
  160. package/src/headers/26/node_buffer.h +92 -0
  161. package/src/headers/26/node_builtins.h +239 -0
  162. package/src/headers/26/node_concepts.h +46 -0
  163. package/src/headers/26/node_config_file.h +77 -0
  164. package/src/headers/26/node_constants.h +82 -0
  165. package/src/headers/26/node_context_data.h +171 -0
  166. package/src/headers/26/node_contextify.h +261 -0
  167. package/src/headers/26/node_crypto.h +66 -0
  168. package/src/headers/26/node_debug.h +30 -0
  169. package/src/headers/26/node_diagnostics_channel.h +121 -0
  170. package/src/headers/26/node_dir.h +52 -0
  171. package/src/headers/26/node_dotenv.h +45 -0
  172. package/src/headers/26/node_errors.h +378 -0
  173. package/src/headers/26/node_exit_code.h +54 -0
  174. package/src/headers/26/node_external_reference.h +171 -0
  175. package/src/headers/26/node_ffi.h +212 -0
  176. package/src/headers/26/node_file-inl.h +421 -0
  177. package/src/headers/26/node_file.h +561 -0
  178. package/src/headers/26/node_file_utils.h +39 -0
  179. package/src/headers/26/node_hash.h +212 -0
  180. package/src/headers/26/node_http2.h +1202 -0
  181. package/src/headers/26/node_http2_state.h +159 -0
  182. package/src/headers/26/node_http_common-inl.h +199 -0
  183. package/src/headers/26/node_http_common.h +535 -0
  184. package/src/headers/26/node_i18n.h +132 -0
  185. package/src/headers/26/node_internals.h +485 -0
  186. package/src/headers/26/node_locks.h +184 -0
  187. package/src/headers/26/node_main_instance.h +67 -0
  188. package/src/headers/26/node_mem-inl.h +113 -0
  189. package/src/headers/26/node_mem.h +45 -0
  190. package/src/headers/26/node_messaging.h +389 -0
  191. package/src/headers/26/node_metadata.h +172 -0
  192. package/src/headers/26/node_modules.h +102 -0
  193. package/src/headers/26/node_mutex.h +323 -0
  194. package/src/headers/26/node_object_wrap.h +145 -0
  195. package/src/headers/26/node_options-inl.h +524 -0
  196. package/src/headers/26/node_options.h +710 -0
  197. package/src/headers/26/node_perf.h +167 -0
  198. package/src/headers/26/node_perf_common.h +103 -0
  199. package/src/headers/26/node_platform.h +290 -0
  200. package/src/headers/26/node_process-inl.h +26 -0
  201. package/src/headers/26/node_process.h +112 -0
  202. package/src/headers/26/node_profiling.h +38 -0
  203. package/src/headers/26/node_realm-inl.h +156 -0
  204. package/src/headers/26/node_realm.h +236 -0
  205. package/src/headers/26/node_report.h +43 -0
  206. package/src/headers/26/node_revert.h +82 -0
  207. package/src/headers/26/node_root_certs.h +2937 -0
  208. package/src/headers/26/node_sea.h +101 -0
  209. package/src/headers/26/node_shadow_realm.h +46 -0
  210. package/src/headers/26/node_snapshot_builder.h +57 -0
  211. package/src/headers/26/node_snapshotable.h +167 -0
  212. package/src/headers/26/node_sockaddr-inl.h +248 -0
  213. package/src/headers/26/node_sockaddr.h +459 -0
  214. package/src/headers/26/node_sqlite.h +607 -0
  215. package/src/headers/26/node_stat_watcher.h +73 -0
  216. package/src/headers/26/node_task_runner.h +92 -0
  217. package/src/headers/26/node_threadsafe_cow-inl.h +54 -0
  218. package/src/headers/26/node_threadsafe_cow.h +105 -0
  219. package/src/headers/26/node_union_bytes.h +81 -0
  220. package/src/headers/26/node_url.h +101 -0
  221. package/src/headers/26/node_url_pattern.h +118 -0
  222. package/src/headers/26/node_v8.h +78 -0
  223. package/src/headers/26/node_v8_embedder.h +26 -0
  224. package/src/headers/26/node_v8_platform-inl.h +96 -0
  225. package/src/headers/26/node_version.h +116 -0
  226. package/src/headers/26/node_wasi.h +184 -0
  227. package/src/headers/26/node_wasm_web_api.h +55 -0
  228. package/src/headers/26/node_watchdog.h +164 -0
  229. package/src/headers/26/node_webstorage.h +62 -0
  230. package/src/headers/26/node_worker.h +162 -0
  231. package/src/headers/26/path.h +36 -0
  232. package/src/headers/26/permission/boolean_permission.h +50 -0
  233. package/src/headers/26/permission/fs_permission.h +192 -0
  234. package/src/headers/26/permission/permission.h +155 -0
  235. package/src/headers/26/permission/permission_base.h +79 -0
  236. package/src/headers/26/pipe_wrap.h +80 -0
  237. package/src/headers/26/quic/application.h +279 -0
  238. package/src/headers/26/quic/arena.h +373 -0
  239. package/src/headers/26/quic/bindingdata.h +440 -0
  240. package/src/headers/26/quic/cid.h +127 -0
  241. package/src/headers/26/quic/data.h +358 -0
  242. package/src/headers/26/quic/defs.h +417 -0
  243. package/src/headers/26/quic/endpoint.h +519 -0
  244. package/src/headers/26/quic/guard.h +5 -0
  245. package/src/headers/26/quic/http3.h +25 -0
  246. package/src/headers/26/quic/packet.h +166 -0
  247. package/src/headers/26/quic/preferredaddress.h +72 -0
  248. package/src/headers/26/quic/session.h +770 -0
  249. package/src/headers/26/quic/session_manager.h +107 -0
  250. package/src/headers/26/quic/sessionticket.h +110 -0
  251. package/src/headers/26/quic/streams.h +518 -0
  252. package/src/headers/26/quic/tlscontext.h +353 -0
  253. package/src/headers/26/quic/tokens.h +263 -0
  254. package/src/headers/26/quic/transportparams.h +184 -0
  255. package/src/headers/26/req_wrap-inl.h +175 -0
  256. package/src/headers/26/req_wrap.h +79 -0
  257. package/src/headers/26/spawn_sync.h +243 -0
  258. package/src/headers/26/stream_base-inl.h +170 -0
  259. package/src/headers/26/stream_base.h +487 -0
  260. package/src/headers/26/stream_pipe.h +76 -0
  261. package/src/headers/26/stream_wrap.h +137 -0
  262. package/src/headers/26/string_bytes.h +114 -0
  263. package/src/headers/26/string_decoder-inl.h +31 -0
  264. package/src/headers/26/string_decoder.h +49 -0
  265. package/src/headers/26/tcp_wrap.h +138 -0
  266. package/src/headers/26/threadpoolwork-inl.h +70 -0
  267. package/src/headers/26/timer_wrap-inl.h +32 -0
  268. package/src/headers/26/timer_wrap.h +87 -0
  269. package/src/headers/26/timers.h +70 -0
  270. package/src/headers/26/tracing/agent.h +125 -0
  271. package/src/headers/26/tracing/agent_legacy.h +146 -0
  272. package/src/headers/26/tracing/agent_perfetto.h +145 -0
  273. package/src/headers/26/tracing/node_trace_buffer.h +91 -0
  274. package/src/headers/26/tracing/node_trace_writer.h +79 -0
  275. package/src/headers/26/tracing/trace_event.h +27 -0
  276. package/src/headers/26/tracing/trace_event_helper.h +40 -0
  277. package/src/headers/26/tracing/trace_event_legacy.h +1113 -0
  278. package/src/headers/26/tracing/trace_event_legacy_inl.h +711 -0
  279. package/src/headers/26/tracing/trace_event_perfetto.h +47 -0
  280. package/src/headers/26/tracing/traced_value.h +167 -0
  281. package/src/headers/26/tty_wrap.h +65 -0
  282. package/src/headers/26/udp_wrap.h +231 -0
  283. package/src/headers/26/undici_version.h +6 -0
  284. package/src/headers/26/util-inl.h +788 -0
  285. package/src/headers/26/util.h +1207 -0
  286. package/src/headers/26/v8-cpp-heap-external.h +56 -0
  287. package/src/headers/26/v8-external-memory-accounter.h +60 -0
  288. package/src/headers/26/v8-fast-api-calls.h +784 -0
  289. package/src/headers/26/v8-inspector-protocol.h +13 -0
  290. package/src/headers/26/v8-inspector.h +458 -0
  291. package/src/headers/26/v8-metrics.h +273 -0
  292. package/src/headers/26/v8-trace-categories.h +28 -0
  293. package/src/headers/26/v8-unwinder-state.h +30 -0
  294. package/src/headers/26/v8-util.h +549 -0
  295. package/src/headers/26/v8-value-serializer-version.h +24 -0
  296. package/src/headers/26/v8-version-string.h +38 -0
  297. package/src/headers/26/v8-wasm-trap-handler-posix.h +31 -0
  298. package/src/headers/26/v8-wasm-trap-handler-win.h +28 -0
  299. package/src/headers/26/zlib_version.h +6 -0
  300. package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Info.plist +0 -20
  301. package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Resources/DWARF/cws_darwin_arm64_node115.node +0 -0
  302. package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Resources/Relocations/aarch64/cws_darwin_arm64_node115.node.yml +0 -931
  303. package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Info.plist +0 -20
  304. package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Resources/DWARF/cws_darwin_arm64_node127.node +0 -0
  305. package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Resources/Relocations/aarch64/cws_darwin_arm64_node127.node.yml +0 -931
@@ -0,0 +1,172 @@
1
+ #ifndef SRC_NODE_METADATA_H_
2
+ #define SRC_NODE_METADATA_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include <array>
7
+ #include <string>
8
+ #include <utility>
9
+ #include "node_version.h"
10
+
11
+ #if HAVE_OPENSSL
12
+ #include <openssl/crypto.h>
13
+ #include <quic/guard.h>
14
+ #ifndef OPENSSL_NO_QUIC
15
+ #include <openssl/quic.h>
16
+ #endif
17
+ #endif // HAVE_OPENSSL
18
+
19
+ namespace node {
20
+
21
+ // if this is a release build and no explicit base has been set
22
+ // substitute the standard release download URL
23
+ #ifndef NODE_RELEASE_URLBASE
24
+ #if NODE_VERSION_IS_RELEASE
25
+ #define NODE_RELEASE_URLBASE "https://nodejs.org/download/release/"
26
+ #endif // NODE_VERSION_IS_RELEASE
27
+ #endif // NODE_RELEASE_URLBASE
28
+
29
+ #if defined(NODE_RELEASE_URLBASE)
30
+ #define NODE_HAS_RELEASE_URLS
31
+ #endif
32
+
33
+ #if HAVE_AMARO && !defined(NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH)
34
+ #define NODE_VERSIONS_KEY_AMARO(V) V(amaro)
35
+ #else
36
+ #define NODE_VERSIONS_KEY_AMARO(V)
37
+ #endif
38
+
39
+ #ifndef NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH
40
+ #define NODE_VERSIONS_KEY_UNDICI(V) V(undici)
41
+ #else
42
+ #define NODE_VERSIONS_KEY_UNDICI(V)
43
+ #endif
44
+
45
+ #define NODE_VERSIONS_KEYS_BASE(V) \
46
+ V(node) \
47
+ V(v8) \
48
+ V(uv) \
49
+ V(zlib) \
50
+ V(brotli) \
51
+ V(zstd) \
52
+ V(ares) \
53
+ V(modules) \
54
+ V(nghttp2) \
55
+ V(napi) \
56
+ V(llhttp) \
57
+ V(uvwasi) \
58
+ V(acorn) \
59
+ V(simdjson) \
60
+ V(simdutf) \
61
+ V(ada) \
62
+ V(nbytes) \
63
+ V(ngtcp2) \
64
+ V(nghttp3) \
65
+ NODE_VERSIONS_KEY_AMARO(V) \
66
+ NODE_VERSIONS_KEY_UNDICI(V) \
67
+ V(merve)
68
+
69
+ #if HAVE_OPENSSL
70
+ #define NODE_VERSIONS_KEY_CRYPTO(V) V(openssl) V(ncrypto)
71
+ #else
72
+ #define NODE_VERSIONS_KEY_CRYPTO(V)
73
+ #endif
74
+
75
+ #ifdef NODE_HAVE_I18N_SUPPORT
76
+ #define NODE_VERSIONS_KEY_INTL(V) \
77
+ V(cldr) \
78
+ V(icu) \
79
+ V(tz) \
80
+ V(unicode)
81
+ #else
82
+ #define NODE_VERSIONS_KEY_INTL(V)
83
+ #endif // NODE_HAVE_I18N_SUPPORT
84
+
85
+ #if HAVE_SQLITE
86
+ #define NODE_VERSIONS_KEY_SQLITE(V) V(sqlite)
87
+ #else
88
+ #define NODE_VERSIONS_KEY_SQLITE(V)
89
+ #endif
90
+
91
+ #if HAVE_FFI
92
+ #define NODE_VERSIONS_KEY_LIBFFI(V) V(libffi)
93
+ #else
94
+ #define NODE_VERSIONS_KEY_LIBFFI(V)
95
+ #endif
96
+
97
+ #if HAVE_LIEF
98
+ #define NODE_VERSIONS_KEY_LIEF(V) V(lief)
99
+ #else
100
+ #define NODE_VERSIONS_KEY_LIEF(V)
101
+ #endif
102
+
103
+ #define NODE_VERSIONS_KEYS(V) \
104
+ NODE_VERSIONS_KEYS_BASE(V) \
105
+ NODE_VERSIONS_KEY_CRYPTO(V) \
106
+ NODE_VERSIONS_KEY_INTL(V) \
107
+ NODE_VERSIONS_KEY_SQLITE(V) \
108
+ NODE_VERSIONS_KEY_LIBFFI(V) \
109
+ NODE_VERSIONS_KEY_LIEF(V)
110
+
111
+ #define V(key) +1
112
+ constexpr int NODE_VERSIONS_KEY_COUNT = NODE_VERSIONS_KEYS(V);
113
+ #undef V
114
+
115
+ class Metadata {
116
+ public:
117
+ Metadata();
118
+ Metadata(Metadata&) = delete;
119
+ Metadata(Metadata&&) = delete;
120
+ Metadata operator=(Metadata&) = delete;
121
+ Metadata operator=(Metadata&&) = delete;
122
+
123
+ struct Versions {
124
+ Versions();
125
+
126
+ #ifdef NODE_HAVE_I18N_SUPPORT
127
+ // Must be called on the main thread after
128
+ // i18n::InitializeICUDirectory()
129
+ void InitializeIntlVersions();
130
+ #endif // NODE_HAVE_I18N_SUPPORT
131
+
132
+ #define V(key) std::string key;
133
+ NODE_VERSIONS_KEYS(V)
134
+ #undef V
135
+
136
+ std::array<std::pair<std::string_view, std::string_view>,
137
+ NODE_VERSIONS_KEY_COUNT>
138
+ pairs() const;
139
+ };
140
+
141
+ struct Release {
142
+ Release();
143
+
144
+ std::string name;
145
+ #if NODE_VERSION_IS_LTS
146
+ std::string lts;
147
+ #endif // NODE_VERSION_IS_LTS
148
+
149
+ #ifdef NODE_HAS_RELEASE_URLS
150
+ std::string source_url;
151
+ std::string headers_url;
152
+ #ifdef _WIN32
153
+ std::string lib_url;
154
+ #endif // _WIN32
155
+ #endif // NODE_HAS_RELEASE_URLS
156
+ };
157
+
158
+ Versions versions;
159
+ const Release release;
160
+ const std::string arch;
161
+ const std::string platform;
162
+ };
163
+
164
+ // Per-process global
165
+ namespace per_process {
166
+ extern Metadata metadata;
167
+ }
168
+
169
+ } // namespace node
170
+
171
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
172
+ #endif // SRC_NODE_METADATA_H_
@@ -0,0 +1,102 @@
1
+ #ifndef SRC_NODE_MODULES_H_
2
+ #define SRC_NODE_MODULES_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "node.h"
7
+ #include "node_snapshotable.h"
8
+ #include "simdjson.h"
9
+ #include "util.h"
10
+ #include "v8-fast-api-calls.h"
11
+ #include "v8.h"
12
+
13
+ #include <filesystem>
14
+ #include <optional>
15
+ #include <string>
16
+ #include <string_view>
17
+ #include <unordered_map>
18
+
19
+ namespace node {
20
+ class ExternalReferenceRegistry;
21
+
22
+ namespace modules {
23
+
24
+ class BindingData : public SnapshotableObject {
25
+ public:
26
+ using InternalFieldInfo = InternalFieldInfoBase;
27
+
28
+ struct PackageConfig {
29
+ std::string file_path;
30
+ std::optional<std::string> name;
31
+ std::optional<std::string> main;
32
+ std::string type = "none";
33
+ std::optional<std::string> exports;
34
+ std::optional<std::string> imports;
35
+ std::optional<std::string> scripts;
36
+ std::string raw_json;
37
+
38
+ v8::Local<v8::Array> Serialize(Realm* realm) const;
39
+ };
40
+
41
+ struct ErrorContext {
42
+ std::optional<std::string> base;
43
+ std::string specifier;
44
+ bool is_esm;
45
+ };
46
+
47
+ BindingData(Realm* realm,
48
+ v8::Local<v8::Object> obj,
49
+ InternalFieldInfo* info = nullptr);
50
+ SERIALIZABLE_OBJECT_METHODS()
51
+ SET_BINDING_ID(modules_binding_data)
52
+
53
+ void MemoryInfo(MemoryTracker* tracker) const override;
54
+ SET_SELF_SIZE(BindingData)
55
+ SET_MEMORY_INFO_NAME(BindingData)
56
+
57
+ static void ReadPackageJSON(const v8::FunctionCallbackInfo<v8::Value>& args);
58
+ static void GetNearestParentPackageJSON(
59
+ const v8::FunctionCallbackInfo<v8::Value>& args);
60
+ static void GetNearestParentPackageJSONType(
61
+ const v8::FunctionCallbackInfo<v8::Value>& args);
62
+ template <bool return_only_type>
63
+ static void GetPackageScopeConfig(
64
+ const v8::FunctionCallbackInfo<v8::Value>& args);
65
+ static void GetPackageJSONScripts(
66
+ const v8::FunctionCallbackInfo<v8::Value>& args);
67
+
68
+ static void CreatePerIsolateProperties(IsolateData* isolate_data,
69
+ v8::Local<v8::ObjectTemplate> ctor);
70
+ static void CreatePerContextProperties(v8::Local<v8::Object> target,
71
+ v8::Local<v8::Value> unused,
72
+ v8::Local<v8::Context> context,
73
+ void* priv);
74
+ static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
75
+
76
+ private:
77
+ /*
78
+ * This map caches `PackageConfig` values by `package.json` path.
79
+ * An empty optional value indicates that no `package.json` file
80
+ * at the given path exists, which we cache to avoid repeated
81
+ * attempts to open the same non-existent paths.
82
+ */
83
+ std::unordered_map<std::string, std::optional<PackageConfig> >
84
+ package_configs_;
85
+ simdjson::ondemand::parser json_parser;
86
+ static const std::filesystem::path NormalizePath(Realm* realm,
87
+ BufferValue* path_value);
88
+ // returns null on error
89
+ static const PackageConfig* GetPackageJSON(
90
+ Realm* realm,
91
+ std::string_view path,
92
+ ErrorContext* error_context = nullptr);
93
+ static const PackageConfig* TraverseParent(
94
+ Realm* realm, const std::filesystem::path& check_path);
95
+ };
96
+
97
+ } // namespace modules
98
+ } // namespace node
99
+
100
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
101
+
102
+ #endif // SRC_NODE_MODULES_H_
@@ -0,0 +1,323 @@
1
+ #ifndef SRC_NODE_MUTEX_H_
2
+ #define SRC_NODE_MUTEX_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "util.h"
7
+ #include "uv.h"
8
+
9
+ #include <memory> // std::shared_ptr<T>
10
+ #include <utility> // std::forward<T>
11
+
12
+ namespace node {
13
+
14
+ template <typename Traits> class ConditionVariableBase;
15
+ template <typename Traits> class MutexBase;
16
+ struct LibuvMutexTraits;
17
+ struct LibuvRwlockTraits;
18
+
19
+ using ConditionVariable = ConditionVariableBase<LibuvMutexTraits>;
20
+ using Mutex = MutexBase<LibuvMutexTraits>;
21
+ using RwLock = MutexBase<LibuvRwlockTraits>;
22
+
23
+ template <typename T, typename MutexT = Mutex>
24
+ class ExclusiveAccess {
25
+ public:
26
+ ExclusiveAccess() = default;
27
+
28
+ template <typename... Args>
29
+ explicit ExclusiveAccess(Args&&... args)
30
+ : item_(std::forward<Args>(args)...) {}
31
+
32
+ ExclusiveAccess(const ExclusiveAccess&) = delete;
33
+ ExclusiveAccess& operator=(const ExclusiveAccess&) = delete;
34
+
35
+ class Scoped {
36
+ public:
37
+ // ExclusiveAccess will commonly be used in conjunction with std::shared_ptr
38
+ // and without this constructor it's too easy to forget to keep a reference
39
+ // around to the shared_ptr while operating on the ExclusiveAccess object.
40
+ explicit Scoped(const std::shared_ptr<ExclusiveAccess>& shared)
41
+ : shared_(shared)
42
+ , scoped_lock_(shared->mutex_)
43
+ , pointer_(&shared->item_) {}
44
+
45
+ explicit Scoped(ExclusiveAccess* exclusive_access)
46
+ : shared_()
47
+ , scoped_lock_(exclusive_access->mutex_)
48
+ , pointer_(&exclusive_access->item_) {}
49
+
50
+ T& operator*() const { return *pointer_; }
51
+ T* operator->() const { return pointer_; }
52
+
53
+ Scoped(const Scoped&) = delete;
54
+ Scoped& operator=(const Scoped&) = delete;
55
+
56
+ private:
57
+ std::shared_ptr<ExclusiveAccess> shared_;
58
+ typename MutexT::ScopedLock scoped_lock_;
59
+ T* const pointer_;
60
+ };
61
+
62
+ private:
63
+ friend class ScopedLock;
64
+ MutexT mutex_;
65
+ T item_;
66
+ };
67
+
68
+ template <typename Traits>
69
+ class MutexBase {
70
+ public:
71
+ inline MutexBase();
72
+ inline ~MutexBase();
73
+ inline void Lock();
74
+ inline void Unlock();
75
+ inline void RdLock();
76
+ inline void RdUnlock();
77
+
78
+ MutexBase(const MutexBase&) = delete;
79
+ MutexBase& operator=(const MutexBase&) = delete;
80
+
81
+ class ScopedLock;
82
+ class ScopedUnlock;
83
+
84
+ class ScopedLock {
85
+ public:
86
+ inline explicit ScopedLock(const MutexBase& mutex);
87
+ inline explicit ScopedLock(const ScopedUnlock& scoped_unlock);
88
+ inline ~ScopedLock();
89
+
90
+ ScopedLock(const ScopedLock&) = delete;
91
+ ScopedLock& operator=(const ScopedLock&) = delete;
92
+
93
+ private:
94
+ template <typename> friend class ConditionVariableBase;
95
+ friend class ScopedUnlock;
96
+ const MutexBase& mutex_;
97
+ };
98
+
99
+ class ScopedReadLock {
100
+ public:
101
+ inline explicit ScopedReadLock(const MutexBase& mutex);
102
+ inline ~ScopedReadLock();
103
+
104
+ ScopedReadLock(const ScopedReadLock&) = delete;
105
+ ScopedReadLock& operator=(const ScopedReadLock&) = delete;
106
+
107
+ private:
108
+ template <typename> friend class ConditionVariableBase;
109
+ const MutexBase& mutex_;
110
+ };
111
+
112
+ using ScopedWriteLock = ScopedLock;
113
+
114
+ class ScopedUnlock {
115
+ public:
116
+ inline explicit ScopedUnlock(const ScopedLock& scoped_lock);
117
+ inline ~ScopedUnlock();
118
+
119
+ ScopedUnlock(const ScopedUnlock&) = delete;
120
+ ScopedUnlock& operator=(const ScopedUnlock&) = delete;
121
+
122
+ private:
123
+ friend class ScopedLock;
124
+ const MutexBase& mutex_;
125
+ };
126
+
127
+ private:
128
+ template <typename> friend class ConditionVariableBase;
129
+ mutable typename Traits::MutexT mutex_;
130
+ };
131
+
132
+ template <typename Traits>
133
+ class ConditionVariableBase {
134
+ public:
135
+ using ScopedLock = typename MutexBase<Traits>::ScopedLock;
136
+
137
+ inline ConditionVariableBase();
138
+ inline ~ConditionVariableBase();
139
+ inline void Broadcast(const ScopedLock&);
140
+ inline void Signal(const ScopedLock&);
141
+ inline void Wait(const ScopedLock& scoped_lock);
142
+
143
+ ConditionVariableBase(const ConditionVariableBase&) = delete;
144
+ ConditionVariableBase& operator=(const ConditionVariableBase&) = delete;
145
+
146
+ private:
147
+ typename Traits::CondT cond_;
148
+ };
149
+
150
+ struct LibuvMutexTraits {
151
+ using CondT = uv_cond_t;
152
+ using MutexT = uv_mutex_t;
153
+
154
+ static inline int cond_init(CondT* cond) {
155
+ return uv_cond_init(cond);
156
+ }
157
+
158
+ static inline int mutex_init(MutexT* mutex) {
159
+ return uv_mutex_init(mutex);
160
+ }
161
+
162
+ static inline void cond_broadcast(CondT* cond) {
163
+ uv_cond_broadcast(cond);
164
+ }
165
+
166
+ static inline void cond_destroy(CondT* cond) {
167
+ uv_cond_destroy(cond);
168
+ }
169
+
170
+ static inline void cond_signal(CondT* cond) {
171
+ uv_cond_signal(cond);
172
+ }
173
+
174
+ static inline void cond_wait(CondT* cond, MutexT* mutex) {
175
+ uv_cond_wait(cond, mutex);
176
+ }
177
+
178
+ static inline void mutex_destroy(MutexT* mutex) {
179
+ uv_mutex_destroy(mutex);
180
+ }
181
+
182
+ static inline void mutex_lock(MutexT* mutex) {
183
+ uv_mutex_lock(mutex);
184
+ }
185
+
186
+ static inline void mutex_unlock(MutexT* mutex) {
187
+ uv_mutex_unlock(mutex);
188
+ }
189
+
190
+ static inline void mutex_rdlock(MutexT* mutex) {
191
+ uv_mutex_lock(mutex);
192
+ }
193
+
194
+ static inline void mutex_rdunlock(MutexT* mutex) {
195
+ uv_mutex_unlock(mutex);
196
+ }
197
+ };
198
+
199
+ struct LibuvRwlockTraits {
200
+ using MutexT = uv_rwlock_t;
201
+
202
+ static inline int mutex_init(MutexT* mutex) {
203
+ return uv_rwlock_init(mutex);
204
+ }
205
+
206
+ static inline void mutex_destroy(MutexT* mutex) {
207
+ uv_rwlock_destroy(mutex);
208
+ }
209
+
210
+ static inline void mutex_lock(MutexT* mutex) {
211
+ uv_rwlock_wrlock(mutex);
212
+ }
213
+
214
+ static inline void mutex_unlock(MutexT* mutex) {
215
+ uv_rwlock_wrunlock(mutex);
216
+ }
217
+
218
+ static inline void mutex_rdlock(MutexT* mutex) {
219
+ uv_rwlock_rdlock(mutex);
220
+ }
221
+
222
+ static inline void mutex_rdunlock(MutexT* mutex) {
223
+ uv_rwlock_rdunlock(mutex);
224
+ }
225
+ };
226
+
227
+ template <typename Traits>
228
+ ConditionVariableBase<Traits>::ConditionVariableBase() {
229
+ CHECK_EQ(0, Traits::cond_init(&cond_));
230
+ }
231
+
232
+ template <typename Traits>
233
+ ConditionVariableBase<Traits>::~ConditionVariableBase() {
234
+ Traits::cond_destroy(&cond_);
235
+ }
236
+
237
+ template <typename Traits>
238
+ void ConditionVariableBase<Traits>::Broadcast(const ScopedLock&) {
239
+ Traits::cond_broadcast(&cond_);
240
+ }
241
+
242
+ template <typename Traits>
243
+ void ConditionVariableBase<Traits>::Signal(const ScopedLock&) {
244
+ Traits::cond_signal(&cond_);
245
+ }
246
+
247
+ template <typename Traits>
248
+ void ConditionVariableBase<Traits>::Wait(const ScopedLock& scoped_lock) {
249
+ Traits::cond_wait(&cond_, &scoped_lock.mutex_.mutex_);
250
+ }
251
+
252
+ template <typename Traits>
253
+ MutexBase<Traits>::MutexBase() {
254
+ CHECK_EQ(0, Traits::mutex_init(&mutex_));
255
+ }
256
+
257
+ template <typename Traits>
258
+ MutexBase<Traits>::~MutexBase() {
259
+ Traits::mutex_destroy(&mutex_);
260
+ }
261
+
262
+ template <typename Traits>
263
+ void MutexBase<Traits>::Lock() {
264
+ Traits::mutex_lock(&mutex_);
265
+ }
266
+
267
+ template <typename Traits>
268
+ void MutexBase<Traits>::Unlock() {
269
+ Traits::mutex_unlock(&mutex_);
270
+ }
271
+
272
+ template <typename Traits>
273
+ void MutexBase<Traits>::RdLock() {
274
+ Traits::mutex_rdlock(&mutex_);
275
+ }
276
+
277
+ template <typename Traits>
278
+ void MutexBase<Traits>::RdUnlock() {
279
+ Traits::mutex_rdunlock(&mutex_);
280
+ }
281
+
282
+ template <typename Traits>
283
+ MutexBase<Traits>::ScopedLock::ScopedLock(const MutexBase& mutex)
284
+ : mutex_(mutex) {
285
+ Traits::mutex_lock(&mutex_.mutex_);
286
+ }
287
+
288
+ template <typename Traits>
289
+ MutexBase<Traits>::ScopedLock::ScopedLock(const ScopedUnlock& scoped_unlock)
290
+ : MutexBase(scoped_unlock.mutex_) {}
291
+
292
+ template <typename Traits>
293
+ MutexBase<Traits>::ScopedLock::~ScopedLock() {
294
+ Traits::mutex_unlock(&mutex_.mutex_);
295
+ }
296
+
297
+ template <typename Traits>
298
+ MutexBase<Traits>::ScopedReadLock::ScopedReadLock(const MutexBase& mutex)
299
+ : mutex_(mutex) {
300
+ Traits::mutex_rdlock(&mutex_.mutex_);
301
+ }
302
+
303
+ template <typename Traits>
304
+ MutexBase<Traits>::ScopedReadLock::~ScopedReadLock() {
305
+ Traits::mutex_rdunlock(&mutex_.mutex_);
306
+ }
307
+
308
+ template <typename Traits>
309
+ MutexBase<Traits>::ScopedUnlock::ScopedUnlock(const ScopedLock& scoped_lock)
310
+ : mutex_(scoped_lock.mutex_) {
311
+ Traits::mutex_unlock(&mutex_.mutex_);
312
+ }
313
+
314
+ template <typename Traits>
315
+ MutexBase<Traits>::ScopedUnlock::~ScopedUnlock() {
316
+ Traits::mutex_lock(&mutex_.mutex_);
317
+ }
318
+
319
+ } // namespace node
320
+
321
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
322
+
323
+ #endif // SRC_NODE_MUTEX_H_