jsf library
JSF provides a QuickJS-backed JavaScript runtime for Flutter native platforms and a browser-runtime implementation for Flutter Web.
The main entry point is JsRuntime. Use JsRuntime.eval for one-shot Dart values and JsRuntime.evalValue when JavaScript object identity or handle-based interop must be preserved.
Classes
- JsArrayHole
- Sentinel representing a missing element in a sparse JavaScript array.
- JsCallbackRegistration
- Invalidates a host callback, including JavaScript references to its old function.
- JsConsoleEvent
- Console output delivered without parsing formatted strings.
- JsDataView
- A snapshot of a JavaScript DataView's visible bytes.
- JsErrorDetails
- Structured details extracted from a JavaScript or Dart callback error.
- JsFetchCancellation
- A cancellation token for one HTTP exchange.
- JsFetchOptions
- Opt-in native Fetch with streaming responses and multipart bodies. Web uses the browser's own Fetch API and resource policies.
- JsFetchRequest
- One HTTP exchange. Redirects are managed by JSF, not by the transport.
- JsFetchResponse
- JsFetchTransport
- A transport must honor cancellation during connection, upload and download.
- JsRegExp
-
Serializable representation of a JavaScript
RegExp. - JsRuntime
- Native QuickJS runtime used on Android, iOS, macOS, Linux, Windows, and OHOS.
-
JsRuntimeApi<
V> - Complete managed-runtime contract, preserving the smaller Runtime interface.
- JsRuntimeCapabilities
- Platform features that applications can test before invoking an API.
- JsRuntimeOptions
- Configuration applied when creating a JsRuntime.
- JsRuntimeStatistics
- An explicit snapshot; collecting engine memory statistics can traverse its heap.
- JsStreamingFetchTransport
- A transport that consumes request.bodyStream on demand and honors cancellation. Other transports receive a bounded, buffered body for compatibility.
- JsTypedArray
- Serializable representation of a JavaScript TypedArray.
- JsUndefined
-
Sentinel representing JavaScript
undefined. - JsUnsupportedValue
- Marker returned when a JavaScript value cannot be represented as a Dart value snapshot.
- JsValue
- Handle to a JavaScript value owned by, or borrowed from, a JsRuntime.
- JsValueScope
- Owns a group of handles until the scope is disposed.
- JsWorker
- A serial JavaScript execution queue in a dedicated Dart isolate. Values cross the boundary as snapshots. A request timeout closes the worker; its finite execution budget allows pending native work to unwind and clean up.
- Runtime
- An abstract class that defines the interface for a runtime environment capable of evaluating and executing code, as well as managing resources.
Constants
- jsArrayHole → const JsArrayHole
- Sentinel used when a JavaScript sparse array contains a hole.
- jsUndefined → const JsUndefined
-
Sentinel used when a Dart value represents JavaScript
undefined.
Functions
-
decodeJsTransferValue(
Object? value) → Object? - Decodes a JSF transfer-schema value into Dart objects.
-
encodeJsTransferValue(
Object? value) → Object? - Encodes a Dart object into JSF's transfer schema.
-
toJavaScriptLiteral(
Object? value) → String -
Encodes
valueas a JavaScript-compatible JSON transfer literal. -
withJsValues<
T> (T operation(JsValueScope scope)) → T - Releases all tracked handles after a synchronous operation, including throws.
-
withJsValuesAsync<
T> (Future< T> operation(JsValueScope scope)) → Future<T> - Keeps tracked handles alive until the asynchronous operation completes.
Typedefs
- JsErrorHandler = void Function(JsException error)
Exceptions / Errors
- JsException
- Structured failure from evaluation, conversion or a host callback.
- JsFetchException