web library
Configuration the browser build needs, and nothing the other platforms do.
The browser build's four files ship inside this package, and
dart run wxscan:fetch_web copies them into web/wxscan, where the
package looks by default. They are files rather than declared assets
because declaring Flutter assets would make this a Flutter package, which
would cost dart run and dart test. This says where they are when they
are somewhere else.
// Before creating a scanner, and only on the web.
configureWxScanWeb(const WxScanWebPaths(
workerUrl: 'assets/wxscan/wxscan_worker.js',
wasmUrl: 'assets/wxscan/wxscan_wasm.wasm',
tfliteUrl: './wxscan_tflite.js',
));
Of the four, wxscan_worker.js is this package's own; the rest are
compiled elsewhere — wxscan_wasm.wasm by crates/wxscan-wasm in
wxscan-rs, and the wxscan_tflite.js and wxscan_tflite.wasm pair by
wxscan-litert-wasm. Only the loader of that pair takes a URL, since it
fetches the module beside itself, and the two must keep their names: the
loader has its module's file name compiled into it.
Classes
- WxScanWebPaths
- Where the browser build's three files are served from.
- WxScanWorker
- A scanner running in a worker.
Functions
-
configureWxScanWeb(
WxScanWebPaths paths) → void - Points the browser build at the files the application serves.
-
startWxScanWorker(
{Uint8List? detectModel, Uint8List? srModel}) → Future< WxScanWorker> - Starts a worker with the engine in it, fetching what it needs.