@ -1,9 +1,11 @@
// Type definitions for QuaggaJS v 2015.05.20 Project:
// Type definitions for QuaggaJS v 0.12.1 (2017-10-19)
// http://serratus.github.io/quaggaJS/ Definitions by: Cam Birch, Peter
// Project: http://serratus.github.io/quaggaJS/
// Horwood aka Madman Pierre
// Definitions by: Cam Birch, Peter Horwood aka Madman Pierre, Dan Manastireanu <https://github.com/danmana>
declare var Quagga : QuaggaJSStatic ;
declare module "quagga" {
export default Quagga ;
var Quagga : QuaggaJSStatic ;
export default Quagga ;
}
interface QuaggaJSStatic {
interface QuaggaJSStatic {
/ * *
/ * *
@ -72,7 +74,7 @@ interface QuaggaJSStatic {
ResultCollector : QuaggaJSResultCollector ;
ResultCollector : QuaggaJSResultCollector ;
registerResultCollector ( resultCollector : QuaggaJSResultCollector ) : void ;
registerResultCollector ( resultCollector : QuaggaJSResultCollector ) : void ;
setReaders ( readers : any ) : void ;
setReaders ( readers : ( QuaggaJSReaderConfig | string ) [ ] ) : void ;
/ * *
/ * *
* In contrast to the calls described
* In contrast to the calls described
@ -108,6 +110,24 @@ interface QuaggaJSStatic {
overlay : HTMLCanvasElement
overlay : HTMLCanvasElement
}
}
} ;
} ;
CameraAccess : QuaggaJSCameraAccess ;
}
/ * *
* Used for accessing information about the active stream track and available video devices .
* /
interface QuaggaJSCameraAccess {
request ( video : HTMLVideoElement , videoConstraints : QuaggaJSConstraints ) : Promise < void > ;
release ( ) : void ;
enumerateVideoDevices ( ) : Promise < MediaDeviceInfo [ ] > ;
getActiveStreamLabel ( ) : string ;
getActiveTrack ( ) : MediaStreamTrack ;
}
}
/ * *
/ * *
@ -217,7 +237,7 @@ interface QuaggaJSResultCollector {
/ *
/ *
* a static function that returns you a ResultCollector
* a static function that returns you a ResultCollector
* /
* /
create ? ( QuaggaJSResultCollector) : QuaggaJSResultCollector ;
create ? ( param: QuaggaJSResultCollector) : QuaggaJSResultCollector ;
getResults ? ( ) : QuaggaJSCodeResult [ ] ;
getResults ? ( ) : QuaggaJSCodeResult [ ] ;
}
}
@ -291,7 +311,9 @@ interface QuaggaJSConfigObject {
* Ex : '/test/fixtures/code_128/image-001.jpg'
* Ex : '/test/fixtures/code_128/image-001.jpg'
* or : 'data:image/jpg;base64,' + data
* or : 'data:image/jpg;base64,' + data
* /
* /
src? : string ; inputStream ? : {
src? : string ;
inputStream ? : {
/ * *
/ * *
* @default "Live"
* @default "Live"
* /
* /
@ -301,33 +323,10 @@ interface QuaggaJSConfigObject {
* @default "LiveStream"
* @default "LiveStream"
* /
* /
type ? : string ;
type ? : string ;
target? : HTMLElement ,
constraints ? : {
constraints? : QuaggaJSConstraints ;
/ * *
* @default 640
* /
width? : number ;
/ * *
* @default 480
* /
height? : number ;
/ * *
* In cases where height / width does not suffice
* /
aspectRatio? : number
/ * *
* @default "environment"
* /
facingMode? : string ;
/ * *
* Explicitly set the camera to the user ' s choice
* /
deviceId? : string
} ;
/ * *
/ * *
* defines rectangle of the detection / localization area . Useful when you
* defines rectangle of the detection / localization area . Useful when you
@ -380,11 +379,19 @@ interface QuaggaJSConfigObject {
* /
* /
numOfWorkers? : number ;
numOfWorkers? : number ;
/ * *
* This top - level property controls the scan - frequency of the video - stream .
* It ’ s optional and defines the maximum number of scans per second .
* This renders useful for cases where the scan - session is long - running and
* resources such as CPU power are of concern .
* /
frequency? : number ;
decoder ? : {
decoder ? : {
/ * *
/ * *
* @default [ "code_128_reader" ]
* @default [ "code_128_reader" ]
* /
* /
readers? : string [ ] ;
readers ? : ( QuaggaJSReaderConfig | string ) [ ] ;
debug ? : {
debug ? : {
/ * *
/ * *
@ -406,7 +413,15 @@ interface QuaggaJSConfigObject {
* @default false
* @default false
* /
* /
showPattern? : boolean ;
showPattern? : boolean ;
}
} ;
/ * *
* The multiple property tells the decoder if it should continue decoding after finding a valid barcode .
* If multiple is set to true , the results will be returned as an array of result objects .
* Each object in the array will have a box , and may have a codeResult
* depending on the success of decoding the individual box .
* /
multiple? : boolean ;
} ;
} ;
locator ? : {
locator ? : {
@ -476,3 +491,40 @@ interface QuaggaJSConfigObject {
}
}
} ;
} ;
}
}
interface QuaggaJSConstraints {
/ * *
* @default 640
* /
width? : number ;
/ * *
* @default 480
* /
height? : number ;
/ * *
* In cases where height / width does not suffice
* /
aspectRatio? : number
/ * *
* @default "environment"
* /
facingMode? : string ;
/ * *
* Explicitly set the camera to the user ' s choice
* /
deviceId? : string
}
/ * *
* Used for extending a reader with supplements ( ex : EAN - 2 , EAN - 5 )
* /
interface QuaggaJSReaderConfig {
format : string ;
config : {
supplements : string [ ] ;
}
}