JsModuleLoadRequest Class

A request to load a module (the arguments of HostLoadImportedModule).

public sealed class JsModuleLoadRequest

Properties

NameDescription
AttributesGets the import attributes (sorted by key).
CurrentRealmGets the current realm when the module is requested: the realm of the code that calls import(), which is not the realm of the referrer when the code runs in another realm (e.g. the code of another window evaluated by its eval); the realm of the importing module for a static import.
HostDefinedGets the value given to JsModule.LoadRequestedModules, or null for a dynamic import.
IsDynamicImportGets whether the request comes from an import() call.
RealmGets the realm of the referrer: the realm of the module to create.
ReferrerHostDefinedGets the data of the host associated with the referrer.
ReferrerModuleGets the module that imports the module, if the referrer is a module.
ReferrerUrlGets the URL of the script or the module that imports the module, if any.
SpecifierGets the module specifier.
TypeGets the value of the type import attribute (e.g. "json"), or null.

Gets the import attributes (sorted by key).

public IReadOnlyList<KeyValuePair<string, string>> Attributes { get; }

CurrentRealm

JsModuleLoader.cs

Gets the current realm when the module is requested: the realm of the code that calls import(), which is not the realm of the referrer when the code runs in another realm (e.g. the code of another window evaluated by its eval); the realm of the importing module for a static import.

public JsRealm CurrentRealm { get; }

Property value

JsRealm

Gets the value given to JsModule.LoadRequestedModules, or null for a dynamic import.

public object? HostDefined { get; }

Property value

object?

IsDynamicImport

JsModuleLoader.cs

Gets whether the request comes from an import() call.

public bool IsDynamicImport { get; }

Property value

bool

Gets the realm of the referrer: the realm of the module to create.

public JsRealm Realm { get; }

Property value

JsRealm

ReferrerHostDefined

JsModuleLoader.cs

Gets the data of the host associated with the referrer.

public object? ReferrerHostDefined { get; }

Property value

object?

ReferrerModule

JsModuleLoader.cs

Gets the module that imports the module, if the referrer is a module.

public JsModule? ReferrerModule { get; }

Property value

JsModule?

Gets the URL of the script or the module that imports the module, if any.

public string? ReferrerUrl { get; }

Property value

string?

Gets the module specifier.

public string Specifier { get; }

Property value

string

Gets the value of the type import attribute (e.g. "json"), or null.

public string? Type { get; }

Property value

string?

Methods

NameDescription
Complete(JsModule)Completes the request with the loaded module (FinishLoadingImportedModule).
Fail(JsException)Fails the request with the value of a JavaScript exception (e.g. the SyntaxError of an invalid module).
Fail(JsValue)Fails the request: the error is the rejection reason of the loading.
Fail(string)Fails the request with a TypeError of the realm.

Complete(JsModule)

JsModuleLoader.cs

Completes the request with the loaded module (FinishLoadingImportedModule).

public void Complete(JsModule module)

Parameters

module JsModule

Exceptions

InvalidOperationException
The request is already completed.

Remarks

On the thread of the engine (a thread that has entered it, e.g. in JsModuleLoader.LoadImportedModule, or the last thread that entered it), the loading continues now. On another thread (e.g. the continuation of a download), the completion is queued and the loading continues on the thread of the engine, from the next JsEngine.RunJobs.

Fail overloads

Fail(JsException)

JsModuleLoader.cs

Fails the request with the value of a JavaScript exception (e.g. the SyntaxError of an invalid module).

public void Fail(JsException exception)
Parameters
exception JsException

Fail(JsValue)

JsModuleLoader.cs

Fails the request: the error is the rejection reason of the loading.

public void Fail(JsValue error)
Parameters
error JsValue
Exceptions
InvalidOperationException
The request is already completed.
Remarks

It can be called from any thread, as JsModuleLoadRequest.Complete.

Fail(string)

JsModuleLoader.cs

Fails the request with a TypeError of the realm.

public void Fail(string message)
Parameters
message string
Exceptions
InvalidOperationException
The request is already completed.
Remarks

It can be called from any thread, as JsModuleLoadRequest.Complete.