engine_web library

dart:js_interop helpers for the web arms of engine packages.

Import only from files that compile for web alone: the web arm of a conditional import or export. Usually that is the DEFAULT branch of a directive whose condition is dart.library.ffi or dart.library.io (false on web), e.g. export 'src/engine_web.dart' if (dart.library.ffi) 'src/engine_io.dart';; sometimes it is the if (dart.library.js_interop) branch. It imports dart:js_interop, so keep it off native code paths. The web-safe engine SPI is engine.dart; tool/check_web_graph.dart walks the web branch of every public library.

Classes

BlobUrlModelSource
WebStorageMode.cacheApi / WebStorageMode.none path. url is a blob: URL produced by WebCacheService / BlobUrlManager, or an https: URL when caching is disabled.
OpfsStreamModelSource
WebStorageMode.streaming + opfs://<filename> path. Carries the WebOPFSService and the OPFS filename so each engine can ask for the form it consumes — MediaPipe wants a ReadableStreamDefaultReader, @litert-lm/core wants the raw ReadableStream.
WebModelSource
Result of resolving an active web model into a form an engine (MediaPipe LlmInference OR @litert-lm/core Engine) can consume.
WebModelSourceResolver
Resolves the active inference model from WebModelManager into the correct WebModelSource subtype based on ServiceRegistry useStreamingStorage and the resolved path prefix. This is the single piece of code that decides blob-URL vs OPFS-stream — both WebInferenceModel (MediaPipe) and LiteRtLmWebInferenceModel (@litert-lm/core) consume it.

Functions

resolveWebModelUrl(String rawPath) → Future<String>
Resolves rawPath — a model or tokenizer path core registered for an installed file — to a URL that fetch() can load.