/* * Copyright (c) 2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include namespace Web::Bindings { JS::VM& main_thread_vm() { static RefPtr vm; if (!vm) { vm = JS::VM::create(make()); static_cast(vm->custom_data())->event_loop.set_vm(*vm); vm->host_resolve_imported_module = [&](JS::ScriptOrModule, JS::ModuleRequest const&) -> JS::ThrowCompletionOr> { return vm->throw_completion(vm->current_realm()->global_object(), JS::ErrorType::NotImplemented, "Modules in the browser"); }; } return *vm; } }