#include <v8-script.h>
Public Types | |
enum | Status { kUninstantiated , kInstantiating , kInstantiated , kEvaluating , kEvaluated , kErrored } |
using | ResolveModuleCallback = MaybeLocal< Module >(*)(Local< Context > context, Local< String > specifier, Local< FixedArray > import_attributes, Local< Module > referrer) |
using | ResolveSourceCallback = MaybeLocal< Object >(*)(Local< Context > context, Local< String > specifier, Local< FixedArray > import_attributes, Local< Module > referrer) |
using | ResolveModuleByIndexCallback = MaybeLocal< Module >(*)(Local< Context > context, size_t module_request_index, Local< Module > referrer) |
using | ResolveSourceByIndexCallback = MaybeLocal< Object >(*)(Local< Context > context, size_t module_request_index, Local< Module > referrer) |
using | SyntheticModuleEvaluationSteps = MaybeLocal< Value >(*)(Local< Context > context, Local< Module > module) |
Static Public Member Functions | |
static Local< Module > | CreateSyntheticModule (Isolate *isolate, Local< String > module_name, const MemorySpan< const Local< String > > &export_names, SyntheticModuleEvaluationSteps evaluation_steps) |
static Module * | Cast (Data *data) |
A compiled JavaScript module.
using v8::Module::ResolveModuleByIndexCallback = MaybeLocal<Module> (*)( Local<Context> context, size_t module_request_index, Local<Module> referrer) |
using v8::Module::ResolveModuleCallback = MaybeLocal<Module> (*)( Local<Context> context, Local<String> specifier, Local<FixedArray> import_attributes, Local<Module> referrer) |
using v8::Module::ResolveSourceByIndexCallback = MaybeLocal<Object> (*)( Local<Context> context, size_t module_request_index, Local<Module> referrer) |
using v8::Module::ResolveSourceCallback = MaybeLocal<Object> (*)( Local<Context> context, Local<String> specifier, Local<FixedArray> import_attributes, Local<Module> referrer) |
using v8::Module::SyntheticModuleEvaluationSteps = MaybeLocal<Value> (*)(Local<Context> context, Local<Module> module) |
enum v8::Module::Status |
|
static |
Creates a new SyntheticModule with the specified export names, where evaluation_steps will be executed upon module evaluation. export_names must not contain duplicates. module_name is used solely for logging/debugging and doesn't affect module behavior.
MaybeLocal< Value > v8::Module::Evaluate | ( | Local< Context > | context | ) |
Evaluates the module and its dependencies.
If status is kInstantiated, run the module's code and return a Promise object. On success, set status to kEvaluated and resolve the Promise with the completion value; on failure, set status to kErrored and reject the Promise with the error.
If IsGraphAsync() is false, the returned Promise is settled.
For a module in kErrored status, this returns the corresponding exception.
int v8::Module::GetIdentityHash | ( | ) | const |
Returns the identity hash for this object.
Returns the namespace object of this module.
The module's status must be at least kInstantiated.
Local< FixedArray > v8::Module::GetModuleRequests | ( | ) | const |
Returns the ModuleRequests for this module.
std::pair< LocalVector< Module >, LocalVector< Message > > v8::Module::GetStalledTopLevelAwaitMessages | ( | Isolate * | isolate | ) |
Search the modules requested directly or indirectly by the module for any top-level await that has not yet resolved. If there is any, the returned pair of vectors (of equal size) contain the unresolved module and corresponding message with the pending top-level await. An embedder may call this before exiting to improve error messages.
Status v8::Module::GetStatus | ( | ) | const |
Returns the module's current status.
Local< UnboundModuleScript > v8::Module::GetUnboundModuleScript | ( | ) |
Returns the corresponding context-unbound module script.
The module must be unevaluated, i.e. its status must not be kEvaluating, kEvaluated or kErrored.
bool v8::Module::HasTopLevelAwait | ( | ) | const |
Returns whether this module is individually asynchronous (for example, if it's a Source Text Module Record containing a top-level await). See [[HasTLA]] in https://tc39.es/ecma262/#sec-cyclic-module-records
Maybe< bool > v8::Module::InstantiateModule | ( | Local< Context > | context, |
ResolveModuleByIndexCallback | module_callback, | ||
ResolveSourceByIndexCallback | source_callback = nullptr |
||
) |
Similar to the variant that takes ResolveModuleCallback and ResolveSourceCallback, but uses the index into the array that is returned by GetModuleRequests() instead of the specifier and import attributes to identify the requests.
Maybe< bool > v8::Module::InstantiateModule | ( | Local< Context > | context, |
ResolveModuleCallback | module_callback, | ||
ResolveSourceCallback | source_callback = nullptr |
||
) |
Instantiates the module and its dependencies.
Returns an empty Maybe<bool> if an exception occurred during instantiation. (In the case where the callback throws an exception, that exception is propagated.)
bool v8::Module::IsGraphAsync | ( | ) | const |
Returns whether this module or any of its requested modules is async, i.e. contains top-level await.
The module's status must be at least kInstantiated.
bool v8::Module::IsSourceTextModule | ( | ) | const |
Returns whether the module is a SourceTextModule.
bool v8::Module::IsSyntheticModule | ( | ) | const |
Returns whether the module is a SyntheticModule.
int v8::Module::ScriptId | ( | ) | const |
Returns the underlying script's id.
The module must be a SourceTextModule and must not have a kErrored status.
Maybe< bool > v8::Module::SetSyntheticModuleExport | ( | Isolate * | isolate, |
Local< String > | export_name, | ||
Local< Value > | export_value | ||
) |
Set this module's exported value for the name export_name to the specified export_value. This method must be called only on Modules created via CreateSyntheticModule. An error will be thrown if export_name is not one of the export_names that were passed in that CreateSyntheticModule call. Returns Just(true) on success, Nothing<bool>() if an error was thrown.
Location v8::Module::SourceOffsetToLocation | ( | int | offset | ) | const |
For the given source text offset in this module, returns the corresponding Location with line and column numbers.