@operato/barcode
Advanced tools
Comparing version 9.0.0-beta.5 to 9.0.0-beta.10
@@ -6,2 +6,11 @@ # Change Log | ||
## [9.0.0-beta.10](https://github.com/hatiolab/operato/compare/v9.0.0-beta.9...v9.0.0-beta.10) (2025-01-25) | ||
### :bug: Bug Fix | ||
* tweak tsconfig.json ([3c424b1](https://github.com/hatiolab/operato/commit/3c424b18d046f95d5619076d113d49a4b4dc9bbb)) | ||
## [9.0.0-beta.5](https://github.com/hatiolab/operato/compare/v9.0.0-beta.4...v9.0.0-beta.5) (2025-01-20) | ||
@@ -8,0 +17,0 @@ |
@@ -8,8 +8,50 @@ import { __decorate } from "tslib"; | ||
super(...arguments); | ||
this.bcid = 'code128'; | ||
this.bcWidth = 30; | ||
this.bcHeight = 10; | ||
this.bcScale = 3; | ||
this.value = ''; | ||
this.includetext = true; | ||
Object.defineProperty(this, "bcid", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: 'code128' | ||
}); | ||
Object.defineProperty(this, "bcWidth", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: 30 | ||
}); | ||
Object.defineProperty(this, "bcHeight", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: 10 | ||
}); | ||
Object.defineProperty(this, "bcScale", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: 3 | ||
}); | ||
Object.defineProperty(this, "value", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: '' | ||
}); | ||
Object.defineProperty(this, "includetext", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: true | ||
}); | ||
Object.defineProperty(this, "validity", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "canvas", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
} | ||
@@ -62,4 +104,8 @@ render() { | ||
}; | ||
Barcode.styles = [ | ||
css ` | ||
Object.defineProperty(Barcode, "styles", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: [ | ||
css ` | ||
:host { | ||
@@ -87,3 +133,4 @@ display: flex; | ||
` | ||
]; | ||
] | ||
}); | ||
__decorate([ | ||
@@ -90,0 +137,0 @@ property({ type: String }) |
const API_URL = 'http://localhost:9100/'; | ||
export default class ZebraBrowserPrintWrapper { | ||
constructor() { | ||
this.device = {}; | ||
this.getAvailablePrinters = async () => { | ||
const config = { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'text/plain;charset=UTF-8' | ||
Object.defineProperty(this, "device", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: {} | ||
}); | ||
Object.defineProperty(this, "getAvailablePrinters", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: async () => { | ||
const config = { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'text/plain;charset=UTF-8' | ||
} | ||
}; | ||
const endpoint = API_URL + 'available'; | ||
const res = await fetch(endpoint, config); | ||
const data = await res.json(); | ||
if (data && data !== undefined && data.printer && data.printer !== undefined && data.printer.length > 0) { | ||
return data.printer; | ||
} | ||
}; | ||
const endpoint = API_URL + 'available'; | ||
const res = await fetch(endpoint, config); | ||
const data = await res.json(); | ||
if (data && data !== undefined && data.printer && data.printer !== undefined && data.printer.length > 0) { | ||
return data.printer; | ||
return new Error('No printers available'); | ||
} | ||
return new Error('No printers available'); | ||
}; | ||
this.getDefaultPrinter = async () => { | ||
const config = { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'text/plain;charset=UTF-8' | ||
}); | ||
Object.defineProperty(this, "getDefaultPrinter", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: async () => { | ||
const config = { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'text/plain;charset=UTF-8' | ||
} | ||
}; | ||
const endpoint = API_URL + 'default'; | ||
const res = await fetch(endpoint, config); | ||
const data = await res.text(); | ||
if (data && data !== undefined && typeof data !== 'object' && data.split('\n\t').length === 7) { | ||
const deviceRaw = data.split('\n\t'); | ||
const name = this.cleanUpString(deviceRaw[1]); | ||
const deviceType = this.cleanUpString(deviceRaw[2]); | ||
const connection = this.cleanUpString(deviceRaw[3]); | ||
const uid = this.cleanUpString(deviceRaw[4]); | ||
const provider = this.cleanUpString(deviceRaw[5]); | ||
const manufacturer = this.cleanUpString(deviceRaw[6]); | ||
return { | ||
connection, | ||
deviceType, | ||
manufacturer, | ||
name, | ||
provider, | ||
uid, | ||
version: 0 | ||
}; | ||
} | ||
}; | ||
const endpoint = API_URL + 'default'; | ||
const res = await fetch(endpoint, config); | ||
const data = await res.text(); | ||
if (data && data !== undefined && typeof data !== 'object' && data.split('\n\t').length === 7) { | ||
const deviceRaw = data.split('\n\t'); | ||
const name = this.cleanUpString(deviceRaw[1]); | ||
const deviceType = this.cleanUpString(deviceRaw[2]); | ||
const connection = this.cleanUpString(deviceRaw[3]); | ||
const uid = this.cleanUpString(deviceRaw[4]); | ||
const provider = this.cleanUpString(deviceRaw[5]); | ||
const manufacturer = this.cleanUpString(deviceRaw[6]); | ||
throw new Error("There's no default printer"); | ||
} | ||
}); | ||
Object.defineProperty(this, "setPrinter", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: (device) => { | ||
this.device = device; | ||
} | ||
}); | ||
Object.defineProperty(this, "getPrinter", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: () => { | ||
return this.device; | ||
} | ||
}); | ||
Object.defineProperty(this, "cleanUpString", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: (str) => { | ||
const [_, ...values] = str.split(':'); | ||
const result = values.join(':').trim(); | ||
return result; | ||
} | ||
}); | ||
Object.defineProperty(this, "checkPrinterStatus", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: async () => { | ||
await this.write('~HQES'); | ||
const result = await this.read(); | ||
const errors = []; | ||
let isReadyToPrint = false; | ||
const isError = result.charAt(70); | ||
const media = result.charAt(88); | ||
const head = result.charAt(87); | ||
const pause = result.charAt(84); | ||
isReadyToPrint = isError === '0'; | ||
switch (media) { | ||
case '1': | ||
errors.push('Paper out'); | ||
break; | ||
case '2': | ||
errors.push('Ribbon Out'); | ||
break; | ||
case '4': | ||
errors.push('Media Door Open'); | ||
break; | ||
case '8': | ||
errors.push('Cutter Fault'); | ||
break; | ||
default: | ||
break; | ||
} | ||
switch (head) { | ||
case '1': | ||
errors.push('Printhead Overheating'); | ||
break; | ||
case '2': | ||
errors.push('Motor Overheating'); | ||
break; | ||
case '4': | ||
errors.push('Printhead Fault'); | ||
break; | ||
case '8': | ||
errors.push('Incorrect Printhead'); | ||
break; | ||
default: | ||
break; | ||
} | ||
if (pause === '1') | ||
errors.push('Printer Paused'); | ||
if (!isReadyToPrint && errors.length === 0) | ||
errors.push('Error: Unknown Error'); | ||
return { | ||
connection, | ||
deviceType, | ||
manufacturer, | ||
name, | ||
provider, | ||
uid, | ||
version: 0 | ||
isReadyToPrint, | ||
errors: errors.join() | ||
}; | ||
} | ||
throw new Error("There's no default printer"); | ||
}; | ||
this.setPrinter = (device) => { | ||
this.device = device; | ||
}; | ||
this.getPrinter = () => { | ||
return this.device; | ||
}; | ||
this.cleanUpString = (str) => { | ||
const [_, ...values] = str.split(':'); | ||
const result = values.join(':').trim(); | ||
return result; | ||
}; | ||
this.checkPrinterStatus = async () => { | ||
await this.write('~HQES'); | ||
const result = await this.read(); | ||
const errors = []; | ||
let isReadyToPrint = false; | ||
const isError = result.charAt(70); | ||
const media = result.charAt(88); | ||
const head = result.charAt(87); | ||
const pause = result.charAt(84); | ||
isReadyToPrint = isError === '0'; | ||
switch (media) { | ||
case '1': | ||
errors.push('Paper out'); | ||
break; | ||
case '2': | ||
errors.push('Ribbon Out'); | ||
break; | ||
case '4': | ||
errors.push('Media Door Open'); | ||
break; | ||
case '8': | ||
errors.push('Cutter Fault'); | ||
break; | ||
default: | ||
break; | ||
}); | ||
Object.defineProperty(this, "write", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: async (data) => { | ||
const endpoint = API_URL + 'write'; | ||
const myData = { | ||
device: this.device, | ||
data | ||
}; | ||
const config = { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'text/plain;charset=UTF-8' | ||
}, | ||
body: JSON.stringify(myData) | ||
}; | ||
await fetch(endpoint, config); | ||
} | ||
switch (head) { | ||
case '1': | ||
errors.push('Printhead Overheating'); | ||
break; | ||
case '2': | ||
errors.push('Motor Overheating'); | ||
break; | ||
case '4': | ||
errors.push('Printhead Fault'); | ||
break; | ||
case '8': | ||
errors.push('Incorrect Printhead'); | ||
break; | ||
default: | ||
break; | ||
}); | ||
Object.defineProperty(this, "read", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: async () => { | ||
const endpoint = API_URL + 'read'; | ||
const myData = { | ||
device: this.device | ||
}; | ||
const config = { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'text/plain;charset=UTF-8' | ||
}, | ||
body: JSON.stringify(myData) | ||
}; | ||
const res = await fetch(endpoint, config); | ||
const data = await res.text(); | ||
return data; | ||
} | ||
if (pause === '1') | ||
errors.push('Printer Paused'); | ||
if (!isReadyToPrint && errors.length === 0) | ||
errors.push('Error: Unknown Error'); | ||
return { | ||
isReadyToPrint, | ||
errors: errors.join() | ||
}; | ||
}; | ||
this.write = async (data) => { | ||
const endpoint = API_URL + 'write'; | ||
const myData = { | ||
device: this.device, | ||
data | ||
}; | ||
const config = { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'text/plain;charset=UTF-8' | ||
}, | ||
body: JSON.stringify(myData) | ||
}; | ||
await fetch(endpoint, config); | ||
}; | ||
this.read = async () => { | ||
const endpoint = API_URL + 'read'; | ||
const myData = { | ||
device: this.device | ||
}; | ||
const config = { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'text/plain;charset=UTF-8' | ||
}, | ||
body: JSON.stringify(myData) | ||
}; | ||
const res = await fetch(endpoint, config); | ||
const data = await res.text(); | ||
return data; | ||
}; | ||
this.print = async (text) => { | ||
await this.write(text); | ||
}; | ||
}); | ||
Object.defineProperty(this, "print", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: async (text) => { | ||
await this.write(text); | ||
} | ||
}); | ||
} | ||
} | ||
//# sourceMappingURL=browser-printer-wrapper.js.map |
import ZebraBrowserPrintWrapper from './browser-printer-wrapper.js'; | ||
export class BrowserPrinter { | ||
constructor() { | ||
this.printer = new ZebraBrowserPrintWrapper(); | ||
Object.defineProperty(this, "printer", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: new ZebraBrowserPrintWrapper() | ||
}); | ||
} | ||
@@ -6,0 +11,0 @@ async print(content) { |
@@ -13,2 +13,14 @@ export class USBPrinter { | ||
]) { | ||
Object.defineProperty(this, "filters", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "device", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.filters = filters; | ||
@@ -15,0 +27,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"author": "barcode", | ||
"version": "9.0.0-beta.5", | ||
"version": "9.0.0-beta.10", | ||
"type": "module", | ||
@@ -82,3 +82,3 @@ "main": "dist/src/index.js", | ||
}, | ||
"gitHead": "d1b2da3d89cfb76336bfe4a596f6e77e0c93d2fd" | ||
"gitHead": "5f56d67c7097c8362e658c78262e6bbec66029cf" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
142632
758