Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-11-13 18:54:57 +0300
committerAnna Henningsen <anna@addaleax.net>2020-03-21 12:57:23 +0300
commitc44edec4daff9f478eb9b5820d03da6c71253787 (patch)
treede93264d6d4a643f478329e67043ecc7f5f8edfc /src/node.h
parenta9fb51f9be570001accfce8a057e885827655a2f (diff)
src: provide a variant of LoadEnvironment taking a callback
This allows embedders to flexibly control how they start JS code rather than using `third_party_main`. PR-URL: https://github.com/nodejs/node/pull/30467 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Diffstat (limited to 'src/node.h')
-rw-r--r--src/node.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/node.h b/src/node.h
index ac5887cb6f4..9561ca39e25 100644
--- a/src/node.h
+++ b/src/node.h
@@ -73,6 +73,7 @@
#include "node_version.h" // NODE_MODULE_VERSION
#include <memory>
+#include <functional>
// We cannot use __POSIX__ in this header because that's only defined when
// building Node.js.
@@ -438,12 +439,20 @@ NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
ThreadId child_thread_id,
const char* child_url);
-// TODO(addaleax): Deprecate this in favour of the MaybeLocal<> overload
-// and provide a more flexible approach than third_party_main.
+struct StartExecutionCallbackInfo {
+ v8::Local<v8::Object> process_object;
+ v8::Local<v8::Function> native_require;
+};
+
+using StartExecutionCallback =
+ std::function<v8::MaybeLocal<v8::Value>(const StartExecutionCallbackInfo&)>;
+
+// TODO(addaleax): Deprecate this in favour of the MaybeLocal<> overload.
NODE_EXTERN void LoadEnvironment(Environment* env);
NODE_EXTERN v8::MaybeLocal<v8::Value> LoadEnvironment(
Environment* env,
- std::unique_ptr<InspectorParentHandle> inspector_parent_handle);
+ StartExecutionCallback cb,
+ std::unique_ptr<InspectorParentHandle> inspector_parent_handle = {});
NODE_EXTERN void FreeEnvironment(Environment* env);
// This may return nullptr if context is not associated with a Node instance.