@capacitor/barcode-scanner 2.0.5-dev-20250901T151658.0 → 2.1.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapacitorBarcodeScanner.podspec +1 -1
- package/README.md +12 -8
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/capacitorjs/barcodescanner/OSBarcodePlugin.kt +8 -3
- package/dist/docs.json +18 -16
- package/dist/esm/definitions.d.ts +1 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.js +17 -5
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +16 -4
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +16 -4
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorBarcodeScannerPlugin.swift +5 -5
- package/ios/Plugin/{OSBarcodeScanArgumentsModel.swift → OSBARCScanParameters+Decodable.swift} +12 -13
- package/ios/Plugin/OSBarcodeError.swift +1 -1
- package/package.json +6 -7
|
@@ -13,6 +13,6 @@ Pod::Spec.new do |s|
|
|
|
13
13
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
14
|
s.ios.deployment_target = '14.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
|
-
s.dependency 'OSBarcodeLib', '~>
|
|
16
|
+
s.dependency 'OSBarcodeLib', '~> 2.0.0'
|
|
17
17
|
s.swift_version = '5.1'
|
|
18
18
|
end
|
package/README.md
CHANGED
|
@@ -19,10 +19,14 @@ ext {
|
|
|
19
19
|
}
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
Note: Android with `ZXING` scanning library supports all formats, while `MLKIT` supports all but `MAXICODE`, `RSS_14`, `RSS_EXPANDED` and `UPC_EAN_EXTENSION` - using one of these in `hint` will default to scanning any format.
|
|
23
|
+
|
|
22
24
|
#### iOS
|
|
23
25
|
|
|
24
26
|
The barcode scanner uses the camera on the device. Ensure you configure the Privacy - Camera Usage Description in your Info.plist file so that your application can access the device's camera.
|
|
25
27
|
|
|
28
|
+
Note: iOS supports all formats but `MAXICODE` and `UPC_EAN_EXTENSION` - using them in `hint` will default to scanning any format. Also, Apple Vision does not distinguish between `UPC_A` and `UPC_E`, so specifying one of these in `hint` will allow to scan both.
|
|
29
|
+
|
|
26
30
|
---
|
|
27
31
|
|
|
28
32
|
## API
|
|
@@ -63,14 +67,7 @@ scanBarcode(options: CapacitorBarcodeScannerOptions) => Promise<CapacitorBarcode
|
|
|
63
67
|
|
|
64
68
|
Defines the structure of the result returned from a barcode scan.
|
|
65
69
|
|
|
66
|
-
<code>{ ScanResult: string }</code>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
#### CapacitorBarcodeScannerOptions
|
|
70
|
-
|
|
71
|
-
Defines the options for configuring a barcode scan.
|
|
72
|
-
|
|
73
|
-
<code>{ hint: <a href="#capacitorbarcodescannertypehint">CapacitorBarcodeScannerTypeHint</a>; scanInstructions?: string; scanButton?: boolean; scanText?: string; cameraDirection?: <a href="#capacitorbarcodescannercameradirection">CapacitorBarcodeScannerCameraDirection</a>; scanOrientation?: <a href="#capacitorbarcodescannerscanorientation">CapacitorBarcodeScannerScanOrientation</a>; android?: { scanningLibrary?: <a href="#capacitorbarcodescannerandroidscanninglibrary">CapacitorBarcodeScannerAndroidScanningLibrary</a>; }; web?: { showCameraSelection?: boolean; scannerFPS?: number; }; }</code>
|
|
70
|
+
<code>{ ScanResult: string; format: <a href="#capacitorbarcodescannertypehint">CapacitorBarcodeScannerTypeHint</a>; }</code>
|
|
74
71
|
|
|
75
72
|
|
|
76
73
|
#### CapacitorBarcodeScannerTypeHint
|
|
@@ -83,6 +80,13 @@ to represent the hint for the type of barcode to be scanned.
|
|
|
83
80
|
<code><a href="#html5qrcodesupportedformats">Html5QrcodeSupportedFormats</a> | <a href="#capacitorbarcodescannertypehintalloption">CapacitorBarcodeScannerTypeHintALLOption</a></code>
|
|
84
81
|
|
|
85
82
|
|
|
83
|
+
#### CapacitorBarcodeScannerOptions
|
|
84
|
+
|
|
85
|
+
Defines the options for configuring a barcode scan.
|
|
86
|
+
|
|
87
|
+
<code>{ hint: <a href="#capacitorbarcodescannertypehint">CapacitorBarcodeScannerTypeHint</a>; scanInstructions?: string; scanButton?: boolean; scanText?: string; cameraDirection?: <a href="#capacitorbarcodescannercameradirection">CapacitorBarcodeScannerCameraDirection</a>; scanOrientation?: <a href="#capacitorbarcodescannerscanorientation">CapacitorBarcodeScannerScanOrientation</a>; android?: { scanningLibrary?: <a href="#capacitorbarcodescannerandroidscanninglibrary">CapacitorBarcodeScannerAndroidScanningLibrary</a>; }; web?: { showCameraSelection?: boolean; scannerFPS?: number; }; }</code>
|
|
88
|
+
|
|
89
|
+
|
|
86
90
|
### Enums
|
|
87
91
|
|
|
88
92
|
|
package/android/build.gradle
CHANGED
|
@@ -58,7 +58,7 @@ repositories {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
dependencies {
|
|
61
|
-
implementation "io.ionic.libs:ionbarcode-android:
|
|
61
|
+
implementation "io.ionic.libs:ionbarcode-android:2.0.0@aar"
|
|
62
62
|
implementation project(':capacitor-android')
|
|
63
63
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
64
64
|
implementation 'androidx.activity:activity-ktx:1.9.3'
|
|
@@ -10,6 +10,8 @@ import com.getcapacitor.annotation.ActivityCallback
|
|
|
10
10
|
import com.getcapacitor.annotation.CapacitorPlugin
|
|
11
11
|
import com.outsystems.plugins.barcode.controller.OSBARCController
|
|
12
12
|
import com.outsystems.plugins.barcode.model.OSBARCScanParameters
|
|
13
|
+
import com.outsystems.plugins.barcode.model.OSBARCScanResult
|
|
14
|
+
import com.outsystems.plugins.barcode.model.OSBARCScannerHint
|
|
13
15
|
import com.outsystems.plugins.barcode.view.OSBARCScannerActivity
|
|
14
16
|
|
|
15
17
|
@CapacitorPlugin(name = "CapacitorBarcodeScanner")
|
|
@@ -28,7 +30,9 @@ class CapacitorBarcodeScannerPlugin : Plugin() {
|
|
|
28
30
|
|
|
29
31
|
@PluginMethod
|
|
30
32
|
fun scanBarcode(call: PluginCall) {
|
|
31
|
-
val hint = call.getInt("hint")
|
|
33
|
+
val hint: OSBARCScannerHint? = call.getInt("hint")?.let {
|
|
34
|
+
OSBARCScannerHint.entries.getOrNull(it)
|
|
35
|
+
}
|
|
32
36
|
val scanInstructions = call.getString("scanInstructions")
|
|
33
37
|
val scanButton = call.getBoolean("scanButton", false) ?: false
|
|
34
38
|
val scanText = call.getString("scanText", "") ?: ""
|
|
@@ -56,9 +60,10 @@ class CapacitorBarcodeScannerPlugin : Plugin() {
|
|
|
56
60
|
fun handleScanResult(call: PluginCall, result: ActivityResult) {
|
|
57
61
|
barcodeController.handleActivityResult(
|
|
58
62
|
SCAN_REQUEST_CODE, result.resultCode, result.data,
|
|
59
|
-
onSuccess = { scanResult ->
|
|
63
|
+
onSuccess = { scanResult: OSBARCScanResult ->
|
|
60
64
|
val ret = JSObject()
|
|
61
|
-
ret.put("ScanResult", scanResult)
|
|
65
|
+
ret.put("ScanResult", scanResult.text)
|
|
66
|
+
ret.put("format", scanResult.format.ordinal)
|
|
62
67
|
call.resolve(ret)
|
|
63
68
|
},
|
|
64
69
|
onError = { error ->
|
package/dist/docs.json
CHANGED
|
@@ -217,23 +217,9 @@
|
|
|
217
217
|
"docs": "Defines the structure of the result returned from a barcode scan.",
|
|
218
218
|
"types": [
|
|
219
219
|
{
|
|
220
|
-
"text": "{
|
|
221
|
-
"complexTypes": []
|
|
222
|
-
}
|
|
223
|
-
]
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
"name": "CapacitorBarcodeScannerOptions",
|
|
227
|
-
"slug": "capacitorbarcodescanneroptions",
|
|
228
|
-
"docs": "Defines the options for configuring a barcode scan.",
|
|
229
|
-
"types": [
|
|
230
|
-
{
|
|
231
|
-
"text": "{\n hint: CapacitorBarcodeScannerTypeHint;\n scanInstructions?: string;\n scanButton?: boolean;\n scanText?: string;\n cameraDirection?: CapacitorBarcodeScannerCameraDirection;\n scanOrientation?: CapacitorBarcodeScannerScanOrientation;\n android?: {\n scanningLibrary?: CapacitorBarcodeScannerAndroidScanningLibrary;\n };\n web?: {\n showCameraSelection?: boolean;\n scannerFPS?: number;\n };\n}",
|
|
220
|
+
"text": "{\n ScanResult: string;\n format: CapacitorBarcodeScannerTypeHint;\n}",
|
|
232
221
|
"complexTypes": [
|
|
233
|
-
"CapacitorBarcodeScannerTypeHint"
|
|
234
|
-
"CapacitorBarcodeScannerCameraDirection",
|
|
235
|
-
"CapacitorBarcodeScannerScanOrientation",
|
|
236
|
-
"CapacitorBarcodeScannerAndroidScanningLibrary"
|
|
222
|
+
"CapacitorBarcodeScannerTypeHint"
|
|
237
223
|
]
|
|
238
224
|
}
|
|
239
225
|
]
|
|
@@ -256,6 +242,22 @@
|
|
|
256
242
|
]
|
|
257
243
|
}
|
|
258
244
|
]
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"name": "CapacitorBarcodeScannerOptions",
|
|
248
|
+
"slug": "capacitorbarcodescanneroptions",
|
|
249
|
+
"docs": "Defines the options for configuring a barcode scan.",
|
|
250
|
+
"types": [
|
|
251
|
+
{
|
|
252
|
+
"text": "{\n hint: CapacitorBarcodeScannerTypeHint;\n scanInstructions?: string;\n scanButton?: boolean;\n scanText?: string;\n cameraDirection?: CapacitorBarcodeScannerCameraDirection;\n scanOrientation?: CapacitorBarcodeScannerScanOrientation;\n android?: {\n scanningLibrary?: CapacitorBarcodeScannerAndroidScanningLibrary;\n };\n web?: {\n showCameraSelection?: boolean;\n scannerFPS?: number;\n };\n}",
|
|
253
|
+
"complexTypes": [
|
|
254
|
+
"CapacitorBarcodeScannerTypeHint",
|
|
255
|
+
"CapacitorBarcodeScannerCameraDirection",
|
|
256
|
+
"CapacitorBarcodeScannerScanOrientation",
|
|
257
|
+
"CapacitorBarcodeScannerAndroidScanningLibrary"
|
|
258
|
+
]
|
|
259
|
+
}
|
|
260
|
+
]
|
|
259
261
|
}
|
|
260
262
|
],
|
|
261
263
|
"pluginConfigs": []
|
|
@@ -62,6 +62,7 @@ export declare enum CapacitorBarcodeScannerAndroidScanningLibrary {
|
|
|
62
62
|
*/
|
|
63
63
|
export type CapacitorBarcodeScannerScanResult = {
|
|
64
64
|
ScanResult: string;
|
|
65
|
+
format: CapacitorBarcodeScannerTypeHint;
|
|
65
66
|
};
|
|
66
67
|
/**
|
|
67
68
|
* Defines the options for configuring a barcode scan.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAN,IAAY,sCAGX;AAHD,WAAY,sCAAsC;IAChD,mGAAQ,CAAA;IACR,qGAAS,CAAA;AACX,CAAC,EAHW,sCAAsC,KAAtC,sCAAsC,QAGjD;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,sCAIX;AAJD,WAAY,sCAAsC;IAChD,2GAAY,CAAA;IACZ,6GAAa,CAAA;IACb,2GAAY,CAAA;AACd,CAAC,EAJW,sCAAsC,KAAtC,sCAAsC,QAIjD;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,wCAEX;AAFD,WAAY,wCAAwC;IAClD,sGAAQ,CAAA;AACV,CAAC,EAFW,wCAAwC,KAAxC,wCAAwC,QAEnD;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,+BAA+B,mCACvC,2BAA2B,GAC3B,wCAAwC,CAC5C,CAAC;AAQF;;GAEG;AACH,MAAM,CAAN,IAAY,6CAGX;AAHD,WAAY,6CAA6C;IACvD,gEAAe,CAAA;IACf,gEAAe,CAAA;AACjB,CAAC,EAHW,6CAA6C,KAA7C,6CAA6C,QAGxD","sourcesContent":["import { Html5QrcodeSupportedFormats } from 'html5-qrcode';\n\n/**\n * Enum representing the direction of the camera to be used for barcode scanning.\n */\nexport enum CapacitorBarcodeScannerCameraDirection {\n BACK = 1,\n FRONT = 2,\n}\n\n/**\n * Enum representing the orientation of the scanner during barcode scanning.\n */\nexport enum CapacitorBarcodeScannerScanOrientation {\n PORTRAIT = 1,\n LANDSCAPE = 2,\n ADAPTIVE = 3,\n}\n\n/**\n * Enum representing a special option to indicate that all barcode types are supported.\n */\nexport enum CapacitorBarcodeScannerTypeHintALLOption {\n ALL = 17,\n}\n\n/**\n * Extends supported formats from Html5Qrcode with a special 'ALL' option,\n * indicating support for all barcode types.\n */\nexport const CapacitorBarcodeScannerTypeHint = {\n ...Html5QrcodeSupportedFormats,\n ...CapacitorBarcodeScannerTypeHintALLOption,\n};\n\n/**\n * Type definition combining Html5QrcodeSupportedFormats and OSBarcodeTypeHintALLOption\n * to represent the hint for the type of barcode to be scanned.\n */\nexport type CapacitorBarcodeScannerTypeHint = Html5QrcodeSupportedFormats | CapacitorBarcodeScannerTypeHintALLOption;\n\n/**\n * Enum representing the library to be used for barcode scanning on Android devices.\n */\nexport enum CapacitorBarcodeScannerAndroidScanningLibrary {\n ZXING = 'zxing',\n MLKIT = 'mlkit',\n}\n\n/**\n * Defines the structure of the result returned from a barcode scan.\n */\nexport type CapacitorBarcodeScannerScanResult = {
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAN,IAAY,sCAGX;AAHD,WAAY,sCAAsC;IAChD,mGAAQ,CAAA;IACR,qGAAS,CAAA;AACX,CAAC,EAHW,sCAAsC,KAAtC,sCAAsC,QAGjD;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,sCAIX;AAJD,WAAY,sCAAsC;IAChD,2GAAY,CAAA;IACZ,6GAAa,CAAA;IACb,2GAAY,CAAA;AACd,CAAC,EAJW,sCAAsC,KAAtC,sCAAsC,QAIjD;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,wCAEX;AAFD,WAAY,wCAAwC;IAClD,sGAAQ,CAAA;AACV,CAAC,EAFW,wCAAwC,KAAxC,wCAAwC,QAEnD;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,+BAA+B,mCACvC,2BAA2B,GAC3B,wCAAwC,CAC5C,CAAC;AAQF;;GAEG;AACH,MAAM,CAAN,IAAY,6CAGX;AAHD,WAAY,6CAA6C;IACvD,gEAAe,CAAA;IACf,gEAAe,CAAA;AACjB,CAAC,EAHW,6CAA6C,KAA7C,6CAA6C,QAGxD","sourcesContent":["import { Html5QrcodeSupportedFormats } from 'html5-qrcode';\n\n/**\n * Enum representing the direction of the camera to be used for barcode scanning.\n */\nexport enum CapacitorBarcodeScannerCameraDirection {\n BACK = 1,\n FRONT = 2,\n}\n\n/**\n * Enum representing the orientation of the scanner during barcode scanning.\n */\nexport enum CapacitorBarcodeScannerScanOrientation {\n PORTRAIT = 1,\n LANDSCAPE = 2,\n ADAPTIVE = 3,\n}\n\n/**\n * Enum representing a special option to indicate that all barcode types are supported.\n */\nexport enum CapacitorBarcodeScannerTypeHintALLOption {\n ALL = 17,\n}\n\n/**\n * Extends supported formats from Html5Qrcode with a special 'ALL' option,\n * indicating support for all barcode types.\n */\nexport const CapacitorBarcodeScannerTypeHint = {\n ...Html5QrcodeSupportedFormats,\n ...CapacitorBarcodeScannerTypeHintALLOption,\n};\n\n/**\n * Type definition combining Html5QrcodeSupportedFormats and OSBarcodeTypeHintALLOption\n * to represent the hint for the type of barcode to be scanned.\n */\nexport type CapacitorBarcodeScannerTypeHint = Html5QrcodeSupportedFormats | CapacitorBarcodeScannerTypeHintALLOption;\n\n/**\n * Enum representing the library to be used for barcode scanning on Android devices.\n */\nexport enum CapacitorBarcodeScannerAndroidScanningLibrary {\n ZXING = 'zxing',\n MLKIT = 'mlkit',\n}\n\n/**\n * Defines the structure of the result returned from a barcode scan.\n */\nexport type CapacitorBarcodeScannerScanResult = {\n ScanResult: string;\n format: CapacitorBarcodeScannerTypeHint;\n};\n\n/**\n * Defines the options for configuring a barcode scan.\n */\nexport type CapacitorBarcodeScannerOptions = {\n hint: CapacitorBarcodeScannerTypeHint;\n scanInstructions?: string;\n scanButton?: boolean;\n scanText?: string;\n cameraDirection?: CapacitorBarcodeScannerCameraDirection;\n scanOrientation?: CapacitorBarcodeScannerScanOrientation;\n android?: {\n scanningLibrary?: CapacitorBarcodeScannerAndroidScanningLibrary;\n };\n web?: {\n showCameraSelection?: boolean;\n scannerFPS?: number;\n };\n};\n\n/**\n * Interface defining the contract for a plugin capable of scanning barcodes.\n * Requires implementation of the scanBarcode method, which initiates a barcode scan with given options.\n */\nexport interface CapacitorBarcodeScannerPlugin {\n scanBarcode(options: CapacitorBarcodeScannerOptions): Promise<CapacitorBarcodeScannerScanResult>;\n}\n"]}
|
package/dist/esm/web.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
2
|
import { Html5Qrcode } from 'html5-qrcode';
|
|
3
|
-
import { CapacitorBarcodeScannerScanOrientation } from './definitions';
|
|
3
|
+
import { CapacitorBarcodeScannerScanOrientation, CapacitorBarcodeScannerTypeHint } from './definitions';
|
|
4
4
|
/**
|
|
5
5
|
* Implements OSBarcodePlugin to provide web functionality for barcode scanning.
|
|
6
6
|
*/
|
|
@@ -85,7 +85,10 @@ export class CapacitorBarcodeScannerWeb extends WebPlugin {
|
|
|
85
85
|
if (!scannerElement) {
|
|
86
86
|
throw new Error('Scanner Element is required for web');
|
|
87
87
|
}
|
|
88
|
-
window.OSBarcodeWebScanner = new Html5Qrcode(scannerElement.id
|
|
88
|
+
window.OSBarcodeWebScanner = new Html5Qrcode(scannerElement.id, {
|
|
89
|
+
formatsToSupport: param.typeHint !== undefined ? [param.typeHint] : undefined,
|
|
90
|
+
verbose: undefined,
|
|
91
|
+
});
|
|
89
92
|
const Html5QrcodeConfig = {
|
|
90
93
|
fps: param.scannerFPS,
|
|
91
94
|
qrbox: scannerElement.getBoundingClientRect().width * (9 / 16) - 10,
|
|
@@ -98,12 +101,21 @@ export class CapacitorBarcodeScannerWeb extends WebPlugin {
|
|
|
98
101
|
},
|
|
99
102
|
};
|
|
100
103
|
// Success and error callbacks for the scanner
|
|
101
|
-
const OSBarcodeWebScannerSuccessCallback = (decodedText,
|
|
104
|
+
const OSBarcodeWebScannerSuccessCallback = (decodedText, decodedResult) => {
|
|
105
|
+
var _a, _b;
|
|
102
106
|
this.stopAndHideScanner();
|
|
103
|
-
resolve({
|
|
107
|
+
resolve({
|
|
108
|
+
ScanResult: decodedText,
|
|
109
|
+
format: (_b = (_a = decodedResult.result.format) === null || _a === void 0 ? void 0 : _a.format) !== null && _b !== void 0 ? _b : CapacitorBarcodeScannerTypeHint.ALL,
|
|
110
|
+
});
|
|
104
111
|
};
|
|
105
112
|
const OSBarcodeWebScannerErrorCallback = (error) => {
|
|
106
|
-
|
|
113
|
+
const allowedErrors = [
|
|
114
|
+
'NotFoundException',
|
|
115
|
+
'No barcode or QR code detected',
|
|
116
|
+
'No MultiFormat Readers were able to detect the code',
|
|
117
|
+
];
|
|
118
|
+
if (!allowedErrors.find((e) => error.indexOf(e) !== -1)) {
|
|
107
119
|
this.stopAndHideScanner();
|
|
108
120
|
console.error(`[Scanner Web Error] ${error}`);
|
|
109
121
|
reject(error);
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAO3C,OAAO,EAAE,sCAAsC,EAAE,MAAM,eAAe,CAAC;AAEvE;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,SAAS;IACvD;;;;OAIG;IACK,KAAK,CAAC,kBAAkB;QAC9B,OAAO,CAAC,GAAG,CAAE,MAAc,CA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CAAC,kBAAkB,EAAE,CAAC;gBAC1B,OAAO,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;YACvC,CAAC,CAAC;YAEF,MAAM,gCAAgC,GAAG,CAAC,KAAa,EAAE,EAAE;gBACzD,IAAI,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,gCAAgC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;oBACxG,IAAI,CAAC,kBAAkB,EAAE,CAAC;oBAC1B,OAAO,CAAC,KAAK,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAC;oBAC9C,MAAM,CAAC,KAAK,CAAC,CAAC;gBAChB,CAAC;YACH,CAAC,CAAC;YAED,MAAc,CAAC,mBAAmB,CAAC,KAAK,CACvC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,EAChC,iBAAiB,EACjB,kCAAkC,EAClC,gCAAgC,CACjC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport type { Html5QrcodeResult } from 'html5-qrcode';\nimport { Html5Qrcode } from 'html5-qrcode';\n\nimport type {\n CapacitorBarcodeScannerPlugin,\n CapacitorBarcodeScannerOptions,\n CapacitorBarcodeScannerScanResult,\n} from './definitions';\nimport { CapacitorBarcodeScannerScanOrientation } from './definitions';\n\n/**\n * Implements OSBarcodePlugin to provide web functionality for barcode scanning.\n */\nexport class CapacitorBarcodeScannerWeb extends WebPlugin implements CapacitorBarcodeScannerPlugin {\n /**\n * Stops the barcode scanner and hides its UI.\n * @private\n * @returns {Promise<void>} A promise that resolves when the scanner has stopped and its UI is hidden.\n */\n private async stopAndHideScanner(): Promise<void> {\n console.log((window as any).OSBarcodeWebScanner);\n if ((window as any).OSBarcodeWebScanner) {\n await (window as any).OSBarcodeWebScanner.stop();\n (window as any).OSBarcodeWebScanner = null;\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container-dialog')!.style.display = 'none';\n }\n\n /**\n * Builds the HTML elements necessary for the barcode scanner UI.\n * This method checks if the scanner container exists before creating it to avoid duplicates.\n * It also sets up the close button to stop and hide the scanner on click.\n * @private\n */\n private buildScannerElement(): void {\n if (document.getElementById('cap-os-barcode-scanner-container')) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container')!.className = 'scanner-container-display';\n return;\n }\n // Create and configure scanner container elements\n const caposbarcodescannercontainer = document.body.appendChild(document.createElement('div'));\n caposbarcodescannercontainer.id = 'cap-os-barcode-scanner-container';\n const caposbarcodescannercontainerdialog = document.createElement('div');\n caposbarcodescannercontainerdialog.id = 'cap-os-barcode-scanner-container-dialog';\n caposbarcodescannercontainerdialog.className = 'scanner-dialog';\n\n // Inner dialog elements including the close button and scanner view\n const caposbarcodescannercontainerdialoginner = document.createElement('div');\n caposbarcodescannercontainerdialoginner.className = 'scanner-dialog-inner';\n\n const caposbarcodescannercontainerdialoginnerclose = document.createElement('span');\n caposbarcodescannercontainerdialoginnerclose.className = 'close-button';\n caposbarcodescannercontainerdialoginnerclose.innerHTML = '×';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnerclose);\n\n const caposbarcodescannercontainerdialoginnercontainerp = document.createElement('p');\n caposbarcodescannercontainerdialoginnercontainerp.innerHTML = ' ';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainerp);\n\n const caposbarcodescannercontainerdialoginnercontainer = document.createElement('div');\n caposbarcodescannercontainerdialoginnercontainer.className = 'scanner-container-full-width';\n caposbarcodescannercontainerdialoginnercontainer.id = 'cap-os-barcode-scanner-container-scanner';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainer);\n\n caposbarcodescannercontainerdialog.appendChild(caposbarcodescannercontainerdialoginner);\n caposbarcodescannercontainer.appendChild(caposbarcodescannercontainerdialog);\n\n caposbarcodescannercontainerdialoginnerclose.onclick = this.stopAndHideScanner;\n }\n\n /**\n * Initiates a barcode scan using the user's camera and HTML5 QR code scanner.\n * Displays the scanner UI and waits for a scan to complete or fail.\n * @param {OSBarcodeScanOptions} options Configuration options for the scan, including camera direction and UI preferences.\n * @returns {Promise<OSBarcodeScanResult>} A promise that resolves with the scan result or rejects with an error.\n */\n async scanBarcode(options: CapacitorBarcodeScannerOptions): Promise<CapacitorBarcodeScannerScanResult> {\n this.buildScannerElement();\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container-dialog')!.style.display = 'block';\n return new Promise((resolve, reject) => {\n const param = {\n facingMode: options.cameraDirection === 1 ? 'environment' : 'user',\n hasScannerButton: false,\n scanButton: options.scanButton === undefined ? false : options.scanButton,\n showScanLine: false,\n scanInstructions: options.scanInstructions ? options.scanInstructions : '',\n orientation: options.scanOrientation\n ? options.scanOrientation\n : CapacitorBarcodeScannerScanOrientation.PORTRAIT,\n showCameraSelection: options.web?.showCameraSelection ? options.web.showCameraSelection : false,\n typeHint: options.hint === 17 ? undefined : options.hint,\n scannerFPS: options.web?.scannerFPS ? options.web.scannerFPS : 50,\n };\n\n // Set up and start the scanner\n const scannerElement = document.getElementById('cap-os-barcode-scanner-container-scanner');\n if (!scannerElement) {\n throw new Error('Scanner Element is required for web');\n }\n\n (window as any).OSBarcodeWebScanner = new Html5Qrcode(scannerElement.id);\n const Html5QrcodeConfig = {\n fps: param.scannerFPS,\n qrbox: scannerElement.getBoundingClientRect().width * (9 / 16) - 10,\n aspectRatio: 16 / 9,\n videoConstraints: {\n focusMode: 'continuous',\n height: { min: 576, ideal: 1920 },\n deviceId: undefined,\n facingMode: param.facingMode,\n },\n };\n\n // Success and error callbacks for the scanner\n const OSBarcodeWebScannerSuccessCallback = (decodedText: string, _decodedResult: Html5QrcodeResult) => {\n this.stopAndHideScanner();\n resolve({ ScanResult: decodedText });\n };\n\n const OSBarcodeWebScannerErrorCallback = (error: string) => {\n if (error.indexOf('NotFoundException') === -1 && error.indexOf('No barcode or QR code detected') === -1) {\n this.stopAndHideScanner();\n console.error(`[Scanner Web Error] ${error}`);\n reject(error);\n }\n };\n\n (window as any).OSBarcodeWebScanner.start(\n { facingMode: param.facingMode },\n Html5QrcodeConfig,\n OSBarcodeWebScannerSuccessCallback,\n OSBarcodeWebScannerErrorCallback\n );\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAO3C,OAAO,EAAE,sCAAsC,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAExG;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,SAAS;IACvD;;;;OAIG;IACK,KAAK,CAAC,kBAAkB;QAC9B,OAAO,CAAC,GAAG,CAAE,MAAc,CAAC,mBAAmB,CAAC,CAAC;QACjD,IAAK,MAAc,CAAC,mBAAmB,EAAE,CAAC;YACxC,MAAO,MAAc,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC;YAChD,MAAc,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAC7C,CAAC;QACD,oEAAoE;QACpE,QAAQ,CAAC,cAAc,CAAC,yCAAyC,CAAE,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IAC7F,CAAC;IAED;;;;;OAKG;IACK,mBAAmB;QACzB,IAAI,QAAQ,CAAC,cAAc,CAAC,kCAAkC,CAAC,EAAE,CAAC;YAChE,oEAAoE;YACpE,QAAQ,CAAC,cAAc,CAAC,kCAAkC,CAAE,CAAC,SAAS,GAAG,2BAA2B,CAAC;YACrG,OAAO;QACT,CAAC;QACD,kDAAkD;QAClD,MAAM,4BAA4B,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAW,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,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;oBACxD,IAAI,CAAC,kBAAkB,EAAE,CAAC;oBAC1B,OAAO,CAAC,KAAK,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAC;oBAC9C,MAAM,CAAC,KAAK,CAAC,CAAC;gBAChB,CAAC;YACH,CAAC,CAAC;YAED,MAAc,CAAC,mBAAmB,CAAC,KAAK,CACvC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,EAChC,iBAAiB,EACjB,kCAAkC,EAClC,gCAAgC,CACjC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport type { Html5QrcodeResult } from 'html5-qrcode';\nimport { Html5Qrcode } from 'html5-qrcode';\n\nimport type {\n CapacitorBarcodeScannerPlugin,\n CapacitorBarcodeScannerOptions,\n CapacitorBarcodeScannerScanResult,\n} from './definitions';\nimport { CapacitorBarcodeScannerScanOrientation, CapacitorBarcodeScannerTypeHint } from './definitions';\n\n/**\n * Implements OSBarcodePlugin to provide web functionality for barcode scanning.\n */\nexport class CapacitorBarcodeScannerWeb extends WebPlugin implements CapacitorBarcodeScannerPlugin {\n /**\n * Stops the barcode scanner and hides its UI.\n * @private\n * @returns {Promise<void>} A promise that resolves when the scanner has stopped and its UI is hidden.\n */\n private async stopAndHideScanner(): Promise<void> {\n console.log((window as any).OSBarcodeWebScanner);\n if ((window as any).OSBarcodeWebScanner) {\n await (window as any).OSBarcodeWebScanner.stop();\n (window as any).OSBarcodeWebScanner = null;\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container-dialog')!.style.display = 'none';\n }\n\n /**\n * Builds the HTML elements necessary for the barcode scanner UI.\n * This method checks if the scanner container exists before creating it to avoid duplicates.\n * It also sets up the close button to stop and hide the scanner on click.\n * @private\n */\n private buildScannerElement(): void {\n if (document.getElementById('cap-os-barcode-scanner-container')) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container')!.className = 'scanner-container-display';\n return;\n }\n // Create and configure scanner container elements\n const caposbarcodescannercontainer = document.body.appendChild(document.createElement('div'));\n caposbarcodescannercontainer.id = 'cap-os-barcode-scanner-container';\n const caposbarcodescannercontainerdialog = document.createElement('div');\n caposbarcodescannercontainerdialog.id = 'cap-os-barcode-scanner-container-dialog';\n caposbarcodescannercontainerdialog.className = 'scanner-dialog';\n\n // Inner dialog elements including the close button and scanner view\n const caposbarcodescannercontainerdialoginner = document.createElement('div');\n caposbarcodescannercontainerdialoginner.className = 'scanner-dialog-inner';\n\n const caposbarcodescannercontainerdialoginnerclose = document.createElement('span');\n caposbarcodescannercontainerdialoginnerclose.className = 'close-button';\n caposbarcodescannercontainerdialoginnerclose.innerHTML = '×';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnerclose);\n\n const caposbarcodescannercontainerdialoginnercontainerp = document.createElement('p');\n caposbarcodescannercontainerdialoginnercontainerp.innerHTML = ' ';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainerp);\n\n const caposbarcodescannercontainerdialoginnercontainer = document.createElement('div');\n caposbarcodescannercontainerdialoginnercontainer.className = 'scanner-container-full-width';\n caposbarcodescannercontainerdialoginnercontainer.id = 'cap-os-barcode-scanner-container-scanner';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainer);\n\n caposbarcodescannercontainerdialog.appendChild(caposbarcodescannercontainerdialoginner);\n caposbarcodescannercontainer.appendChild(caposbarcodescannercontainerdialog);\n\n caposbarcodescannercontainerdialoginnerclose.onclick = this.stopAndHideScanner;\n }\n\n /**\n * Initiates a barcode scan using the user's camera and HTML5 QR code scanner.\n * Displays the scanner UI and waits for a scan to complete or fail.\n * @param {OSBarcodeScanOptions} options Configuration options for the scan, including camera direction and UI preferences.\n * @returns {Promise<OSBarcodeScanResult>} A promise that resolves with the scan result or rejects with an error.\n */\n async scanBarcode(options: CapacitorBarcodeScannerOptions): Promise<CapacitorBarcodeScannerScanResult> {\n this.buildScannerElement();\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container-dialog')!.style.display = 'block';\n return new Promise((resolve, reject) => {\n const param = {\n facingMode: options.cameraDirection === 1 ? 'environment' : 'user',\n hasScannerButton: false,\n scanButton: options.scanButton === undefined ? false : options.scanButton,\n showScanLine: false,\n scanInstructions: options.scanInstructions ? options.scanInstructions : '',\n orientation: options.scanOrientation\n ? options.scanOrientation\n : CapacitorBarcodeScannerScanOrientation.PORTRAIT,\n showCameraSelection: options.web?.showCameraSelection ? options.web.showCameraSelection : false,\n typeHint: options.hint === 17 ? undefined : options.hint,\n scannerFPS: options.web?.scannerFPS ? options.web.scannerFPS : 50,\n };\n\n // Set up and start the scanner\n const scannerElement = document.getElementById('cap-os-barcode-scanner-container-scanner');\n if (!scannerElement) {\n throw new Error('Scanner Element is required for web');\n }\n\n (window as any).OSBarcodeWebScanner = new Html5Qrcode(scannerElement.id, {\n formatsToSupport: param.typeHint !== undefined ? [param.typeHint] : undefined,\n verbose: undefined,\n });\n const Html5QrcodeConfig = {\n fps: param.scannerFPS,\n qrbox: scannerElement.getBoundingClientRect().width * (9 / 16) - 10,\n aspectRatio: 16 / 9,\n videoConstraints: {\n focusMode: 'continuous',\n height: { min: 576, ideal: 1920 },\n deviceId: undefined,\n facingMode: param.facingMode,\n },\n };\n\n // Success and error callbacks for the scanner\n const OSBarcodeWebScannerSuccessCallback = (decodedText: string, decodedResult: Html5QrcodeResult) => {\n this.stopAndHideScanner();\n resolve({\n ScanResult: decodedText,\n format: decodedResult.result.format?.format ?? CapacitorBarcodeScannerTypeHint.ALL,\n });\n };\n\n const OSBarcodeWebScannerErrorCallback = (error: string) => {\n const allowedErrors = [\n 'NotFoundException',\n 'No barcode or QR code detected',\n 'No MultiFormat Readers were able to detect the code',\n ];\n\n if (!allowedErrors.find((e) => error.indexOf(e) !== -1)) {\n this.stopAndHideScanner();\n console.error(`[Scanner Web Error] ${error}`);\n reject(error);\n }\n };\n\n (window as any).OSBarcodeWebScanner.start(\n { facingMode: param.facingMode },\n Html5QrcodeConfig,\n OSBarcodeWebScannerSuccessCallback,\n OSBarcodeWebScannerErrorCallback\n );\n });\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -204,7 +204,10 @@ class CapacitorBarcodeScannerWeb extends core.WebPlugin {
|
|
|
204
204
|
if (!scannerElement) {
|
|
205
205
|
throw new Error('Scanner Element is required for web');
|
|
206
206
|
}
|
|
207
|
-
window.OSBarcodeWebScanner = new html5Qrcode.Html5Qrcode(scannerElement.id
|
|
207
|
+
window.OSBarcodeWebScanner = new html5Qrcode.Html5Qrcode(scannerElement.id, {
|
|
208
|
+
formatsToSupport: param.typeHint !== undefined ? [param.typeHint] : undefined,
|
|
209
|
+
verbose: undefined,
|
|
210
|
+
});
|
|
208
211
|
const Html5QrcodeConfig = {
|
|
209
212
|
fps: param.scannerFPS,
|
|
210
213
|
qrbox: scannerElement.getBoundingClientRect().width * (9 / 16) - 10,
|
|
@@ -217,12 +220,21 @@ class CapacitorBarcodeScannerWeb extends core.WebPlugin {
|
|
|
217
220
|
},
|
|
218
221
|
};
|
|
219
222
|
// Success and error callbacks for the scanner
|
|
220
|
-
const OSBarcodeWebScannerSuccessCallback = (decodedText,
|
|
223
|
+
const OSBarcodeWebScannerSuccessCallback = (decodedText, decodedResult) => {
|
|
224
|
+
var _a, _b;
|
|
221
225
|
this.stopAndHideScanner();
|
|
222
|
-
resolve({
|
|
226
|
+
resolve({
|
|
227
|
+
ScanResult: decodedText,
|
|
228
|
+
format: (_b = (_a = decodedResult.result.format) === null || _a === void 0 ? void 0 : _a.format) !== null && _b !== void 0 ? _b : CapacitorBarcodeScannerTypeHint.ALL,
|
|
229
|
+
});
|
|
223
230
|
};
|
|
224
231
|
const OSBarcodeWebScannerErrorCallback = (error) => {
|
|
225
|
-
|
|
232
|
+
const allowedErrors = [
|
|
233
|
+
'NotFoundException',
|
|
234
|
+
'No barcode or QR code detected',
|
|
235
|
+
'No MultiFormat Readers were able to detect the code',
|
|
236
|
+
];
|
|
237
|
+
if (!allowedErrors.find((e) => error.indexOf(e) !== -1)) {
|
|
226
238
|
this.stopAndHideScanner();
|
|
227
239
|
console.error(`[Scanner Web Error] ${error}`);
|
|
228
240
|
reject(error);
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/utils.js","esm/index.js","esm/web.js"],"sourcesContent":["import { Html5QrcodeSupportedFormats } from 'html5-qrcode';\n/**\n * Enum representing the direction of the camera to be used for barcode scanning.\n */\nexport var CapacitorBarcodeScannerCameraDirection;\n(function (CapacitorBarcodeScannerCameraDirection) {\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"BACK\"] = 1] = \"BACK\";\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"FRONT\"] = 2] = \"FRONT\";\n})(CapacitorBarcodeScannerCameraDirection || (CapacitorBarcodeScannerCameraDirection = {}));\n/**\n * Enum representing the orientation of the scanner during barcode scanning.\n */\nexport var CapacitorBarcodeScannerScanOrientation;\n(function (CapacitorBarcodeScannerScanOrientation) {\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"PORTRAIT\"] = 1] = \"PORTRAIT\";\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"LANDSCAPE\"] = 2] = \"LANDSCAPE\";\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"ADAPTIVE\"] = 3] = \"ADAPTIVE\";\n})(CapacitorBarcodeScannerScanOrientation || (CapacitorBarcodeScannerScanOrientation = {}));\n/**\n * Enum representing a special option to indicate that all barcode types are supported.\n */\nexport var CapacitorBarcodeScannerTypeHintALLOption;\n(function (CapacitorBarcodeScannerTypeHintALLOption) {\n CapacitorBarcodeScannerTypeHintALLOption[CapacitorBarcodeScannerTypeHintALLOption[\"ALL\"] = 17] = \"ALL\";\n})(CapacitorBarcodeScannerTypeHintALLOption || (CapacitorBarcodeScannerTypeHintALLOption = {}));\n/**\n * Extends supported formats from Html5Qrcode with a special 'ALL' option,\n * indicating support for all barcode types.\n */\nexport const CapacitorBarcodeScannerTypeHint = Object.assign(Object.assign({}, Html5QrcodeSupportedFormats), CapacitorBarcodeScannerTypeHintALLOption);\n/**\n * Enum representing the library to be used for barcode scanning on Android devices.\n */\nexport var CapacitorBarcodeScannerAndroidScanningLibrary;\n(function (CapacitorBarcodeScannerAndroidScanningLibrary) {\n CapacitorBarcodeScannerAndroidScanningLibrary[\"ZXING\"] = \"zxing\";\n CapacitorBarcodeScannerAndroidScanningLibrary[\"MLKIT\"] = \"mlkit\";\n})(CapacitorBarcodeScannerAndroidScanningLibrary || (CapacitorBarcodeScannerAndroidScanningLibrary = {}));\n//# sourceMappingURL=definitions.js.map","/**\n * Predefined CSS rules for styling barcode scanner components.\n * Each object in the array defines a CSS rule, with a selector and the CSS properties to apply.\n */\nexport const barcodeScannerCss = [\n { selector: '.scanner-container-display', css: 'display: block;' },\n {\n selector: '.scanner-dialog',\n css: 'display: none; position: fixed; z-index: 999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4);',\n },\n {\n selector: '.scanner-dialog-inner',\n css: 'background-color: #fefefe; margin: 2% auto; padding: 20px; border: 1px solid #888; width: 96%;',\n },\n { selector: '.close-button', css: 'color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer;' },\n { selector: '.close-button:hover', css: 'color: #222;' },\n { selector: '.scanner-container-full-width', css: 'width: 100%;' },\n];\n/**\n * Dynamically applies a set of CSS rules to the document.\n * If a custom style element with a specific ID does not exist, it is created and appended to the document's head.\n * Existing rules in the style element are cleared before new ones are applied.\n * This function supports both modern and older browsers by using `CSSStyleSheet.insertRule` and `textContent` respectively.\n *\n * @param {Array<{selector: string, css: string}>} cssRules - An array of objects containing CSS selectors and styles to apply.\n */\nexport function applyCss(cssRules) {\n const styleId = 'custom-style-os-cap-barcode'; // Unique identifier for the style element.\n let styleElement = document.getElementById(styleId);\n if (!styleElement) {\n // Create and append a new style element if it does not exist.\n styleElement = document.createElement('style');\n styleElement.type = 'text/css';\n styleElement.id = styleId;\n document.head.appendChild(styleElement);\n }\n if (styleElement.sheet) {\n // Clear existing CSS rules.\n while (styleElement.sheet.cssRules.length) {\n styleElement.sheet.deleteRule(0);\n }\n // Insert new CSS rules.\n for (const { selector, css } of cssRules) {\n styleElement.sheet.insertRule(`${selector} { ${css} }`);\n }\n }\n else {\n // Fallback for older browsers using textContent.\n styleElement.textContent = '';\n for (const { selector, css } of cssRules) {\n styleElement.textContent += `${selector} { ${css} }`;\n }\n }\n}\n//# sourceMappingURL=utils.js.map","import { registerPlugin } from '@capacitor/core';\nimport { CapacitorBarcodeScannerCameraDirection, CapacitorBarcodeScannerScanOrientation, } from './definitions'; // Importing the interface for type checking.\nimport { applyCss, barcodeScannerCss } from './utils'; // Import utilities for applying CSS.\n/**\n * Registers the `OSBarcode` plugin with Capacitor.\n * For web platforms, it applies necessary CSS for the barcode scanner and dynamically imports the web implementation.\n * This allows for lazy loading of the web code only when needed, optimizing overall bundle size.\n */\nconst CapacitorBarcodeScannerImpl = registerPlugin('CapacitorBarcodeScanner', {\n web: () => {\n applyCss(barcodeScannerCss); // Apply the CSS styles necessary for the web implementation of the barcode scanner.\n return import('./web').then((m) => new m.CapacitorBarcodeScannerWeb()); // Dynamically import the web implementation and instantiate it.\n },\n});\nclass CapacitorBarcodeScanner {\n static async scanBarcode(options) {\n options.scanInstructions = options.scanInstructions || ' '; // Ensure scanInstructions is at least a space.\n options.scanButton = options.scanButton || false; // Set scanButton to false if not provided.\n options.scanText = options.scanText || ' '; // Ensure scanText is at least a space.\n options.cameraDirection = options.cameraDirection || CapacitorBarcodeScannerCameraDirection.BACK; // Set cameraDirection to 'BACK' if not provided.\n options.scanOrientation = options.scanOrientation || CapacitorBarcodeScannerScanOrientation.ADAPTIVE; // Set scanOrientation to 'ADAPTIVE' if not provided.\n return CapacitorBarcodeScannerImpl.scanBarcode(options);\n }\n}\nexport { CapacitorBarcodeScanner }; // Export the `CapacitorBarcodeScanner` class.\nexport * from './definitions'; // Re-export all exports from the definitions file.\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { Html5Qrcode } from 'html5-qrcode';\nimport { CapacitorBarcodeScannerScanOrientation } from './definitions';\n/**\n * Implements OSBarcodePlugin to provide web functionality for barcode scanning.\n */\nexport class CapacitorBarcodeScannerWeb extends WebPlugin {\n /**\n * Stops the barcode scanner and hides its UI.\n * @private\n * @returns {Promise<void>} A promise that resolves when the scanner has stopped and its UI is hidden.\n */\n async stopAndHideScanner() {\n console.log(window.OSBarcodeWebScanner);\n if (window.OSBarcodeWebScanner) {\n await window.OSBarcodeWebScanner.stop();\n window.OSBarcodeWebScanner = null;\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container-dialog').style.display = 'none';\n }\n /**\n * Builds the HTML elements necessary for the barcode scanner UI.\n * This method checks if the scanner container exists before creating it to avoid duplicates.\n * It also sets up the close button to stop and hide the scanner on click.\n * @private\n */\n buildScannerElement() {\n if (document.getElementById('cap-os-barcode-scanner-container')) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container').className = 'scanner-container-display';\n return;\n }\n // Create and configure scanner container elements\n const caposbarcodescannercontainer = document.body.appendChild(document.createElement('div'));\n caposbarcodescannercontainer.id = 'cap-os-barcode-scanner-container';\n const caposbarcodescannercontainerdialog = document.createElement('div');\n caposbarcodescannercontainerdialog.id = 'cap-os-barcode-scanner-container-dialog';\n caposbarcodescannercontainerdialog.className = 'scanner-dialog';\n // Inner dialog elements including the close button and scanner view\n const caposbarcodescannercontainerdialoginner = document.createElement('div');\n caposbarcodescannercontainerdialoginner.className = 'scanner-dialog-inner';\n const caposbarcodescannercontainerdialoginnerclose = document.createElement('span');\n caposbarcodescannercontainerdialoginnerclose.className = 'close-button';\n caposbarcodescannercontainerdialoginnerclose.innerHTML = '×';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnerclose);\n const caposbarcodescannercontainerdialoginnercontainerp = document.createElement('p');\n caposbarcodescannercontainerdialoginnercontainerp.innerHTML = ' ';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainerp);\n const caposbarcodescannercontainerdialoginnercontainer = document.createElement('div');\n caposbarcodescannercontainerdialoginnercontainer.className = 'scanner-container-full-width';\n caposbarcodescannercontainerdialoginnercontainer.id = 'cap-os-barcode-scanner-container-scanner';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainer);\n caposbarcodescannercontainerdialog.appendChild(caposbarcodescannercontainerdialoginner);\n caposbarcodescannercontainer.appendChild(caposbarcodescannercontainerdialog);\n caposbarcodescannercontainerdialoginnerclose.onclick = this.stopAndHideScanner;\n }\n /**\n * Initiates a barcode scan using the user's camera and HTML5 QR code scanner.\n * Displays the scanner UI and waits for a scan to complete or fail.\n * @param {OSBarcodeScanOptions} options Configuration options for the scan, including camera direction and UI preferences.\n * @returns {Promise<OSBarcodeScanResult>} A promise that resolves with the scan result or rejects with an error.\n */\n async scanBarcode(options) {\n this.buildScannerElement();\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container-dialog').style.display = 'block';\n return new Promise((resolve, reject) => {\n var _a, _b;\n const param = {\n facingMode: options.cameraDirection === 1 ? 'environment' : 'user',\n hasScannerButton: false,\n scanButton: options.scanButton === undefined ? false : options.scanButton,\n showScanLine: false,\n scanInstructions: options.scanInstructions ? options.scanInstructions : '',\n orientation: options.scanOrientation\n ? options.scanOrientation\n : CapacitorBarcodeScannerScanOrientation.PORTRAIT,\n showCameraSelection: ((_a = options.web) === null || _a === void 0 ? void 0 : _a.showCameraSelection) ? options.web.showCameraSelection : false,\n typeHint: options.hint === 17 ? undefined : options.hint,\n scannerFPS: ((_b = options.web) === null || _b === void 0 ? void 0 : _b.scannerFPS) ? options.web.scannerFPS : 50,\n };\n // Set up and start the scanner\n const scannerElement = document.getElementById('cap-os-barcode-scanner-container-scanner');\n if (!scannerElement) {\n throw new Error('Scanner Element is required for web');\n }\n window.OSBarcodeWebScanner = new Html5Qrcode(scannerElement.id);\n const Html5QrcodeConfig = {\n fps: param.scannerFPS,\n qrbox: scannerElement.getBoundingClientRect().width * (9 / 16) - 10,\n aspectRatio: 16 / 9,\n videoConstraints: {\n focusMode: 'continuous',\n height: { min: 576, ideal: 1920 },\n deviceId: undefined,\n facingMode: param.facingMode,\n },\n };\n // Success and error callbacks for the scanner\n const OSBarcodeWebScannerSuccessCallback = (decodedText, _decodedResult) => {\n this.stopAndHideScanner();\n resolve({ ScanResult: decodedText });\n };\n const OSBarcodeWebScannerErrorCallback = (error) => {\n if (error.indexOf('NotFoundException') === -1 && error.indexOf('No barcode or QR code detected') === -1) {\n this.stopAndHideScanner();\n console.error(`[Scanner Web Error] ${error}`);\n reject(error);\n }\n };\n window.OSBarcodeWebScanner.start({ facingMode: param.facingMode }, Html5QrcodeConfig, OSBarcodeWebScannerSuccessCallback, OSBarcodeWebScannerErrorCallback);\n });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["CapacitorBarcodeScannerCameraDirection","CapacitorBarcodeScannerScanOrientation","CapacitorBarcodeScannerTypeHintALLOption","Html5QrcodeSupportedFormats","CapacitorBarcodeScannerAndroidScanningLibrary","registerPlugin","WebPlugin","Html5Qrcode"],"mappings":";;;;;;;AACA;AACA;AACA;AACWA,wDAAuC;AAClD,CAAC,UAAU,sCAAsC,EAAE;AACnD,IAAI,sCAAsC,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mBAAmB,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,EAAE,iBAAiB,EAAE,kCAAkC,EAAE,gCAAgC,CAAC,CAAC;AACxK,SAAS,CAAC,CAAC;AACX,KAAK;AACL;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/utils.js","esm/index.js","esm/web.js"],"sourcesContent":["import { Html5QrcodeSupportedFormats } from 'html5-qrcode';\n/**\n * Enum representing the direction of the camera to be used for barcode scanning.\n */\nexport var CapacitorBarcodeScannerCameraDirection;\n(function (CapacitorBarcodeScannerCameraDirection) {\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"BACK\"] = 1] = \"BACK\";\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"FRONT\"] = 2] = \"FRONT\";\n})(CapacitorBarcodeScannerCameraDirection || (CapacitorBarcodeScannerCameraDirection = {}));\n/**\n * Enum representing the orientation of the scanner during barcode scanning.\n */\nexport var CapacitorBarcodeScannerScanOrientation;\n(function (CapacitorBarcodeScannerScanOrientation) {\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"PORTRAIT\"] = 1] = \"PORTRAIT\";\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"LANDSCAPE\"] = 2] = \"LANDSCAPE\";\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"ADAPTIVE\"] = 3] = \"ADAPTIVE\";\n})(CapacitorBarcodeScannerScanOrientation || (CapacitorBarcodeScannerScanOrientation = {}));\n/**\n * Enum representing a special option to indicate that all barcode types are supported.\n */\nexport var CapacitorBarcodeScannerTypeHintALLOption;\n(function (CapacitorBarcodeScannerTypeHintALLOption) {\n CapacitorBarcodeScannerTypeHintALLOption[CapacitorBarcodeScannerTypeHintALLOption[\"ALL\"] = 17] = \"ALL\";\n})(CapacitorBarcodeScannerTypeHintALLOption || (CapacitorBarcodeScannerTypeHintALLOption = {}));\n/**\n * Extends supported formats from Html5Qrcode with a special 'ALL' option,\n * indicating support for all barcode types.\n */\nexport const CapacitorBarcodeScannerTypeHint = Object.assign(Object.assign({}, Html5QrcodeSupportedFormats), CapacitorBarcodeScannerTypeHintALLOption);\n/**\n * Enum representing the library to be used for barcode scanning on Android devices.\n */\nexport var CapacitorBarcodeScannerAndroidScanningLibrary;\n(function (CapacitorBarcodeScannerAndroidScanningLibrary) {\n CapacitorBarcodeScannerAndroidScanningLibrary[\"ZXING\"] = \"zxing\";\n CapacitorBarcodeScannerAndroidScanningLibrary[\"MLKIT\"] = \"mlkit\";\n})(CapacitorBarcodeScannerAndroidScanningLibrary || (CapacitorBarcodeScannerAndroidScanningLibrary = {}));\n//# sourceMappingURL=definitions.js.map","/**\n * Predefined CSS rules for styling barcode scanner components.\n * Each object in the array defines a CSS rule, with a selector and the CSS properties to apply.\n */\nexport const barcodeScannerCss = [\n { selector: '.scanner-container-display', css: 'display: block;' },\n {\n selector: '.scanner-dialog',\n css: 'display: none; position: fixed; z-index: 999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4);',\n },\n {\n selector: '.scanner-dialog-inner',\n css: 'background-color: #fefefe; margin: 2% auto; padding: 20px; border: 1px solid #888; width: 96%;',\n },\n { selector: '.close-button', css: 'color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer;' },\n { selector: '.close-button:hover', css: 'color: #222;' },\n { selector: '.scanner-container-full-width', css: 'width: 100%;' },\n];\n/**\n * Dynamically applies a set of CSS rules to the document.\n * If a custom style element with a specific ID does not exist, it is created and appended to the document's head.\n * Existing rules in the style element are cleared before new ones are applied.\n * This function supports both modern and older browsers by using `CSSStyleSheet.insertRule` and `textContent` respectively.\n *\n * @param {Array<{selector: string, css: string}>} cssRules - An array of objects containing CSS selectors and styles to apply.\n */\nexport function applyCss(cssRules) {\n const styleId = 'custom-style-os-cap-barcode'; // Unique identifier for the style element.\n let styleElement = document.getElementById(styleId);\n if (!styleElement) {\n // Create and append a new style element if it does not exist.\n styleElement = document.createElement('style');\n styleElement.type = 'text/css';\n styleElement.id = styleId;\n document.head.appendChild(styleElement);\n }\n if (styleElement.sheet) {\n // Clear existing CSS rules.\n while (styleElement.sheet.cssRules.length) {\n styleElement.sheet.deleteRule(0);\n }\n // Insert new CSS rules.\n for (const { selector, css } of cssRules) {\n styleElement.sheet.insertRule(`${selector} { ${css} }`);\n }\n }\n else {\n // Fallback for older browsers using textContent.\n styleElement.textContent = '';\n for (const { selector, css } of cssRules) {\n styleElement.textContent += `${selector} { ${css} }`;\n }\n }\n}\n//# sourceMappingURL=utils.js.map","import { registerPlugin } from '@capacitor/core';\nimport { CapacitorBarcodeScannerCameraDirection, CapacitorBarcodeScannerScanOrientation, } from './definitions'; // Importing the interface for type checking.\nimport { applyCss, barcodeScannerCss } from './utils'; // Import utilities for applying CSS.\n/**\n * Registers the `OSBarcode` plugin with Capacitor.\n * For web platforms, it applies necessary CSS for the barcode scanner and dynamically imports the web implementation.\n * This allows for lazy loading of the web code only when needed, optimizing overall bundle size.\n */\nconst CapacitorBarcodeScannerImpl = registerPlugin('CapacitorBarcodeScanner', {\n web: () => {\n applyCss(barcodeScannerCss); // Apply the CSS styles necessary for the web implementation of the barcode scanner.\n return import('./web').then((m) => new m.CapacitorBarcodeScannerWeb()); // Dynamically import the web implementation and instantiate it.\n },\n});\nclass CapacitorBarcodeScanner {\n static async scanBarcode(options) {\n options.scanInstructions = options.scanInstructions || ' '; // Ensure scanInstructions is at least a space.\n options.scanButton = options.scanButton || false; // Set scanButton to false if not provided.\n options.scanText = options.scanText || ' '; // Ensure scanText is at least a space.\n options.cameraDirection = options.cameraDirection || CapacitorBarcodeScannerCameraDirection.BACK; // Set cameraDirection to 'BACK' if not provided.\n options.scanOrientation = options.scanOrientation || CapacitorBarcodeScannerScanOrientation.ADAPTIVE; // Set scanOrientation to 'ADAPTIVE' if not provided.\n return CapacitorBarcodeScannerImpl.scanBarcode(options);\n }\n}\nexport { CapacitorBarcodeScanner }; // Export the `CapacitorBarcodeScanner` class.\nexport * from './definitions'; // Re-export all exports from the definitions file.\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { Html5Qrcode } from 'html5-qrcode';\nimport { CapacitorBarcodeScannerScanOrientation, CapacitorBarcodeScannerTypeHint } from './definitions';\n/**\n * Implements OSBarcodePlugin to provide web functionality for barcode scanning.\n */\nexport class CapacitorBarcodeScannerWeb extends WebPlugin {\n /**\n * Stops the barcode scanner and hides its UI.\n * @private\n * @returns {Promise<void>} A promise that resolves when the scanner has stopped and its UI is hidden.\n */\n async stopAndHideScanner() {\n console.log(window.OSBarcodeWebScanner);\n if (window.OSBarcodeWebScanner) {\n await window.OSBarcodeWebScanner.stop();\n window.OSBarcodeWebScanner = null;\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container-dialog').style.display = 'none';\n }\n /**\n * Builds the HTML elements necessary for the barcode scanner UI.\n * This method checks if the scanner container exists before creating it to avoid duplicates.\n * It also sets up the close button to stop and hide the scanner on click.\n * @private\n */\n buildScannerElement() {\n if (document.getElementById('cap-os-barcode-scanner-container')) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container').className = 'scanner-container-display';\n return;\n }\n // Create and configure scanner container elements\n const caposbarcodescannercontainer = document.body.appendChild(document.createElement('div'));\n caposbarcodescannercontainer.id = 'cap-os-barcode-scanner-container';\n const caposbarcodescannercontainerdialog = document.createElement('div');\n caposbarcodescannercontainerdialog.id = 'cap-os-barcode-scanner-container-dialog';\n caposbarcodescannercontainerdialog.className = 'scanner-dialog';\n // Inner dialog elements including the close button and scanner view\n const caposbarcodescannercontainerdialoginner = document.createElement('div');\n caposbarcodescannercontainerdialoginner.className = 'scanner-dialog-inner';\n const caposbarcodescannercontainerdialoginnerclose = document.createElement('span');\n caposbarcodescannercontainerdialoginnerclose.className = 'close-button';\n caposbarcodescannercontainerdialoginnerclose.innerHTML = '×';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnerclose);\n const caposbarcodescannercontainerdialoginnercontainerp = document.createElement('p');\n caposbarcodescannercontainerdialoginnercontainerp.innerHTML = ' ';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainerp);\n const caposbarcodescannercontainerdialoginnercontainer = document.createElement('div');\n caposbarcodescannercontainerdialoginnercontainer.className = 'scanner-container-full-width';\n caposbarcodescannercontainerdialoginnercontainer.id = 'cap-os-barcode-scanner-container-scanner';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainer);\n caposbarcodescannercontainerdialog.appendChild(caposbarcodescannercontainerdialoginner);\n caposbarcodescannercontainer.appendChild(caposbarcodescannercontainerdialog);\n caposbarcodescannercontainerdialoginnerclose.onclick = this.stopAndHideScanner;\n }\n /**\n * Initiates a barcode scan using the user's camera and HTML5 QR code scanner.\n * Displays the scanner UI and waits for a scan to complete or fail.\n * @param {OSBarcodeScanOptions} options Configuration options for the scan, including camera direction and UI preferences.\n * @returns {Promise<OSBarcodeScanResult>} A promise that resolves with the scan result or rejects with an error.\n */\n async scanBarcode(options) {\n this.buildScannerElement();\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container-dialog').style.display = 'block';\n return new Promise((resolve, reject) => {\n var _a, _b;\n const param = {\n facingMode: options.cameraDirection === 1 ? 'environment' : 'user',\n hasScannerButton: false,\n scanButton: options.scanButton === undefined ? false : options.scanButton,\n showScanLine: false,\n scanInstructions: options.scanInstructions ? options.scanInstructions : '',\n orientation: options.scanOrientation\n ? options.scanOrientation\n : CapacitorBarcodeScannerScanOrientation.PORTRAIT,\n showCameraSelection: ((_a = options.web) === null || _a === void 0 ? void 0 : _a.showCameraSelection) ? options.web.showCameraSelection : false,\n typeHint: options.hint === 17 ? undefined : options.hint,\n scannerFPS: ((_b = options.web) === null || _b === void 0 ? void 0 : _b.scannerFPS) ? options.web.scannerFPS : 50,\n };\n // Set up and start the scanner\n const scannerElement = document.getElementById('cap-os-barcode-scanner-container-scanner');\n if (!scannerElement) {\n throw new Error('Scanner Element is required for web');\n }\n window.OSBarcodeWebScanner = new Html5Qrcode(scannerElement.id, {\n formatsToSupport: param.typeHint !== undefined ? [param.typeHint] : undefined,\n verbose: undefined,\n });\n const Html5QrcodeConfig = {\n fps: param.scannerFPS,\n qrbox: scannerElement.getBoundingClientRect().width * (9 / 16) - 10,\n aspectRatio: 16 / 9,\n videoConstraints: {\n focusMode: 'continuous',\n height: { min: 576, ideal: 1920 },\n deviceId: undefined,\n facingMode: param.facingMode,\n },\n };\n // Success and error callbacks for the scanner\n const OSBarcodeWebScannerSuccessCallback = (decodedText, decodedResult) => {\n var _a, _b;\n this.stopAndHideScanner();\n resolve({\n ScanResult: decodedText,\n format: (_b = (_a = decodedResult.result.format) === null || _a === void 0 ? void 0 : _a.format) !== null && _b !== void 0 ? _b : CapacitorBarcodeScannerTypeHint.ALL,\n });\n };\n const OSBarcodeWebScannerErrorCallback = (error) => {\n const allowedErrors = [\n 'NotFoundException',\n 'No barcode or QR code detected',\n 'No MultiFormat Readers were able to detect the code',\n ];\n if (!allowedErrors.find((e) => error.indexOf(e) !== -1)) {\n this.stopAndHideScanner();\n console.error(`[Scanner Web Error] ${error}`);\n reject(error);\n }\n };\n window.OSBarcodeWebScanner.start({ facingMode: param.facingMode }, Html5QrcodeConfig, OSBarcodeWebScannerSuccessCallback, OSBarcodeWebScannerErrorCallback);\n });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["CapacitorBarcodeScannerCameraDirection","CapacitorBarcodeScannerScanOrientation","CapacitorBarcodeScannerTypeHintALLOption","Html5QrcodeSupportedFormats","CapacitorBarcodeScannerAndroidScanningLibrary","registerPlugin","WebPlugin","Html5Qrcode"],"mappings":";;;;;;;AACA;A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MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,EAAE,GAAG,+BAA+B,CAAC,GAAG;AACzL,iBAAiB,CAAC,CAAC;AACnB,aAAa,CAAC;AACd,YAAY,MAAM,gCAAgC,GAAG,CAAC,KAAK,KAAK;AAChE,gBAAgB,MAAM,aAAa,GAAG;AACtC,oBAAoB,mBAAmB;AACvC,oBAAoB,gCAAgC;AACpD,oBAAoB,qDAAqD;AACzE,iBAAiB,CAAC;AAClB,gBAAgB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;AACzE,oBAAoB,IAAI,CAAC,kBAAkB,EAAE,CAAC;AAC9C,oBAAoB,OAAO,CAAC,KAAK,CAAC,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAClE,oBAAoB,MAAM,CAAC,KAAK,CAAC,CAAC;AAClC,iBAAiB;AACjB,aAAa,CAAC;AACd,YAAY,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,EAAE,iBAAiB,EAAE,kCAAkC,EAAE,gCAAgC,CAAC,CAAC;AACxK,SAAS,CAAC,CAAC;AACX,KAAK;AACL;;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -200,7 +200,10 @@ var capacitorOSBarcode = (function (exports, core, html5Qrcode) {
|
|
|
200
200
|
if (!scannerElement) {
|
|
201
201
|
throw new Error('Scanner Element is required for web');
|
|
202
202
|
}
|
|
203
|
-
window.OSBarcodeWebScanner = new html5Qrcode.Html5Qrcode(scannerElement.id
|
|
203
|
+
window.OSBarcodeWebScanner = new html5Qrcode.Html5Qrcode(scannerElement.id, {
|
|
204
|
+
formatsToSupport: param.typeHint !== undefined ? [param.typeHint] : undefined,
|
|
205
|
+
verbose: undefined,
|
|
206
|
+
});
|
|
204
207
|
const Html5QrcodeConfig = {
|
|
205
208
|
fps: param.scannerFPS,
|
|
206
209
|
qrbox: scannerElement.getBoundingClientRect().width * (9 / 16) - 10,
|
|
@@ -213,12 +216,21 @@ var capacitorOSBarcode = (function (exports, core, html5Qrcode) {
|
|
|
213
216
|
},
|
|
214
217
|
};
|
|
215
218
|
// Success and error callbacks for the scanner
|
|
216
|
-
const OSBarcodeWebScannerSuccessCallback = (decodedText,
|
|
219
|
+
const OSBarcodeWebScannerSuccessCallback = (decodedText, decodedResult) => {
|
|
220
|
+
var _a, _b;
|
|
217
221
|
this.stopAndHideScanner();
|
|
218
|
-
resolve({
|
|
222
|
+
resolve({
|
|
223
|
+
ScanResult: decodedText,
|
|
224
|
+
format: (_b = (_a = decodedResult.result.format) === null || _a === void 0 ? void 0 : _a.format) !== null && _b !== void 0 ? _b : CapacitorBarcodeScannerTypeHint.ALL,
|
|
225
|
+
});
|
|
219
226
|
};
|
|
220
227
|
const OSBarcodeWebScannerErrorCallback = (error) => {
|
|
221
|
-
|
|
228
|
+
const allowedErrors = [
|
|
229
|
+
'NotFoundException',
|
|
230
|
+
'No barcode or QR code detected',
|
|
231
|
+
'No MultiFormat Readers were able to detect the code',
|
|
232
|
+
];
|
|
233
|
+
if (!allowedErrors.find((e) => error.indexOf(e) !== -1)) {
|
|
222
234
|
this.stopAndHideScanner();
|
|
223
235
|
console.error(`[Scanner Web Error] ${error}`);
|
|
224
236
|
reject(error);
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/utils.js","esm/index.js","esm/web.js"],"sourcesContent":["import { Html5QrcodeSupportedFormats } from 'html5-qrcode';\n/**\n * Enum representing the direction of the camera to be used for barcode scanning.\n */\nexport var CapacitorBarcodeScannerCameraDirection;\n(function (CapacitorBarcodeScannerCameraDirection) {\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"BACK\"] = 1] = \"BACK\";\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"FRONT\"] = 2] = \"FRONT\";\n})(CapacitorBarcodeScannerCameraDirection || (CapacitorBarcodeScannerCameraDirection = {}));\n/**\n * Enum representing the orientation of the scanner during barcode scanning.\n */\nexport var CapacitorBarcodeScannerScanOrientation;\n(function (CapacitorBarcodeScannerScanOrientation) {\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"PORTRAIT\"] = 1] = \"PORTRAIT\";\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"LANDSCAPE\"] = 2] = \"LANDSCAPE\";\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"ADAPTIVE\"] = 3] = \"ADAPTIVE\";\n})(CapacitorBarcodeScannerScanOrientation || (CapacitorBarcodeScannerScanOrientation = {}));\n/**\n * Enum representing a special option to indicate that all barcode types are supported.\n */\nexport var CapacitorBarcodeScannerTypeHintALLOption;\n(function (CapacitorBarcodeScannerTypeHintALLOption) {\n CapacitorBarcodeScannerTypeHintALLOption[CapacitorBarcodeScannerTypeHintALLOption[\"ALL\"] = 17] = \"ALL\";\n})(CapacitorBarcodeScannerTypeHintALLOption || (CapacitorBarcodeScannerTypeHintALLOption = {}));\n/**\n * Extends supported formats from Html5Qrcode with a special 'ALL' option,\n * indicating support for all barcode types.\n */\nexport const CapacitorBarcodeScannerTypeHint = Object.assign(Object.assign({}, Html5QrcodeSupportedFormats), CapacitorBarcodeScannerTypeHintALLOption);\n/**\n * Enum representing the library to be used for barcode scanning on Android devices.\n */\nexport var CapacitorBarcodeScannerAndroidScanningLibrary;\n(function (CapacitorBarcodeScannerAndroidScanningLibrary) {\n CapacitorBarcodeScannerAndroidScanningLibrary[\"ZXING\"] = \"zxing\";\n CapacitorBarcodeScannerAndroidScanningLibrary[\"MLKIT\"] = \"mlkit\";\n})(CapacitorBarcodeScannerAndroidScanningLibrary || (CapacitorBarcodeScannerAndroidScanningLibrary = {}));\n//# sourceMappingURL=definitions.js.map","/**\n * Predefined CSS rules for styling barcode scanner components.\n * Each object in the array defines a CSS rule, with a selector and the CSS properties to apply.\n */\nexport const barcodeScannerCss = [\n { selector: '.scanner-container-display', css: 'display: block;' },\n {\n selector: '.scanner-dialog',\n css: 'display: none; position: fixed; z-index: 999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4);',\n },\n {\n selector: '.scanner-dialog-inner',\n css: 'background-color: #fefefe; margin: 2% auto; padding: 20px; border: 1px solid #888; width: 96%;',\n },\n { selector: '.close-button', css: 'color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer;' },\n { selector: '.close-button:hover', css: 'color: #222;' },\n { selector: '.scanner-container-full-width', css: 'width: 100%;' },\n];\n/**\n * Dynamically applies a set of CSS rules to the document.\n * If a custom style element with a specific ID does not exist, it is created and appended to the document's head.\n * Existing rules in the style element are cleared before new ones are applied.\n * This function supports both modern and older browsers by using `CSSStyleSheet.insertRule` and `textContent` respectively.\n *\n * @param {Array<{selector: string, css: string}>} cssRules - An array of objects containing CSS selectors and styles to apply.\n */\nexport function applyCss(cssRules) {\n const styleId = 'custom-style-os-cap-barcode'; // Unique identifier for the style element.\n let styleElement = document.getElementById(styleId);\n if (!styleElement) {\n // Create and append a new style element if it does not exist.\n styleElement = document.createElement('style');\n styleElement.type = 'text/css';\n styleElement.id = styleId;\n document.head.appendChild(styleElement);\n }\n if (styleElement.sheet) {\n // Clear existing CSS rules.\n while (styleElement.sheet.cssRules.length) {\n styleElement.sheet.deleteRule(0);\n }\n // Insert new CSS rules.\n for (const { selector, css } of cssRules) {\n styleElement.sheet.insertRule(`${selector} { ${css} }`);\n }\n }\n else {\n // Fallback for older browsers using textContent.\n styleElement.textContent = '';\n for (const { selector, css } of cssRules) {\n styleElement.textContent += `${selector} { ${css} }`;\n }\n }\n}\n//# sourceMappingURL=utils.js.map","import { registerPlugin } from '@capacitor/core';\nimport { CapacitorBarcodeScannerCameraDirection, CapacitorBarcodeScannerScanOrientation, } from './definitions'; // Importing the interface for type checking.\nimport { applyCss, barcodeScannerCss } from './utils'; // Import utilities for applying CSS.\n/**\n * Registers the `OSBarcode` plugin with Capacitor.\n * For web platforms, it applies necessary CSS for the barcode scanner and dynamically imports the web implementation.\n * This allows for lazy loading of the web code only when needed, optimizing overall bundle size.\n */\nconst CapacitorBarcodeScannerImpl = registerPlugin('CapacitorBarcodeScanner', {\n web: () => {\n applyCss(barcodeScannerCss); // Apply the CSS styles necessary for the web implementation of the barcode scanner.\n return import('./web').then((m) => new m.CapacitorBarcodeScannerWeb()); // Dynamically import the web implementation and instantiate it.\n },\n});\nclass CapacitorBarcodeScanner {\n static async scanBarcode(options) {\n options.scanInstructions = options.scanInstructions || ' '; // Ensure scanInstructions is at least a space.\n options.scanButton = options.scanButton || false; // Set scanButton to false if not provided.\n options.scanText = options.scanText || ' '; // Ensure scanText is at least a space.\n options.cameraDirection = options.cameraDirection || CapacitorBarcodeScannerCameraDirection.BACK; // Set cameraDirection to 'BACK' if not provided.\n options.scanOrientation = options.scanOrientation || CapacitorBarcodeScannerScanOrientation.ADAPTIVE; // Set scanOrientation to 'ADAPTIVE' if not provided.\n return CapacitorBarcodeScannerImpl.scanBarcode(options);\n }\n}\nexport { CapacitorBarcodeScanner }; // Export the `CapacitorBarcodeScanner` class.\nexport * from './definitions'; // Re-export all exports from the definitions file.\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { Html5Qrcode } from 'html5-qrcode';\nimport { CapacitorBarcodeScannerScanOrientation } from './definitions';\n/**\n * Implements OSBarcodePlugin to provide web functionality for barcode scanning.\n */\nexport class CapacitorBarcodeScannerWeb extends WebPlugin {\n /**\n * Stops the barcode scanner and hides its UI.\n * @private\n * @returns {Promise<void>} A promise that resolves when the scanner has stopped and its UI is hidden.\n */\n async stopAndHideScanner() {\n console.log(window.OSBarcodeWebScanner);\n if (window.OSBarcodeWebScanner) {\n await window.OSBarcodeWebScanner.stop();\n window.OSBarcodeWebScanner = null;\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container-dialog').style.display = 'none';\n }\n /**\n * Builds the HTML elements necessary for the barcode scanner UI.\n * This method checks if the scanner container exists before creating it to avoid duplicates.\n * It also sets up the close button to stop and hide the scanner on click.\n * @private\n */\n buildScannerElement() {\n if (document.getElementById('cap-os-barcode-scanner-container')) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container').className = 'scanner-container-display';\n return;\n }\n // Create and configure scanner container elements\n const caposbarcodescannercontainer = document.body.appendChild(document.createElement('div'));\n caposbarcodescannercontainer.id = 'cap-os-barcode-scanner-container';\n const caposbarcodescannercontainerdialog = document.createElement('div');\n caposbarcodescannercontainerdialog.id = 'cap-os-barcode-scanner-container-dialog';\n caposbarcodescannercontainerdialog.className = 'scanner-dialog';\n // Inner dialog elements including the close button and scanner view\n const caposbarcodescannercontainerdialoginner = document.createElement('div');\n caposbarcodescannercontainerdialoginner.className = 'scanner-dialog-inner';\n const caposbarcodescannercontainerdialoginnerclose = document.createElement('span');\n caposbarcodescannercontainerdialoginnerclose.className = 'close-button';\n caposbarcodescannercontainerdialoginnerclose.innerHTML = '×';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnerclose);\n const caposbarcodescannercontainerdialoginnercontainerp = document.createElement('p');\n caposbarcodescannercontainerdialoginnercontainerp.innerHTML = ' ';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainerp);\n const caposbarcodescannercontainerdialoginnercontainer = document.createElement('div');\n caposbarcodescannercontainerdialoginnercontainer.className = 'scanner-container-full-width';\n caposbarcodescannercontainerdialoginnercontainer.id = 'cap-os-barcode-scanner-container-scanner';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainer);\n caposbarcodescannercontainerdialog.appendChild(caposbarcodescannercontainerdialoginner);\n caposbarcodescannercontainer.appendChild(caposbarcodescannercontainerdialog);\n caposbarcodescannercontainerdialoginnerclose.onclick = this.stopAndHideScanner;\n }\n /**\n * Initiates a barcode scan using the user's camera and HTML5 QR code scanner.\n * Displays the scanner UI and waits for a scan to complete or fail.\n * @param {OSBarcodeScanOptions} options Configuration options for the scan, including camera direction and UI preferences.\n * @returns {Promise<OSBarcodeScanResult>} A promise that resolves with the scan result or rejects with an error.\n */\n async scanBarcode(options) {\n this.buildScannerElement();\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container-dialog').style.display = 'block';\n return new Promise((resolve, reject) => {\n var _a, _b;\n const param = {\n facingMode: options.cameraDirection === 1 ? 'environment' : 'user',\n hasScannerButton: false,\n scanButton: options.scanButton === undefined ? false : options.scanButton,\n showScanLine: false,\n scanInstructions: options.scanInstructions ? options.scanInstructions : '',\n orientation: options.scanOrientation\n ? options.scanOrientation\n : CapacitorBarcodeScannerScanOrientation.PORTRAIT,\n showCameraSelection: ((_a = options.web) === null || _a === void 0 ? void 0 : _a.showCameraSelection) ? options.web.showCameraSelection : false,\n typeHint: options.hint === 17 ? undefined : options.hint,\n scannerFPS: ((_b = options.web) === null || _b === void 0 ? void 0 : _b.scannerFPS) ? options.web.scannerFPS : 50,\n };\n // Set up and start the scanner\n const scannerElement = document.getElementById('cap-os-barcode-scanner-container-scanner');\n if (!scannerElement) {\n throw new Error('Scanner Element is required for web');\n }\n window.OSBarcodeWebScanner = new Html5Qrcode(scannerElement.id);\n const Html5QrcodeConfig = {\n fps: param.scannerFPS,\n qrbox: scannerElement.getBoundingClientRect().width * (9 / 16) - 10,\n aspectRatio: 16 / 9,\n videoConstraints: {\n focusMode: 'continuous',\n height: { min: 576, ideal: 1920 },\n deviceId: undefined,\n facingMode: param.facingMode,\n },\n };\n // Success and error callbacks for the scanner\n const OSBarcodeWebScannerSuccessCallback = (decodedText, _decodedResult) => {\n this.stopAndHideScanner();\n resolve({ ScanResult: decodedText });\n };\n const OSBarcodeWebScannerErrorCallback = (error) => {\n if (error.indexOf('NotFoundException') === -1 && error.indexOf('No barcode or QR code detected') === -1) {\n this.stopAndHideScanner();\n console.error(`[Scanner Web Error] ${error}`);\n reject(error);\n }\n };\n window.OSBarcodeWebScanner.start({ facingMode: param.facingMode }, Html5QrcodeConfig, OSBarcodeWebScannerSuccessCallback, OSBarcodeWebScannerErrorCallback);\n });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["CapacitorBarcodeScannerCameraDirection","CapacitorBarcodeScannerScanOrientation","CapacitorBarcodeScannerTypeHintALLOption","Html5QrcodeSupportedFormats","CapacitorBarcodeScannerAndroidScanningLibrary","registerPlugin","WebPlugin","Html5Qrcode"],"mappings":";;;IACA;IACA;IACA;AACWA,4DAAuC;IAClD,CAAC,UAAU,sCAAsC,EAAE;IACnD,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;IACxG,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC;IAC1G,CAAC,EAAEA,8CAAsC,KAAKA,8CAAsC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC5F;IACA;IACA;AACWC,4DAAuC;IAClD,CAAC,UAAU,sCAAsC,EAAE;IACnD,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;IAChH,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC;IAClH,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;IAChH,CAAC,EAAEA,8CAAsC,KAAKA,8CAAsC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC5F;IACA;IACA;AACWC,8DAAyC;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xF,gBAAgB,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC1C,gBAAgB,OAAO,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;IACrD,aAAa,CAAC;IACd,YAAY,MAAM,gCAAgC,GAAG,CAAC,KAAK,KAAK;IAChE,gBAAgB,IAAI,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,gCAAgC,CAAC,KAAK,CAAC,CAAC,EAAE;IACzH,oBAAoB,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC9C,oBAAoB,OAAO,CAAC,KAAK,CAAC,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAClE,oBAAoB,MAAM,CAAC,KAAK,CAAC,CAAC;IAClC,iBAAiB;IACjB,aAAa,CAAC;IACd,YAAY,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,EAAE,iBAAiB,EAAE,kCAAkC,EAAE,gCAAgC,CAAC,CAAC;IACxK,SAAS,CAAC,CAAC;IACX,KAAK;IACL;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/utils.js","esm/index.js","esm/web.js"],"sourcesContent":["import { Html5QrcodeSupportedFormats } from 'html5-qrcode';\n/**\n * Enum representing the direction of the camera to be used for barcode scanning.\n */\nexport var CapacitorBarcodeScannerCameraDirection;\n(function (CapacitorBarcodeScannerCameraDirection) {\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"BACK\"] = 1] = \"BACK\";\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"FRONT\"] = 2] = \"FRONT\";\n})(CapacitorBarcodeScannerCameraDirection || (CapacitorBarcodeScannerCameraDirection = {}));\n/**\n * Enum representing the orientation of the scanner during barcode scanning.\n */\nexport var CapacitorBarcodeScannerScanOrientation;\n(function (CapacitorBarcodeScannerScanOrientation) {\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"PORTRAIT\"] = 1] = \"PORTRAIT\";\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"LANDSCAPE\"] = 2] = \"LANDSCAPE\";\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"ADAPTIVE\"] = 3] = \"ADAPTIVE\";\n})(CapacitorBarcodeScannerScanOrientation || (CapacitorBarcodeScannerScanOrientation = {}));\n/**\n * Enum representing a special option to indicate that all barcode types are supported.\n */\nexport var CapacitorBarcodeScannerTypeHintALLOption;\n(function (CapacitorBarcodeScannerTypeHintALLOption) {\n CapacitorBarcodeScannerTypeHintALLOption[CapacitorBarcodeScannerTypeHintALLOption[\"ALL\"] = 17] = \"ALL\";\n})(CapacitorBarcodeScannerTypeHintALLOption || (CapacitorBarcodeScannerTypeHintALLOption = {}));\n/**\n * Extends supported formats from Html5Qrcode with a special 'ALL' option,\n * indicating support for all barcode types.\n */\nexport const CapacitorBarcodeScannerTypeHint = Object.assign(Object.assign({}, Html5QrcodeSupportedFormats), CapacitorBarcodeScannerTypeHintALLOption);\n/**\n * Enum representing the library to be used for barcode scanning on Android devices.\n */\nexport var CapacitorBarcodeScannerAndroidScanningLibrary;\n(function (CapacitorBarcodeScannerAndroidScanningLibrary) {\n CapacitorBarcodeScannerAndroidScanningLibrary[\"ZXING\"] = \"zxing\";\n CapacitorBarcodeScannerAndroidScanningLibrary[\"MLKIT\"] = \"mlkit\";\n})(CapacitorBarcodeScannerAndroidScanningLibrary || (CapacitorBarcodeScannerAndroidScanningLibrary = {}));\n//# sourceMappingURL=definitions.js.map","/**\n * Predefined CSS rules for styling barcode scanner components.\n * Each object in the array defines a CSS rule, with a selector and the CSS properties to apply.\n */\nexport const barcodeScannerCss = [\n { selector: '.scanner-container-display', css: 'display: block;' },\n {\n selector: '.scanner-dialog',\n css: 'display: none; position: fixed; z-index: 999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4);',\n },\n {\n selector: '.scanner-dialog-inner',\n css: 'background-color: #fefefe; margin: 2% auto; padding: 20px; border: 1px solid #888; width: 96%;',\n },\n { selector: '.close-button', css: 'color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer;' },\n { selector: '.close-button:hover', css: 'color: #222;' },\n { selector: '.scanner-container-full-width', css: 'width: 100%;' },\n];\n/**\n * Dynamically applies a set of CSS rules to the document.\n * If a custom style element with a specific ID does not exist, it is created and appended to the document's head.\n * Existing rules in the style element are cleared before new ones are applied.\n * This function supports both modern and older browsers by using `CSSStyleSheet.insertRule` and `textContent` respectively.\n *\n * @param {Array<{selector: string, css: string}>} cssRules - An array of objects containing CSS selectors and styles to apply.\n */\nexport function applyCss(cssRules) {\n const styleId = 'custom-style-os-cap-barcode'; // Unique identifier for the style element.\n let styleElement = document.getElementById(styleId);\n if (!styleElement) {\n // Create and append a new style element if it does not exist.\n styleElement = document.createElement('style');\n styleElement.type = 'text/css';\n styleElement.id = styleId;\n document.head.appendChild(styleElement);\n }\n if (styleElement.sheet) {\n // Clear existing CSS rules.\n while (styleElement.sheet.cssRules.length) {\n styleElement.sheet.deleteRule(0);\n }\n // Insert new CSS rules.\n for (const { selector, css } of cssRules) {\n styleElement.sheet.insertRule(`${selector} { ${css} }`);\n }\n }\n else {\n // Fallback for older browsers using textContent.\n styleElement.textContent = '';\n for (const { selector, css } of cssRules) {\n styleElement.textContent += `${selector} { ${css} }`;\n }\n }\n}\n//# sourceMappingURL=utils.js.map","import { registerPlugin } from '@capacitor/core';\nimport { CapacitorBarcodeScannerCameraDirection, CapacitorBarcodeScannerScanOrientation, } from './definitions'; // Importing the interface for type checking.\nimport { applyCss, barcodeScannerCss } from './utils'; // Import utilities for applying CSS.\n/**\n * Registers the `OSBarcode` plugin with Capacitor.\n * For web platforms, it applies necessary CSS for the barcode scanner and dynamically imports the web implementation.\n * This allows for lazy loading of the web code only when needed, optimizing overall bundle size.\n */\nconst CapacitorBarcodeScannerImpl = registerPlugin('CapacitorBarcodeScanner', {\n web: () => {\n applyCss(barcodeScannerCss); // Apply the CSS styles necessary for the web implementation of the barcode scanner.\n return import('./web').then((m) => new m.CapacitorBarcodeScannerWeb()); // Dynamically import the web implementation and instantiate it.\n },\n});\nclass CapacitorBarcodeScanner {\n static async scanBarcode(options) {\n options.scanInstructions = options.scanInstructions || ' '; // Ensure scanInstructions is at least a space.\n options.scanButton = options.scanButton || false; // Set scanButton to false if not provided.\n options.scanText = options.scanText || ' '; // Ensure scanText is at least a space.\n options.cameraDirection = options.cameraDirection || CapacitorBarcodeScannerCameraDirection.BACK; // Set cameraDirection to 'BACK' if not provided.\n options.scanOrientation = options.scanOrientation || CapacitorBarcodeScannerScanOrientation.ADAPTIVE; // Set scanOrientation to 'ADAPTIVE' if not provided.\n return CapacitorBarcodeScannerImpl.scanBarcode(options);\n }\n}\nexport { CapacitorBarcodeScanner }; // Export the `CapacitorBarcodeScanner` class.\nexport * from './definitions'; // Re-export all exports from the definitions file.\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { Html5Qrcode } from 'html5-qrcode';\nimport { CapacitorBarcodeScannerScanOrientation, CapacitorBarcodeScannerTypeHint } from './definitions';\n/**\n * Implements OSBarcodePlugin to provide web functionality for barcode scanning.\n */\nexport class CapacitorBarcodeScannerWeb extends WebPlugin {\n /**\n * Stops the barcode scanner and hides its UI.\n * @private\n * @returns {Promise<void>} A promise that resolves when the scanner has stopped and its UI is hidden.\n */\n async stopAndHideScanner() {\n console.log(window.OSBarcodeWebScanner);\n if (window.OSBarcodeWebScanner) {\n await window.OSBarcodeWebScanner.stop();\n window.OSBarcodeWebScanner = null;\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container-dialog').style.display = 'none';\n }\n /**\n * Builds the HTML elements necessary for the barcode scanner UI.\n * This method checks if the scanner container exists before creating it to avoid duplicates.\n * It also sets up the close button to stop and hide the scanner on click.\n * @private\n */\n buildScannerElement() {\n if (document.getElementById('cap-os-barcode-scanner-container')) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container').className = 'scanner-container-display';\n return;\n }\n // Create and configure scanner container elements\n const caposbarcodescannercontainer = document.body.appendChild(document.createElement('div'));\n caposbarcodescannercontainer.id = 'cap-os-barcode-scanner-container';\n const caposbarcodescannercontainerdialog = document.createElement('div');\n caposbarcodescannercontainerdialog.id = 'cap-os-barcode-scanner-container-dialog';\n caposbarcodescannercontainerdialog.className = 'scanner-dialog';\n // Inner dialog elements including the close button and scanner view\n const caposbarcodescannercontainerdialoginner = document.createElement('div');\n caposbarcodescannercontainerdialoginner.className = 'scanner-dialog-inner';\n const caposbarcodescannercontainerdialoginnerclose = document.createElement('span');\n caposbarcodescannercontainerdialoginnerclose.className = 'close-button';\n caposbarcodescannercontainerdialoginnerclose.innerHTML = '×';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnerclose);\n const caposbarcodescannercontainerdialoginnercontainerp = document.createElement('p');\n caposbarcodescannercontainerdialoginnercontainerp.innerHTML = ' ';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainerp);\n const caposbarcodescannercontainerdialoginnercontainer = document.createElement('div');\n caposbarcodescannercontainerdialoginnercontainer.className = 'scanner-container-full-width';\n caposbarcodescannercontainerdialoginnercontainer.id = 'cap-os-barcode-scanner-container-scanner';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainer);\n caposbarcodescannercontainerdialog.appendChild(caposbarcodescannercontainerdialoginner);\n caposbarcodescannercontainer.appendChild(caposbarcodescannercontainerdialog);\n caposbarcodescannercontainerdialoginnerclose.onclick = this.stopAndHideScanner;\n }\n /**\n * Initiates a barcode scan using the user's camera and HTML5 QR code scanner.\n * Displays the scanner UI and waits for a scan to complete or fail.\n * @param {OSBarcodeScanOptions} options Configuration options for the scan, including camera direction and UI preferences.\n * @returns {Promise<OSBarcodeScanResult>} A promise that resolves with the scan result or rejects with an error.\n */\n async scanBarcode(options) {\n this.buildScannerElement();\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container-dialog').style.display = 'block';\n return new Promise((resolve, reject) => {\n var _a, _b;\n const param = {\n facingMode: options.cameraDirection === 1 ? 'environment' : 'user',\n hasScannerButton: false,\n scanButton: options.scanButton === undefined ? false : options.scanButton,\n showScanLine: false,\n scanInstructions: options.scanInstructions ? options.scanInstructions : '',\n orientation: options.scanOrientation\n ? options.scanOrientation\n : CapacitorBarcodeScannerScanOrientation.PORTRAIT,\n showCameraSelection: ((_a = options.web) === null || _a === void 0 ? void 0 : _a.showCameraSelection) ? options.web.showCameraSelection : false,\n typeHint: options.hint === 17 ? undefined : options.hint,\n scannerFPS: ((_b = options.web) === null || _b === void 0 ? void 0 : _b.scannerFPS) ? options.web.scannerFPS : 50,\n };\n // Set up and start the scanner\n const scannerElement = document.getElementById('cap-os-barcode-scanner-container-scanner');\n if (!scannerElement) {\n throw new Error('Scanner Element is required for web');\n }\n window.OSBarcodeWebScanner = new Html5Qrcode(scannerElement.id, {\n formatsToSupport: param.typeHint !== undefined ? [param.typeHint] : undefined,\n verbose: undefined,\n });\n const Html5QrcodeConfig = {\n fps: param.scannerFPS,\n qrbox: scannerElement.getBoundingClientRect().width * (9 / 16) - 10,\n aspectRatio: 16 / 9,\n videoConstraints: {\n focusMode: 'continuous',\n height: { min: 576, ideal: 1920 },\n deviceId: undefined,\n facingMode: param.facingMode,\n },\n };\n // Success and error callbacks for the scanner\n const OSBarcodeWebScannerSuccessCallback = (decodedText, decodedResult) => {\n var _a, _b;\n this.stopAndHideScanner();\n resolve({\n ScanResult: decodedText,\n format: (_b = (_a = decodedResult.result.format) === null || _a === void 0 ? void 0 : _a.format) !== null && _b !== void 0 ? _b : CapacitorBarcodeScannerTypeHint.ALL,\n });\n };\n const OSBarcodeWebScannerErrorCallback = (error) => {\n const allowedErrors = [\n 'NotFoundException',\n 'No barcode or QR code detected',\n 'No MultiFormat Readers were able to detect the code',\n ];\n if (!allowedErrors.find((e) => error.indexOf(e) !== -1)) {\n this.stopAndHideScanner();\n console.error(`[Scanner Web Error] ${error}`);\n reject(error);\n }\n };\n window.OSBarcodeWebScanner.start({ facingMode: param.facingMode }, Html5QrcodeConfig, OSBarcodeWebScannerSuccessCallback, OSBarcodeWebScannerErrorCallback);\n });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["CapacitorBarcodeScannerCameraDirection","CapacitorBarcodeScannerScanOrientation","CapacitorBarcodeScannerTypeHintALLOption","Html5QrcodeSupportedFormats","CapacitorBarcodeScannerAndroidScanningLibrary","registerPlugin","WebPlugin","Html5Qrcode"],"mappings":";;;IACA;IACA;IACA;AACWA,4DAAuC;IAClD,CAAC,UAAU,sCAAsC,EAAE;IACnD,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;IACxG,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC;IAC1G,CAAC,EAAEA,8CAAsC,KAAKA,8CAAsC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC5F;IACA;IACA;AACWC,4DAAuC;IAClD,CAAC,UAAU,sCAAsC,EAAE;IACnD,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;IAChH,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC;IAClH,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;IAChH,CAAC,EAAEA,8CAAsC,K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mBAAmB,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,EAAE,iBAAiB,EAAE,kCAAkC,EAAE,gCAAgC,CAAC,CAAC;IACxK,SAAS,CAAC,CAAC;IACX,KAAK;IACL;;;;;;;;;;;;;;;;;;"}
|
|
@@ -27,15 +27,15 @@ public class CapacitorBarcodeScannerPlugin: CAPPlugin {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
guard let argumentsData = try? JSONSerialization.data(withJSONObject: call.jsObjectRepresentation),
|
|
30
|
-
let scanArguments = try? JSONDecoder().decode(
|
|
30
|
+
let scanArguments = try? JSONDecoder().decode(OSBARCScanParameters.self, from: argumentsData) else {
|
|
31
31
|
call.sendError(with: OSBarcodeError.scanInputArgumentsIssue)
|
|
32
32
|
return
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
Task {
|
|
36
36
|
do {
|
|
37
|
-
let scannedBarcode = try await manager.scanBarcode(with: scanArguments
|
|
38
|
-
call.resolve(["ScanResult": scannedBarcode])
|
|
37
|
+
let scannedBarcode = try await manager.scanBarcode(with: scanArguments)
|
|
38
|
+
call.resolve(["ScanResult": scannedBarcode.text, "format": scannedBarcode.format.rawValue])
|
|
39
39
|
} catch OSBARCManagerError.cameraAccessDenied {
|
|
40
40
|
call.sendError(with: OSBarcodeError.cameraAccessDenied)
|
|
41
41
|
} catch OSBARCManagerError.scanningCancelled {
|
|
@@ -48,9 +48,9 @@ public class CapacitorBarcodeScannerPlugin: CAPPlugin {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
extension CAPPluginCall {
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
func sendError(with error: OSBarcodeError) {
|
|
53
53
|
self.reject(error.errorDescription, error.errorCode)
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
}
|
package/ios/Plugin/{OSBarcodeScanArgumentsModel.swift → OSBARCScanParameters+Decodable.swift}
RENAMED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import OSBarcodeLib
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
let scanInstructions: String
|
|
6
|
-
let scanButtonText: String?
|
|
7
|
-
let cameraDirection: OSBARCCameraModel
|
|
8
|
-
let scanOrientation: OSBARCOrientationModel
|
|
4
|
+
extension OSBARCScanParameters: Decodable {
|
|
9
5
|
|
|
10
6
|
enum CodingKeys: CodingKey {
|
|
11
7
|
case scanButton
|
|
@@ -13,9 +9,10 @@ struct OSBarcodeScanArgumentsModel: Decodable {
|
|
|
13
9
|
case scanText
|
|
14
10
|
case cameraDirection
|
|
15
11
|
case scanOrientation
|
|
12
|
+
case hint
|
|
16
13
|
}
|
|
17
14
|
|
|
18
|
-
init(from decoder: Decoder) throws {
|
|
15
|
+
public init(from decoder: Decoder) throws {
|
|
19
16
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
20
17
|
|
|
21
18
|
let scanInstructions = try container.decode(String.self, forKey: .scanInstructions)
|
|
@@ -32,13 +29,15 @@ struct OSBarcodeScanArgumentsModel: Decodable {
|
|
|
32
29
|
let scanOrientationInt = try container.decode(Int.self, forKey: .scanOrientation)
|
|
33
30
|
let scanOrientation = OSBARCOrientationModel.map(value: scanOrientationInt)
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
let hintInt = try container.decode(Int.self, forKey: .hint)
|
|
33
|
+
let hint = OSBARCScannerHint(rawValue: hintInt)
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
self.init(
|
|
36
|
+
scanInstructions: scanInstructions,
|
|
37
|
+
scanButtonText: scanButtonText,
|
|
38
|
+
cameraDirection: cameraDirection,
|
|
39
|
+
scanOrientation: scanOrientation,
|
|
40
|
+
hint: hint
|
|
41
|
+
)
|
|
43
42
|
}
|
|
44
43
|
}
|
|
@@ -22,7 +22,7 @@ enum OSBarcodeError: Int, CustomNSError, LocalizedError {
|
|
|
22
22
|
case .bridgeNotInitialized: return "Capacitor bridge or viewController is not initialized."
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
var errorCode: String {
|
|
27
27
|
return "\(OSBarcodeErrorLabels.codeFormat)\(String(format: "%04d", self.rawValue))"
|
|
28
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/barcode-scanner",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0-dev.1",
|
|
4
4
|
"description": "Capacitor plugin using Outsystems Barcode libs",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"html5-qrcode": "2.3.8"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@capacitor/android": "
|
|
55
|
-
"@capacitor/core": "
|
|
54
|
+
"@capacitor/android": "^7.0.0",
|
|
55
|
+
"@capacitor/core": "^7.0.0",
|
|
56
56
|
"@capacitor/docgen": "^0.2.2",
|
|
57
|
-
"@capacitor/ios": "
|
|
57
|
+
"@capacitor/ios": "^7.0.0",
|
|
58
58
|
"@ionic/swiftlint-config": "^1.1.2",
|
|
59
59
|
"@types/node": "~20.12.4",
|
|
60
60
|
"@typescript-eslint/eslint-plugin": "^5.59.2",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"rimraf": "^3.0.2",
|
|
67
67
|
"rollup": "^2.78.1",
|
|
68
68
|
"swiftlint": "^1.0.2",
|
|
69
|
-
"typescript": "
|
|
69
|
+
"typescript": "~5.7.2"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"@capacitor/core": ">=7.0.0"
|
|
@@ -79,6 +79,5 @@
|
|
|
79
79
|
"android": {
|
|
80
80
|
"src": "android"
|
|
81
81
|
}
|
|
82
|
-
}
|
|
83
|
-
"gitHead": "f0f81c487d21316ff48d5bdf4acb4c0544c3c172"
|
|
82
|
+
}
|
|
84
83
|
}
|