@@ -1105,6 +1105,28 @@ class V8_EXPORT Module {
11051105 V8_WARN_UNUSED_RESULT MaybeLocal<Value> Evaluate(Local<Context> context);
11061106};
11071107
1108+ /**
1109+ * This is an unfinished experimental feature, and is only exposed
1110+ * here for internal testing purposes. DO NOT USE.
1111+ *
1112+ * A compiled JavaScript module.
1113+ */
1114+ class V8_EXPORT DynamicImportResult {
1115+ public:
1116+ /**
1117+ * Resolves the promise with the namespace object of the given
1118+ * module.
1119+ */
1120+ V8_WARN_UNUSED_RESULT bool FinishDynamicImportSuccess(Local<Context> context,
1121+ Local<Module> module);
1122+
1123+ /**
1124+ * Rejects the promise with the given exception.
1125+ */
1126+ V8_WARN_UNUSED_RESULT bool FinishDynamicImportFailure(Local<Context> context,
1127+ Local<Value> exception);
1128+ };
1129+
11081130/**
11091131 * A compiled JavaScript script, tied to a Context which was active when the
11101132 * script was compiled.
@@ -5948,6 +5970,25 @@ typedef void (*BeforeCallEnteredCallback)(Isolate*);
59485970typedef void (*CallCompletedCallback)(Isolate*);
59495971typedef void (*DeprecatedCallCompletedCallback)();
59505972
5973+ /**
5974+ * HostImportDynamicallyCallback is called when we require the
5975+ * embedder to load a module. This is used as part of the dynamic
5976+ * import syntax. The behavior of this callback is not specified in
5977+ * EcmaScript.
5978+ *
5979+ * The referrer is the name of the file which calls the dynamic
5980+ * import. The referrer can be used to resolve the module location.
5981+ *
5982+ * The specifier is the name of the module that should be imported.
5983+ *
5984+ * The DynamicImportResult object is used to signal success or failure
5985+ * by calling it's respective methods.
5986+ *
5987+ */
5988+ typedef void (*HostImportModuleDynamicallyCallback)(
5989+ Isolate* isolate, Local<String> referrer, Local<String> specifier,
5990+ Local<DynamicImportResult> result);
5991+
59515992/**
59525993 * PromiseHook with type kInit is called when a new promise is
59535994 * created. When a new promise is created as part of the chain in the
@@ -6495,7 +6536,8 @@ class V8_EXPORT Isolate {
64956536 add_histogram_sample_callback(nullptr),
64966537 array_buffer_allocator(nullptr),
64976538 external_references(nullptr),
6498- allow_atomics_wait(true) {}
6539+ allow_atomics_wait(true),
6540+ host_import_module_dynamically_callback_(nullptr) {}
64996541
65006542 /**
65016543 * The optional entry_hook allows the host application to provide the
@@ -6558,6 +6600,16 @@ class V8_EXPORT Isolate {
65586600 * this isolate.
65596601 */
65606602 bool allow_atomics_wait;
6603+
6604+ /**
6605+ * This is an unfinished experimental feature, and is only exposed
6606+ * here for internal testing purposes. DO NOT USE.
6607+ *
6608+ * This specifies the callback called by the upcoming dynamic
6609+ * import() language feature to load modules.
6610+ */
6611+ HostImportModuleDynamicallyCallback
6612+ host_import_module_dynamically_callback_;
65616613 };
65626614
65636615
0 commit comments