Skip to content

Commit a84120f

Browse files
committed
add HostImportModuleDynamicallyCallback
1 parent 1d25fcf commit a84120f

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/binding.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,12 @@ const v8::Value* v8__Isolate__ThrowException(
297297
return local_to_ptr(isolate->ThrowException(ptr_to_local(&exception)));
298298
}
299299

300+
void v8__Isolate__SetHostImportModuleDynamicallyCallback(
301+
v8::Isolate* isolate,
302+
v8::HostImportModuleDynamicallyCallback callback) {
303+
isolate->SetHostImportModuleDynamicallyCallback(callback);
304+
}
305+
300306
void v8__Isolate__SetPromiseRejectCallback(
301307
v8::Isolate* isolate,
302308
v8::PromiseRejectCallback callback) {

src/binding.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ typedef enum PromiseRejectEvent {
7676
} PromiseRejectEvent;
7777
typedef struct PromiseRejectMessage PromiseRejectMessage;
7878
typedef void (*PromiseRejectCallback)(PromiseRejectMessage);
79+
typedef Promise* (*HostImportModuleDynamicallyCallback)(Context*, Data*, Value*, String*, FixedArray*);
7980
typedef enum MessageErrorLevel {
8081
kMessageLog = (1 << 0),
8182
kMessageDebug = (1 << 1),
@@ -211,6 +212,9 @@ Context* v8__Isolate__GetCurrentContext(Isolate* isolate);
211212
const Value* v8__Isolate__ThrowException(
212213
Isolate* isolate,
213214
const Value* exception);
215+
void v8__Isolate__SetHostImportModuleDynamicallyCallback(
216+
Isolate* isolate,
217+
HostImportModuleDynamicallyCallback callback);
214218
void v8__Isolate__SetPromiseRejectCallback(
215219
Isolate* isolate,
216220
PromiseRejectCallback callback);

src/v8.zig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,14 @@ pub const Isolate = struct {
322322
.handle = c.v8__Isolate__ThrowException(self.handle, getValueHandle(value)).?,
323323
};
324324
}
325+
/// [V8]
326+
/// This specifies the callback called by the upcoming dynamic import() language feature to load modules.
327+
pub fn setHostImportModuleDynamicallyCallback(
328+
self: Self,
329+
callback: c.HostImportModuleDynamicallyCallback,
330+
) void {
331+
c.v8__Isolate__SetHostImportModuleDynamicallyCallback(self.handle, callback);
332+
}
325333

326334
/// [V8]
327335
/// Set callback to notify about promise reject with no handler, or

0 commit comments

Comments
 (0)