← API demos

Worker API, three ways

One session, one worker. These buttons prove the explicit @webreflection/barcode/worker entry, the thread-aware @webreflection/barcode entry inside a real module Worker, and the main-thread default.

1 · Auto entry on the main thread

import barcode from '@webreflection/barcode' must give the session factory here, never the worker bootstrap.

2 · Explicit /worker entry

Spawn worker.js yourself, then hand it to barcode({ worker }). The same worker renders and scans.

3 · Auto entry inside a worker

A module Worker that imports @webreflection/barcode; its default is the bootstrap promise. The page binds it with barcode({ worker }) and uses it immediately.

ready.