@@ -23,25 +23,35 @@ using node::contextify::ContextifyContext;
23
23
using v8::Array;
24
24
using v8::ArrayBufferView;
25
25
using v8::Context;
26
+ using v8::Data;
26
27
using v8::EscapableHandleScope;
28
+ using v8::Exception;
27
29
using v8::FixedArray;
28
30
using v8::Function;
29
31
using v8::FunctionCallbackInfo;
30
32
using v8::FunctionTemplate;
33
+ using v8::Global;
31
34
using v8::HandleScope;
32
35
using v8::Int32;
33
36
using v8::Integer;
34
37
using v8::Isolate;
38
+ using v8::Just;
35
39
using v8::Local;
40
+ using v8::LocalVector;
41
+ using v8::Maybe;
36
42
using v8::MaybeLocal;
37
43
using v8::MemorySpan;
44
+ using v8::Message;
38
45
using v8::MicrotaskQueue;
39
46
using v8::Module;
40
47
using v8::ModuleRequest;
48
+ using v8::Name;
49
+ using v8::Null;
41
50
using v8::Object;
42
51
using v8::ObjectTemplate;
43
52
using v8::PrimitiveArray;
44
53
using v8::Promise;
54
+ using v8::PromiseRejectEvent;
45
55
using v8::ScriptCompiler;
46
56
using v8::ScriptOrigin;
47
57
using v8::String;
@@ -103,7 +113,7 @@ ModuleWrap* ModuleWrap::GetFromModule(Environment* env,
103
113
return nullptr ;
104
114
}
105
115
106
- v8:: Maybe<bool > ModuleWrap::CheckUnsettledTopLevelAwait () {
116
+ Maybe<bool > ModuleWrap::CheckUnsettledTopLevelAwait () {
107
117
Isolate* isolate = env ()->isolate ();
108
118
Local<Context> context = env ()->context ();
109
119
@@ -115,17 +125,17 @@ v8::Maybe<bool> ModuleWrap::CheckUnsettledTopLevelAwait() {
115
125
Local<Module> module = module_.Get (isolate);
116
126
// It's a synthetic module, likely a facade wrapping CJS.
117
127
if (!module->IsSourceTextModule ()) {
118
- return v8:: Just (true );
128
+ return Just (true );
119
129
}
120
130
121
131
if (!module->IsGraphAsync ()) { // There is no TLA, no need to check.
122
- return v8:: Just (true );
132
+ return Just (true );
123
133
}
124
134
125
135
auto stalled_messages =
126
136
std::get<1 >(module->GetStalledTopLevelAwaitMessages (isolate));
127
137
if (stalled_messages.empty ()) {
128
- return v8:: Just (true );
138
+ return Just (true );
129
139
}
130
140
131
141
if (env ()->options ()->warnings ) {
@@ -138,7 +148,7 @@ v8::Maybe<bool> ModuleWrap::CheckUnsettledTopLevelAwait() {
138
148
}
139
149
}
140
150
141
- return v8:: Just (false );
151
+ return Just (false );
142
152
}
143
153
144
154
Local<PrimitiveArray> ModuleWrap::GetHostDefinedOptions (
@@ -229,7 +239,7 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
229
239
Local<Array> export_names_arr = args[2 ].As <Array>();
230
240
231
241
uint32_t len = export_names_arr->Length ();
232
- std::vector<Local< String>> export_names (len);
242
+ LocalVector< String> export_names (realm-> isolate (), len);
233
243
for (uint32_t i = 0 ; i < len; i++) {
234
244
Local<Value> export_name_val =
235
245
export_names_arr->Get (context, i).ToLocalChecked ();
@@ -245,7 +255,7 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
245
255
// When we are compiling for the default loader, this will be
246
256
// std::nullopt, and CompileSourceTextModule() should use
247
257
// on-disk cache.
248
- std::optional<v8:: ScriptCompiler::CachedData*> user_cached_data;
258
+ std::optional<ScriptCompiler::CachedData*> user_cached_data;
249
259
if (id_symbol !=
250
260
realm->isolate_data ()->source_text_module_default_hdo ()) {
251
261
user_cached_data = nullptr ;
@@ -324,7 +334,7 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
324
334
// be stored in an internal field.
325
335
Local<Object> context_object = context->GetExtrasBindingObject ();
326
336
Local<Value> synthetic_evaluation_step =
327
- synthetic ? args[3 ] : Undefined (realm->isolate ()).As <v8:: Value>();
337
+ synthetic ? args[3 ] : Undefined (realm->isolate ()).As <Value>();
328
338
329
339
ModuleWrap* obj = new ModuleWrap (
330
340
realm, that, module, url, context_object, synthetic_evaluation_step);
@@ -405,22 +415,22 @@ static Local<Object> createImportAttributesContainer(
405
415
const int elements_per_attribute) {
406
416
CHECK_EQ (raw_attributes->Length () % elements_per_attribute, 0 );
407
417
size_t num_attributes = raw_attributes->Length () / elements_per_attribute;
408
- std::vector<Local<v8:: Name>> names (num_attributes);
409
- std::vector<Local<v8:: Value>> values (num_attributes);
418
+ LocalVector< Name> names (isolate, num_attributes);
419
+ LocalVector< Value> values (isolate, num_attributes);
410
420
411
421
for (int i = 0 ; i < raw_attributes->Length (); i += elements_per_attribute) {
412
422
int idx = i / elements_per_attribute;
413
- names[idx] = raw_attributes->Get (realm->context (), i).As <v8:: Name>();
423
+ names[idx] = raw_attributes->Get (realm->context (), i).As <Name>();
414
424
values[idx] = raw_attributes->Get (realm->context (), i + 1 ).As <Value>();
415
425
}
416
426
417
427
return Object::New (
418
- isolate, v8:: Null (isolate), names.data (), values.data (), num_attributes);
428
+ isolate, Null (isolate), names.data (), values.data (), num_attributes);
419
429
}
420
430
421
431
static Local<Array> createModuleRequestsContainer (
422
432
Realm* realm, Isolate* isolate, Local<FixedArray> raw_requests) {
423
- std::vector<Local< Value>> requests (raw_requests->Length ());
433
+ LocalVector< Value> requests (isolate, raw_requests->Length ());
424
434
425
435
for (int i = 0 ; i < raw_requests->Length (); i++) {
426
436
Local<ModuleRequest> module_request =
@@ -434,7 +444,7 @@ static Local<Array> createModuleRequestsContainer(
434
444
Local<Object> attributes =
435
445
createImportAttributesContainer (realm, isolate, raw_attributes, 3 );
436
446
437
- Local<v8:: Name> names[] = {
447
+ Local<Name> names[] = {
438
448
realm->isolate_data ()->specifier_string (),
439
449
realm->isolate_data ()->attributes_string (),
440
450
};
@@ -444,8 +454,8 @@ static Local<Array> createModuleRequestsContainer(
444
454
};
445
455
DCHECK_EQ (arraysize (names), arraysize (values));
446
456
447
- Local<Object> request = Object::New (
448
- isolate, v8:: Null (isolate), names, values, arraysize (names));
457
+ Local<Object> request =
458
+ Object::New ( isolate, Null (isolate), names, values, arraysize (names));
449
459
450
460
requests[i] = request;
451
461
}
@@ -481,11 +491,11 @@ void ModuleWrap::Link(const FunctionCallbackInfo<Value>& args) {
481
491
Local<Array> modules = args[1 ].As <Array>();
482
492
CHECK_EQ (specifiers->Length (), modules->Length ());
483
493
484
- std::vector<v8:: Global<Value>> specifiers_buffer;
494
+ std::vector<Global<Value>> specifiers_buffer;
485
495
if (FromV8Array (context, specifiers, &specifiers_buffer).IsNothing ()) {
486
496
return ;
487
497
}
488
- std::vector<v8:: Global<Value>> modules_buffer;
498
+ std::vector<Global<Value>> modules_buffer;
489
499
if (FromV8Array (context, modules, &modules_buffer).IsNothing ()) {
490
500
return ;
491
501
}
@@ -669,19 +679,18 @@ void ModuleWrap::EvaluateSync(const FunctionCallbackInfo<Value>& args) {
669
679
// before handler was added which would remove it from the unhandled
670
680
// rejection handling, since we are converting it into an error and throw
671
681
// from here directly.
672
- Local<Value> type = v8::Integer::New (
673
- isolate,
674
- static_cast <int32_t >(
675
- v8:: PromiseRejectEvent::kPromiseHandlerAddedAfterReject ));
682
+ Local<Value> type =
683
+ Integer::New ( isolate,
684
+ static_cast <int32_t >(
685
+ PromiseRejectEvent::kPromiseHandlerAddedAfterReject ));
676
686
Local<Value> args[] = {type, promise, Undefined (isolate)};
677
687
if (env->promise_reject_callback ()
678
688
->Call (context, Undefined (isolate), arraysize (args), args)
679
689
.IsEmpty ()) {
680
690
return ;
681
691
}
682
692
Local<Value> exception = promise->Result ();
683
- Local<v8::Message> message =
684
- v8::Exception::CreateMessage (isolate, exception );
693
+ Local<Message> message = Exception::CreateMessage (isolate, exception );
685
694
AppendExceptionLine (
686
695
env, exception , message, ErrorHandlingMode::MODULE_ERROR);
687
696
isolate->ThrowException (exception );
@@ -718,15 +727,15 @@ void ModuleWrap::GetNamespaceSync(const FunctionCallbackInfo<Value>& args) {
718
727
Local<Module> module = obj->module_ .Get (isolate);
719
728
720
729
switch (module->GetStatus ()) {
721
- case v8:: Module::Status::kUninstantiated :
722
- case v8:: Module::Status::kInstantiating :
730
+ case Module::Status::kUninstantiated :
731
+ case Module::Status::kInstantiating :
723
732
return realm->env ()->ThrowError (
724
733
" Cannot get namespace, module has not been instantiated" );
725
- case v8:: Module::Status::kInstantiated :
726
- case v8:: Module::Status::kEvaluated :
727
- case v8:: Module::Status::kErrored :
734
+ case Module::Status::kInstantiated :
735
+ case Module::Status::kEvaluated :
736
+ case Module::Status::kErrored :
728
737
break ;
729
- case v8:: Module::Status::kEvaluating :
738
+ case Module::Status::kEvaluating :
730
739
UNREACHABLE ();
731
740
}
732
741
@@ -746,14 +755,14 @@ void ModuleWrap::GetNamespace(const FunctionCallbackInfo<Value>& args) {
746
755
Local<Module> module = obj->module_ .Get (isolate);
747
756
748
757
switch (module->GetStatus ()) {
749
- case v8:: Module::Status::kUninstantiated :
750
- case v8:: Module::Status::kInstantiating :
758
+ case Module::Status::kUninstantiated :
759
+ case Module::Status::kInstantiating :
751
760
return realm->env ()->ThrowError (
752
761
" cannot get namespace, module has not been instantiated" );
753
- case v8:: Module::Status::kInstantiated :
754
- case v8:: Module::Status::kEvaluating :
755
- case v8:: Module::Status::kEvaluated :
756
- case v8:: Module::Status::kErrored :
762
+ case Module::Status::kInstantiated :
763
+ case Module::Status::kEvaluating :
764
+ case Module::Status::kEvaluated :
765
+ case Module::Status::kErrored :
757
766
break ;
758
767
default :
759
768
UNREACHABLE ();
@@ -825,7 +834,7 @@ MaybeLocal<Module> ModuleWrap::ResolveModuleCallback(
825
834
826
835
static MaybeLocal<Promise> ImportModuleDynamically (
827
836
Local<Context> context,
828
- Local<v8:: Data> host_defined_options,
837
+ Local<Data> host_defined_options,
829
838
Local<Value> resource_name,
830
839
Local<String> specifier,
831
840
Local<FixedArray> import_attributes) {
@@ -1011,7 +1020,7 @@ void ModuleWrap::CreateCachedData(const FunctionCallbackInfo<Value>& args) {
1011
1020
1012
1021
Local<Module> module = obj->module_ .Get (isolate);
1013
1022
1014
- CHECK_LT (module->GetStatus (), v8:: Module::Status::kEvaluating );
1023
+ CHECK_LT (module->GetStatus (), Module::Status::kEvaluating );
1015
1024
1016
1025
Local<UnboundModuleScript> unbound_module_script =
1017
1026
module->GetUnboundModuleScript ();
0 commit comments