escpos-buffer
Advanced tools
Comparing version 4.0.5 to 4.1.0
@@ -146,2 +146,5 @@ declare const capabilities: { | ||
}, { | ||
readonly model: "Q4"; | ||
readonly profile: "tectoy"; | ||
}, { | ||
readonly model: "PertoPrinter"; | ||
@@ -302,2 +305,15 @@ readonly profile: "perto"; | ||
}; | ||
readonly tectoy: { | ||
readonly profile: "epson"; | ||
readonly brand: "TecToy"; | ||
readonly columns: 48; | ||
readonly feed: 4; | ||
readonly fonts: readonly [{ | ||
readonly name: "Font A"; | ||
readonly columns: 48; | ||
}, { | ||
readonly name: "Font B"; | ||
readonly columns: 56; | ||
}]; | ||
}; | ||
readonly generic: { | ||
@@ -304,0 +320,0 @@ readonly brand: "Generic"; |
@@ -195,2 +195,6 @@ "use strict"; | ||
{ | ||
model: 'Q4', | ||
profile: 'tectoy', | ||
}, | ||
{ | ||
model: 'PertoPrinter', | ||
@@ -375,2 +379,18 @@ profile: 'perto', | ||
}, | ||
tectoy: { | ||
profile: 'epson', | ||
brand: 'TecToy', | ||
columns: 48, | ||
feed: 4, | ||
fonts: [ | ||
{ | ||
name: 'Font A', | ||
columns: 48, | ||
}, | ||
{ | ||
name: 'Font B', | ||
columns: 56, | ||
}, | ||
], | ||
}, | ||
generic: { | ||
@@ -377,0 +397,0 @@ brand: 'Generic', |
@@ -14,2 +14,3 @@ "use strict"; | ||
const Sweda_1 = require("./profile/Sweda"); | ||
const TecToy_1 = require("./profile/TecToy"); | ||
const cache = new Map(); | ||
@@ -45,2 +46,4 @@ class Model { | ||
return new Sweda_1.default(capability); | ||
case 'tectoy': | ||
return new TecToy_1.default(capability); | ||
default: | ||
@@ -47,0 +50,0 @@ return new Epson_1.default(capability); |
@@ -9,3 +9,3 @@ import Epson from './Epson'; | ||
qrcode(data: string, size: number): Promise<void>; | ||
protected fontChanged(current: Font, previows: Font): Promise<void>; | ||
protected fontChanged(current: Font, previous: Font): Promise<void>; | ||
} |
@@ -77,3 +77,3 @@ "use strict"; | ||
} | ||
fontChanged(current, previows) { | ||
fontChanged(current, previous) { | ||
const _super = Object.create(null, { | ||
@@ -87,3 +87,3 @@ fontChanged: { get: () => super.fontChanged } | ||
yield this.connection.write(Buffer.from('\x1D\xf951', 'ascii')); | ||
return _super.fontChanged.call(this, current, previows); | ||
return _super.fontChanged.call(this, current, previous); | ||
}); | ||
@@ -90,0 +90,0 @@ } |
@@ -8,3 +8,3 @@ import Epson from './Epson'; | ||
initialize(): Promise<void>; | ||
protected fontChanged(current: Font, previows: Font): Promise<void>; | ||
protected fontChanged(current: Font, previous: Font): Promise<void>; | ||
} |
@@ -47,3 +47,3 @@ "use strict"; | ||
} | ||
fontChanged(current, previows) { | ||
fontChanged(current, previous) { | ||
const _super = Object.create(null, { | ||
@@ -57,3 +57,3 @@ fontChanged: { get: () => super.fontChanged } | ||
else { | ||
return _super.fontChanged.call(this, current, previows); | ||
return _super.fontChanged.call(this, current, previous); | ||
} | ||
@@ -60,0 +60,0 @@ }); |
@@ -11,5 +11,5 @@ import Epson from './Epson'; | ||
initialize(): Promise<void>; | ||
protected fontChanged(current: Font, previows: Font): Promise<void>; | ||
protected fontChanged(current: Font, previous: Font): Promise<void>; | ||
qrcode(data: string, size: number): Promise<void>; | ||
protected get bitmapCmd(): string; | ||
} |
@@ -76,3 +76,3 @@ "use strict"; | ||
} | ||
fontChanged(current, previows) { | ||
fontChanged(current, previous) { | ||
const _super = Object.create(null, { | ||
@@ -82,3 +82,3 @@ fontChanged: { get: () => super.fontChanged } | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
yield _super.fontChanged.call(this, current, previows); | ||
yield _super.fontChanged.call(this, current, previous); | ||
return this.applyCodePage(); | ||
@@ -85,0 +85,0 @@ }); |
@@ -17,3 +17,3 @@ import { Align, Style, Cut, Drawer } from '../actions'; | ||
qrcode(data: string, size: number): Promise<void>; | ||
protected fontChanged(current: Font, previows: Font): Promise<void>; | ||
protected fontChanged(current: Font, previous: Font): Promise<void>; | ||
} |
@@ -133,3 +133,3 @@ "use strict"; | ||
} | ||
fontChanged(current, previows) { | ||
fontChanged(current, previous) { | ||
const _super = Object.create(null, { | ||
@@ -145,3 +145,3 @@ fontChanged: { get: () => super.fontChanged } | ||
} | ||
return _super.fontChanged.call(this, current, previows); | ||
return _super.fontChanged.call(this, current, previous); | ||
}); | ||
@@ -148,0 +148,0 @@ } |
const { Printer, Align, Model, InMemory, Image } = require('../dist') | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
(async () => { | ||
const image = new Image(path.join(__dirname, 'sample.png')) | ||
const image = new Image({ | ||
data: fs.readFileSync(path.join(__dirname, 'sample.png')), | ||
width: 180, | ||
height: 215 | ||
}) | ||
const model = new Model('MP-4200 TH') | ||
@@ -7,0 +12,0 @@ const connection = new InMemory() |
const { Printer, Align, Model, InMemory } = require('../dist'); | ||
const { ImageManager } = require('escpos-buffer-image'); | ||
(async () => { | ||
const model = new Model('PrintiD') | ||
const connection = new InMemory() | ||
const printer = await Printer.CONNECT(model, connection) | ||
await printer.setAlignment(Align.Center) | ||
await printer.qrcode('https://github.com/grandchef/escpos-buffer') | ||
await printer.setAlignment(Align.Left) | ||
await printer.buzzer() | ||
await printer.cutter() | ||
process.stdout.write(connection.buffer()) | ||
})() | ||
const model = new Model('PrintiD'); | ||
const connection = new InMemory(); | ||
const imageManager = new ImageManager(); | ||
const printer = await Printer.CONNECT(model, connection, imageManager); | ||
await printer.setAlignment(Align.Center); | ||
await printer.qrcode('https://github.com/grandchef/escpos-buffer'); | ||
await printer.setAlignment(Align.Left); | ||
await printer.buzzer(); | ||
await printer.cutter(); | ||
process.stdout.write(connection.buffer()); | ||
})(); | ||
//> node examples/qrcode.js | lp -d MyCupsPrinterName |
@@ -1,69 +0,112 @@ | ||
const { Printer, Style, Align, Drawer, Model, InMemory, Image } = require('../') | ||
const { | ||
Printer, | ||
Style, | ||
Align, | ||
Drawer, | ||
Model, | ||
InMemory, | ||
Image, | ||
} = require('../'); | ||
const path = require('path'); | ||
const { ImageManager } = require('escpos-buffer-image'); | ||
(async () => { | ||
const args = process.argv.slice(2) | ||
const no_qrcode = args[2] | ||
const no_picture = args[3] | ||
const modelName = args[0] || 'MP-4200 TH' | ||
const capability = Model.EXPAND(Model.FIND(modelName)) | ||
const model = new Model(modelName) | ||
const { feed } = capability | ||
const connection = new InMemory() | ||
const printer = await Printer.CONNECT(model, connection) | ||
await printer.setColumns(args[1] || 48) | ||
await printer.writeln('Align Center', 0, Align.Center) | ||
await printer.writeln('Align Left', 0, Align.Left) | ||
await printer.writeln('Align Right', 0, Align.Right) | ||
await printer.writeln() | ||
await printer.writeln('Bold Text', Style.Bold, Align.Center) | ||
await printer.writeln('Italic Text', Style.Italic, Align.Center) | ||
await printer.writeln('Underline Text', Style.Underline, Align.Center) | ||
await printer.writeln('Condensed Text', Style.Condensed, Align.Center) | ||
await printer.writeln('All Styles', Style.Bold + Style.Italic + Style.Underline + Style.Condensed, Align.Center) | ||
await printer.writeln() | ||
await printer.writeln('DOUBLE WIDTH', Style.DoubleWidth, Align.Center) | ||
await printer.writeln('DOUBLE HEIGHT', Style.DoubleHeight, Align.Center) | ||
await printer.writeln('WIDTH AND HEIGHT', Style.DoubleWidth + Style.DoubleHeight, Align.Center) | ||
await printer.writeln() | ||
await printer.writeln('With bold', 0, Align.Center) | ||
await printer.writeln('DOUBLE WIDTH', Style.DoubleWidth + Style.Bold, Align.Center) | ||
await printer.writeln('DOUBLE HEIGHT', Style.DoubleHeight + Style.Bold, Align.Center) | ||
await printer.writeln('WIDTH AND HEIGHT', Style.DoubleWidth + Style.DoubleHeight + Style.Bold, Align.Center) | ||
await printer.writeln() | ||
await printer.writeln('Áçênts $ 5', Style.DoubleWidth | Style.DoubleWidth, Align.Center) | ||
await printer.writeln() | ||
await printer.writeln(`Columns: ${printer.columns}`, 0, Align.Center) | ||
await printer.writeln('1 10 20 30 40 50 60 70 80') | ||
await printer.writeln('12345678901234567890123456789012345678901234567890123456789012345678901234567890') | ||
await printer.writeln() | ||
const args = process.argv.slice(2); | ||
const no_qrcode = args[2]; | ||
const no_picture = args[3]; | ||
const modelName = args[0] || 'MP-4200 TH'; | ||
const capability = Model.EXPAND(Model.FIND(modelName)); | ||
const model = new Model(modelName); | ||
const { feed } = capability; | ||
const connection = new InMemory(); | ||
const imageManager = new ImageManager(); | ||
const printer = await Printer.CONNECT(model, connection, imageManager); | ||
await printer.setColumns(args[1] || 48); | ||
await printer.writeln('Align Center', 0, Align.Center); | ||
await printer.writeln('Align Left', 0, Align.Left); | ||
await printer.writeln('Align Right', 0, Align.Right); | ||
await printer.writeln(); | ||
await printer.writeln('Bold Text', Style.Bold, Align.Center); | ||
await printer.writeln('Italic Text', Style.Italic, Align.Center); | ||
await printer.writeln('Underline Text', Style.Underline, Align.Center); | ||
await printer.writeln('Condensed Text', Style.Condensed, Align.Center); | ||
await printer.writeln( | ||
'All Styles', | ||
Style.Bold + Style.Italic + Style.Underline + Style.Condensed, | ||
Align.Center, | ||
); | ||
await printer.writeln(); | ||
await printer.writeln('DOUBLE WIDTH', Style.DoubleWidth, Align.Center); | ||
await printer.writeln('DOUBLE HEIGHT', Style.DoubleHeight, Align.Center); | ||
await printer.writeln( | ||
'WIDTH AND HEIGHT', | ||
Style.DoubleWidth + Style.DoubleHeight, | ||
Align.Center, | ||
); | ||
await printer.writeln(); | ||
await printer.writeln('With bold', 0, Align.Center); | ||
await printer.writeln( | ||
'DOUBLE WIDTH', | ||
Style.DoubleWidth + Style.Bold, | ||
Align.Center, | ||
); | ||
await printer.writeln( | ||
'DOUBLE HEIGHT', | ||
Style.DoubleHeight + Style.Bold, | ||
Align.Center, | ||
); | ||
await printer.writeln( | ||
'WIDTH AND HEIGHT', | ||
Style.DoubleWidth + Style.DoubleHeight + Style.Bold, | ||
Align.Center, | ||
); | ||
await printer.writeln(); | ||
await printer.writeln( | ||
'Áçênts $ 5', | ||
Style.DoubleWidth | Style.DoubleWidth, | ||
Align.Center, | ||
); | ||
await printer.writeln(); | ||
await printer.writeln(`Columns: ${printer.columns}`, 0, Align.Center); | ||
await printer.writeln( | ||
'1 10 20 30 40 50 60 70 80', | ||
); | ||
await printer.writeln( | ||
'12345678901234567890123456789012345678901234567890123456789012345678901234567890', | ||
); | ||
await printer.writeln(); | ||
if (!no_qrcode) { | ||
await printer.writeln('QR Code', 0, Align.Center) | ||
await printer.setAlignment(Align.Center) | ||
await printer.qrcode('https://github.com/grandchef/escpos-buffer') | ||
await printer.setAlignment(Align.Left) | ||
await printer.writeln('End QR Code', 0, Align.Center) | ||
await printer.writeln('QR Code', 0, Align.Center); | ||
await printer.setAlignment(Align.Center); | ||
await printer.qrcode('https://github.com/grandchef/escpos-buffer'); | ||
await printer.setAlignment(Align.Left); | ||
await printer.writeln('End QR Code', 0, Align.Center); | ||
} | ||
if (!no_picture) { | ||
const image = new Image(path.join(__dirname, 'transparent_sample.png')) | ||
await printer.writeln('Picture', 0, Align.Center) | ||
await printer.setAlignment(Align.Center) | ||
await printer.draw(image) | ||
const image2 = new Image(path.join(__dirname, 'sample.png')) | ||
await printer.draw(image2) | ||
await printer.setAlignment(Align.Left) | ||
await printer.writeln('End Picture', 0, Align.Center) | ||
const image = new Image( | ||
await imageManager.loadImage( | ||
path.join(__dirname, 'transparent_sample.png'), | ||
), | ||
); | ||
await printer.writeln('Picture', 0, Align.Center); | ||
await printer.setAlignment(Align.Center); | ||
await printer.draw(image); | ||
const image2 = new Image( | ||
await imageManager.loadImage(path.join(__dirname, 'sample.png')), | ||
); | ||
await printer.draw(image2); | ||
await printer.setAlignment(Align.Left); | ||
await printer.writeln('End Picture', 0, Align.Center); | ||
} | ||
await printer.writeln(`Last Line - Feed: ${feed}`, 0, Align.Center) | ||
await printer.writeln(`Last Line - Feed: ${feed}`, 0, Align.Center); | ||
if (feed > 0) { | ||
await printer.feed(feed) | ||
await printer.feed(feed); | ||
} | ||
await printer.cutter() | ||
await printer.buzzer() | ||
await printer.drawer(Drawer.First) | ||
process.stdout.write(connection.buffer()) | ||
})() | ||
await printer.cutter(); | ||
await printer.buzzer(); | ||
await printer.drawer(Drawer.First); | ||
process.stdout.write(connection.buffer()); | ||
})(); | ||
//> node examples/test.js "MODEL" COLUMNS | lp -d PRINTER_NAME | ||
@@ -70,0 +113,0 @@ |
{ | ||
"name": "escpos-buffer", | ||
"version": "4.0.5", | ||
"version": "4.1.0", | ||
"description": "Library to generate buffer for thermal printers.", | ||
@@ -44,2 +44,3 @@ "author": "GrandChef Team <desenvolvimento@grandchef.com.br>", | ||
"ts-jest": "^29.0.5", | ||
"ts-node": "^10.9.1", | ||
"tslint": "^6.1.3", | ||
@@ -46,0 +47,0 @@ "tslint-config-prettier": "1.18.0", |
@@ -208,2 +208,8 @@ const capabilities = { | ||
// TecToy | ||
{ | ||
model: 'Q4', | ||
profile: 'tectoy', | ||
}, | ||
// Perto | ||
@@ -394,2 +400,18 @@ { | ||
}, | ||
tectoy: { | ||
profile: 'epson', | ||
brand: 'TecToy', | ||
columns: 48, | ||
feed: 4, | ||
fonts: [ | ||
{ | ||
name: 'Font A', | ||
columns: 48, | ||
}, | ||
{ | ||
name: 'Font B', | ||
columns: 56, | ||
}, | ||
], | ||
}, | ||
generic: { | ||
@@ -396,0 +418,0 @@ brand: 'Generic', |
@@ -13,2 +13,3 @@ import { Profile } from './profile'; | ||
import Sweda from './profile/Sweda'; | ||
import TecToy from './profile/TecToy'; | ||
@@ -48,2 +49,4 @@ const cache = new Map<string, Capability>(); | ||
return new Sweda(capability); | ||
case 'tectoy': | ||
return new TecToy(capability); | ||
default: | ||
@@ -50,0 +53,0 @@ return new Epson(capability); |
@@ -74,3 +74,3 @@ import Epson from './Epson'; | ||
protected async fontChanged(current: Font, previows: Font): Promise<void> { | ||
protected async fontChanged(current: Font, previous: Font): Promise<void> { | ||
if (current.name == 'Font C') { | ||
@@ -80,4 +80,4 @@ return this.connection.write(Buffer.from('\x1D\xf950', 'ascii')); | ||
await this.connection.write(Buffer.from('\x1D\xf951', 'ascii')); | ||
return super.fontChanged(current, previows); | ||
return super.fontChanged(current, previous); | ||
} | ||
} |
@@ -35,3 +35,3 @@ import Epson from './Epson'; | ||
protected async fontChanged(current: Font, previows: Font) { | ||
protected async fontChanged(current: Font, previous: Font) { | ||
if (current.name == 'Font C') { | ||
@@ -41,5 +41,5 @@ return this.connection.write(Buffer.from('\x1BM\x02', 'ascii')); | ||
// Font A and B | ||
return super.fontChanged(current, previows); | ||
return super.fontChanged(current, previous); | ||
} | ||
} | ||
} |
@@ -66,4 +66,4 @@ import Epson from './Epson'; | ||
protected async fontChanged(current: Font, previows: Font) { | ||
await super.fontChanged(current, previows); | ||
protected async fontChanged(current: Font, previous: Font) { | ||
await super.fontChanged(current, previous); | ||
return this.applyCodePage(); | ||
@@ -70,0 +70,0 @@ } |
@@ -148,3 +148,3 @@ import { Align, Style, Cut, Drawer } from '../actions'; | ||
protected async fontChanged(current: Font, previows: Font) { | ||
protected async fontChanged(current: Font, previous: Font) { | ||
if (current.name == 'Font A') { | ||
@@ -156,4 +156,4 @@ await this.connection.write(Buffer.from('\x1BM\x00', 'ascii')); | ||
} | ||
return super.fontChanged(current, previows); | ||
return super.fontChanged(current, previous); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
428549
220
5907
15
1