@kungfu-tech/libnode-win32-x64 0.0.0-bootstrap.0 → 22.22.3-kf.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 (343) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/dist/node/include/acorn_version.h +6 -0
  4. package/dist/node/include/aliased_buffer-inl.h +244 -0
  5. package/dist/node/include/aliased_buffer.h +206 -0
  6. package/dist/node/include/aliased_struct-inl.h +54 -0
  7. package/dist/node/include/aliased_struct.h +63 -0
  8. package/dist/node/include/amaro_version.h +6 -0
  9. package/dist/node/include/async_context_frame.h +33 -0
  10. package/dist/node/include/async_wrap-inl.h +96 -0
  11. package/dist/node/include/async_wrap.h +243 -0
  12. package/dist/node/include/base_object-inl.h +335 -0
  13. package/dist/node/include/base_object.h +342 -0
  14. package/dist/node/include/base_object_types.h +74 -0
  15. package/dist/node/include/blob_serializer_deserializer-inl.h +385 -0
  16. package/dist/node/include/blob_serializer_deserializer.h +132 -0
  17. package/dist/node/include/callback_queue-inl.h +97 -0
  18. package/dist/node/include/callback_queue.h +79 -0
  19. package/dist/node/include/cares_wrap.h +447 -0
  20. package/dist/node/include/cjs_module_lexer_version.h +6 -0
  21. package/dist/node/include/cleanup_queue-inl.h +36 -0
  22. package/dist/node/include/cleanup_queue.h +79 -0
  23. package/dist/node/include/compile_cache.h +104 -0
  24. package/dist/node/include/connect_wrap.h +26 -0
  25. package/dist/node/include/connection_wrap.h +30 -0
  26. package/dist/node/include/cppgc/allocation.h +310 -0
  27. package/dist/node/include/cppgc/common.h +28 -0
  28. package/dist/node/include/cppgc/cross-thread-persistent.h +466 -0
  29. package/dist/node/include/cppgc/custom-space.h +97 -0
  30. package/dist/node/include/cppgc/default-platform.h +67 -0
  31. package/dist/node/include/cppgc/ephemeron-pair.h +30 -0
  32. package/dist/node/include/cppgc/explicit-management.h +100 -0
  33. package/dist/node/include/cppgc/garbage-collected.h +106 -0
  34. package/dist/node/include/cppgc/heap-consistency.h +309 -0
  35. package/dist/node/include/cppgc/heap-handle.h +48 -0
  36. package/dist/node/include/cppgc/heap-state.h +82 -0
  37. package/dist/node/include/cppgc/heap-statistics.h +120 -0
  38. package/dist/node/include/cppgc/heap.h +202 -0
  39. package/dist/node/include/cppgc/internal/api-constants.h +87 -0
  40. package/dist/node/include/cppgc/internal/atomic-entry-flag.h +48 -0
  41. package/dist/node/include/cppgc/internal/base-page-handle.h +45 -0
  42. package/dist/node/include/cppgc/internal/caged-heap-local-data.h +121 -0
  43. package/dist/node/include/cppgc/internal/caged-heap.h +68 -0
  44. package/dist/node/include/cppgc/internal/compiler-specific.h +38 -0
  45. package/dist/node/include/cppgc/internal/finalizer-trait.h +93 -0
  46. package/dist/node/include/cppgc/internal/gc-info.h +148 -0
  47. package/dist/node/include/cppgc/internal/logging.h +50 -0
  48. package/dist/node/include/cppgc/internal/member-storage.h +256 -0
  49. package/dist/node/include/cppgc/internal/name-trait.h +137 -0
  50. package/dist/node/include/cppgc/internal/persistent-node.h +214 -0
  51. package/dist/node/include/cppgc/internal/pointer-policies.h +243 -0
  52. package/dist/node/include/cppgc/internal/write-barrier.h +487 -0
  53. package/dist/node/include/cppgc/liveness-broker.h +78 -0
  54. package/dist/node/include/cppgc/macros.h +35 -0
  55. package/dist/node/include/cppgc/member.h +629 -0
  56. package/dist/node/include/cppgc/name-provider.h +65 -0
  57. package/dist/node/include/cppgc/object-size-trait.h +58 -0
  58. package/dist/node/include/cppgc/persistent.h +377 -0
  59. package/dist/node/include/cppgc/platform.h +163 -0
  60. package/dist/node/include/cppgc/prefinalizer.h +75 -0
  61. package/dist/node/include/cppgc/process-heap-statistics.h +36 -0
  62. package/dist/node/include/cppgc/sentinel-pointer.h +39 -0
  63. package/dist/node/include/cppgc/source-location.h +16 -0
  64. package/dist/node/include/cppgc/testing.h +106 -0
  65. package/dist/node/include/cppgc/trace-trait.h +128 -0
  66. package/dist/node/include/cppgc/type-traits.h +271 -0
  67. package/dist/node/include/cppgc/visitor.h +504 -0
  68. package/dist/node/include/crypto/crypto_aes.h +88 -0
  69. package/dist/node/include/crypto/crypto_bio.h +193 -0
  70. package/dist/node/include/crypto/crypto_cipher.h +293 -0
  71. package/dist/node/include/crypto/crypto_clienthello-inl.h +90 -0
  72. package/dist/node/include/crypto/crypto_clienthello.h +131 -0
  73. package/dist/node/include/crypto/crypto_common.h +64 -0
  74. package/dist/node/include/crypto/crypto_context.h +171 -0
  75. package/dist/node/include/crypto/crypto_dh.h +126 -0
  76. package/dist/node/include/crypto/crypto_dsa.h +52 -0
  77. package/dist/node/include/crypto/crypto_ec.h +164 -0
  78. package/dist/node/include/crypto/crypto_hash.h +91 -0
  79. package/dist/node/include/crypto/crypto_hkdf.h +61 -0
  80. package/dist/node/include/crypto/crypto_hmac.h +92 -0
  81. package/dist/node/include/crypto/crypto_keygen.h +299 -0
  82. package/dist/node/include/crypto/crypto_keys.h +392 -0
  83. package/dist/node/include/crypto/crypto_pbkdf2.h +74 -0
  84. package/dist/node/include/crypto/crypto_random.h +124 -0
  85. package/dist/node/include/crypto/crypto_rsa.h +136 -0
  86. package/dist/node/include/crypto/crypto_scrypt.h +85 -0
  87. package/dist/node/include/crypto/crypto_sig.h +165 -0
  88. package/dist/node/include/crypto/crypto_spkac.h +21 -0
  89. package/dist/node/include/crypto/crypto_timing.h +20 -0
  90. package/dist/node/include/crypto/crypto_tls.h +305 -0
  91. package/dist/node/include/crypto/crypto_util.h +725 -0
  92. package/dist/node/include/crypto/crypto_x509.h +140 -0
  93. package/dist/node/include/dataqueue/queue.h +306 -0
  94. package/dist/node/include/debug_utils-inl.h +278 -0
  95. package/dist/node/include/debug_utils.h +196 -0
  96. package/dist/node/include/diagnosticfilename-inl.h +33 -0
  97. package/dist/node/include/embedded_data.h +17 -0
  98. package/dist/node/include/encoding_binding.h +61 -0
  99. package/dist/node/include/env-inl.h +984 -0
  100. package/dist/node/include/env.h +1287 -0
  101. package/dist/node/include/env_properties.h +540 -0
  102. package/dist/node/include/handle_wrap.h +123 -0
  103. package/dist/node/include/histogram-inl.h +107 -0
  104. package/dist/node/include/histogram.h +279 -0
  105. package/dist/node/include/inspector/io_agent.h +30 -0
  106. package/dist/node/include/inspector/main_thread_interface.h +116 -0
  107. package/dist/node/include/inspector/network_agent.h +94 -0
  108. package/dist/node/include/inspector/network_inspector.h +45 -0
  109. package/dist/node/include/inspector/network_requests_buffer.h +195 -0
  110. package/dist/node/include/inspector/network_resource_manager.h +29 -0
  111. package/dist/node/include/inspector/node_json.h +24 -0
  112. package/dist/node/include/inspector/node_string.h +101 -0
  113. package/dist/node/include/inspector/protocol_helper.h +27 -0
  114. package/dist/node/include/inspector/runtime_agent.h +41 -0
  115. package/dist/node/include/inspector/target_agent.h +75 -0
  116. package/dist/node/include/inspector/tracing_agent.h +43 -0
  117. package/dist/node/include/inspector/worker_agent.h +40 -0
  118. package/dist/node/include/inspector/worker_inspector.h +124 -0
  119. package/dist/node/include/inspector_agent.h +165 -0
  120. package/dist/node/include/inspector_io.h +78 -0
  121. package/dist/node/include/inspector_profiler.h +149 -0
  122. package/dist/node/include/inspector_socket.h +60 -0
  123. package/dist/node/include/inspector_socket_server.h +110 -0
  124. package/dist/node/include/js_native_api.h +607 -0
  125. package/dist/node/include/js_native_api_types.h +226 -0
  126. package/dist/node/include/js_native_api_v8.h +485 -0
  127. package/dist/node/include/js_native_api_v8_internals.h +45 -0
  128. package/dist/node/include/js_stream.h +52 -0
  129. package/dist/node/include/json_utils.h +172 -0
  130. package/dist/node/include/large_pages/node_large_page.h +34 -0
  131. package/dist/node/include/libplatform/libplatform-export.h +29 -0
  132. package/dist/node/include/libplatform/libplatform.h +112 -0
  133. package/dist/node/include/libplatform/v8-tracing.h +333 -0
  134. package/dist/node/include/memory_tracker-inl.h +359 -0
  135. package/dist/node/include/memory_tracker.h +289 -0
  136. package/dist/node/include/module_wrap.h +216 -0
  137. package/dist/node/include/node.h +1593 -0
  138. package/dist/node/include/node_api.h +265 -0
  139. package/dist/node/include/node_api_internals.h +48 -0
  140. package/dist/node/include/node_api_types.h +56 -0
  141. package/dist/node/include/node_binding.h +161 -0
  142. package/dist/node/include/node_blob.h +159 -0
  143. package/dist/node/include/node_bob-inl.h +36 -0
  144. package/dist/node/include/node_bob.h +107 -0
  145. package/dist/node/include/node_buffer.h +92 -0
  146. package/dist/node/include/node_builtins.h +220 -0
  147. package/dist/node/include/node_config_file.h +46 -0
  148. package/dist/node/include/node_constants.h +82 -0
  149. package/dist/node/include/node_context_data.h +168 -0
  150. package/dist/node/include/node_contextify.h +204 -0
  151. package/dist/node/include/node_crypto.h +56 -0
  152. package/dist/node/include/node_debug.h +30 -0
  153. package/dist/node/include/node_dir.h +52 -0
  154. package/dist/node/include/node_dotenv.h +45 -0
  155. package/dist/node/include/node_errors.h +380 -0
  156. package/dist/node/include/node_exit_code.h +54 -0
  157. package/dist/node/include/node_external_reference.h +165 -0
  158. package/dist/node/include/node_file-inl.h +406 -0
  159. package/dist/node/include/node_file.h +537 -0
  160. package/dist/node/include/node_http2.h +1177 -0
  161. package/dist/node/include/node_http2_state.h +159 -0
  162. package/dist/node/include/node_http_common-inl.h +202 -0
  163. package/dist/node/include/node_http_common.h +535 -0
  164. package/dist/node/include/node_i18n.h +132 -0
  165. package/dist/node/include/node_internals.h +483 -0
  166. package/dist/node/include/node_main_instance.h +67 -0
  167. package/dist/node/include/node_mem-inl.h +113 -0
  168. package/dist/node/include/node_mem.h +45 -0
  169. package/dist/node/include/node_messaging.h +389 -0
  170. package/dist/node/include/node_metadata.h +164 -0
  171. package/dist/node/include/node_modules.h +91 -0
  172. package/dist/node/include/node_mutex.h +323 -0
  173. package/dist/node/include/node_object_wrap.h +132 -0
  174. package/dist/node/include/node_options-inl.h +490 -0
  175. package/dist/node/include/node_options.h +615 -0
  176. package/dist/node/include/node_perf.h +166 -0
  177. package/dist/node/include/node_perf_common.h +102 -0
  178. package/dist/node/include/node_platform.h +238 -0
  179. package/dist/node/include/node_process-inl.h +26 -0
  180. package/dist/node/include/node_process.h +112 -0
  181. package/dist/node/include/node_realm-inl.h +151 -0
  182. package/dist/node/include/node_realm.h +183 -0
  183. package/dist/node/include/node_report.h +43 -0
  184. package/dist/node/include/node_revert.h +82 -0
  185. package/dist/node/include/node_root_certs.h +3520 -0
  186. package/dist/node/include/node_sea.h +74 -0
  187. package/dist/node/include/node_shadow_realm.h +46 -0
  188. package/dist/node/include/node_snapshot_builder.h +57 -0
  189. package/dist/node/include/node_snapshotable.h +174 -0
  190. package/dist/node/include/node_sockaddr-inl.h +257 -0
  191. package/dist/node/include/node_sockaddr.h +394 -0
  192. package/dist/node/include/node_sqlite.h +270 -0
  193. package/dist/node/include/node_stat_watcher.h +73 -0
  194. package/dist/node/include/node_task_runner.h +92 -0
  195. package/dist/node/include/node_threadsafe_cow-inl.h +54 -0
  196. package/dist/node/include/node_threadsafe_cow.h +105 -0
  197. package/dist/node/include/node_union_bytes.h +81 -0
  198. package/dist/node/include/node_url.h +96 -0
  199. package/dist/node/include/node_v8.h +77 -0
  200. package/dist/node/include/node_v8_platform-inl.h +185 -0
  201. package/dist/node/include/node_version.h +110 -0
  202. package/dist/node/include/node_wasi.h +184 -0
  203. package/dist/node/include/node_wasm_web_api.h +55 -0
  204. package/dist/node/include/node_watchdog.h +154 -0
  205. package/dist/node/include/node_webstorage.h +60 -0
  206. package/dist/node/include/node_worker.h +158 -0
  207. package/dist/node/include/path.h +33 -0
  208. package/dist/node/include/permission/addon_permission.h +31 -0
  209. package/dist/node/include/permission/child_process_permission.h +31 -0
  210. package/dist/node/include/permission/fs_permission.h +167 -0
  211. package/dist/node/include/permission/inspector_permission.h +31 -0
  212. package/dist/node/include/permission/permission.h +138 -0
  213. package/dist/node/include/permission/permission_base.h +65 -0
  214. package/dist/node/include/permission/wasi_permission.h +31 -0
  215. package/dist/node/include/permission/worker_permission.h +31 -0
  216. package/dist/node/include/pipe_wrap.h +80 -0
  217. package/dist/node/include/quic/application.h +159 -0
  218. package/dist/node/include/quic/bindingdata.h +272 -0
  219. package/dist/node/include/quic/cid.h +127 -0
  220. package/dist/node/include/quic/data.h +148 -0
  221. package/dist/node/include/quic/defs.h +245 -0
  222. package/dist/node/include/quic/endpoint.h +458 -0
  223. package/dist/node/include/quic/http3.h +15 -0
  224. package/dist/node/include/quic/logstream.h +81 -0
  225. package/dist/node/include/quic/packet.h +152 -0
  226. package/dist/node/include/quic/preferredaddress.h +72 -0
  227. package/dist/node/include/quic/session.h +443 -0
  228. package/dist/node/include/quic/sessionticket.h +108 -0
  229. package/dist/node/include/quic/streams.h +232 -0
  230. package/dist/node/include/quic/tlscontext.h +227 -0
  231. package/dist/node/include/quic/tokens.h +256 -0
  232. package/dist/node/include/quic/transportparams.h +165 -0
  233. package/dist/node/include/req_wrap-inl.h +171 -0
  234. package/dist/node/include/req_wrap.h +77 -0
  235. package/dist/node/include/spawn_sync.h +243 -0
  236. package/dist/node/include/stream_base-inl.h +173 -0
  237. package/dist/node/include/stream_base.h +478 -0
  238. package/dist/node/include/stream_pipe.h +76 -0
  239. package/dist/node/include/stream_wrap.h +132 -0
  240. package/dist/node/include/string_bytes.h +113 -0
  241. package/dist/node/include/string_decoder-inl.h +31 -0
  242. package/dist/node/include/string_decoder.h +49 -0
  243. package/dist/node/include/tcp_wrap.h +105 -0
  244. package/dist/node/include/threadpoolwork-inl.h +70 -0
  245. package/dist/node/include/timer_wrap-inl.h +32 -0
  246. package/dist/node/include/timer_wrap.h +85 -0
  247. package/dist/node/include/timers.h +70 -0
  248. package/dist/node/include/tracing/agent.h +195 -0
  249. package/dist/node/include/tracing/node_trace_buffer.h +83 -0
  250. package/dist/node/include/tracing/node_trace_writer.h +75 -0
  251. package/dist/node/include/tracing/trace_event.h +722 -0
  252. package/dist/node/include/tracing/trace_event_common.h +1109 -0
  253. package/dist/node/include/tracing/traced_value.h +129 -0
  254. package/dist/node/include/tty_wrap.h +65 -0
  255. package/dist/node/include/udp_wrap.h +230 -0
  256. package/dist/node/include/undici_version.h +6 -0
  257. package/dist/node/include/util-inl.h +700 -0
  258. package/dist/node/include/util.h +1021 -0
  259. package/dist/node/include/uv/aix.h +32 -0
  260. package/dist/node/include/uv/bsd.h +34 -0
  261. package/dist/node/include/uv/darwin.h +61 -0
  262. package/dist/node/include/uv/errno.h +483 -0
  263. package/dist/node/include/uv/linux.h +34 -0
  264. package/dist/node/include/uv/os390.h +33 -0
  265. package/dist/node/include/uv/posix.h +31 -0
  266. package/dist/node/include/uv/sunos.h +44 -0
  267. package/dist/node/include/uv/threadpool.h +37 -0
  268. package/dist/node/include/uv/tree.h +521 -0
  269. package/dist/node/include/uv/unix.h +512 -0
  270. package/dist/node/include/uv/version.h +43 -0
  271. package/dist/node/include/uv/win.h +698 -0
  272. package/dist/node/include/uv.h +1990 -0
  273. package/dist/node/include/v8-array-buffer.h +525 -0
  274. package/dist/node/include/v8-callbacks.h +462 -0
  275. package/dist/node/include/v8-container.h +183 -0
  276. package/dist/node/include/v8-context.h +485 -0
  277. package/dist/node/include/v8-cppgc.h +245 -0
  278. package/dist/node/include/v8-data.h +80 -0
  279. package/dist/node/include/v8-date.h +48 -0
  280. package/dist/node/include/v8-debug.h +168 -0
  281. package/dist/node/include/v8-embedder-heap.h +82 -0
  282. package/dist/node/include/v8-embedder-state-scope.h +52 -0
  283. package/dist/node/include/v8-exception.h +223 -0
  284. package/dist/node/include/v8-extension.h +62 -0
  285. package/dist/node/include/v8-external.h +37 -0
  286. package/dist/node/include/v8-fast-api-calls.h +984 -0
  287. package/dist/node/include/v8-forward.h +82 -0
  288. package/dist/node/include/v8-function-callback.h +607 -0
  289. package/dist/node/include/v8-function.h +140 -0
  290. package/dist/node/include/v8-handle-base.h +137 -0
  291. package/dist/node/include/v8-initialization.h +289 -0
  292. package/dist/node/include/v8-inspector-protocol.h +13 -0
  293. package/dist/node/include/v8-inspector.h +419 -0
  294. package/dist/node/include/v8-internal.h +1397 -0
  295. package/dist/node/include/v8-isolate.h +1767 -0
  296. package/dist/node/include/v8-json.h +47 -0
  297. package/dist/node/include/v8-local-handle.h +758 -0
  298. package/dist/node/include/v8-locker.h +138 -0
  299. package/dist/node/include/v8-maybe.h +160 -0
  300. package/dist/node/include/v8-memory-span.h +198 -0
  301. package/dist/node/include/v8-message.h +233 -0
  302. package/dist/node/include/v8-metrics.h +264 -0
  303. package/dist/node/include/v8-microtask-queue.h +157 -0
  304. package/dist/node/include/v8-microtask.h +28 -0
  305. package/dist/node/include/v8-object.h +824 -0
  306. package/dist/node/include/v8-persistent-handle.h +582 -0
  307. package/dist/node/include/v8-platform.h +1358 -0
  308. package/dist/node/include/v8-primitive-object.h +118 -0
  309. package/dist/node/include/v8-primitive.h +877 -0
  310. package/dist/node/include/v8-profiler.h +1302 -0
  311. package/dist/node/include/v8-promise.h +174 -0
  312. package/dist/node/include/v8-proxy.h +50 -0
  313. package/dist/node/include/v8-regexp.h +106 -0
  314. package/dist/node/include/v8-script.h +904 -0
  315. package/dist/node/include/v8-snapshot.h +266 -0
  316. package/dist/node/include/v8-source-location.h +92 -0
  317. package/dist/node/include/v8-statistics.h +238 -0
  318. package/dist/node/include/v8-template.h +1297 -0
  319. package/dist/node/include/v8-traced-handle.h +432 -0
  320. package/dist/node/include/v8-typed-array.h +390 -0
  321. package/dist/node/include/v8-unwinder-state.h +31 -0
  322. package/dist/node/include/v8-unwinder.h +132 -0
  323. package/dist/node/include/v8-util.h +665 -0
  324. package/dist/node/include/v8-value-serializer-version.h +24 -0
  325. package/dist/node/include/v8-value-serializer.h +316 -0
  326. package/dist/node/include/v8-value.h +655 -0
  327. package/dist/node/include/v8-version-string.h +38 -0
  328. package/dist/node/include/v8-version.h +20 -0
  329. package/dist/node/include/v8-wasm-trap-handler-posix.h +31 -0
  330. package/dist/node/include/v8-wasm-trap-handler-win.h +28 -0
  331. package/dist/node/include/v8-wasm.h +201 -0
  332. package/dist/node/include/v8-weak-callback-info.h +80 -0
  333. package/dist/node/include/v8.h +88 -0
  334. package/dist/node/include/v8config.h +981 -0
  335. package/dist/node/include/zlib_version.h +6 -0
  336. package/dist/node/libnode.dll +0 -0
  337. package/dist/node/libnode.lib +0 -0
  338. package/dist/node/libnodebuildinfo.json +10 -0
  339. package/dist/node/link_node.lib +0 -0
  340. package/dist/node/link_node.node +0 -0
  341. package/index.js +5 -0
  342. package/libnode.release.json +8 -0
  343. package/package.json +29 -1
