@operato/scene-label 1.0.0-alpha.21 → 1.0.0-alpha.24

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/barcode-scanner.js +6 -12
  3. package/dist/barcode-scanner.js.map +1 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/label-printer.js +1 -2
  6. package/dist/label-printer.js.map +1 -1
  7. package/helps/scene/component/barcode-scanner.ko.md +1 -1
  8. package/helps/scene/component/barcode-scanner.md +1 -1
  9. package/helps/scene/component/barcode-scanner.zh.md +1 -1
  10. package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +14 -4
  11. package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +13 -13
  12. package/logs/application-2022-06-13-11.log +19 -0
  13. package/logs/application-2022-06-20-09.log +4 -0
  14. package/logs/application-2022-06-20-11.log +4 -0
  15. package/logs/application-2022-06-20-12.log +4 -0
  16. package/logs/connections-2022-06-13-11.log +70 -35
  17. package/logs/connections-2022-06-20-09.log +35 -0
  18. package/logs/connections-2022-06-20-11.log +35 -0
  19. package/logs/connections-2022-06-20-12.log +35 -0
  20. package/package.json +8 -7
  21. package/src/barcode-scanner.ts +7 -12
  22. package/src/label-printer.ts +1 -3
  23. package/translations/en.json +1 -1
  24. package/translations/ko.json +1 -1
  25. package/translations/ms.json +3 -3
  26. package/translations/zh.json +3 -3
  27. package/tsconfig.tsbuildinfo +1 -1
  28. package/logs/application-2022-06-15-23.log +0 -4
  29. package/logs/connections-2022-06-09-23.log +0 -70
  30. package/logs/connections-2022-06-13-12.log +0 -35
  31. package/logs/connections-2022-06-15-23.log +0 -35
  32. package/src/direct-print/browser-printer.ts +0 -21
  33. package/src/direct-print/usb-printer.ts +0 -84
@@ -1,84 +0,0 @@
1
- const DEFAULT_FILTERS = [
2
- {
3
- vendorId: 0x0a5f /* zebra */
4
- },
5
- {
6
- vendorId: 0x04f9 /* brother */
7
- },
8
- {
9
- vendorId: 0x0828 /* sato */
10
- }
11
- ]
12
-
13
- export class USBPrinter {
14
- filters: {
15
- vendorId: number
16
- }[] = DEFAULT_FILTERS
17
-
18
- device: any
19
-
20
- constructor(filters = DEFAULT_FILTERS) {
21
- this.filters = filters
22
- }
23
-
24
- async setup() {
25
- //@ts-ignore
26
- if (!navigator.usb) {
27
- throw new Error('Browser could not access USB device. You can print only https or localhost origin.')
28
- }
29
-
30
- //@ts-ignore
31
- var selectedDevice = await navigator.usb.requestDevice({
32
- filters: this.filters
33
- })
34
-
35
- this.device = selectedDevice
36
- console.log(this.device)
37
-
38
- await this.device.open()
39
- if (!this.device.configuration) {
40
- await this.device.selectConfiguration(1)
41
- }
42
- await this.device.claimInterface(0)
43
- if (!this.device.configuration.interfaces[0].alternate) {
44
- await this.device.selectAlternateInterface(0, 0)
45
- }
46
- }
47
-
48
- async read() {
49
- const { endpointNumber } = this.device.configuration.interfaces[0].alternate.endpoints[0]
50
-
51
- var result = await this.device.transferIn(endpointNumber, 64)
52
- var textDecoder = new TextDecoder()
53
-
54
- return textDecoder.decode(result.data)
55
- }
56
-
57
- async _print(content: string) {
58
- var encoder = new TextEncoder()
59
- var data = encoder.encode(content)
60
-
61
- const { endpointNumber } = this.device.configuration.interfaces[0].alternate.endpoints[1]
62
- await this.device.transferOut(endpointNumber, data)
63
- }
64
-
65
- async connectAndPrint(content: string) {
66
- this.print(content)
67
- }
68
-
69
- async print(content: string) {
70
- try {
71
- if (!this.device) {
72
- await this.setup()
73
- await this._print(content)
74
- } else {
75
- await this._print(content)
76
- }
77
- } catch (e) {
78
- console.log(e)
79
- delete this.device
80
-
81
- throw e
82
- }
83
- }
84
- }