156 Commits
Author SHA1 Message Date
Daniel abcfe1bce2 v1.4.2 2022-11-22 21:05:48 -06:00
Daniel 987bbb06c2 Disable native BarcodeDetector on M1/M2 Macs with Ventura
On Macs with an M1/M2 processor and macOS Ventura (macOS version 13), the BarcodeDetector
is broken in Chromium based browsers, regardless of the version. For that constellation,
the BarcodeDetector does not error but does not detect QR codes. Macs without an M1/M2 or
before Ventura are fine. See https://bugs.chromium.org/p/chromium/issues/detail?id=1382442.

Fixes #209
2022-11-22 21:01:12 -06:00
Daniel 34bccc6b27 Readme: add additional notes of using new api vs old 2022-06-02 00:09:38 +02:00
Wes BosandGitHub c6da93458d Fix deprecated example 2022-05-31 15:39:46 -04:00
Shane ReustleandSören Schwert aa9714cdd9 Make demo link clickable 2022-05-02 13:58:48 +02:00
Daniel 1cd3b15285 v1.4.1 2022-02-22 23:28:17 +01:00
Daniel 2714cb9944 Identify scan requests to worker by unique id's
This avoids that parallel scans on the same worker instance ALL interpret
the first incoming scan result as their result. Instead, now each scan
request to the worker waits for their individual response.

Fixes #149
2022-02-22 23:27:02 +01:00
Daniel 9373237718 Always create new worker instead of reusing a singleton worker
Create a new worker instance on each call to createQrEngine instead of
using a singleton worker instance. Sharing a singleton instance resulted
in problems when destroying the worker, for example in a call to
QrScanner.scanImage, while it was still needed in a scanner instance or
further calls to scanImage.
2022-02-22 18:17:13 +01:00
Daniel 3a2719213b Improve documentation for .destroy()
Make clear that destroyed instances can not be started again.

Closes #144
2022-02-21 14:36:54 +01:00
Daniel 9a70dd984c Fix type generation for namespaced types
Fixes #147
2022-02-21 14:36:54 +01:00
Daniel 78e65c6b42 Build legacy build as umd instead of esm
Building as es module doesn't make too much sense as browser support for
es modules is lower as for es6 generally, and anyone who would import the
legacy build via es import, could already pretty much use the regular build.

Also improves on documentation for legacy build.

Closes #143
2022-02-08 23:39:17 +01:00
Daniel 8bb46c3cbc v1.4.0 2022-02-04 12:18:13 +01:00
Daniel 2991d0a411 Inline worker script in legacy build
Older browsers that arleady supported es6 did not support dynamic imports.
Also change worker output type to esm as the build is slightly smaller.
2022-02-03 16:48:11 +01:00
Daniel d4bbd3b02d Restructure rollup.config.js
Now avoids duplication of common options between regular and legacy build.
Also adding more comments.
2022-02-02 22:32:04 +01:00
Daniel 60a2b3b2ce Import worker as dynamic import
Doed now not import the worker as a separate worker script via the Worker
constructor which required copying over the worker script and specifying
QrScanner.WORKER_PATH. Instead, the dynamic import will now be handled
automatically by bundlers like Rollup or Webpack.
2022-02-02 17:42:30 +01:00
Daniel 54b40bf917 Nicer default highlight styles 2022-01-28 19:17:22 +01:00
Daniel 70335ba5c2 Better handling of internal issues of native BarcodeDetector
Fixes #98
2022-01-28 18:24:20 +01:00
Daniel 3ce4f1bf6b Limit scan rate to camera's frame rate 2022-01-28 18:24:20 +01:00
Daniel 8ee8d7a45a Support throttling the scans per second
Closes #93
2022-01-28 18:24:20 +01:00
Daniel 158fbf585b Support providing an external overlay element 2022-01-28 18:24:20 +01:00
Daniel 0d48a807f5 Support highlighting the outline of detected codes 2022-01-28 18:24:13 +01:00
Daniel 16ad9b9b82 Smarter positioning of scan region highlight
Now does not make any assumptions on the parent element anymore and can
handle object-fit or object-position being set on the video.
2022-01-26 18:10:12 +01:00
Daniel 6cffe506d6 Demo: add examples of custom scan region highlight styling 2022-01-26 16:43:32 +01:00
Daniel dea704924f Support highlighting the scan region
Closes #86
2022-01-26 16:43:25 +01:00
Daniel 57b2a52734 Provide more detailed scan results, for now adding qr location
Closes #66
Closes #109
2022-01-25 11:59:08 +01:00
Daniel 954d3e2930 Switch constructor and scanImage to using options objects 2022-01-25 10:21:26 +01:00
Daniel b769540c3b Improve handling of pending actions if scanner was paused or destroyed
- Avoid starting camera stream if scanner was paused in the meantime
- Be lenient on fails to .start() if the scanner was paused in the meantime
- Disallow starting the stream or flash if the scanner was destroyed
- Await video.play calls

