Skip to main content

ModuleLoadHook

Type Alias ModuleLoadHook 

Source
pub type ModuleLoadHook = Option<unsafe extern "C" fn(*mut JSContext, Handle<*mut JSScript>, Handle<*mut JSObject>, Handle<Value>, Handle<Value>, u32, ColumnNumberOneOrigin) -> bool>;
Expand description

The HostLoadImportedModule hook.

See: https://tc39.es/ecma262/#sec-HostLoadImportedModule

This embedding-defined hook is used to implement module loading. It is called to get or create a module object corresponding to |moduleRequest| occurring in the context of the script or module |referrer| with private value |referencingPrivate|.

The module specifier string for the request can be obtained by calling JS::GetModuleRequestSpecifier.

The private value for a script or module is set with JS::SetScriptPrivate or JS::SetModulePrivate. It’s assumed that the embedding can handle receiving either here.

If this call succeeds then the embedding must call FinishLoadingImportedModule or one of the FinishLoadingImportedModuleFailed APIs at some point in the future. This is handled by the engine if the call returns false.

This hook must obey the restrictions defined in the spec:

  • Each time the hook is called with the same (referrer, referencingPrivate) pair, then it must call FinishLoadingImportedModule with the same result each time.
  • The operation must treat the |payload| argument as an opaque value to be passed through to FinishLoadingImportedModule.

Aliased Type§

pub enum ModuleLoadHook {
    None,
    Some(unsafe extern "C" fn(*mut JSContext, Handle<*mut JSScript>, Handle<*mut JSObject>, Handle<Value>, Handle<Value>, u32, ColumnNumberOneOrigin) -> bool),
}

Variants§

§1.0.0

None

No value.

§1.0.0

Some(unsafe extern "C" fn(*mut JSContext, Handle<*mut JSScript>, Handle<*mut JSObject>, Handle<Value>, Handle<Value>, u32, ColumnNumberOneOrigin) -> bool)

Some value of type T.