Skip to content

Commit

Permalink
Merge pull request #204 from zxing-js/release/v0.15.1
Browse files Browse the repository at this point in the history
Release/v0.15.1.

May the force be with you. 💚
  • Loading branch information
odahcam authored Jul 24, 2019
2 parents e033be1 + 049a842 commit 79d9a32
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
26 changes: 13 additions & 13 deletions src/browser/BrowserCodeReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export class BrowserCodeReader {
*
* @memberOf BrowserCodeReader
*/
private async decodeFromConstraints(constraints: MediaStreamConstraints, videoSource: string | HTMLVideoElement, callbackFn: DecodeContinuouslyCallback): Promise<void> {
public async decodeFromConstraints(constraints: MediaStreamConstraints, videoSource: string | HTMLVideoElement, callbackFn: DecodeContinuouslyCallback): Promise<void> {

const stream = await navigator.mediaDevices.getUserMedia(constraints);

Expand All @@ -348,7 +348,7 @@ export class BrowserCodeReader {
*
* @memberOf BrowserCodeReader
*/
private async decodeFromStream(stream: MediaStream, videoSource: string | HTMLVideoElement, callbackFn: DecodeContinuouslyCallback) {
public async decodeFromStream(stream: MediaStream, videoSource: string | HTMLVideoElement, callbackFn: DecodeContinuouslyCallback) {

this.reset();

Expand Down Expand Up @@ -446,7 +446,7 @@ export class BrowserCodeReader {
/**
* Searches and validates a media element.
*/
protected getMediaElement(mediaElementId: string, type: string): HTMLVisualMediaElement {
public getMediaElement(mediaElementId: string, type: string): HTMLVisualMediaElement {

const mediaElement = document.getElementById(mediaElementId);

Expand Down Expand Up @@ -683,7 +683,7 @@ export class BrowserCodeReader {
this.decodeContinuously(videoElement, callbackFn);
}

protected isImageLoaded(img: HTMLImageElement) {
public isImageLoaded(img: HTMLImageElement) {
// During the onload event, IE correctly identifies any images that
// weren’t downloaded as not complete. Others should too. Gecko-based
// browsers act like NS4 in that they report this incorrectly.
Expand All @@ -703,7 +703,7 @@ export class BrowserCodeReader {
return true;
}

protected prepareImageElement(imageSource?: HTMLImageElement | string): HTMLImageElement {
public prepareImageElement(imageSource?: HTMLImageElement | string): HTMLImageElement {

let imageElement: HTMLImageElement;

Expand All @@ -729,7 +729,7 @@ export class BrowserCodeReader {
*
* @param videoSource The HTMLVideoElement to be set.
*/
protected prepareVideoElement(videoSource?: HTMLVideoElement | string): HTMLVideoElement {
public prepareVideoElement(videoSource?: HTMLVideoElement | string): HTMLVideoElement {

let videoElement: HTMLVideoElement;

Expand Down Expand Up @@ -758,7 +758,7 @@ export class BrowserCodeReader {
/**
* Tries to decode from the video input until it finds some value.
*/
private decodeOnce(element: HTMLVisualMediaElement, retryIfNotFound = true, retryIfChecksumOrFormatError = true): Promise<Result> {
public decodeOnce(element: HTMLVisualMediaElement, retryIfNotFound = true, retryIfChecksumOrFormatError = true): Promise<Result> {

this._stopAsyncDecode = false;

Expand Down Expand Up @@ -794,7 +794,7 @@ export class BrowserCodeReader {
/**
* Continuously decodes from video input.
*/
private decodeContinuously(element: HTMLVideoElement, callbackFn: DecodeContinuouslyCallback): void {
public decodeContinuously(element: HTMLVideoElement, callbackFn: DecodeContinuouslyCallback): void {

this._stopContinuousDecode = false;

Expand Down Expand Up @@ -830,7 +830,7 @@ export class BrowserCodeReader {
/**
* Gets the BinaryBitmap for ya! (and decodes it)
*/
protected decode(element: HTMLVisualMediaElement): Result {
public decode(element: HTMLVisualMediaElement): Result {

// get binary bitmap for decode function
const binaryBitmap = this.createBinaryBitmap(element);
Expand All @@ -843,7 +843,7 @@ export class BrowserCodeReader {
*
* @param mediaElement HTML element containing drawable image source.
*/
protected createBinaryBitmap(mediaElement: HTMLVisualMediaElement): BinaryBitmap {
public createBinaryBitmap(mediaElement: HTMLVisualMediaElement): BinaryBitmap {

const ctx = this.getCaptureCanvasContext(mediaElement);

Expand Down Expand Up @@ -887,21 +887,21 @@ export class BrowserCodeReader {
/**
* Ovewriting this allows you to manipulate the snapshot image in anyway you want before decode.
*/
protected drawImageOnCanvas(canvasElementContext: CanvasRenderingContext2D, srcElement: HTMLVisualMediaElement) {
public drawImageOnCanvas(canvasElementContext: CanvasRenderingContext2D, srcElement: HTMLVisualMediaElement) {
canvasElementContext.drawImage(srcElement, 0, 0);
}

/**
* Call the encapsulated readers decode
*/
protected decodeBitmap(binaryBitmap: BinaryBitmap): Result {
public decodeBitmap(binaryBitmap: BinaryBitmap): Result {
return this.reader.decode(binaryBitmap, this._hints);
}

/**
* 🖌 Prepares the canvas for capture and scan frames.
*/
protected createCaptureCanvas(mediaElement?: HTMLVisualMediaElement): HTMLCanvasElement {
public createCaptureCanvas(mediaElement?: HTMLVisualMediaElement): HTMLCanvasElement {

if (typeof document === 'undefined') {
this._destroyCaptureCanvas();
Expand Down
2 changes: 1 addition & 1 deletion src/browser/BrowserMultiFormatReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class BrowserMultiFormatReader extends BrowserCodeReader {
* Overwrite decodeBitmap to call decodeWithState, which will pay
* attention to the hints set in the constructor function
*/
protected decodeBitmap(binaryBitmap: BinaryBitmap): Result {
public decodeBitmap(binaryBitmap: BinaryBitmap): Result {
return this.reader.decodeWithState(binaryBitmap);
}
}
10 changes: 10 additions & 0 deletions src/browser/VideoInputDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ export class VideoInputDevice implements MediaDeviceInfo {
public constructor(public deviceId: string, public label: string, groupId?: string) {
this.groupId = groupId || undefined;
}

/** @inheritdoc */
toJSON() {
return {
kind: this.kind,
groupId: this.groupId,
deviceId: this.deviceId,
label: this.label,
};
}
}

0 comments on commit 79d9a32

Please sign in to comment.