@@ -0,0 +1,74 @@
1
+ #ifndef SRC_NODE_SEA_H_
2
+ #define SRC_NODE_SEA_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include <cinttypes>
7
+ #include <optional>
8
+ #include <string>
9
+ #include <string_view>
10
+ #include <tuple>
11
+ #include <unordered_map>
12
+ #include <vector>
13
+
14
+ #include "node_exit_code.h"
15
+
16
+ namespace node {
17
+ class Environment;
18
+ namespace sea {
19
+ // A special number that will appear at the beginning of the single executable
20
+ // preparation blobs ready to be injected into the binary. We use this to check
21
+ // that the data given to us are intended for building single executable
22
+ // applications.
23
+ const uint32_t kMagic = 0x143da20;
24
+
25
+ enum class SeaFlags : uint32_t {
26
+ kDefault = 0,
27
+ kDisableExperimentalSeaWarning = 1 << 0,
28
+ kUseSnapshot = 1 << 1,
29
+ kUseCodeCache = 1 << 2,
30
+ kIncludeAssets = 1 << 3,
31
+ kIncludeExecArgv = 1 << 4,
32
+ };
33
+
34
+ enum class SeaExecArgvExtension : uint8_t {
35
+ kNone = 0,
36
+ kEnv = 1,
37
+ kCli = 2,
38
+ };
39
+
40
+ struct SeaResource {
41
+ SeaFlags flags = SeaFlags::kDefault;
42
+ SeaExecArgvExtension exec_argv_extension = SeaExecArgvExtension::kEnv;
43
+ std::string_view code_path;
44
+ std::string_view main_code_or_snapshot;
45
+ std::optional<std::string_view> code_cache;
46
+ std::unordered_map<std::string_view, std::string_view> assets;
47
+ std::vector<std::string_view> exec_argv;
48
+
49
+ bool use_snapshot() const;
50
+ bool use_code_cache() const;
51
+
52
+ static constexpr size_t kHeaderSize =
53
+ sizeof(kMagic) + sizeof(SeaFlags) + sizeof(SeaExecArgvExtension);
54
+ };
55
+
56
+ bool IsSingleExecutable();
57
+ SeaResource FindSingleExecutableResource();
58
+ std::tuple<int, char**> FixupArgsForSEA(int argc, char** argv);
59
+ node::ExitCode BuildSingleExecutableBlob(
60
+ const std::string& config_path,
61
+ const std::vector<std::string>& args,
62
+ const std::vector<std::string>& exec_args);
63
+
64
+ // Try loading the Environment as a single-executable application.
65
+ // Returns true if it is loaded as a single-executable application.
66
+ // Otherwise returns false and the caller is expected to call LoadEnvironment()
67
+ // differently.
68
+ bool MaybeLoadSingleExecutableApplication(Environment* env);
69
+ } // namespace sea
70
+ } // namespace node
71
+
72
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
73
+
74
+ #endif // SRC_NODE_SEA_H_
@@ -0,0 +1,46 @@
1
+ #ifndef SRC_NODE_SHADOW_REALM_H_
2
+ #define SRC_NODE_SHADOW_REALM_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "node_realm.h"
7
+ #include "v8.h"
8
+
9
+ namespace node {
10
+ namespace shadow_realm {
11
+
12
+ class ShadowRealm final : public Realm {
13
+ public:
14
+ static ShadowRealm* New(Environment* env);
15
+
16
+ SET_MEMORY_INFO_NAME(ShadowRealm)
17
+ SET_SELF_SIZE(ShadowRealm)
18
+
19
+ v8::Local<v8::Context> context() const override;
20
+
21
+ #define V(PropertyName, TypeName) \
22
+ v8::Local<TypeName> PropertyName() const override; \
23
+ void set_##PropertyName(v8::Local<TypeName> value) override;
24
+ PER_REALM_STRONG_PERSISTENT_VALUES(V)
25
+ #undef V
26
+
27
+ protected:
28
+ v8::MaybeLocal<v8::Value> BootstrapRealm() override;
29
+
30
+ private:
31
+ static void WeakCallback(const v8::WeakCallbackInfo<ShadowRealm>& data);
32
+ static void DeleteMe(void* data);
33
+
34
+ explicit ShadowRealm(Environment* env);
35
+ ~ShadowRealm();
36
+ };
37
+
38
+ v8::MaybeLocal<v8::Context> HostCreateShadowRealmContextCallback(
39
+ v8::Local<v8::Context> initiator_context);
40
+
41
+ } // namespace shadow_realm
42
+ } // namespace node
43
+
44
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
45
+
46
+ #endif // SRC_NODE_SHADOW_REALM_H_
@@ -0,0 +1,57 @@
1
+
2
+ #ifndef SRC_NODE_SNAPSHOT_BUILDER_H_
3
+ #define SRC_NODE_SNAPSHOT_BUILDER_H_
4
+
5
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
6
+
7
+ #include <cstdint>
8
+ #include <optional>
9
+ #include <string_view>
10
+ #include "node_exit_code.h"
11
+ #include "node_mutex.h"
12
+ #include "v8.h"
13
+
14
+ namespace node {
15
+
16
+ class ExternalReferenceRegistry;
17
+ struct SnapshotData;
18
+
19
+ std::optional<SnapshotConfig> ReadSnapshotConfig(const char* path);
20
+
21
+ class NODE_EXTERN_PRIVATE SnapshotBuilder {
22
+ public:
23
+ static ExitCode GenerateAsSource(const char* out_path,
24
+ const std::vector<std::string>& args,
25
+ const std::vector<std::string>& exec_args,
26
+ const SnapshotConfig& config,
27
+ bool use_array_literals = false);
28
+
29
+ // Generate the snapshot into out. builder_script_content should match
30
+ // config.builder_script_path. This is passed separately
31
+ // in case the script is already read for other purposes.
32
+ static ExitCode Generate(
33
+ SnapshotData* out,
34
+ const std::vector<std::string>& args,
35
+ const std::vector<std::string>& exec_args,
36
+ std::optional<std::string_view> builder_script_content,
37
+ const SnapshotConfig& config);
38
+
39
+ // If nullptr is returned, the binary is not built with embedded
40
+ // snapshot.
41
+ static const SnapshotData* GetEmbeddedSnapshotData();
42
+ static void InitializeIsolateParams(const SnapshotData* data,
43
+ v8::Isolate::CreateParams* params);
44
+
45
+ static const std::vector<intptr_t>& CollectExternalReferences();
46
+
47
+ static ExitCode CreateSnapshot(SnapshotData* out,
48
+ CommonEnvironmentSetup* setup);
49
+
50
+ private:
51
+ static std::unique_ptr<ExternalReferenceRegistry> registry_;
52
+ };
53
+ } // namespace node
54
+
55
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
56
+
57
+ #endif // SRC_NODE_SNAPSHOT_BUILDER_H_
@@ -0,0 +1,174 @@
1
+
2
+ #ifndef SRC_NODE_SNAPSHOTABLE_H_
3
+ #define SRC_NODE_SNAPSHOTABLE_H_
4
+
5
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
6
+
7
+ #include "aliased_buffer.h"
8
+ #include "base_object.h"
9
+ #include "util.h"
10
+
11
+ namespace node {
12
+
13
+ class Environment;
14
+ struct RealmSerializeInfo;
15
+ struct SnapshotData;
16
+ class ExternalReferenceRegistry;
17
+
18
+ using SnapshotIndex = size_t;
19
+
20
+ struct PropInfo {
21
+ std::string name; // name for debugging
22
+ uint32_t id; // In the list - in case there are any empty entries
23
+ SnapshotIndex index; // In the snapshot
24
+ };
25
+
26
+ typedef size_t SnapshotIndex;
27
+
28
+ bool WithoutCodeCache(const SnapshotFlags& flags);
29
+ bool WithoutCodeCache(const SnapshotConfig& config);
30
+
31
+ // When serializing an embedder object, we'll serialize the native states
32
+ // into a chunk that can be mapped into a subclass of InternalFieldInfoBase,
33
+ // and pass it into the V8 callback as the payload of StartupData.
34
+ // The memory chunk looks like this:
35
+ //
36
+ // [ type ] - EmbedderObjectType (a uint8_t)
37
+ // [ length ] - a size_t
38
+ // [ ... ] - custom bytes of size |length - header size|
39
+ struct InternalFieldInfoBase {
40
+ public:
41
+ EmbedderObjectType type;
42
+ size_t length;
43
+
44
+ template <typename T>
45
+ static T* New(EmbedderObjectType type) {
46
+ static_assert(std::is_base_of_v<InternalFieldInfoBase, T> ||
47
+ std::is_same_v<InternalFieldInfoBase, T>,
48
+ "Can only accept InternalFieldInfoBase subclasses");
49
+ void* buf = ::operator new[](sizeof(T));
50
+ memset(buf, 0, sizeof(T)); // Make the padding reproducible.
51
+ T* result = new (buf) T;
52
+ result->type = type;
53
+ result->length = sizeof(T);
54
+ return result;
55
+ }
56
+
57
+ template <typename T>
58
+ T* Copy() const {
59
+ static_assert(std::is_base_of_v<InternalFieldInfoBase, T> ||
60
+ std::is_same_v<InternalFieldInfoBase, T>,
61
+ "Can only accept InternalFieldInfoBase subclasses");
62
+ static_assert(std::is_trivially_copyable_v<T>,
63
+ "Can only memcpy trivially copyable class");
64
+ void* buf = ::operator new[](sizeof(T));
65
+ T* result = new (buf) T;
66
+ memcpy(result, this, sizeof(T));
67
+ return result;
68
+ }
69
+
70
+ void Delete() { ::operator delete[](this); }
71
+
72
+ InternalFieldInfoBase() = default;
73
+ };
74
+
75
+ struct EmbedderTypeInfo {
76
+ enum class MemoryMode : uint8_t { kBaseObject, kCppGC };
77
+ EmbedderTypeInfo(EmbedderObjectType t, MemoryMode m) : type(t), mode(m) {}
78
+ EmbedderTypeInfo() = default;
79
+ EmbedderObjectType type;
80
+ MemoryMode mode;
81
+ };
82
+
83
+ // An interface for snapshotable native objects to inherit from.
84
+ // Use the SERIALIZABLE_OBJECT_METHODS() macro in the class to define
85
+ // the following methods to implement:
86
+ //
87
+ // - PrepareForSerialization(): This would be run prior to context
88
+ // serialization. Use this method to e.g. release references that
89
+ // can be re-initialized, or perform property store operations
90
+ // that needs a V8 context.
91
+ // - Serialize(): This would be called during context serialization,
92
+ // once for each embedder field of the object.
93
+ // Allocate and construct an InternalFieldInfoBase object that contains
94
+ // data that can be used to deserialize native states.
95
+ // - Deserialize(): This would be called after the context is
96
+ // deserialized and the object graph is complete, once for each
97
+ // embedder field of the object. Use this to restore native states
98
+ // in the object.
99
+ class SnapshotableObject : public BaseObject {
100
+ public:
101
+ SnapshotableObject(Realm* realm,
102
+ v8::Local<v8::Object> wrap,
103
+ EmbedderObjectType type);
104
+ std::string GetTypeName() const;
105
+
106
+ // If returns false, the object will not be serialized.
107
+ virtual bool PrepareForSerialization(v8::Local<v8::Context> context,
108
+ v8::SnapshotCreator* creator) = 0;
109
+ virtual InternalFieldInfoBase* Serialize(int index) = 0;
110
+ bool is_snapshotable() const override { return true; }
111
+ // We'll make sure that the type is set in the constructor
112
+ EmbedderObjectType type() { return type_; }
113
+
114
+ private:
115
+ EmbedderObjectType type_;
116
+ };
117
+
118
+ #define SERIALIZABLE_OBJECT_METHODS() \
119
+ bool PrepareForSerialization(v8::Local<v8::Context> context, \
120
+ v8::SnapshotCreator* creator) override; \
121
+ InternalFieldInfoBase* Serialize(int index) override; \
122
+ static void Deserialize(v8::Local<v8::Context> context, \
123
+ v8::Local<v8::Object> holder, \
124
+ int index, \
125
+ InternalFieldInfoBase* info);
126
+
127
+ v8::StartupData SerializeNodeContextInternalFields(v8::Local<v8::Object> holder,
128
+ int index,
129
+ void* env);
130
+ v8::StartupData SerializeNodeContextData(v8::Local<v8::Context> holder,
131
+ int index,
132
+ void* env);
133
+ void DeserializeNodeInternalFields(v8::Local<v8::Object> holder,
134
+ int index,
135
+ v8::StartupData payload,
136
+ void* env);
137
+ void DeserializeNodeContextData(v8::Local<v8::Context> holder,
138
+ int index,
139
+ v8::StartupData payload,
140
+ void* env);
141
+ void SerializeSnapshotableObjects(Realm* realm,
142
+ v8::SnapshotCreator* creator,
143
+ RealmSerializeInfo* info);
144
+
145
+ #define DCHECK_IS_SNAPSHOT_SLOT(index) DCHECK_EQ(index, BaseObject::kSlot)
146
+
147
+ namespace mksnapshot {
148
+ class BindingData : public SnapshotableObject {
149
+ public:
150
+ struct InternalFieldInfo : public node::InternalFieldInfoBase {
151
+ AliasedBufferIndex is_building_snapshot_buffer;
152
+ };
153
+
154
+ BindingData(Realm* realm,
155
+ v8::Local<v8::Object> obj,
156
+ InternalFieldInfo* info = nullptr);
157
+ SET_BINDING_ID(mksnapshot_binding_data)
158
+ SERIALIZABLE_OBJECT_METHODS()
159
+
160
+ void MemoryInfo(MemoryTracker* tracker) const override;
161
+ SET_SELF_SIZE(BindingData)
162
+ SET_MEMORY_INFO_NAME(BindingData)
163
+
164
+ private:
165
+ AliasedUint8Array is_building_snapshot_buffer_;
166
+ InternalFieldInfo* internal_field_info_ = nullptr;
167
+ };
168
+ } // namespace mksnapshot
169
+
170
+ } // namespace node
171
+
172
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
173
+
174
+ #endif // SRC_NODE_SNAPSHOTABLE_H_
@@ -0,0 +1,257 @@
1
+ #ifndef SRC_NODE_SOCKADDR_INL_H_
2
+ #define SRC_NODE_SOCKADDR_INL_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "node.h"
7
+ #include "env-inl.h"
8
+ #include "node_internals.h"
9
+ #include "node_sockaddr.h"
10
+ #include "util-inl.h"
11
+ #include "memory_tracker-inl.h"
12
+
13
+ #include <string>
14
+
15
+ namespace node {
16
+
17
+ static constexpr uint32_t kLabelMask = 0xFFFFF;
18
+
19
+ inline void hash_combine(size_t* seed) { }
20
+
21
+ template <typename T, typename... Args>
22
+ inline void hash_combine(size_t* seed, const T& value, Args... rest) {
23
+ *seed ^= std::hash<T>{}(value) + 0x9e3779b9 + (*seed << 6) + (*seed >> 2);
24
+ hash_combine(seed, rest...);
25
+ }
26
+
27
+ bool SocketAddress::is_numeric_host(const char* hostname) {
28
+ return is_numeric_host(hostname, AF_INET) ||
29
+ is_numeric_host(hostname, AF_INET6);
30
+ }
31
+
32
+ bool SocketAddress::is_numeric_host(const char* hostname, int family) {
33
+ in6_addr dst;
34
+ return inet_pton(family, hostname, &dst) == 1;
35
+ }
36
+
37
+ int SocketAddress::GetPort(const sockaddr* addr) {
38
+ CHECK(addr->sa_family == AF_INET || addr->sa_family == AF_INET6);
39
+ return ntohs(addr->sa_family == AF_INET ?
40
+ reinterpret_cast<const sockaddr_in*>(addr)->sin_port :
41
+ reinterpret_cast<const sockaddr_in6*>(addr)->sin6_port);
42
+ }
43
+
44
+ int SocketAddress::GetPort(const sockaddr_storage* addr) {
45
+ return GetPort(reinterpret_cast<const sockaddr*>(addr));
46
+ }
47
+
48
+ std::string SocketAddress::GetAddress(const sockaddr* addr) {
49
+ CHECK(addr->sa_family == AF_INET || addr->sa_family == AF_INET6);
50
+ char host[INET6_ADDRSTRLEN];
51
+ const void* src = addr->sa_family == AF_INET ?
52
+ static_cast<const void*>(
53
+ &(reinterpret_cast<const sockaddr_in*>(addr)->sin_addr)) :
54
+ static_cast<const void*>(
55
+ &(reinterpret_cast<const sockaddr_in6*>(addr)->sin6_addr));
56
+ uv_inet_ntop(addr->sa_family, src, host, INET6_ADDRSTRLEN);
57
+ return std::string(host);
58
+ }
59
+
60
+ std::string SocketAddress::GetAddress(const sockaddr_storage* addr) {
61
+ return GetAddress(reinterpret_cast<const sockaddr*>(addr));
62
+ }
63
+
64
+ size_t SocketAddress::GetLength(const sockaddr* addr) {
65
+ return addr->sa_family == AF_INET ?
66
+ sizeof(sockaddr_in) : sizeof(sockaddr_in6);
67
+ }
68
+
69
+ size_t SocketAddress::GetLength(const sockaddr_storage* addr) {
70
+ return GetLength(reinterpret_cast<const sockaddr*>(addr));
71
+ }
72
+
73
+ SocketAddress::SocketAddress(const sockaddr* addr) {
74
+ memcpy(&address_, addr, GetLength(addr));
75
+ }
76
+
77
+ SocketAddress::SocketAddress(const SocketAddress& addr) {
78
+ memcpy(&address_, &addr.address_, addr.length());
79
+ }
80
+
81
+ SocketAddress& SocketAddress::operator=(const sockaddr* addr) {
82
+ if (reinterpret_cast<const sockaddr*>(&address_) != addr) {
83
+ memcpy(&address_, addr, GetLength(addr));
84
+ }
85
+ return *this;
86
+ }
87
+
88
+ SocketAddress& SocketAddress::operator=(const SocketAddress& addr) {
89
+ if (this != &addr) {
90
+ memcpy(&address_, &addr.address_, addr.length());
91
+ }
92
+ return *this;
93
+ }
94
+
95
+ const sockaddr& SocketAddress::operator*() const {
96
+ return *data();
97
+ }
98
+
99
+ const sockaddr* SocketAddress::operator->() const {
100
+ return data();
101
+ }
102
+
103
+ size_t SocketAddress::length() const {
104
+ return GetLength(&address_);
105
+ }
106
+
107
+ const sockaddr* SocketAddress::data() const {
108
+ return reinterpret_cast<const sockaddr*>(&address_);
109
+ }
110
+
111
+ const uint8_t* SocketAddress::raw() const {
112
+ return reinterpret_cast<const uint8_t*>(&address_);
113
+ }
114
+
115
+ sockaddr* SocketAddress::storage() {
116
+ return reinterpret_cast<sockaddr*>(&address_);
117
+ }
118
+
119
+ int SocketAddress::family() const {
120
+ return address_.ss_family;
121
+ }
122
+
123
+ std::string SocketAddress::address() const {
124
+ return GetAddress(&address_);
125
+ }
126
+
127
+ int SocketAddress::port() const {
128
+ return GetPort(&address_);
129
+ }
130
+
131
+ uint32_t SocketAddress::flow_label() const {
132
+ if (family() != AF_INET6)
133
+ return 0;
134
+ const sockaddr_in6* in = reinterpret_cast<const sockaddr_in6*>(data());
135
+ return in->sin6_flowinfo;
136
+ }
137
+
138
+ void SocketAddress::set_flow_label(uint32_t label) {
139
+ if (family() != AF_INET6)
140
+ return;
141
+ CHECK_LE(label, kLabelMask);
142
+ sockaddr_in6* in = reinterpret_cast<sockaddr_in6*>(&address_);
143
+ in->sin6_flowinfo = label;
144
+ }
145
+
146
+ std::string SocketAddress::ToString() const {
147
+ if (family() != AF_INET && family() != AF_INET6) return "";
148
+ return (family() == AF_INET6 ?
149
+ std::string("[") + address() + "]:" :
150
+ address() + ":") +
151
+ std::to_string(port());
152
+ }
153
+
154
+ void SocketAddress::Update(uint8_t* data, size_t len) {
155
+ CHECK_LE(len, sizeof(address_));
156
+ memcpy(&address_, data, len);
157
+ }
158
+
159
+ void SocketAddress::Update(const sockaddr* data, size_t len) {
160
+ CHECK_LE(len, sizeof(address_));
161
+ memcpy(&address_, data, len);
162
+ }
163
+
164
+ v8::MaybeLocal<v8::Object> SocketAddress::ToJS(
165
+ Environment* env,
166
+ v8::Local<v8::Object> info) const {
167
+ return AddressToJS(env, data(), info);
168
+ }
169
+
170
+ bool SocketAddress::operator==(const SocketAddress& other) const {
171
+ if (family() != other.family()) return false;
172
+ return memcmp(raw(), other.raw(), length()) == 0;
173
+ }
174
+
175
+ bool SocketAddress::operator!=(const SocketAddress& other) const {
176
+ return !(*this == other);
177
+ }
178
+
179
+ std::partial_ordering SocketAddress::operator<=>(
180
+ const SocketAddress& other) const {
181
+ return compare(other);
182
+ }
183
+
184
+ template <typename T>
185
+ SocketAddressLRU<T>::SocketAddressLRU(
186
+ size_t max_size)
187
+ : max_size_(max_size) {}
188
+
189
+ template <typename T>
190
+ typename T::Type* SocketAddressLRU<T>::Peek(
191
+ const SocketAddress& address) const {
192
+ auto it = map_.find(address);
193
+ return it == std::end(map_) ? nullptr : &it->second->second;
194
+ }
195
+
196
+ template <typename T>
197
+ void SocketAddressLRU<T>::CheckExpired() {
198
+ auto it = list_.rbegin();
199
+ while (it != list_.rend()) {
200
+ if (T::CheckExpired(it->first, it->second)) {
201
+ map_.erase(it->first);
202
+ list_.pop_back();
203
+ it = list_.rbegin();
204
+ continue;
205
+ } else {
206
+ break;
207
+ }
208
+ }
209
+ }
210
+
211
+ template <typename T>
212
+ void SocketAddressLRU<T>::MemoryInfo(MemoryTracker* tracker) const {
213
+ tracker->TrackFieldWithSize("list", size() * sizeof(Pair));
214
+ }
215
+
216
+ // If an item already exists for the given address, bump up it's
217
+ // position in the LRU list and return it. If the item does not
218
+ // exist, create it. If an item is created, check the size of the
219
+ // cache and adjust if necessary. Whether the item exists or not,
220
+ // purge expired items.
221
+ template <typename T>
222
+ typename T::Type* SocketAddressLRU<T>::Upsert(
223
+ const SocketAddress& address) {
224
+
225
+ auto on_exit = OnScopeLeave([&]() { CheckExpired(); });
226
+
227
+ auto it = map_.find(address);
228
+ if (it != std::end(map_)) {
229
+ list_.splice(list_.begin(), list_, it->second);
230
+ T::Touch(it->first, &it->second->second);
231
+ return &it->second->second;
232
+ }
233
+
234
+ list_.push_front(Pair(address, { }));
235
+ map_[address] = list_.begin();
236
+ T::Touch(list_.begin()->first, &list_.begin()->second);
237
+
238
+ // Drop the last item in the list if we are
239
+ // over the size limit...
240
+ if (map_.size() > max_size_) {
241
+ auto last = list_.end();
242
+ map_.erase((--last)->first);
243
+ list_.pop_back();
244
+ }
245
+
246
+ return &map_[address]->second;
247
+ }
248
+
249
+ v8::MaybeLocal<v8::Value> SocketAddressBlockList::Rule::ToV8String(
250
+ Environment* env) {
251
+ std::string str = ToString();
252
+ return ToV8Value(env->context(), str);
253
+ }
254
+ } // namespace node
255
+
256
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
257
+ #endif // SRC_NODE_SOCKADDR_INL_H_