@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.
- package/LICENSE +201 -0
- package/README.md +3 -0
- package/dist/node/include/acorn_version.h +6 -0
- package/dist/node/include/aliased_buffer-inl.h +244 -0
- package/dist/node/include/aliased_buffer.h +206 -0
- package/dist/node/include/aliased_struct-inl.h +54 -0
- package/dist/node/include/aliased_struct.h +63 -0
- package/dist/node/include/amaro_version.h +6 -0
- package/dist/node/include/async_context_frame.h +33 -0
- package/dist/node/include/async_wrap-inl.h +96 -0
- package/dist/node/include/async_wrap.h +243 -0
- package/dist/node/include/base_object-inl.h +335 -0
- package/dist/node/include/base_object.h +342 -0
- package/dist/node/include/base_object_types.h +74 -0
- package/dist/node/include/blob_serializer_deserializer-inl.h +385 -0
- package/dist/node/include/blob_serializer_deserializer.h +132 -0
- package/dist/node/include/callback_queue-inl.h +97 -0
- package/dist/node/include/callback_queue.h +79 -0
- package/dist/node/include/cares_wrap.h +447 -0
- package/dist/node/include/cjs_module_lexer_version.h +6 -0
- package/dist/node/include/cleanup_queue-inl.h +36 -0
- package/dist/node/include/cleanup_queue.h +79 -0
- package/dist/node/include/compile_cache.h +104 -0
- package/dist/node/include/connect_wrap.h +26 -0
- package/dist/node/include/connection_wrap.h +30 -0
- package/dist/node/include/cppgc/allocation.h +310 -0
- package/dist/node/include/cppgc/common.h +28 -0
- package/dist/node/include/cppgc/cross-thread-persistent.h +466 -0
- package/dist/node/include/cppgc/custom-space.h +97 -0
- package/dist/node/include/cppgc/default-platform.h +67 -0
- package/dist/node/include/cppgc/ephemeron-pair.h +30 -0
- package/dist/node/include/cppgc/explicit-management.h +100 -0
- package/dist/node/include/cppgc/garbage-collected.h +106 -0
- package/dist/node/include/cppgc/heap-consistency.h +309 -0
- package/dist/node/include/cppgc/heap-handle.h +48 -0
- package/dist/node/include/cppgc/heap-state.h +82 -0
- package/dist/node/include/cppgc/heap-statistics.h +120 -0
- package/dist/node/include/cppgc/heap.h +202 -0
- package/dist/node/include/cppgc/internal/api-constants.h +87 -0
- package/dist/node/include/cppgc/internal/atomic-entry-flag.h +48 -0
- package/dist/node/include/cppgc/internal/base-page-handle.h +45 -0
- package/dist/node/include/cppgc/internal/caged-heap-local-data.h +121 -0
- package/dist/node/include/cppgc/internal/caged-heap.h +68 -0
- package/dist/node/include/cppgc/internal/compiler-specific.h +38 -0
- package/dist/node/include/cppgc/internal/finalizer-trait.h +93 -0
- package/dist/node/include/cppgc/internal/gc-info.h +148 -0
- package/dist/node/include/cppgc/internal/logging.h +50 -0
- package/dist/node/include/cppgc/internal/member-storage.h +256 -0
- package/dist/node/include/cppgc/internal/name-trait.h +137 -0
- package/dist/node/include/cppgc/internal/persistent-node.h +214 -0
- package/dist/node/include/cppgc/internal/pointer-policies.h +243 -0
- package/dist/node/include/cppgc/internal/write-barrier.h +487 -0
- package/dist/node/include/cppgc/liveness-broker.h +78 -0
- package/dist/node/include/cppgc/macros.h +35 -0
- package/dist/node/include/cppgc/member.h +629 -0
- package/dist/node/include/cppgc/name-provider.h +65 -0
- package/dist/node/include/cppgc/object-size-trait.h +58 -0
- package/dist/node/include/cppgc/persistent.h +377 -0
- package/dist/node/include/cppgc/platform.h +163 -0
- package/dist/node/include/cppgc/prefinalizer.h +75 -0
- package/dist/node/include/cppgc/process-heap-statistics.h +36 -0
- package/dist/node/include/cppgc/sentinel-pointer.h +39 -0
- package/dist/node/include/cppgc/source-location.h +16 -0
- package/dist/node/include/cppgc/testing.h +106 -0
- package/dist/node/include/cppgc/trace-trait.h +128 -0
- package/dist/node/include/cppgc/type-traits.h +271 -0
- package/dist/node/include/cppgc/visitor.h +504 -0
- package/dist/node/include/crypto/crypto_aes.h +88 -0
- package/dist/node/include/crypto/crypto_bio.h +193 -0
- package/dist/node/include/crypto/crypto_cipher.h +293 -0
- package/dist/node/include/crypto/crypto_clienthello-inl.h +90 -0
- package/dist/node/include/crypto/crypto_clienthello.h +131 -0
- package/dist/node/include/crypto/crypto_common.h +64 -0
- package/dist/node/include/crypto/crypto_context.h +171 -0
- package/dist/node/include/crypto/crypto_dh.h +126 -0
- package/dist/node/include/crypto/crypto_dsa.h +52 -0
- package/dist/node/include/crypto/crypto_ec.h +164 -0
- package/dist/node/include/crypto/crypto_hash.h +91 -0
- package/dist/node/include/crypto/crypto_hkdf.h +61 -0
- package/dist/node/include/crypto/crypto_hmac.h +92 -0
- package/dist/node/include/crypto/crypto_keygen.h +299 -0
- package/dist/node/include/crypto/crypto_keys.h +392 -0
- package/dist/node/include/crypto/crypto_pbkdf2.h +74 -0
- package/dist/node/include/crypto/crypto_random.h +124 -0
- package/dist/node/include/crypto/crypto_rsa.h +136 -0
- package/dist/node/include/crypto/crypto_scrypt.h +85 -0
- package/dist/node/include/crypto/crypto_sig.h +165 -0
- package/dist/node/include/crypto/crypto_spkac.h +21 -0
- package/dist/node/include/crypto/crypto_timing.h +20 -0
- package/dist/node/include/crypto/crypto_tls.h +305 -0
- package/dist/node/include/crypto/crypto_util.h +725 -0
- package/dist/node/include/crypto/crypto_x509.h +140 -0
- package/dist/node/include/dataqueue/queue.h +306 -0
- package/dist/node/include/debug_utils-inl.h +278 -0
- package/dist/node/include/debug_utils.h +196 -0
- package/dist/node/include/diagnosticfilename-inl.h +33 -0
- package/dist/node/include/embedded_data.h +17 -0
- package/dist/node/include/encoding_binding.h +61 -0
- package/dist/node/include/env-inl.h +984 -0
- package/dist/node/include/env.h +1287 -0
- package/dist/node/include/env_properties.h +540 -0
- package/dist/node/include/handle_wrap.h +123 -0
- package/dist/node/include/histogram-inl.h +107 -0
- package/dist/node/include/histogram.h +279 -0
- package/dist/node/include/inspector/io_agent.h +30 -0
- package/dist/node/include/inspector/main_thread_interface.h +116 -0
- package/dist/node/include/inspector/network_agent.h +94 -0
- package/dist/node/include/inspector/network_inspector.h +45 -0
- package/dist/node/include/inspector/network_requests_buffer.h +195 -0
- package/dist/node/include/inspector/network_resource_manager.h +29 -0
- package/dist/node/include/inspector/node_json.h +24 -0
- package/dist/node/include/inspector/node_string.h +101 -0
- package/dist/node/include/inspector/protocol_helper.h +27 -0
- package/dist/node/include/inspector/runtime_agent.h +41 -0
- package/dist/node/include/inspector/target_agent.h +75 -0
- package/dist/node/include/inspector/tracing_agent.h +43 -0
- package/dist/node/include/inspector/worker_agent.h +40 -0
- package/dist/node/include/inspector/worker_inspector.h +124 -0
- package/dist/node/include/inspector_agent.h +165 -0
- package/dist/node/include/inspector_io.h +78 -0
- package/dist/node/include/inspector_profiler.h +149 -0
- package/dist/node/include/inspector_socket.h +60 -0
- package/dist/node/include/inspector_socket_server.h +110 -0
- package/dist/node/include/js_native_api.h +607 -0
- package/dist/node/include/js_native_api_types.h +226 -0
- package/dist/node/include/js_native_api_v8.h +485 -0
- package/dist/node/include/js_native_api_v8_internals.h +45 -0
- package/dist/node/include/js_stream.h +52 -0
- package/dist/node/include/json_utils.h +172 -0
- package/dist/node/include/large_pages/node_large_page.h +34 -0
- package/dist/node/include/libplatform/libplatform-export.h +29 -0
- package/dist/node/include/libplatform/libplatform.h +112 -0
- package/dist/node/include/libplatform/v8-tracing.h +333 -0
- package/dist/node/include/memory_tracker-inl.h +359 -0
- package/dist/node/include/memory_tracker.h +289 -0
- package/dist/node/include/module_wrap.h +216 -0
- package/dist/node/include/node.h +1593 -0
- package/dist/node/include/node_api.h +265 -0
- package/dist/node/include/node_api_internals.h +48 -0
- package/dist/node/include/node_api_types.h +56 -0
- package/dist/node/include/node_binding.h +161 -0
- package/dist/node/include/node_blob.h +159 -0
- package/dist/node/include/node_bob-inl.h +36 -0
- package/dist/node/include/node_bob.h +107 -0
- package/dist/node/include/node_buffer.h +92 -0
- package/dist/node/include/node_builtins.h +220 -0
- package/dist/node/include/node_config_file.h +46 -0
- package/dist/node/include/node_constants.h +82 -0
- package/dist/node/include/node_context_data.h +168 -0
- package/dist/node/include/node_contextify.h +204 -0
- package/dist/node/include/node_crypto.h +56 -0
- package/dist/node/include/node_debug.h +30 -0
- package/dist/node/include/node_dir.h +52 -0
- package/dist/node/include/node_dotenv.h +45 -0
- package/dist/node/include/node_errors.h +380 -0
- package/dist/node/include/node_exit_code.h +54 -0
- package/dist/node/include/node_external_reference.h +165 -0
- package/dist/node/include/node_file-inl.h +406 -0
- package/dist/node/include/node_file.h +537 -0
- package/dist/node/include/node_http2.h +1177 -0
- package/dist/node/include/node_http2_state.h +159 -0
- package/dist/node/include/node_http_common-inl.h +202 -0
- package/dist/node/include/node_http_common.h +535 -0
- package/dist/node/include/node_i18n.h +132 -0
- package/dist/node/include/node_internals.h +483 -0
- package/dist/node/include/node_main_instance.h +67 -0
- package/dist/node/include/node_mem-inl.h +113 -0
- package/dist/node/include/node_mem.h +45 -0
- package/dist/node/include/node_messaging.h +389 -0
- package/dist/node/include/node_metadata.h +164 -0
- package/dist/node/include/node_modules.h +91 -0
- package/dist/node/include/node_mutex.h +323 -0
- package/dist/node/include/node_object_wrap.h +132 -0
- package/dist/node/include/node_options-inl.h +490 -0
- package/dist/node/include/node_options.h +615 -0
- package/dist/node/include/node_perf.h +166 -0
- package/dist/node/include/node_perf_common.h +102 -0
- package/dist/node/include/node_platform.h +238 -0
- package/dist/node/include/node_process-inl.h +26 -0
- package/dist/node/include/node_process.h +112 -0
- package/dist/node/include/node_realm-inl.h +151 -0
- package/dist/node/include/node_realm.h +183 -0
- package/dist/node/include/node_report.h +43 -0
- package/dist/node/include/node_revert.h +82 -0
- package/dist/node/include/node_root_certs.h +3520 -0
- package/dist/node/include/node_sea.h +74 -0
- package/dist/node/include/node_shadow_realm.h +46 -0
- package/dist/node/include/node_snapshot_builder.h +57 -0
- package/dist/node/include/node_snapshotable.h +174 -0
- package/dist/node/include/node_sockaddr-inl.h +257 -0
- package/dist/node/include/node_sockaddr.h +394 -0
- package/dist/node/include/node_sqlite.h +270 -0
- package/dist/node/include/node_stat_watcher.h +73 -0
- package/dist/node/include/node_task_runner.h +92 -0
- package/dist/node/include/node_threadsafe_cow-inl.h +54 -0
- package/dist/node/include/node_threadsafe_cow.h +105 -0
- package/dist/node/include/node_union_bytes.h +81 -0
- package/dist/node/include/node_url.h +96 -0
- package/dist/node/include/node_v8.h +77 -0
- package/dist/node/include/node_v8_platform-inl.h +185 -0
- package/dist/node/include/node_version.h +110 -0
- package/dist/node/include/node_wasi.h +184 -0
- package/dist/node/include/node_wasm_web_api.h +55 -0
- package/dist/node/include/node_watchdog.h +154 -0
- package/dist/node/include/node_webstorage.h +60 -0
- package/dist/node/include/node_worker.h +158 -0
- package/dist/node/include/path.h +33 -0
- package/dist/node/include/permission/addon_permission.h +31 -0
- package/dist/node/include/permission/child_process_permission.h +31 -0
- package/dist/node/include/permission/fs_permission.h +167 -0
- package/dist/node/include/permission/inspector_permission.h +31 -0
- package/dist/node/include/permission/permission.h +138 -0
- package/dist/node/include/permission/permission_base.h +65 -0
- package/dist/node/include/permission/wasi_permission.h +31 -0
- package/dist/node/include/permission/worker_permission.h +31 -0
- package/dist/node/include/pipe_wrap.h +80 -0
- package/dist/node/include/quic/application.h +159 -0
- package/dist/node/include/quic/bindingdata.h +272 -0
- package/dist/node/include/quic/cid.h +127 -0
- package/dist/node/include/quic/data.h +148 -0
- package/dist/node/include/quic/defs.h +245 -0
- package/dist/node/include/quic/endpoint.h +458 -0
- package/dist/node/include/quic/http3.h +15 -0
- package/dist/node/include/quic/logstream.h +81 -0
- package/dist/node/include/quic/packet.h +152 -0
- package/dist/node/include/quic/preferredaddress.h +72 -0
- package/dist/node/include/quic/session.h +443 -0
- package/dist/node/include/quic/sessionticket.h +108 -0
- package/dist/node/include/quic/streams.h +232 -0
- package/dist/node/include/quic/tlscontext.h +227 -0
- package/dist/node/include/quic/tokens.h +256 -0
- package/dist/node/include/quic/transportparams.h +165 -0
- package/dist/node/include/req_wrap-inl.h +171 -0
- package/dist/node/include/req_wrap.h +77 -0
- package/dist/node/include/spawn_sync.h +243 -0
- package/dist/node/include/stream_base-inl.h +173 -0
- package/dist/node/include/stream_base.h +478 -0
- package/dist/node/include/stream_pipe.h +76 -0
- package/dist/node/include/stream_wrap.h +132 -0
- package/dist/node/include/string_bytes.h +113 -0
- package/dist/node/include/string_decoder-inl.h +31 -0
- package/dist/node/include/string_decoder.h +49 -0
- package/dist/node/include/tcp_wrap.h +105 -0
- package/dist/node/include/threadpoolwork-inl.h +70 -0
- package/dist/node/include/timer_wrap-inl.h +32 -0
- package/dist/node/include/timer_wrap.h +85 -0
- package/dist/node/include/timers.h +70 -0
- package/dist/node/include/tracing/agent.h +195 -0
- package/dist/node/include/tracing/node_trace_buffer.h +83 -0
- package/dist/node/include/tracing/node_trace_writer.h +75 -0
- package/dist/node/include/tracing/trace_event.h +722 -0
- package/dist/node/include/tracing/trace_event_common.h +1109 -0
- package/dist/node/include/tracing/traced_value.h +129 -0
- package/dist/node/include/tty_wrap.h +65 -0
- package/dist/node/include/udp_wrap.h +230 -0
- package/dist/node/include/undici_version.h +6 -0
- package/dist/node/include/util-inl.h +700 -0
- package/dist/node/include/util.h +1021 -0
- package/dist/node/include/uv/aix.h +32 -0
- package/dist/node/include/uv/bsd.h +34 -0
- package/dist/node/include/uv/darwin.h +61 -0
- package/dist/node/include/uv/errno.h +483 -0
- package/dist/node/include/uv/linux.h +34 -0
- package/dist/node/include/uv/os390.h +33 -0
- package/dist/node/include/uv/posix.h +31 -0
- package/dist/node/include/uv/sunos.h +44 -0
- package/dist/node/include/uv/threadpool.h +37 -0
- package/dist/node/include/uv/tree.h +521 -0
- package/dist/node/include/uv/unix.h +512 -0
- package/dist/node/include/uv/version.h +43 -0
- package/dist/node/include/uv/win.h +698 -0
- package/dist/node/include/uv.h +1990 -0
- package/dist/node/include/v8-array-buffer.h +525 -0
- package/dist/node/include/v8-callbacks.h +462 -0
- package/dist/node/include/v8-container.h +183 -0
- package/dist/node/include/v8-context.h +485 -0
- package/dist/node/include/v8-cppgc.h +245 -0
- package/dist/node/include/v8-data.h +80 -0
- package/dist/node/include/v8-date.h +48 -0
- package/dist/node/include/v8-debug.h +168 -0
- package/dist/node/include/v8-embedder-heap.h +82 -0
- package/dist/node/include/v8-embedder-state-scope.h +52 -0
- package/dist/node/include/v8-exception.h +223 -0
- package/dist/node/include/v8-extension.h +62 -0
- package/dist/node/include/v8-external.h +37 -0
- package/dist/node/include/v8-fast-api-calls.h +984 -0
- package/dist/node/include/v8-forward.h +82 -0
- package/dist/node/include/v8-function-callback.h +607 -0
- package/dist/node/include/v8-function.h +140 -0
- package/dist/node/include/v8-handle-base.h +137 -0
- package/dist/node/include/v8-initialization.h +289 -0
- package/dist/node/include/v8-inspector-protocol.h +13 -0
- package/dist/node/include/v8-inspector.h +419 -0
- package/dist/node/include/v8-internal.h +1397 -0
- package/dist/node/include/v8-isolate.h +1767 -0
- package/dist/node/include/v8-json.h +47 -0
- package/dist/node/include/v8-local-handle.h +758 -0
- package/dist/node/include/v8-locker.h +138 -0
- package/dist/node/include/v8-maybe.h +160 -0
- package/dist/node/include/v8-memory-span.h +198 -0
- package/dist/node/include/v8-message.h +233 -0
- package/dist/node/include/v8-metrics.h +264 -0
- package/dist/node/include/v8-microtask-queue.h +157 -0
- package/dist/node/include/v8-microtask.h +28 -0
- package/dist/node/include/v8-object.h +824 -0
- package/dist/node/include/v8-persistent-handle.h +582 -0
- package/dist/node/include/v8-platform.h +1358 -0
- package/dist/node/include/v8-primitive-object.h +118 -0
- package/dist/node/include/v8-primitive.h +877 -0
- package/dist/node/include/v8-profiler.h +1302 -0
- package/dist/node/include/v8-promise.h +174 -0
- package/dist/node/include/v8-proxy.h +50 -0
- package/dist/node/include/v8-regexp.h +106 -0
- package/dist/node/include/v8-script.h +904 -0
- package/dist/node/include/v8-snapshot.h +266 -0
- package/dist/node/include/v8-source-location.h +92 -0
- package/dist/node/include/v8-statistics.h +238 -0
- package/dist/node/include/v8-template.h +1297 -0
- package/dist/node/include/v8-traced-handle.h +432 -0
- package/dist/node/include/v8-typed-array.h +390 -0
- package/dist/node/include/v8-unwinder-state.h +31 -0
- package/dist/node/include/v8-unwinder.h +132 -0
- package/dist/node/include/v8-util.h +665 -0
- package/dist/node/include/v8-value-serializer-version.h +24 -0
- package/dist/node/include/v8-value-serializer.h +316 -0
- package/dist/node/include/v8-value.h +655 -0
- package/dist/node/include/v8-version-string.h +38 -0
- package/dist/node/include/v8-version.h +20 -0
- package/dist/node/include/v8-wasm-trap-handler-posix.h +31 -0
- package/dist/node/include/v8-wasm-trap-handler-win.h +28 -0
- package/dist/node/include/v8-wasm.h +201 -0
- package/dist/node/include/v8-weak-callback-info.h +80 -0
- package/dist/node/include/v8.h +88 -0
- package/dist/node/include/v8config.h +981 -0
- package/dist/node/include/zlib_version.h +6 -0
- package/dist/node/libnode.dll +0 -0
- package/dist/node/libnode.lib +0 -0
- package/dist/node/libnodebuildinfo.json +10 -0
- package/dist/node/link_node.lib +0 -0
- package/dist/node/link_node.node +0 -0
- package/index.js +5 -0
- package/libnode.release.json +8 -0
- package/package.json +29 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#ifndef SRC_NODE_MEM_H_
|
|
2
|
+
#define SRC_NODE_MEM_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include <cstddef>
|
|
7
|
+
|
|
8
|
+
namespace node {
|
|
9
|
+
namespace mem {
|
|
10
|
+
|
|
11
|
+
// nghttp2 allows custom allocators that
|
|
12
|
+
// follow exactly the same structure and behavior, but
|
|
13
|
+
// use different struct names. To allow for code re-use,
|
|
14
|
+
// the NgLibMemoryManager template class can be used for both.
|
|
15
|
+
|
|
16
|
+
struct NgLibMemoryManagerBase {
|
|
17
|
+
virtual void StopTrackingMemory(void* ptr) = 0;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
template <typename Class, typename AllocatorStructName>
|
|
21
|
+
class NgLibMemoryManager : public NgLibMemoryManagerBase {
|
|
22
|
+
public:
|
|
23
|
+
// Class needs to provide these methods:
|
|
24
|
+
// void CheckAllocatedSize(size_t previous_size) const;
|
|
25
|
+
// void IncreaseAllocatedSize(size_t size);
|
|
26
|
+
// void DecreaseAllocatedSize(size_t size);
|
|
27
|
+
// Environment* env() const;
|
|
28
|
+
|
|
29
|
+
AllocatorStructName MakeAllocator();
|
|
30
|
+
|
|
31
|
+
void StopTrackingMemory(void* ptr) override;
|
|
32
|
+
|
|
33
|
+
private:
|
|
34
|
+
static void* ReallocImpl(void* ptr, size_t size, void* user_data);
|
|
35
|
+
static void* MallocImpl(size_t size, void* user_data);
|
|
36
|
+
static void FreeImpl(void* ptr, void* user_data);
|
|
37
|
+
static void* CallocImpl(size_t nmemb, size_t size, void* user_data);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
} // namespace mem
|
|
41
|
+
} // namespace node
|
|
42
|
+
|
|
43
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
44
|
+
|
|
45
|
+
#endif // SRC_NODE_MEM_H_
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
#ifndef SRC_NODE_MESSAGING_H_
|
|
2
|
+
#define SRC_NODE_MESSAGING_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "env.h"
|
|
7
|
+
#include "node_mutex.h"
|
|
8
|
+
#include "v8.h"
|
|
9
|
+
#include <deque>
|
|
10
|
+
#include <string>
|
|
11
|
+
#include <unordered_map>
|
|
12
|
+
#include <set>
|
|
13
|
+
|
|
14
|
+
namespace node {
|
|
15
|
+
namespace worker {
|
|
16
|
+
|
|
17
|
+
class MessagePortData;
|
|
18
|
+
class MessagePort;
|
|
19
|
+
|
|
20
|
+
typedef MaybeStackBuffer<v8::Local<v8::Value>, 8> TransferList;
|
|
21
|
+
|
|
22
|
+
// Used to represent the in-flight structure of an object that is being
|
|
23
|
+
// transferred or cloned using postMessage().
|
|
24
|
+
class TransferData : public MemoryRetainer {
|
|
25
|
+
public:
|
|
26
|
+
// Deserialize this object on the receiving end after a .postMessage() call.
|
|
27
|
+
// - `context` may not be the same as `env->context()`. This method should
|
|
28
|
+
// not produce JS objects coming from Contexts other than `context`.
|
|
29
|
+
// - `self` is a unique_ptr for the object that this is being called on.
|
|
30
|
+
// - The return value is treated like a `Maybe`, i.e. if `nullptr` is
|
|
31
|
+
// returned, any further deserialization of the message is stopped and
|
|
32
|
+
// control is returned to the event loop or JS as soon as possible.
|
|
33
|
+
virtual BaseObjectPtr<BaseObject> Deserialize(
|
|
34
|
+
Environment* env,
|
|
35
|
+
v8::Local<v8::Context> context,
|
|
36
|
+
std::unique_ptr<TransferData> self) = 0;
|
|
37
|
+
// FinalizeTransferWrite() is the counterpart to
|
|
38
|
+
// BaseObject::FinalizeTransferRead(). It is called right after the transfer
|
|
39
|
+
// data was created, and defaults to doing nothing. After this function,
|
|
40
|
+
// this object should not hold any more Isolate-specific data.
|
|
41
|
+
virtual v8::Maybe<bool> FinalizeTransferWrite(
|
|
42
|
+
v8::Local<v8::Context> context, v8::ValueSerializer* serializer);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// Represents a single communication message.
|
|
46
|
+
class Message : public MemoryRetainer {
|
|
47
|
+
public:
|
|
48
|
+
// Create a Message with a specific underlying payload, in the format of the
|
|
49
|
+
// V8 ValueSerializer API. If `payload` is empty, this message indicates
|
|
50
|
+
// that the receiving message port should close itself.
|
|
51
|
+
explicit Message(MallocedBuffer<char>&& payload = MallocedBuffer<char>());
|
|
52
|
+
~Message() = default;
|
|
53
|
+
|
|
54
|
+
Message(Message&& other) = default;
|
|
55
|
+
Message& operator=(Message&& other) = default;
|
|
56
|
+
Message& operator=(const Message&) = delete;
|
|
57
|
+
Message(const Message&) = delete;
|
|
58
|
+
|
|
59
|
+
// Whether this is a message indicating that the port is to be closed.
|
|
60
|
+
// This is the last message to be received by a MessagePort.
|
|
61
|
+
bool IsCloseMessage() const;
|
|
62
|
+
|
|
63
|
+
// Deserialize the contained JS value. May only be called once, and only
|
|
64
|
+
// after Serialize() has been called (e.g. by another thread).
|
|
65
|
+
v8::MaybeLocal<v8::Value> Deserialize(
|
|
66
|
+
Environment* env,
|
|
67
|
+
v8::Local<v8::Context> context,
|
|
68
|
+
v8::Local<v8::Value>* port_list = nullptr);
|
|
69
|
+
|
|
70
|
+
// Serialize a JS value, and optionally transfer objects, into this message.
|
|
71
|
+
// The Message object retains ownership of all transferred objects until
|
|
72
|
+
// deserialization.
|
|
73
|
+
// The source_port parameter, if provided, will make Serialize() throw a
|
|
74
|
+
// "DataCloneError" DOMException if source_port is found in transfer_list.
|
|
75
|
+
v8::Maybe<bool> Serialize(Environment* env,
|
|
76
|
+
v8::Local<v8::Context> context,
|
|
77
|
+
v8::Local<v8::Value> input,
|
|
78
|
+
const TransferList& transfer_list,
|
|
79
|
+
v8::Local<v8::Object> source_port =
|
|
80
|
+
v8::Local<v8::Object>());
|
|
81
|
+
|
|
82
|
+
// Internal method of Message that is called when a new SharedArrayBuffer
|
|
83
|
+
// object is encountered in the incoming value's structure.
|
|
84
|
+
void AddSharedArrayBuffer(std::shared_ptr<v8::BackingStore> backing_store);
|
|
85
|
+
// Internal method of Message that is called once serialization finishes
|
|
86
|
+
// and that transfers ownership of `data` to this message.
|
|
87
|
+
void AddTransferable(std::unique_ptr<TransferData>&& data);
|
|
88
|
+
// Internal method of Message that is called when a new WebAssembly.Module
|
|
89
|
+
// object is encountered in the incoming value's structure.
|
|
90
|
+
uint32_t AddWASMModule(v8::CompiledWasmModule&& mod);
|
|
91
|
+
// Internal method of Message that is called when a shared value is
|
|
92
|
+
// encountered for the first time in the incoming value's structure.
|
|
93
|
+
void AdoptSharedValueConveyor(v8::SharedValueConveyor&& conveyor);
|
|
94
|
+
|
|
95
|
+
// The host objects that will be transferred, as recorded by Serialize()
|
|
96
|
+
// (e.g. MessagePorts).
|
|
97
|
+
// Used for warning user about posting the target MessagePort to itself,
|
|
98
|
+
// which will as a side effect destroy the communication channel.
|
|
99
|
+
const std::vector<std::unique_ptr<TransferData>>& transferables() const {
|
|
100
|
+
return transferables_;
|
|
101
|
+
}
|
|
102
|
+
bool has_transferables() const {
|
|
103
|
+
return !transferables_.empty() || !array_buffers_.empty();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
107
|
+
|
|
108
|
+
SET_MEMORY_INFO_NAME(Message)
|
|
109
|
+
SET_SELF_SIZE(Message)
|
|
110
|
+
|
|
111
|
+
private:
|
|
112
|
+
MallocedBuffer<char> main_message_buf_;
|
|
113
|
+
// TODO(addaleax): Make this a std::variant to save storage size in the common
|
|
114
|
+
// case (which is that all of these vectors are empty) once that is available
|
|
115
|
+
// with C++17.
|
|
116
|
+
std::vector<std::shared_ptr<v8::BackingStore>> array_buffers_;
|
|
117
|
+
std::vector<std::shared_ptr<v8::BackingStore>> shared_array_buffers_;
|
|
118
|
+
std::vector<std::unique_ptr<TransferData>> transferables_;
|
|
119
|
+
std::vector<v8::CompiledWasmModule> wasm_modules_;
|
|
120
|
+
std::optional<v8::SharedValueConveyor> shared_value_conveyor_;
|
|
121
|
+
|
|
122
|
+
friend class MessagePort;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
class SiblingGroup final : public std::enable_shared_from_this<SiblingGroup> {
|
|
126
|
+
public:
|
|
127
|
+
// Named SiblingGroup, Used for one-to-many BroadcastChannels.
|
|
128
|
+
static std::shared_ptr<SiblingGroup> Get(const std::string& name);
|
|
129
|
+
|
|
130
|
+
// Anonymous SiblingGroup, Used for one-to-one MessagePort pairs.
|
|
131
|
+
SiblingGroup() = default;
|
|
132
|
+
explicit SiblingGroup(const std::string& name);
|
|
133
|
+
~SiblingGroup();
|
|
134
|
+
|
|
135
|
+
// Dispatches the Message to the collection of associated
|
|
136
|
+
// ports. If there is more than one destination port and
|
|
137
|
+
// the Message contains transferables, Dispatch will fail.
|
|
138
|
+
// Returns Just(true) if successful and the message was
|
|
139
|
+
// dispatched to at least one destination. Returns Just(false)
|
|
140
|
+
// if there were no destinations. Returns Nothing<bool>()
|
|
141
|
+
// if there was an error. If error is not nullptr, it will
|
|
142
|
+
// be set to an error message or warning message as appropriate.
|
|
143
|
+
v8::Maybe<bool> Dispatch(
|
|
144
|
+
MessagePortData* source,
|
|
145
|
+
std::shared_ptr<Message> message,
|
|
146
|
+
std::string* error = nullptr);
|
|
147
|
+
|
|
148
|
+
void Entangle(MessagePortData* data);
|
|
149
|
+
void Entangle(std::initializer_list<MessagePortData*> data);
|
|
150
|
+
void Disentangle(MessagePortData* data);
|
|
151
|
+
|
|
152
|
+
const std::string& name() const { return name_; }
|
|
153
|
+
|
|
154
|
+
size_t size() const { return ports_.size(); }
|
|
155
|
+
|
|
156
|
+
private:
|
|
157
|
+
const std::string name_;
|
|
158
|
+
RwLock group_mutex_; // Protects ports_.
|
|
159
|
+
std::set<MessagePortData*> ports_;
|
|
160
|
+
|
|
161
|
+
static void CheckSiblingGroup(const std::string& name);
|
|
162
|
+
|
|
163
|
+
using Map =
|
|
164
|
+
std::unordered_map<std::string, std::weak_ptr<SiblingGroup>>;
|
|
165
|
+
|
|
166
|
+
static Mutex groups_mutex_;
|
|
167
|
+
static Map groups_;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// This contains all data for a `MessagePort` instance that is not tied to
|
|
171
|
+
// a specific Environment/Isolate/event loop, for easier transfer between those.
|
|
172
|
+
class MessagePortData : public TransferData {
|
|
173
|
+
public:
|
|
174
|
+
explicit MessagePortData(MessagePort* owner);
|
|
175
|
+
~MessagePortData() override;
|
|
176
|
+
|
|
177
|
+
MessagePortData(MessagePortData&& other) = delete;
|
|
178
|
+
MessagePortData& operator=(MessagePortData&& other) = delete;
|
|
179
|
+
MessagePortData(const MessagePortData& other) = delete;
|
|
180
|
+
MessagePortData& operator=(const MessagePortData& other) = delete;
|
|
181
|
+
|
|
182
|
+
// Add a message to the incoming queue and notify the receiver.
|
|
183
|
+
// This may be called from any thread.
|
|
184
|
+
void AddToIncomingQueue(std::shared_ptr<Message> message);
|
|
185
|
+
v8::Maybe<bool> Dispatch(
|
|
186
|
+
std::shared_ptr<Message> message,
|
|
187
|
+
std::string* error = nullptr);
|
|
188
|
+
|
|
189
|
+
// Turns `a` and `b` into siblings, i.e. connects the sending side of one
|
|
190
|
+
// to the receiving side of the other. This is not thread-safe.
|
|
191
|
+
static void Entangle(MessagePortData* a, MessagePortData* b);
|
|
192
|
+
|
|
193
|
+
// Removes any possible sibling. This is thread-safe (it acquires both
|
|
194
|
+
// `sibling_mutex_` and `mutex_`), and has to be because it is called once
|
|
195
|
+
// the corresponding JS handle handle wants to close
|
|
196
|
+
// which can happen on either side of a worker.
|
|
197
|
+
void Disentangle();
|
|
198
|
+
|
|
199
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
200
|
+
BaseObjectPtr<BaseObject> Deserialize(
|
|
201
|
+
Environment* env,
|
|
202
|
+
v8::Local<v8::Context> context,
|
|
203
|
+
std::unique_ptr<TransferData> self) override;
|
|
204
|
+
|
|
205
|
+
SET_MEMORY_INFO_NAME(MessagePortData)
|
|
206
|
+
SET_SELF_SIZE(MessagePortData)
|
|
207
|
+
|
|
208
|
+
private:
|
|
209
|
+
// This mutex protects all fields below it, with the exception of
|
|
210
|
+
// sibling_.
|
|
211
|
+
mutable Mutex mutex_;
|
|
212
|
+
// TODO(addaleax): Make this a std::variant<std::shared_ptr, std::unique_ptr>
|
|
213
|
+
// once that is available with C++17, because std::shared_ptr comes with
|
|
214
|
+
// overhead that is only necessary for BroadcastChannel.
|
|
215
|
+
std::deque<std::shared_ptr<Message>> incoming_messages_;
|
|
216
|
+
MessagePort* owner_ = nullptr;
|
|
217
|
+
std::shared_ptr<SiblingGroup> group_;
|
|
218
|
+
friend class MessagePort;
|
|
219
|
+
friend class SiblingGroup;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// A message port that receives messages from other threads, including
|
|
223
|
+
// the uv_async_t handle that is used to notify the current event loop of
|
|
224
|
+
// new incoming messages.
|
|
225
|
+
class MessagePort : public HandleWrap {
|
|
226
|
+
private:
|
|
227
|
+
// Create a new MessagePort. The `context` argument specifies the Context
|
|
228
|
+
// instance that is used for creating the values emitted from this port.
|
|
229
|
+
// This is called by MessagePort::New(), which is the public API used for
|
|
230
|
+
// creating MessagePort instances.
|
|
231
|
+
MessagePort(Environment* env,
|
|
232
|
+
v8::Local<v8::Context> context,
|
|
233
|
+
v8::Local<v8::Object> wrap);
|
|
234
|
+
|
|
235
|
+
public:
|
|
236
|
+
~MessagePort() override;
|
|
237
|
+
|
|
238
|
+
// Create a new message port instance, optionally over an existing
|
|
239
|
+
// `MessagePortData` object.
|
|
240
|
+
static MessagePort* New(Environment* env,
|
|
241
|
+
v8::Local<v8::Context> context,
|
|
242
|
+
std::unique_ptr<MessagePortData> data = {},
|
|
243
|
+
std::shared_ptr<SiblingGroup> sibling_group = {});
|
|
244
|
+
|
|
245
|
+
// Send a message, i.e. deliver it into the sibling's incoming queue.
|
|
246
|
+
// If this port is closed, or if there is no sibling, this message is
|
|
247
|
+
// serialized with transfers, then silently discarded.
|
|
248
|
+
v8::Maybe<bool> PostMessage(Environment* env,
|
|
249
|
+
v8::Local<v8::Context> context,
|
|
250
|
+
v8::Local<v8::Value> message,
|
|
251
|
+
const TransferList& transfer);
|
|
252
|
+
|
|
253
|
+
// Start processing messages on this port as a receiving end.
|
|
254
|
+
void Start();
|
|
255
|
+
// Stop processing messages on this port as a receiving end.
|
|
256
|
+
void Stop();
|
|
257
|
+
|
|
258
|
+
/* constructor */
|
|
259
|
+
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
260
|
+
/* prototype methods */
|
|
261
|
+
static void PostMessage(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
262
|
+
static void Start(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
263
|
+
static void Stop(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
264
|
+
static void Drain(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
265
|
+
static void ReceiveMessage(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
266
|
+
|
|
267
|
+
/* static */
|
|
268
|
+
static void MoveToContext(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
269
|
+
|
|
270
|
+
// Turns `a` and `b` into siblings, i.e. connects the sending side of one
|
|
271
|
+
// to the receiving side of the other. This is not thread-safe.
|
|
272
|
+
static void Entangle(MessagePort* a, MessagePort* b);
|
|
273
|
+
static void Entangle(MessagePort* a, MessagePortData* b);
|
|
274
|
+
|
|
275
|
+
// Detach this port's data for transferring. After this, the MessagePortData
|
|
276
|
+
// is no longer associated with this handle, although it can still receive
|
|
277
|
+
// messages.
|
|
278
|
+
std::unique_ptr<MessagePortData> Detach();
|
|
279
|
+
|
|
280
|
+
void Close(
|
|
281
|
+
v8::Local<v8::Value> close_callback = v8::Local<v8::Value>()) override;
|
|
282
|
+
|
|
283
|
+
// Returns true if either data_ has been freed, or if the handle is being
|
|
284
|
+
// closed. Equivalent to the [[Detached]] internal slot in the HTML Standard.
|
|
285
|
+
//
|
|
286
|
+
// If checking if a JavaScript MessagePort object is detached, this method
|
|
287
|
+
// alone is often not enough, since the backing C++ MessagePort object may
|
|
288
|
+
// have been deleted already. For all intents and purposes, an object with a
|
|
289
|
+
// NULL pointer to the C++ MessagePort object is also detached.
|
|
290
|
+
inline bool IsDetached() const;
|
|
291
|
+
|
|
292
|
+
BaseObject::TransferMode GetTransferMode() const override;
|
|
293
|
+
std::unique_ptr<TransferData> TransferForMessaging() override;
|
|
294
|
+
|
|
295
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
296
|
+
SET_MEMORY_INFO_NAME(MessagePort)
|
|
297
|
+
SET_SELF_SIZE(MessagePort)
|
|
298
|
+
|
|
299
|
+
private:
|
|
300
|
+
enum class MessageProcessingMode {
|
|
301
|
+
kNormalOperation,
|
|
302
|
+
kForceReadMessages
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
void OnClose() override;
|
|
306
|
+
void OnMessage(MessageProcessingMode mode);
|
|
307
|
+
void TriggerAsync();
|
|
308
|
+
v8::MaybeLocal<v8::Value> ReceiveMessage(
|
|
309
|
+
v8::Local<v8::Context> context,
|
|
310
|
+
MessageProcessingMode mode,
|
|
311
|
+
v8::Local<v8::Value>* port_list = nullptr);
|
|
312
|
+
|
|
313
|
+
std::unique_ptr<MessagePortData> data_ = nullptr;
|
|
314
|
+
bool receiving_messages_ = false;
|
|
315
|
+
uv_async_t async_;
|
|
316
|
+
v8::Global<v8::Function> emit_message_fn_;
|
|
317
|
+
|
|
318
|
+
friend class MessagePortData;
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// Provide a wrapper class created when a built-in JS classes that being
|
|
322
|
+
// transferable or cloneable by postMessage().
|
|
323
|
+
// See e.g. FileHandle in internal/fs/promises.js for an example.
|
|
324
|
+
class JSTransferable : public BaseObject {
|
|
325
|
+
public:
|
|
326
|
+
static BaseObjectPtr<JSTransferable> Wrap(Environment* env,
|
|
327
|
+
v8::Local<v8::Object> target);
|
|
328
|
+
static bool IsJSTransferable(Environment* env,
|
|
329
|
+
v8::Local<v8::Context> context,
|
|
330
|
+
v8::Local<v8::Object> object);
|
|
331
|
+
|
|
332
|
+
JSTransferable(Environment* env,
|
|
333
|
+
v8::Local<v8::Object> obj,
|
|
334
|
+
v8::Local<v8::Object> target);
|
|
335
|
+
~JSTransferable();
|
|
336
|
+
|
|
337
|
+
BaseObject::TransferMode GetTransferMode() const override;
|
|
338
|
+
std::unique_ptr<TransferData> TransferForMessaging() override;
|
|
339
|
+
std::unique_ptr<TransferData> CloneForMessaging() const override;
|
|
340
|
+
v8::Maybe<std::vector<BaseObjectPtr<BaseObject>>>
|
|
341
|
+
NestedTransferables() const override;
|
|
342
|
+
v8::Maybe<void> FinalizeTransferRead(
|
|
343
|
+
v8::Local<v8::Context> context,
|
|
344
|
+
v8::ValueDeserializer* deserializer) override;
|
|
345
|
+
|
|
346
|
+
SET_NO_MEMORY_INFO()
|
|
347
|
+
SET_MEMORY_INFO_NAME(JSTransferable)
|
|
348
|
+
SET_SELF_SIZE(JSTransferable)
|
|
349
|
+
|
|
350
|
+
v8::Local<v8::Object> target() const;
|
|
351
|
+
|
|
352
|
+
private:
|
|
353
|
+
template <TransferMode mode>
|
|
354
|
+
std::unique_ptr<TransferData> TransferOrClone() const;
|
|
355
|
+
|
|
356
|
+
v8::Global<v8::Object> target_;
|
|
357
|
+
|
|
358
|
+
class Data : public TransferData {
|
|
359
|
+
public:
|
|
360
|
+
Data(std::string&& deserialize_info, v8::Global<v8::Value>&& data);
|
|
361
|
+
|
|
362
|
+
BaseObjectPtr<BaseObject> Deserialize(
|
|
363
|
+
Environment* env,
|
|
364
|
+
v8::Local<v8::Context> context,
|
|
365
|
+
std::unique_ptr<TransferData> self) override;
|
|
366
|
+
v8::Maybe<bool> FinalizeTransferWrite(
|
|
367
|
+
v8::Local<v8::Context> context,
|
|
368
|
+
v8::ValueSerializer* serializer) override;
|
|
369
|
+
|
|
370
|
+
SET_NO_MEMORY_INFO()
|
|
371
|
+
SET_MEMORY_INFO_NAME(JSTransferableTransferData)
|
|
372
|
+
SET_SELF_SIZE(Data)
|
|
373
|
+
|
|
374
|
+
private:
|
|
375
|
+
std::string deserialize_info_;
|
|
376
|
+
v8::Global<v8::Value> data_;
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
v8::Local<v8::FunctionTemplate> GetMessagePortConstructorTemplate(
|
|
381
|
+
IsolateData* isolate_data);
|
|
382
|
+
|
|
383
|
+
} // namespace worker
|
|
384
|
+
} // namespace node
|
|
385
|
+
|
|
386
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
#endif // SRC_NODE_MESSAGING_H_
|
|
@@ -0,0 +1,164 @@
|
|
|
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
|
+
#if NODE_OPENSSL_HAS_QUIC
|
|
14
|
+
#include <openssl/quic.h>
|
|
15
|
+
#endif
|
|
16
|
+
#endif // HAVE_OPENSSL
|
|
17
|
+
|
|
18
|
+
namespace node {
|
|
19
|
+
|
|
20
|
+
// if this is a release build and no explicit base has been set
|
|
21
|
+
// substitute the standard release download URL
|
|
22
|
+
#ifndef NODE_RELEASE_URLBASE
|
|
23
|
+
#if NODE_VERSION_IS_RELEASE
|
|
24
|
+
#define NODE_RELEASE_URLBASE "https://nodejs.org/download/release/"
|
|
25
|
+
#endif // NODE_VERSION_IS_RELEASE
|
|
26
|
+
#endif // NODE_RELEASE_URLBASE
|
|
27
|
+
|
|
28
|
+
#if defined(NODE_RELEASE_URLBASE)
|
|
29
|
+
#define NODE_HAS_RELEASE_URLS
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
#if HAVE_AMARO && !defined(NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH)
|
|
33
|
+
#define NODE_VERSIONS_KEY_AMARO(V) V(amaro)
|
|
34
|
+
#else
|
|
35
|
+
#define NODE_VERSIONS_KEY_AMARO(V)
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#ifndef NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH
|
|
39
|
+
#define NODE_VERSIONS_KEY_UNDICI(V) V(undici)
|
|
40
|
+
#else
|
|
41
|
+
#define NODE_VERSIONS_KEY_UNDICI(V)
|
|
42
|
+
#endif
|
|
43
|
+
|
|
44
|
+
#define NODE_VERSIONS_KEYS_BASE(V) \
|
|
45
|
+
V(node) \
|
|
46
|
+
V(v8) \
|
|
47
|
+
V(uv) \
|
|
48
|
+
V(zlib) \
|
|
49
|
+
V(brotli) \
|
|
50
|
+
V(zstd) \
|
|
51
|
+
V(ares) \
|
|
52
|
+
V(modules) \
|
|
53
|
+
V(nghttp2) \
|
|
54
|
+
V(napi) \
|
|
55
|
+
V(llhttp) \
|
|
56
|
+
V(uvwasi) \
|
|
57
|
+
V(acorn) \
|
|
58
|
+
V(simdjson) \
|
|
59
|
+
V(simdutf) \
|
|
60
|
+
V(ada) \
|
|
61
|
+
V(nbytes) \
|
|
62
|
+
NODE_VERSIONS_KEY_AMARO(V) \
|
|
63
|
+
NODE_VERSIONS_KEY_UNDICI(V) \
|
|
64
|
+
V(cjs_module_lexer)
|
|
65
|
+
|
|
66
|
+
#if HAVE_OPENSSL
|
|
67
|
+
#define NODE_VERSIONS_KEY_CRYPTO(V) V(openssl) V(ncrypto)
|
|
68
|
+
#else
|
|
69
|
+
#define NODE_VERSIONS_KEY_CRYPTO(V)
|
|
70
|
+
#endif
|
|
71
|
+
|
|
72
|
+
#ifdef NODE_HAVE_I18N_SUPPORT
|
|
73
|
+
#define NODE_VERSIONS_KEY_INTL(V) \
|
|
74
|
+
V(cldr) \
|
|
75
|
+
V(icu) \
|
|
76
|
+
V(tz) \
|
|
77
|
+
V(unicode)
|
|
78
|
+
#else
|
|
79
|
+
#define NODE_VERSIONS_KEY_INTL(V)
|
|
80
|
+
#endif // NODE_HAVE_I18N_SUPPORT
|
|
81
|
+
|
|
82
|
+
#ifdef OPENSSL_INFO_QUIC
|
|
83
|
+
#define NODE_VERSIONS_KEY_QUIC(V) \
|
|
84
|
+
V(ngtcp2) \
|
|
85
|
+
V(nghttp3)
|
|
86
|
+
#else
|
|
87
|
+
#define NODE_VERSIONS_KEY_QUIC(V)
|
|
88
|
+
#endif
|
|
89
|
+
|
|
90
|
+
#if HAVE_SQLITE
|
|
91
|
+
#define NODE_VERSIONS_KEY_SQLITE(V) V(sqlite)
|
|
92
|
+
#else
|
|
93
|
+
#define NODE_VERSIONS_KEY_SQLITE(V)
|
|
94
|
+
#endif
|
|
95
|
+
|
|
96
|
+
#define NODE_VERSIONS_KEYS(V) \
|
|
97
|
+
NODE_VERSIONS_KEYS_BASE(V) \
|
|
98
|
+
NODE_VERSIONS_KEY_CRYPTO(V) \
|
|
99
|
+
NODE_VERSIONS_KEY_INTL(V) \
|
|
100
|
+
NODE_VERSIONS_KEY_QUIC(V) \
|
|
101
|
+
NODE_VERSIONS_KEY_SQLITE(V)
|
|
102
|
+
|
|
103
|
+
#define V(key) +1
|
|
104
|
+
constexpr int NODE_VERSIONS_KEY_COUNT = NODE_VERSIONS_KEYS(V);
|
|
105
|
+
#undef V
|
|
106
|
+
|
|
107
|
+
class Metadata {
|
|
108
|
+
public:
|
|
109
|
+
Metadata();
|
|
110
|
+
Metadata(Metadata&) = delete;
|
|
111
|
+
Metadata(Metadata&&) = delete;
|
|
112
|
+
Metadata operator=(Metadata&) = delete;
|
|
113
|
+
Metadata operator=(Metadata&&) = delete;
|
|
114
|
+
|
|
115
|
+
struct Versions {
|
|
116
|
+
Versions();
|
|
117
|
+
|
|
118
|
+
#ifdef NODE_HAVE_I18N_SUPPORT
|
|
119
|
+
// Must be called on the main thread after
|
|
120
|
+
// i18n::InitializeICUDirectory()
|
|
121
|
+
void InitializeIntlVersions();
|
|
122
|
+
#endif // NODE_HAVE_I18N_SUPPORT
|
|
123
|
+
|
|
124
|
+
#define V(key) std::string key;
|
|
125
|
+
NODE_VERSIONS_KEYS(V)
|
|
126
|
+
#undef V
|
|
127
|
+
|
|
128
|
+
std::array<std::pair<std::string_view, std::string_view>,
|
|
129
|
+
NODE_VERSIONS_KEY_COUNT>
|
|
130
|
+
pairs() const;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
struct Release {
|
|
134
|
+
Release();
|
|
135
|
+
|
|
136
|
+
std::string name;
|
|
137
|
+
#if NODE_VERSION_IS_LTS
|
|
138
|
+
std::string lts;
|
|
139
|
+
#endif // NODE_VERSION_IS_LTS
|
|
140
|
+
|
|
141
|
+
#ifdef NODE_HAS_RELEASE_URLS
|
|
142
|
+
std::string source_url;
|
|
143
|
+
std::string headers_url;
|
|
144
|
+
#ifdef _WIN32
|
|
145
|
+
std::string lib_url;
|
|
146
|
+
#endif // _WIN32
|
|
147
|
+
#endif // NODE_HAS_RELEASE_URLS
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
Versions versions;
|
|
151
|
+
const Release release;
|
|
152
|
+
const std::string arch;
|
|
153
|
+
const std::string platform;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// Per-process global
|
|
157
|
+
namespace per_process {
|
|
158
|
+
extern Metadata metadata;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
} // namespace node
|
|
162
|
+
|
|
163
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
164
|
+
#endif // SRC_NODE_METADATA_H_
|
|
@@ -0,0 +1,91 @@
|
|
|
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 GetNearestParentPackageJSONType(
|
|
59
|
+
const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
60
|
+
template <bool return_only_type>
|
|
61
|
+
static void GetPackageScopeConfig(
|
|
62
|
+
const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
63
|
+
static void GetPackageJSONScripts(
|
|
64
|
+
const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
65
|
+
|
|
66
|
+
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
|
67
|
+
v8::Local<v8::ObjectTemplate> ctor);
|
|
68
|
+
static void CreatePerContextProperties(v8::Local<v8::Object> target,
|
|
69
|
+
v8::Local<v8::Value> unused,
|
|
70
|
+
v8::Local<v8::Context> context,
|
|
71
|
+
void* priv);
|
|
72
|
+
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
|
73
|
+
|
|
74
|
+
private:
|
|
75
|
+
std::unordered_map<std::string, PackageConfig> package_configs_;
|
|
76
|
+
simdjson::ondemand::parser json_parser;
|
|
77
|
+
// returns null on error
|
|
78
|
+
static const PackageConfig* GetPackageJSON(
|
|
79
|
+
Realm* realm,
|
|
80
|
+
std::string_view path,
|
|
81
|
+
ErrorContext* error_context = nullptr);
|
|
82
|
+
static const PackageConfig* TraverseParent(
|
|
83
|
+
Realm* realm, const std::filesystem::path& check_path);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
} // namespace modules
|
|
87
|
+
} // namespace node
|
|
88
|
+
|
|
89
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
90
|
+
|
|
91
|
+
#endif // SRC_NODE_MODULES_H_
|