js_widget_runtime library
Run JavaScript widgets as Flutter widgets.
Classes
- AssetWidgetFileReader
- WidgetFileReader that reads widget files from Flutter assets.
- Cube3dController
-
A Js3dController implementation that backs a
flutter_cubescene. - Cube3dHost
-
A Js3dHost that drives a
flutter_cubescene from JS commands. - ExternalAssetResolver
-
Resolves external asset identifiers (
external:<id>) to raw bytes. - Flame3dController
-
A Js3dController implementation that backs a
flame_3dscene. - Flame3dHost
-
A Js3dHost that drives a
flame_3dscene from JS commands. - HeadlessScrollBehavior
- A global custom scroll behavior for the headless/offscreen renderer.
- HeadlessScrollPhysics
- A custom ScrollPhysics that overrides recommendDeferredLoading to bypass the standard Flutter View.of lookup, avoiding headless runtime exceptions.
- IframeWebViewHost
- Placeholder so the stub compiles; never instantiated on non-web.
- Js3dCaptureSync
- Global pending-work tracker for offscreen/headless capture pipelines.
- Js3dCommand
- A command issued from JS to mutate a 3D scene.
- Js3dController
- Host-provided controller for a single 3D scene.
- Js3dDispatcherHost
-
Dispatches
scene3dnodes to either theflutter_cubehost or theflame_3dhost based on the requested engine or model file extension. - Js3dHost
-
Factory provided by the host to create concrete 3D controllers for
scene3d/model3dnodes. - Js3dUrlGlbParser
- GLB parser that resolves non-asset sources as bytes before chunk-walking.
- JsAudioController
- Controller for audio nodes.
- JsAudioPlayerWidget
-
Zero-size, frame-driven audio player rendered for
type: 'audio_player'nodes when a JsMediaHost is configured. - JsAudioWidget
-
Host-provided audio widget rendered for
type: 'audio'nodes when a JsMediaHost is configured. - JsFlame3dGame
- JsFontLoader
- Loads custom fonts into Flutter's engine at runtime.
- JsKeyboardCapture
-
Keyboard capture wrapper for
jsr.onKey. - JsMediaController
-
Base controller for media playback used by the renderer's
videoandaudionodes. - JsMediaHost
-
Factory provided by the host to create concrete media controllers for
videoandaudionodes. - JsonWidgetRenderer
- Converts a JSON widget tree (produced by JS widgets) into Flutter widgets.
- JsonWidgetTheme
- Minimal color theme used by JsonWidgetRenderer when the host does not provide one.
- JsRuntimeConfig
-
Configuration and injected handlers for a
JsWidgetRuntime. - JsScene3dMeshNode
-
Renders a
scene3dnode with ameshesprop using a tiny software pipeline on CustomPaint: perspective-projected triangles, painter's z-sort, flat Lambert shading. Pure Dart — no native dependencies. - JsVideoController
- Controller for video nodes.
- JsVideoWidget
-
Host-provided video widget rendered for
type: 'video'nodes when a JsMediaHost is configured. - JsWebViewHost
-
Factory provided by the host to embed web content for
webViewnodes. - JsWidgetApp
- Loads a JS widget from a WidgetManifest and runs it inside a JsWidgetRuntimeWidget.
- JsWidgetBridge
- Shared bridge logic for the JS widget engine.
- JsWidgetDemoMenu
- Lists available JS widget manifests and opens a detail page when tapped.
- JsWidgetEngine
- Entry point for running a JS widget.
- JsWidgetEngineBackend
- Abstract backend for the JS widget engine.
- JsWidgetRuntimeWidget
- Runs a JavaScript widget and renders its declarative JSON UI tree.
- MemoryWidgetFileReader
- Simple in-memory WidgetFileReader backed by a map of path → content.
- RefCountedJs3dController
- Reference-counting plumbing for controllers managed by a Js3dControllerRegistry.
- Scene3dCamera
- Camera specification for the software 3D pipeline.
- Scene3dConfig
-
Fully parsed configuration of a software-rendered
scene3dnode. - Scene3dMesh
- A parsed 3D mesh: vertices in model space, triangle faces as index triples into vertices, and a flat base color.
- Scene3dMeshPainter
- CustomPainter backing JsScene3dMeshNode. Exposed for tests.
- Scene3dProjector
- Perspective projector: model space → rotation → view space → screen.
- UiViewBindings
-
Resolves
{{key}}placeholders in declarative UI trees from panel storage. - UiViewFieldRegistry
-
Live readers for form fields keyed by JSON
id/storageKey. - UiViewTreeNormalizer
- Normalizes declarative UI trees from LLMs (React/HTML habits, wrong types).
- WebMediaHost
- Placeholder so the stub compiles; never instantiated on non-web.
- WidgetFileReader
- Abstracts file reads for widget loading so the host can provide the implementation (filesystem on VM, indexed DB/assets on web).
- WidgetManifest
- Describes a custom JS widget stored under a base path.
Mixins
-
Js3dControllerRegistry<
T extends RefCountedJs3dController> - Reference-counted controller registry shared by the built-in hosts.
Functions
-
createCube3dHost(
) → Js3dHost -
Creates a Js3dHost implementation backed by
flutter_cube. -
createFlame3dHost(
{Js3dFileBytesLoader? fileBytesLoader}) → Js3dHost -
Creates a Js3dHost implementation backed by
flame_3d. -
createIframeWebViewHost(
) → JsWebViewHost -
Non-web stub: the iframe-backed host only exists on web. Guard call
sites with
kIsWeb(the VM reference host lives in the example app). -
createJs3dHost(
{Js3dFileBytesLoader? fileBytesLoader}) → Js3dHost - Creates the default Js3dHost for the runtime.
-
createWebMediaHost(
) → JsMediaHost -
Non-web stub: the HTML-element media host only exists on web. Guard
call sites with
kIsWeb(the VM reference host lives in the example app; hosts may back the same interface with media_kit). -
jsrSetFlameAssetBundle(
AssetBundle bundle) → void - Replaces Flame's global asset bundle.
-
parseScene3dConfig(
Map< String, dynamic> config) → Scene3dConfig - Parses the raw node map into a Scene3dConfig. Tolerates garbage: malformed meshes, vertices and faces are skipped individually.
Typedefs
-
Js3dFileBytesLoader
= Future<
Uint8List?> Function(String src) -
Loads model bytes for a source that lives outside the Flutter asset
bundle — e.g. a sandboxed Documents tree on mobile, where installed
widgets keep their files (
Documents/fah_sandbox/apps/...). -
JsExecHandler
= Future<
void> Function(String id, String cmd) -
Callback for
jsr.exec(cmd). -
JsFetchHandler
= Future<
void> Function(String id, String url, String method, Map<String, String> headers) -
Callback for an HTTP request initiated by
jsr.fetchJson. -
JsFontResolver
= Future<
Uint8List> Function(String family) - Resolves a font family name to raw font bytes.
- JsIntervalTickHandler = void Function(String id)
- Callback invoked when a Dart-backed interval fires.
-
JsLoadAssetHandler
= Future<
void> Function(String id, String cmd) -
Callback for
jsr.loadAsset(path). - JsPermissionChecker = bool Function(String capability)
- Callback invoked to check whether a capability is allowed. Capabilities: 'fetch', 'storage', 'secrets', 'exec'.
- JsRafTickHandler = void Function(String id, int elapsedMs)
- Callback invoked when a Dart-backed animation frame fires.
- JsResolveCallback = void Function(String id, dynamic value)
- Callback used by the bridge to return async values to the JS runtime.
-
JsSecretsReadHandler
= Future<
void> Function(String id, String cmd) -
Callback for
jsr.secrets.get(key). -
JsSecretsWriteHandler
= Future<
void> Function(String id, String key, dynamic value) -
Callback for
jsr.secrets.set(key, value).