@scrumble-nl/react-native-honeywell-scanner 1.3.0 → 1.3.2
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/README.md +10 -54
- package/dist/index.d.ts +20 -2
- package/dist/index.js +30 -30
- package/package.json +4 -8
package/README.md
CHANGED
|
@@ -4,67 +4,23 @@ This module is forked and upgraded from react-native-honeywell-scanner-v2.
|
|
|
4
4
|
|
|
5
5
|
## Getting started
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```shell
|
|
8
|
+
$ npm install @scrumble-nl/react-native-honeywell-scanner
|
|
9
|
+
```
|
|
8
10
|
|
|
9
11
|
## Usage
|
|
10
12
|
```typescript jsx
|
|
11
|
-
import
|
|
13
|
+
import Honeywell from '@scrumble-nl/react-native-honeywell-scanner';
|
|
12
14
|
|
|
13
15
|
...
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
console.log('Received data', event.data);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
return () => {
|
|
24
|
-
HoneywellScanner.stopReader().then(() => {
|
|
25
|
-
HoneywellScanner.offBarcodeReadSuccess();
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}, []);
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### Example code in custom scanner hook
|
|
33
|
-
```typescript jsx
|
|
34
|
-
import {useEffect, useRef} from 'react';
|
|
35
|
-
|
|
36
|
-
import HoneywellScanner from '@scrumble-nl/react-native-honeywell-scanner';
|
|
37
|
-
|
|
38
|
-
type ScanCallback = (scanValue: string) => void;
|
|
39
|
-
type Scanner = {
|
|
40
|
-
startScanner: () => void;
|
|
41
|
-
stopScanner: () => void;
|
|
17
|
+
const startScanner = (callback: (scanValue: string) => void): void => {
|
|
18
|
+
Honeywell.registerListener((event: {data: string}) => {
|
|
19
|
+
callback(event.data.trim());
|
|
20
|
+
});
|
|
42
21
|
};
|
|
43
22
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
callbackRef.current = onScan;
|
|
49
|
-
}, [onScan]);
|
|
50
|
-
|
|
51
|
-
const startScanner = (): void => {
|
|
52
|
-
setTimeout(() => {
|
|
53
|
-
HoneywellScanner.startReader().then(() => {
|
|
54
|
-
HoneywellScanner.onBarcodeReadSuccess((event: {data: string}) => {
|
|
55
|
-
callbackRef.current(event.data.trim());
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}, 100);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const stopScanner = (): void => {
|
|
62
|
-
HoneywellScanner.stopReader().then(HoneywellScanner.offBarcodeReadSuccess);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
stopScanner,
|
|
67
|
-
startScanner,
|
|
68
|
-
};
|
|
23
|
+
const stopScanner = (): void => {
|
|
24
|
+
Honeywell.clearEventListeners();
|
|
69
25
|
};
|
|
70
26
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Listen for available events
|
|
3
|
+
* @param {String} eventName Name of event one of barcodeReadSuccess, barcodeReadFail
|
|
4
|
+
* @param {Function} handler Event handler
|
|
5
|
+
*/
|
|
6
|
+
interface Scanner {
|
|
7
|
+
registerListener: (event: (...args: any[]) => any) => void;
|
|
8
|
+
clearEventListeners: () => void;
|
|
9
|
+
onBarcodeReadFail?: (event: (...args: any[]) => any) => void;
|
|
10
|
+
}
|
|
11
|
+
declare class Honeywell implements Scanner {
|
|
12
|
+
barcodeReaderEmitter: any;
|
|
13
|
+
subscriptionBarcodeReadSuccess: any;
|
|
14
|
+
subscriptionBarcodeReadFail: any;
|
|
15
|
+
registerListener: (event: (...args: any[]) => any) => void;
|
|
16
|
+
clearEventListeners: () => void;
|
|
17
|
+
onBarcodeReadFail: (event: (...args: any[]) => any) => void;
|
|
18
|
+
}
|
|
19
|
+
declare const _default: Honeywell;
|
|
20
|
+
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -2,33 +2,33 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const react_native_1 = require("react-native");
|
|
4
4
|
const { HoneywellScanner } = react_native_1.NativeModules;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
exports.default =
|
|
5
|
+
class Honeywell {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.barcodeReaderEmitter = new react_native_1.NativeEventEmitter(HoneywellScanner);
|
|
8
|
+
this.subscriptionBarcodeReadSuccess = null;
|
|
9
|
+
this.subscriptionBarcodeReadFail = null;
|
|
10
|
+
this.registerListener = (event) => {
|
|
11
|
+
setTimeout(() => {
|
|
12
|
+
HoneywellScanner.startScanner().then(() => {
|
|
13
|
+
var _a;
|
|
14
|
+
(_a = this.subscriptionBarcodeReadSuccess) === null || _a === void 0 ? void 0 : _a.remove();
|
|
15
|
+
this.subscriptionBarcodeReadSuccess = null;
|
|
16
|
+
this.subscriptionBarcodeReadSuccess = this.barcodeReaderEmitter.addListener(HoneywellScanner.BARCODE_READ_SUCCESS, event);
|
|
17
|
+
});
|
|
18
|
+
}, 100);
|
|
19
|
+
};
|
|
20
|
+
this.clearEventListeners = () => {
|
|
21
|
+
HoneywellScanner.stopReader().then(() => {
|
|
22
|
+
var _a;
|
|
23
|
+
(_a = this.subscriptionBarcodeReadSuccess) === null || _a === void 0 ? void 0 : _a.remove();
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
this.onBarcodeReadFail = (event) => {
|
|
27
|
+
var _a;
|
|
28
|
+
(_a = this.subscriptionBarcodeReadFail) === null || _a === void 0 ? void 0 : _a.remove();
|
|
29
|
+
this.subscriptionBarcodeReadFail = null;
|
|
30
|
+
this.subscriptionBarcodeReadFail = this.barcodeReaderEmitter.addListener(HoneywellScanner.BARCODE_READ_FAIL, event);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.default = new Honeywell();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrumble-nl/react-native-honeywell-scanner",
|
|
3
3
|
"title": "React Native Honeywell Scanner",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.2",
|
|
5
5
|
"description": "Bridge to use the Honeywell scanner",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -25,12 +25,8 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"licenseFilename": "LICENSE",
|
|
27
27
|
"readmeFilename": "README.md",
|
|
28
|
-
"
|
|
29
|
-
"react": "
|
|
30
|
-
"react-native": "0
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"react": "16.*",
|
|
34
|
-
"react-native": "0.*"
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"react": "^17.0.2",
|
|
30
|
+
"react-native": "^0.68.5"
|
|
35
31
|
}
|
|
36
32
|
}
|