Fixes #90
Fixes #139
2022-01-25 10:21:26 +01:00
Daniel d704d3ab37 Don't open a second stream if we already have permission for device listing
This is an optimization but also a fix for iOS Safari which stops an already ongoing
stream when a second stream is opened, see https://bugs.webkit.org/show_bug.cgi?id=179363.

Fixes #125
2022-01-25 10:21:26 +01:00
Daniel a3e87bcf1e Remove limitation to MediaStreams as video srcObject 2022-01-25 10:21:26 +01:00
Daniel 2ba049f759 Switch to yarn 2022-01-25 10:21:26 +01:00
Daniel ce3189aeb0 Automatically generate type declarations 2022-01-25 10:21:26 +01:00
Daniel bcd5b19f82 Convert to typescript 2022-01-25 10:20:37 +01:00
Daniel ffdb944b62 Update closure compiler
Now generates slightly smaller builds
2022-01-20 09:10:15 +01:00
Daniel 8041e59ad7 Add legacy ECMAScript 2015 (ES6) build 2022-01-19 20:57:10 +01:00
Daniel 8bf0dc47aa Convert to ES2017 with async/await
Also saves 4.3% in size for qr-scanner.min.js
2022-01-19 17:58:59 +01:00
Daniel 72049e55bd v1.3.0 2021-08-17 12:37:09 +02:00
Daniel a1493c127d Check whether BarcodeDetector.getSupportedFormats exists
Some browsers (iOS specific?) had issues, see issue #115.
2021-08-17 12:10:51 +02:00
Daniel f232f32211 Support hasFlash even if no stream is currently running
But still doing it after scanner.start() is recommended, to avoid creating
a temporary stream.
2021-08-17 12:02:35 +02:00
Daniel 2877944bce Refactor hasFlash to potentially support Firefox and Safari in the future 2021-08-17 08:53:28 +02:00
Daniel fe31236d51 Fix turning flash off
applyConstraints with torch: false does not work to turn the
flashlight off, as a stream's torch stays continuously on, see
https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#torch.
Therefore, we have to stop the stream to turn the flashlight off.
2021-08-16 21:20:32 +02:00
Daniel e2edfe1e88 Restart the flash if it was previously on
Also now support flagging the flash as on while the stream is
paused.
2021-08-16 21:14:29 +02:00
Daniel 5f13ff064e Merge PR#112 (lafriks-fork:feat/camera_list) with fixes 2021-08-16 14:08:30 +02:00
Daniel 4cfaf31fe5 Demo: update flash availability when switching camera 2021-08-16 14:03:56 +02:00
Daniel 28c43cdbe3 Simplify and improve setCamera
- Use .pause instead of copying the code
- Remove the unnecessary 300ms delay
- Avoid overwriting _offTimeout if another pause call happened shortly
  before.
- Don't start the stream if is was paused.
2021-08-16 13:40:56 +02:00
Daniel 6a6c593c2d Merge deviceId and preferredFacingMode into preferredCamera
- Merge deviceId and preferredFacingMode options into a single
  option preferredCamera. Also previously, the deviceId took
  precedence over the preferredFacingMode.
- .setCamera now also allows setting a preferred facingMode
  instead of a deviceId.

Additinal fixes to PR#112:

- Correctly fallback to not applying any constraints in .start if
  the preferredCamera (previously deviceId and preferredFacingMode)
  is not available. Previously, if neither for the deviceId nor
  the preferredFacingMode contraint a camera was found, no attempt
  without a constraint was attempted.
- A add missing documentation for deviceId support in the constructor
  to the Readme and generally adapt Readme for merged preferredCamera
  option.
- Fix missing type for deviceId (now merged into preferredCamera) in
  the constructor type definitions and generally adapt the types for
  merged preferredCamera option.
2021-08-14 14:13:33 +02:00
Daniel 1e9f6c6598 Refactor listCameras and improve readme wording
- rename the method from getCameraList to listCameras
- make requesting labels (and the required camera permission) optional
- refactor hasCamera using listCameras

Additinal fixes to PR#112:

- add fallback labels for when no exact labels were requested
- remove unnecessary outer Promise
- make sure the created stream is always destroyed in a finally
2021-08-13 20:49:59 +02:00
Daniel 450de34ae3 Update our jsQR fork
Especially with the following changes:
- Attempt to fix Safari RangeError exceptions
- Support "structured append" qr codes
- Binarizer: adapt blackBias for slightly higher detection rate
2021-08-10 21:00:35 +02:00
Daniel d7a09be088 Avoid that Safari stops the video stream on hidden videos 2021-08-09 11:22:27 +02:00
Daniel e8d107a171 Performance improvements
- round scan region to whole pixel positions to avoid blurry
  drawing at sub-pixel positions
- avoid clearing the canvas by resetting the canvas width or
  height when they actually didn't change.
2021-07-29 19:37:15 +02:00
Daniel 5836ac719b Rename fixedCanvasSize to disallowCanvasResizing 2021-07-29 17:26:29 +02:00