Skip to content

Commit 7e2452b

Browse files
authored
feat(dynamsoft barcode scanner): update plugin (#4176)
BREAKING: original plugin is replaced by https://github.com/xulihang/cordova-plugin-dynamsoft-barcode-reader
1 parent 5f9f58e commit 7e2452b

File tree

3 files changed

+130
-87
lines changed

3 files changed

+130
-87
lines changed
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
# Dynamsoft Barcode Scanner
22

33
```
4-
$ git clone https://github.com/Dynamsoft/cordova-plugin-dbr/
5-
$ ionic cordova plugin add cordova-plugin-dbr
4+
$ ionic cordova plugin add cordova-plugin-dynamsoft-barcode-reader
65
$ npm install @awesome-cordova-plugins/dynamsoft-barcode-scanner
76
```
87

98
## [Usage Documentation](https://danielsogl.gitbook.io/awesome-cordova-plugins/plugins/dynamsoft-barcode-scanner/)
109

11-
Plugin Repo: [https://github.com/Dynamsoft/cordova-plugin-dbr/](https://github.com/Dynamsoft/cordova-plugin-dbr/)
10+
Plugin Repo: [https://github.com/xulihang/cordova-plugin-dynamsoft-barcode-reader](https://github.com/xulihang/cordova-plugin-dynamsoft-barcode-reader)
1211

13-
The Dynamsoft Barcode Scanner Plugin opens a camera view and automatically scans a barcode, returning the data back to you.
12+
The Dynamsoft Barcode Scanner Plugin can read barcodes from images as well as camera previews.
1413

1514
## Supported platforms
1615

17-
- Android
18-
- iOS
16+
* Android
17+
* iOS
1918

2019

2120

docs/plugins/dynamsoft-barcode-scanner/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# Dynamsoft Barcode Scanner
22

33
```
4-
$ git clone https://github.com/Dynamsoft/cordova-plugin-dbr/
5-
$ ionic cordova plugin add cordova-plugin-dbr
4+
$ ionic cordova plugin add cordova-plugin-dynamsoft-barcode-reader
65
$ npm install @awesome-cordova-plugins/dynamsoft-barcode-scanner
76
```
87

98
## [Usage Documentation](https://danielsogl.gitbook.io/awesome-cordova-plugins/plugins/dynamsoft-barcode-scanner/)
109

11-
Plugin Repo: [https://github.com/Dynamsoft/cordova-plugin-dbr/](https://github.com/Dynamsoft/cordova-plugin-dbr/)
10+
Plugin Repo: [https://github.com/xulihang/cordova-plugin-dynamsoft-barcode-reader](https://github.com/xulihang/cordova-plugin-dynamsoft-barcode-reader)
1211

13-
The Dynamsoft Barcode Scanner Plugin opens a camera view and automatically scans a barcode, returning the data back to you.
12+
The Dynamsoft Barcode Scanner Plugin can read barcodes from images as well as camera previews.
1413

1514
## Supported platforms
1615

src/@awesome-cordova-plugins/plugins/dynamsoft-barcode-scanner/index.ts

Lines changed: 122 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -9,114 +9,159 @@ import {
99
} from '@awesome-cordova-plugins/core';
1010
import { Observable } from 'rxjs';
1111

12-
export interface BarcodeScannerOptions {
13-
/**
14-
* Prefer front camera. Supported on iOS and Android.
15-
*/
16-
preferFrontCamera?: boolean;
17-
18-
/**
19-
* Show flip camera button. Supported on iOS and Android.
20-
*/
21-
showFlipCameraButton?: boolean;
12+
export interface FrameResult {
13+
frameWidth: number;
14+
frameHeight: number;
15+
results: BarcodeResult[];
16+
}
2217

23-
/**
24-
* Show torch button. Supported on iOS and Android.
25-
*/
26-
showTorchButton?: boolean;
18+
export interface BarcodeResult {
19+
barcodeText: string;
20+
barcodeFormat: string;
21+
x1: number;
22+
x2: number;
23+
x3: number;
24+
x4: number;
25+
y1: number;
26+
y2: number;
27+
y3: number;
28+
y4: number;
29+
}
2730

31+
/**
32+
* @name dynamsoft-barcode-scanner
33+
* @description
34+
* This plugin scans barcodes using Dynamsoft Barcode Reader
35+
*
36+
* @usage
37+
* ```typescript
38+
* import { dynamsoft-barcode-scanner } from '@awesome-cordova-plugins/dynamsoft-barcode-scanner';
39+
*
40+
*
41+
* constructor(private dynamsoft-barcode-scanner: dynamsoft-barcode-scanner) { }
42+
*
43+
* ...
44+
*
45+
*
46+
* await this.dynamsoft-barcode-scanner.init("license");
47+
* this.dynamsoft-barcode-scanner.startScanning("license").subscribe(result => {
48+
console.log(result);
49+
});
50+
*
51+
* ```
52+
*/
53+
@Plugin({
54+
pluginName: 'dynamsoft-barcode-scanner',
55+
plugin: 'cordova-plugin-dynamsoft-barcode-reader',
56+
pluginRef: 'cordova.plugins.DBR',
57+
repo: 'https://github.com/xulihang/cordova-plugin-dynamsoft-barcode-reader',
58+
install: '',
59+
installVariables: [],
60+
platforms: ['Android', 'iOS'],
61+
})
62+
@Injectable()
63+
export class BarcodeScanner extends AwesomeCordovaNativePlugin {
2864
/**
29-
* Disable animations. Supported on iOS only.
65+
* Initialize Dynamsoft Barcode Reader
66+
* @param license {string}
67+
* @return {Promise<any>} Returns a promise that resolves when the initialization is done
3068
*/
31-
disableAnimations?: boolean;
69+
@Cordova({
70+
successIndex: 1,
71+
errorIndex: 2,
72+
})
73+
init(license: string): Promise<any> {
74+
return;
75+
}
3276

3377
/**
34-
* Disable success beep. Supported on iOS only.
78+
* Set up runtime settings
79+
* @param settings {string} runtime settings template in JSON
80+
* @return {Promise<any>} Returns a promise
3581
*/
36-
disableSuccessBeep?: boolean;
82+
@Cordova({
83+
successIndex: 1,
84+
errorIndex: 2,
85+
})
86+
initRuntimeSettingsWithString(settings?: string): Promise<any> {
87+
return;
88+
}
3789

3890
/**
39-
* Prompt text. Supported on Android only.
91+
* Output runtime settings to JSON string
92+
* @return {Promise<String>} Returns a promise
4093
*/
41-
prompt?: string;
94+
@Cordova({ successIndex: 1, errorIndex: 2 })
95+
outputSettingsToString(): Promise<string> {
96+
return;
97+
}
4298

4399
/**
44-
* Formats separated by commas. Defaults to all formats except `PDF_417` and `RSS_EXPANDED`.
100+
* destroy Dynamsoft Barcode Reader
101+
* @return {Promise<any>} Returns a promise
45102
*/
46-
formats?: string;
103+
@Cordova({ successIndex: 1, errorIndex: 2 })
104+
destroy(): Promise<any> {
105+
return;
106+
}
47107

48108
/**
49-
* Orientation. Supported on Android only. Can be set to `portrait` or `landscape`. Defaults to none so the user can rotate the phone and pick an orientation.
109+
* start the camera to scan barcodes
110+
* @param dceLicense {string} License of Dynamsoft Camera Enhancer
111+
* @return {Observable<FrameResult>}
50112
*/
51-
orientation?: string;
113+
@Cordova({
114+
successIndex: 1,
115+
errorIndex: 2,
116+
observable: true,
117+
})
118+
startScanning(dceLicense?: string): Observable<FrameResult> {
119+
return;
120+
}
52121

53122
/**
54-
* Launch with the torch switched on (if available). Supported on Android only.
123+
* stop scanning
124+
* @return {Promise<any>} Returns a promise
55125
*/
56-
torchOn?: boolean;
126+
@Cordova({ successIndex: 1, errorIndex: 2 })
127+
stopScanning(): Promise<any> {
128+
return;
129+
}
57130

58131
/**
59-
* Save scan history. Defaults to `false`. Supported on Android only.
132+
* resume scanning
133+
* @return {Promise<any>} Returns a promise
60134
*/
61-
saveHistory?: boolean;
135+
@Cordova({ successIndex: 1, errorIndex: 2 })
136+
resumeScanning(): Promise<any> {
137+
return;
138+
}
62139

63140
/**
64-
* Display scanned text for X ms. 0 suppresses it entirely, default 1500. Supported on Android only.
141+
* pause scanning
142+
* @return {Promise<any>} Returns a promise
65143
*/
66-
resultDisplayDuration?: number;
144+
@Cordova({ successIndex: 1, errorIndex: 2 })
145+
pauseScanning(): Promise<any> {
146+
return;
147+
}
67148

68149
/**
69-
* Long key for Dynamsoft Barcode Reader
150+
* get resolution like: 1280x720
151+
* @return {Promise<string>} Returns a promise
70152
*/
71-
dynamsoftlicense?: string;
72-
}
73-
74-
export interface BarcodeScanResult {
75-
format: string;
76-
cancelled: boolean;
77-
text: string;
78-
}
153+
@Cordova({ successIndex: 1, errorIndex: 2 })
154+
getResolution(): Promise<string> {
155+
return;
156+
}
79157

80-
/**
81-
* @name dynamsoft-barcode-scanner
82-
* @description
83-
* The Barcode Scanner Plugin opens a camera view and automatically scans a barcode, returning the data back to you.
84-
* Requires this Cordova plugin: [BarcodeScanner plugin](https://github.com/Dynamsoft/cordova-plugin-dbr/).
85-
* @usage
86-
* ```typescript
87-
* import { BarcodeScanner } from '@awesome-cordova-plugins/dynamsoft-barcode-scanner';
88-
*
89-
* ...
90-
*
91-
* const results = await BarcodeScanner.scan({"dynamsoftlicense":"license"});
92-
* console.log(results);
93-
*
94-
* ```
95-
* @interfaces
96-
* BarcodeScannerOptions
97-
* BarcodeScanResult
98-
*/
99-
@Plugin({
100-
pluginName: 'dynamsoft-barcode-scanner',
101-
plugin: 'cordova-plugin-dbr',
102-
pluginRef: 'cordova.plugins.barcodeScanner',
103-
repo: 'https://github.com/Dynamsoft/cordova-plugin-dbr',
104-
install: '',
105-
installVariables: [],
106-
platforms: ['Android', 'iOS'],
107-
})
108-
@Injectable()
109-
export class BarcodeScanner extends AwesomeCordovaNativePlugin {
110158
/**
111-
* Open the barcode scanner.
112-
*
113-
* @param {BarcodeScannerOptions} [options] Optional options to pass to the scanner
114-
* @returns {Promise<any>} Returns a Promise that resolves with scanner data, or rejects with an error.
159+
* switch torch
160+
* @param desiredStatus {string} on or off
161+
* @return {Promise<any>} Returns a promise
115162
*/
116-
@Cordova({
117-
callbackOrder: 'reverse',
118-
})
119-
scan(options?: BarcodeScannerOptions): Promise<BarcodeScanResult> {
163+
@Cordova({ successIndex: 1, errorIndex: 2 })
164+
switchTorch(desiredStatus: string): Promise<any> {
120165
return;
121166
}
122167
}

0 commit comments

Comments
 (0)