forked from mebjas/html5-qrcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
experimental-features.ts
62 lines (56 loc) · 1.94 KB
/
experimental-features.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* @fileoverview
* Core library for experimental features.
*
* @author mebjas <[email protected]>
*
* Experimental features are those which have limited browser compatibility and
* hidden from official documentations. These features are not recommended by
* the author to be used in production unless explictly tested.
*
* Subset of the features are expected to upgrade to official feature list from
* time to time.
*
* The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED
* http://www.denso-wave.com/qrcode/faqpatent-e.html
*/
/**
* Configuration for enabling or disabling experimental features in the library.
*
* These features will eventually upgrade as fully supported features in the
* library.
*/
export interface ExperimentalFeaturesConfig {
/**
* {@class BarcodeDetector} is being implemented by browsers at the moment.
* It has very limited browser support but as it gets available it could
* enable faster native code scanning experience.
*
* Set this flag to true, to enable using {@class BarcodeDetector} if
* supported. This is false by default.
*
* Documentations:
* - https://developer.mozilla.org/en-US/docs/Web/API/BarcodeDetector
* - https://web.dev/shape-detection/#barcodedetector
*/
useBarCodeDetectorIfSupported?: boolean | undefined;
}
/** Factory for {@interface ExperimentalFeaturesConfig}. */
export class ExperimentalFeaturesConfigFactory {
/**
* Creates fully filled experimental config.
*/
public static createExperimentalFeaturesConfig(
config?: ExperimentalFeaturesConfig | undefined)
: ExperimentalFeaturesConfig {
if (!config) {
return {
useBarCodeDetectorIfSupported: false
};
}
if (config.useBarCodeDetectorIfSupported !== true) {
config.useBarCodeDetectorIfSupported = false;
}
return config;
}
}