@credenza3/scanner-lib 0.1.0 → 0.1.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @credenza3/scanner-lib@0.1.0 build /home/runner/work/scanner/scanner/packages/scanner-lib
2
+ > @credenza3/scanner-lib@0.1.1 build /home/runner/work/scanner/scanner/packages/scanner-lib
3
3
  > vite build
4
4
 
5
5
  Vite command: 'build', mode: 'production'
@@ -13,8 +13,8 @@ computing gzip size...
13
13
  [vite:dts] Start rollup declaration files...
14
14
  Analysis will use the bundled TypeScript version 5.4.2
15
15
  *** The target project appears to use TypeScript 5.9.3 which is newer than the bundled compiler engine; consider upgrading API Extractor.
16
- [vite:dts] Declaration files built in 3898ms.
16
+ [vite:dts] Declaration files built in 3221ms.
17
17
 
18
- dist/scanner.es.js 718.36 kB │ gzip: 162.66 kB
19
- dist/scanner.umd.js 371.74 kB │ gzip: 112.41 kB
20
- ✓ built in 7.33s
18
+ dist/scanner.es.js 718.22 kB │ gzip: 162.62 kB
19
+ dist/scanner.umd.js 371.67 kB │ gzip: 112.37 kB
20
+ ✓ built in 6.98s
package/README.md CHANGED
@@ -48,12 +48,6 @@ const scanner = new Scanner({target: '.scanner-placeholder'}) // query selector
48
48
 
49
49
  `Scanner.events` - list of events produced by scanner
50
50
 
51
- ### Get a list of available video input devices
52
-
53
- ```
54
- await scanner.listVideoInputDevices()
55
- ```
56
-
57
51
  ### Scan
58
52
 
59
53
  ```
@@ -61,7 +55,7 @@ scanner.scan({
61
55
  deviceId?: string,
62
56
  isCloseButton?: boolean
63
57
  maxScansPerSecond? number // 25
64
- }) // (await scanner.listVideoInputDevices())[0].id by default
58
+ })
65
59
  ```
66
60
 
67
61
  ### Cancel
@@ -76,8 +70,14 @@ On capture
76
70
 
77
71
  ```
78
72
  // 'capture'
79
- scanner.on(Scanner.events.CAPTURE, ({ rawString, message, scanType, aud }) => {
80
- console.log('Scan completed', { rawString, message, aud })
73
+ scanner.on(Scanner.events.CAPTURE, ({ rawString, message, scanType, sub, format, raw }: { rawString: string, message: string, scanType?: string, sub?: string, format: string, raw?: string }) => {
74
+
75
+ // if format is JSON, then sub, aud, scanType are available
76
+ if (format === 'JSON') {
77
+ console.log('Scan completed', { rawString, message, sub, format, scanType });
78
+ } else { // if format is RAW_TEXT only rawString and raw are available
79
+ console.log('Scan completed', { rawString, format, raw });
80
+ }
81
81
  })
82
82
  ```
83
83
 
@@ -1424,21 +1424,11 @@ const Ws = (x) => {
1424
1424
  const f = Rr.Buffer.from(x, "base64").toString("utf8"), u = Rr.Buffer.from(f, "binary").toString("base64");
1425
1425
  return x === u ? f : x;
1426
1426
  }, Hs = async (x) => {
1427
- const f = Ws(x);
1428
- try {
1429
- const u = JSON.parse(f);
1430
- return {
1431
- message: f,
1432
- ...u,
1433
- format: "JSON"
1434
- };
1435
- } catch {
1436
- return {
1437
- message: f,
1438
- raw: x,
1439
- format: "RAW_TEXT"
1440
- };
1441
- }
1427
+ const f = Ws(x), u = JSON.parse(f);
1428
+ return {
1429
+ message: f,
1430
+ ...u
1431
+ };
1442
1432
  };
1443
1433
  var j;
1444
1434
  (function(x) {