JsWebModule class
One independently installable unit of the Web platform API.
Modules are a functional split: they exist so a context only pays, in
heap and install time, for the APIs it uses. They are not a permission
or security boundary. Leaving a module out does not sandbox a script, and
several modules reach the host (core has timers, console and the system
random source; navigator reports the configured user agent). What a
script may do outside the heap is decided by the host objects you pass in,
such as JsFetchOptions.allowUrl, and by the runtime's memoryLimit and
timeout. See doc/wiki/guides/security.md.
Modules declare what they need in requires; JsWebApis installs the dependency closure of whatever you ask for, in dependency order. Depending on another module is an implementation detail of the module, not something callers have to model.
A module can also list optional modules: they are never pulled in, but
when they are installed anyway they come first, and the module enables the
features that need them (for example TextEncoderStream in streams needs
encoding).
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hostConfig → String?
-
Name of the host configuration object this module cannot be installed
without, or
nullif it needs none. Today only fetch has one (JsFetchOptions).final - name → String
-
Stable identifier, also the bytecode cache key and the script name that
appears in stack traces (
web:<name>).final -
optional
→ List<
JsWebModule> -
Modules this one uses when present. Not installed on its behalf.
final
-
requires
→ List<
JsWebModule> -
Modules that must be installed before this one.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- source → String
-
The module's JS source, for tests that check its use of
internal.no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- blob → const JsWebModule
-
Blob,File,FormData.Blob.prototype.streamneeds streams. - core → const JsWebModule
-
Timers,
queueMicrotask,reportError,console,performance,structuredClone,atob/btoa,DOMException,crypto.getRandomValues/crypto.randomUUID. - crypto → const JsWebModule
-
crypto.subtle:digestand HMAC. - encoding → const JsWebModule
-
TextEncoderandTextDecoder(UTF-8 only). - events → const JsWebModule
-
Event,CustomEvent,EventTarget,AbortController,AbortSignal. - fetch → const JsWebModule
-
The global
fetch. Needs JsFetchOptions, which carries the network policy; see hostConfig. - http → const JsWebModule
-
Headers,Request,Responseand the body mixin.blob()andformData(), andBlob/FormDatarequest bodies, need blob. -
Navigatorand thenavigatorglobal, includingnavigator.userAgent. -
standard
→ const Set<
JsWebModule> - Every module that needs no host configuration, i.e. all of them except fetch.
- streams → const JsWebModule
-
ReadableStream/WritableStream/TransformStreamand the queuing strategies.TextEncoderStream/TextDecoderStreamneed encoding. - url → const JsWebModule
-
URLandURLSearchParams(WHATWG parser).