JsContext class final
An isolated JavaScript global and module namespace owned by a runtime.
- Implemented types
Properties
Methods
-
bindStream(
String name) → Future< Stream< Object?> > -
Binds a JavaScript
{emit, close, error}sink to a Dart stream. -
call(
String method, List< Object?> args, {Duration? timeout}) → Future<Object?> -
Calls a function stored on this context's
globalThis. -
callPluginExport(
JsPlugin plugin, String method, List< Object?> args, {Duration? timeout}) → Future<Object?> -
Calls one export declared by the supplied plugin.
override
-
callRaw(
String method, List< Object?> args, {Duration? timeout}) → Future<String> - Calls a global function and returns the raw QuickJS bridge string.
-
dispose(
) → Future< void> - 释放 Context 及其回调、插件和模块状态;重复调用返回同一 Future。
-
disposePlugin(
JsPlugin plugin, {Duration? timeout}) → Future< Object?> -
Calls the plugin's optional disposal export.
override
-
eval(
String code, {Duration? timeout, String name = '<eval>', Map< String, Object?> tempGlobals = const {}}) → Future<Object?> -
同步求值
code并将结构化结果转换为 Dart 值。 -
evalRaw(
String code, {Duration? timeout, String name = '<eval>', Map< String, Object?> tempGlobals = const {}}) → Future<String> -
同步求值
code并返回底层 Bridge 的原始字符串。 -
initPlugin(
JsPlugin plugin, {Map< String, Object?> context = const <String, Object?>{}, Duration? timeout}) → Future<Object?> -
Calls the plugin's optional initialization export.
override
-
injectFunction(
String name, FutureOr< Object?> callback(List<Object?> args)) → Future<void> -
Temporarily injects a Promise-returning Dart function into this context.
Reusing
namereplaces and releases the previous callback. The function remains available until the context is disposed. -
injectStream<
T> (String name, Stream< T> stream) → Future<void> - Injects a Dart stream as a JavaScript async iterable in this context. It remains available until the context is disposed.
-
loadFeatures(
JsFeatures features, {JsFeaturesConflictPolicy conflictPolicy = JsFeaturesConflictPolicy.reject}) → Future< void> - Installs a capability bundle directly into this context.
-
loadPlugin(
JsPlugin plugin, {bool initialize = true, Map< String, Object?> context = const <String, Object?>{}, Duration? timeout}) → Future<void> - Features, validates and optionally initializes a dynamic plugin in place.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pumpTimers(
) → Future< Duration?> - Advances this context's JavaScript event loop once.
-
run(
String code, {Duration? timeout, String name = '<run>', Map< String, Object?> tempGlobals = const {}}) → Future<Object?> -
求值
code、等待其 Promise 结果并转换为 Dart 值。 -
runModule(
String source, {required String name, Map< String, String> modules = const {}, Duration? timeout}) → Future<String> -
以
name为入口模块执行source,并提供额外modules。 -
runRaw(
String code, {Duration? timeout, String name = '<run>', Map< String, Object?> tempGlobals = const {}}) → Future<String> -
求值
code、等待 Promise 并返回底层 Bridge 的原始字符串。 -
toString(
) → String -
A string representation of this object.
inherited
-
validatePlugin(
JsPlugin plugin, {Duration? timeout}) → Future< void> -
Validates the plugin manifest, module graph, and declared exports.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited