Skip to content

Commit 1e5fe42

Browse files
Merge PR mebjas#982 from upstream
2 parents 10d16a6 + 62276ba commit 1e5fe42

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/core.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,45 @@ export interface QrcodeResultDebugData {
147147
decoderName?: string;
148148
}
149149

150+
/** types of metadata that can exist in a result */
151+
export enum ResultMetadataType {
152+
OTHER = 0,
153+
ORIENTATION = 1,
154+
BYTE_SEGMENTS = 2,
155+
ERROR_CORRECTION_LEVEL = 3,
156+
ISSUE_NUMBER = 4,
157+
SUGGESTED_PRICE = 5,
158+
POSSIBLE_COUNTRY = 6,
159+
UPC_EAN_EXTENSION = 7,
160+
PDF417_EXTRA_METADATA = 8,
161+
STRUCTURED_APPEND_SEQUENCE = 9,
162+
STRUCTURED_APPEND_PARITY = 10
163+
}
164+
165+
/** metadata for a result, basically a `Map` but with specific key/value pairs */
166+
export interface ResultMetadata {
167+
get (key: ResultMetadataType.OTHER): unknown | undefined;
168+
get (key: ResultMetadataType.ORIENTATION): number | undefined;
169+
get (key: ResultMetadataType.BYTE_SEGMENTS): Uint8Array[] | undefined;
170+
get (key: ResultMetadataType.ERROR_CORRECTION_LEVEL): unknown;
171+
get (key: ResultMetadataType.ISSUE_NUMBER): number | undefined;
172+
get (key: ResultMetadataType.SUGGESTED_PRICE): string | undefined;
173+
get (key: ResultMetadataType.POSSIBLE_COUNTRY): string | undefined;
174+
get (key: ResultMetadataType.UPC_EAN_EXTENSION): unknown | undefined;
175+
get (key: ResultMetadataType.PDF417_EXTRA_METADATA): unknown | undefined;
176+
get (key: ResultMetadataType.STRUCTURED_APPEND_SEQUENCE): unknown | undefined;
177+
get (key: ResultMetadataType.STRUCTURED_APPEND_PARITY): unknown | undefined;
178+
}
179+
150180
/**
151181
* Detailed scan result.
152182
*/
153183
export interface QrcodeResult {
154184
/** Decoded text. */
155185
text: string;
156186

187+
metadata?: ResultMetadata;
188+
157189
/** Format that was successfully scanned. */
158190
format?: QrcodeResultFormat,
159191

src/zxing-html5-qrcode-decoder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export class ZXingHtml5QrcodeDecoder implements QrcodeDecoderAsync {
110110
let result = zxingDecoder.decode(binaryBitmap);
111111
return {
112112
text: result.text,
113+
metadata: result.getResultMetadata(),
113114
format: QrcodeResultFormat.create(
114115
this.toHtml5QrcodeSupportedFormats(result.format)),
115116
debugData: this.createDebugData(),

0 commit comments

Comments
 (0)