JavascriptRuntime class abstract

Implementers
Available extensions

Constructors

JavascriptRuntime()

Properties

dartContext Map<String, dynamic>
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
localContext Map<String, dynamic>
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
webApis JsWebApis
Web platform APIs installed by init and reinstalled after resets.
no setter

Methods

callFunction(Pointer<NativeType> fn, Pointer<NativeType> obj) JsEvalResult
compile(String code, String fileName, {bool stripSource = false, bool asModule = false}) Uint8List
Compile code to bytecode. stripSource drops function source text: a smaller heap, but Function.prototype.toString no longer shows it.
convertValue<T>(JsEvalResult jsValue) → T?
createWebNatives() Object?
Engine-specific native helpers handed to the Web API layer, or null.
dispose() → void
disposeChannelFunctions() → void
Removes channel registrations for this engine (call from dispose).
enableHandlePromises() → void

Available on JavascriptRuntime, provided by the HandlePromises extension

Optional no-op friendly setup for callers that still invoke this.
evaluate(String code, {String? sourceUrl}) JsEvalResult
evaluateAsync(String code, {String? sourceUrl}) Future<JsEvalResult>
evaluateAsyncBytecode(Uint8List bytecode) Future<JsEvalResult>
evaluateBytecode(Uint8List bytecode) JsEvalResult
evaluateJson(String code, {String? sourceUrl}) → dynamic
evaluateJsonBatch(Iterable<String> expressions, {String? sourceUrl}) List
Evaluate multiple JavaScript expressions and decode the results through one JSON round-trip. Expressions must be JSON-serializable and are evaluated in order in the same runtime.
executePendingJob() int
executePendingJobs({int maxJobs = 10000}) int
Drain the QuickJS job queue until empty or maxJobs jobs run. Returns the number of jobs executed, or stops early on error (-1 job).
getEngineInstanceId() String
getMemoryUsage() JsMemoryUsage?
QuickJS heap usage snapshot, or null if unavailable.
handlePromise(JsEvalResult value, {Duration? timeout}) Future<JsEvalResult>

Available on JavascriptRuntime, provided by the HandlePromises extension

init() JavascriptRuntime
initChannelFunctions() → void
jsonStringify(JsEvalResult jsValue) String
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onMessage(String channelName, dynamic fn(dynamic args)) → void
registerModuleBytecode(Uint8List bytecode, {bool resolve = false}) → void
Register module bytecode in the current context without running it, so that import of its name resolves from the context instead of calling the module loader. With resolve, the module's own imports are linked now (every dependency must already be registered).
reinitialize() → void
Drop native heap and re-run channel / Web API setup. Used by JsEnginePool when resetting a leased engine. Default is no-op.
releaseHostCaches() → void
Free Dart-side JS refs that must not outlive close; call before native free. Cancels Web API timers and host work installed by init.
runGC() → void
Force a QuickJS GC pass. No-op if the engine is not ready / disposed.
sendMessage({required String channelName, required List<String> args, String? uuid}) → void
Dart → JS message helper. Prefer not to inject untrusted strings into evaluate; use registered bridges + sendMessage from JS instead.
setInspectable(bool inspectable) → void
setupBridge(String channelName, void fn(dynamic args)) bool
softReset() → void
Clear tenant state without destroying the native QuickJS engine.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

channelFunctionsRegistered Map<String, Map<String, dynamic Function(dynamic args)>>
no setter
debugEnabled bool
getter/setter pair