Navaron Bracke

update the zxing JS interop definition

  1 +import 'dart:js_interop';
  2 +
  3 +import 'package:js/js.dart';
  4 +import 'package:web/web.dart';
  5 +
  6 +/// The JS interop class for the ZXing BrowserMultiFormatReader.
  7 +///
  8 +/// See https://github.com/zxing-js/library/blob/master/src/browser/BrowserMultiFormatReader.ts
  9 +@JS('ZXing.BrowserMultiFormatReader')
  10 +@staticInterop
  11 +class ZXingBrowserMultiFormatReader {
  12 + /// Construct a new ZXingBrowserMultiFormatReader.
  13 + ///
  14 + /// The [hints] are the configuration options for the reader.
  15 + /// The [timeBetweenScansMillis] is the allowed time between scans in milliseconds.
  16 + ///
  17 + /// See also: https://github.com/zxing-js/library/blob/master/src/core/DecodeHintType.ts
  18 + external factory ZXingBrowserMultiFormatReader(
  19 + JSAny? hints,
  20 + int? timeBetweenScansMillis,
  21 + );
  22 +}
  23 +
  24 +extension ZXingBrowserMultiFormatReaderExt on ZXingBrowserMultiFormatReader {
  25 + /// Set the source for the [HTMLVideoElement] that acts as input for the barcode reader.
  26 + ///
  27 + /// This function takes a [HTMLVideoElement], and a [MediaStream] as arguments,
  28 + /// and returns no result.
  29 + ///
  30 + /// See https://github.com/zxing-js/library/blob/master/src/browser/BrowserCodeReader.ts#L1182
  31 + external JSFunction addVideoSource;
  32 +
  33 + /// Continuously decode barcodes from a [HTMLVideoElement].
  34 + ///
  35 + /// When a barcode is found, a callback function is called with the result.
  36 + /// The callback function receives a [Result] and an exception object as arguments.
  37 + ///
  38 + /// See also: https://github.com/zxing-js/library/blob/master/src/browser/DecodeContinuouslyCallback.ts
  39 + external JSFunction decodeContinuously;
  40 +
  41 + /// Whether the video stream is currently playing.
  42 + ///
  43 + /// This function takes a [HTMLVideoElement] as argument,
  44 + /// and returns a [bool].
  45 + ///
  46 + /// See https://github.com/zxing-js/library/blob/master/src/browser/BrowserCodeReader.ts#L458
  47 + external JSFunction isVideoPlaying;
  48 +
  49 + /// Prepare the video element for the barcode reader.
  50 + ///
  51 + /// This function takes a [HTMLVideoElement] as argument,
  52 + /// and returns the same [HTMLVideoElement],
  53 + /// after it was prepared for the barcode reader.
  54 + ///
  55 + /// See https://github.com/zxing-js/library/blob/master/src/browser/BrowserCodeReader.ts#L802
  56 + external JSFunction prepareVideoElement;
  57 +
  58 + /// Reset the barcode reader to it's initial state,
  59 + /// and stop any ongoing barcode decoding.
  60 + ///
  61 + /// This function takes no arguments and returns no result.
  62 + ///
  63 + /// See https://github.com/zxing-js/library/blob/master/src/browser/BrowserCodeReader.ts#L1104
  64 + external JSFunction reset;
  65 +
  66 + /// Stop decoding barcodes.
  67 + ///
  68 + /// This function takes no arguments and returns no result.
  69 + ///
  70 + /// See https://github.com/zxing-js/library/blob/master/src/browser/BrowserCodeReader.ts#L396
  71 + external JSFunction stopContinuousDecode;
  72 +}