@@ -26,17 +26,20 @@ using v8::Array; |
26 | 26 | using v8::ArrayBufferView; |
27 | 27 | using v8::Context; |
28 | 28 | using v8::EscapableHandleScope; |
| 29 | +using v8::FixedArray; |
29 | 30 | using v8::Function; |
30 | 31 | using v8::FunctionCallbackInfo; |
31 | 32 | using v8::FunctionTemplate; |
32 | 33 | using v8::HandleScope; |
| 34 | +using v8::Int32; |
33 | 35 | using v8::Integer; |
34 | 36 | using v8::IntegrityLevel; |
35 | 37 | using v8::Isolate; |
36 | 38 | using v8::Local; |
37 | 39 | using v8::MaybeLocal; |
38 | 40 | using v8::MicrotaskQueue; |
39 | 41 | using v8::Module; |
| 42 | +using v8::ModuleRequest; |
40 | 43 | using v8::Number; |
41 | 44 | using v8::Object; |
42 | 45 | using v8::PrimitiveArray; |
@@ -128,8 +131,8 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) { |
128 | 131 | context = contextify_context->context(); |
129 | 132 | } |
130 | 133 |
|
131 | | - Local<Integer> line_offset; |
132 | | - Local<Integer> column_offset; |
| 134 | + int line_offset = 0; |
| 135 | + int column_offset = 0; |
133 | 136 |
|
134 | 137 | bool synthetic = args[2]->IsArray(); |
135 | 138 | if (synthetic) { |
@@ -139,9 +142,9 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) { |
139 | 142 | // new ModuleWrap(url, context, source, lineOffset, columOffset, cachedData) |
140 | 143 | CHECK(args[2]->IsString()); |
141 | 144 | CHECK(args[3]->IsNumber()); |
142 | | - line_offset = args[3].As<Integer>(); |
| 145 | + line_offset = args[3].As<Int32>()->Value(); |
143 | 146 | CHECK(args[4]->IsNumber()); |
144 | | - column_offset = args[4].As<Integer>(); |
| 147 | + column_offset = args[4].As<Int32>()->Value(); |
145 | 148 | } |
146 | 149 |
|
147 | 150 | Local<PrimitiveArray> host_defined_options = |
@@ -185,14 +188,14 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) { |
185 | 188 |
|
186 | 189 | Local<String> source_text = args[2].As<String>(); |
187 | 190 | ScriptOrigin origin(url, |
188 | | - line_offset, // line offset |
189 | | - column_offset, // column offset |
190 | | - True(isolate), // is cross origin |
191 | | - Local<Integer>(), // script id |
| 191 | + line_offset, |
| 192 | + column_offset, |
| 193 | + true, // is cross origin |
| 194 | + -1, // script id |
192 | 195 | Local<Value>(), // source map URL |
193 | | - False(isolate), // is opaque (?) |
194 | | - False(isolate), // is WASM |
195 | | - True(isolate), // is ES Module |
| 196 | + false, // is opaque (?) |
| 197 | + false, // is WASM |
| 198 | + true, // is ES Module |
196 | 199 | host_defined_options); |
197 | 200 | ScriptCompiler::Source source(source_text, origin, cached_data); |
198 | 201 | ScriptCompiler::CompileOptions options; |
@@ -270,12 +273,15 @@ void ModuleWrap::Link(const FunctionCallbackInfo<Value>& args) { |
270 | 273 | Local<Context> mod_context = obj->context(); |
271 | 274 | Local<Module> module = obj->module_.Get(isolate); |
272 | 275 |
|
273 | | - const int module_requests_length = module->GetModuleRequestsLength(); |
| 276 | + Local<FixedArray> module_requests = module->GetModuleRequests(); |
| 277 | + const int module_requests_length = module_requests->Length(); |
274 | 278 | MaybeStackBuffer<Local<Value>, 16> promises(module_requests_length); |
275 | 279 |
|
276 | 280 | // call the dependency resolve callbacks |
277 | 281 | for (int i = 0; i < module_requests_length; i++) { |
278 | | - Local<String> specifier = module->GetModuleRequest(i); |
| 282 | + Local<ModuleRequest> module_request = |
| 283 | + module_requests->Get(env->context(), i).As<ModuleRequest>(); |
| 284 | + Local<String> specifier = module_request->GetSpecifier(); |
279 | 285 | Utf8Value specifier_utf8(env->isolate(), specifier); |
280 | 286 | std::string specifier_std(*specifier_utf8, specifier_utf8.length()); |
281 | 287 |
|
@@ -311,7 +317,7 @@ void ModuleWrap::Instantiate(const FunctionCallbackInfo<Value>& args) { |
311 | 317 | Local<Context> context = obj->context(); |
312 | 318 | Local<Module> module = obj->module_.Get(isolate); |
313 | 319 | TryCatchScope try_catch(env); |
314 | | - USE(module->InstantiateModule(context, ResolveCallback)); |
| 320 | + USE(module->InstantiateModule(context, ResolveModuleCallback)); |
315 | 321 |
|
316 | 322 | // clear resolve cache on instantiate |
317 | 323 | obj->resolve_cache_.clear(); |
@@ -453,12 +459,16 @@ void ModuleWrap::GetStaticDependencySpecifiers( |
453 | 459 |
|
454 | 460 | Local<Module> module = obj->module_.Get(env->isolate()); |
455 | 461 |
|
456 | | - int count = module->GetModuleRequestsLength(); |
| 462 | + Local<FixedArray> module_requests = module->GetModuleRequests(); |
| 463 | + int count = module_requests->Length(); |
457 | 464 |
|
458 | 465 | MaybeStackBuffer<Local<Value>, 16> specifiers(count); |
459 | 466 |
|
460 | | - for (int i = 0; i < count; i++) |
461 | | - specifiers[i] = module->GetModuleRequest(i); |
| 467 | + for (int i = 0; i < count; i++) { |
| 468 | + Local<ModuleRequest> module_request = |
| 469 | + module_requests->Get(env->context(), i).As<ModuleRequest>(); |
| 470 | + specifiers[i] = module_request->GetSpecifier(); |
| 471 | + } |
462 | 472 |
|
463 | 473 | args.GetReturnValue().Set( |
464 | 474 | Array::New(env->isolate(), specifiers.out(), count)); |
@@ -473,9 +483,11 @@ void ModuleWrap::GetError(const FunctionCallbackInfo<Value>& args) { |
473 | 483 | args.GetReturnValue().Set(module->GetException()); |
474 | 484 | } |
475 | 485 |
|
476 | | -MaybeLocal<Module> ModuleWrap::ResolveCallback(Local<Context> context, |
477 | | - Local<String> specifier, |
478 | | - Local<Module> referrer) { |
| 486 | +MaybeLocal<Module> ModuleWrap::ResolveModuleCallback( |
| 487 | + Local<Context> context, |
| 488 | + Local<String> specifier, |
| 489 | + Local<FixedArray> import_assertions, |
| 490 | + Local<Module> referrer) { |
479 | 491 | Environment* env = Environment::GetCurrent(context); |
480 | 492 | if (env == nullptr) { |
481 | 493 | Isolate* isolate = context->GetIsolate(); |
@@ -524,14 +536,14 @@ static MaybeLocal<Promise> ImportModuleDynamically( |
524 | 536 | Local<Context> context, |
525 | 537 | Local<ScriptOrModule> referrer, |
526 | 538 | Local<String> specifier) { |
527 | | - Isolate* iso = context->GetIsolate(); |
| 539 | + Isolate* isolate = context->GetIsolate(); |
528 | 540 | Environment* env = Environment::GetCurrent(context); |
529 | 541 | if (env == nullptr) { |
530 | | - THROW_ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE(iso); |
| 542 | + THROW_ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE(isolate); |
531 | 543 | return MaybeLocal<Promise>(); |
532 | 544 | } |
533 | 545 |
|
534 | | - EscapableHandleScope handle_scope(iso); |
| 546 | + EscapableHandleScope handle_scope(isolate); |
535 | 547 |
|
536 | 548 | Local<Function> import_callback = |
537 | 549 | env->host_import_module_dynamically_callback(); |
@@ -550,11 +562,11 @@ static MaybeLocal<Promise> ImportModuleDynamically( |
550 | 562 |
|
551 | 563 | Local<Value> object; |
552 | 564 |
|
553 | | - int type = options->Get(iso, HostDefinedOptions::kType) |
| 565 | + int type = options->Get(isolate, HostDefinedOptions::kType) |
554 | 566 | .As<Number>() |
555 | 567 | ->Int32Value(context) |
556 | 568 | .ToChecked(); |
557 | | - uint32_t id = options->Get(iso, HostDefinedOptions::kID) |
| 569 | + uint32_t id = options->Get(isolate, HostDefinedOptions::kID) |
558 | 570 | .As<Number>() |
559 | 571 | ->Uint32Value(context) |
560 | 572 | .ToChecked(); |
@@ -580,7 +592,7 @@ static MaybeLocal<Promise> ImportModuleDynamically( |
580 | 592 | Local<Value> result; |
581 | 593 | if (import_callback->Call( |
582 | 594 | context, |
583 | | - Undefined(iso), |
| 595 | + Undefined(isolate), |
584 | 596 | arraysize(import_args), |
585 | 597 | import_args).ToLocal(&result)) { |
586 | 598 | CHECK(result->IsPromise()); |
@@ -592,16 +604,16 @@ static MaybeLocal<Promise> ImportModuleDynamically( |
592 | 604 |
|
593 | 605 | void ModuleWrap::SetImportModuleDynamicallyCallback( |
594 | 606 | const FunctionCallbackInfo<Value>& args) { |
595 | | - Isolate* iso = args.GetIsolate(); |
| 607 | + Isolate* isolate = args.GetIsolate(); |
596 | 608 | Environment* env = Environment::GetCurrent(args); |
597 | | - HandleScope handle_scope(iso); |
| 609 | + HandleScope handle_scope(isolate); |
598 | 610 |
|
599 | 611 | CHECK_EQ(args.Length(), 1); |
600 | 612 | CHECK(args[0]->IsFunction()); |
601 | 613 | Local<Function> import_callback = args[0].As<Function>(); |
602 | 614 | env->set_host_import_module_dynamically_callback(import_callback); |
603 | 615 |
|
604 | | - iso->SetHostImportModuleDynamicallyCallback(ImportModuleDynamically); |
| 616 | + isolate->SetHostImportModuleDynamicallyCallback(ImportModuleDynamically); |
605 | 617 | } |
606 | 618 |
|
607 | 619 | void ModuleWrap::HostInitializeImportMetaObjectCallback( |
|