Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
// For this demo we're going to make use of the USB printer manager
// so it can take care of concerns like the USB connect and disconnect events.

// For this demo we're going to make use of the USB printer manager
// so it can take care of concerns like the USB connect and disconnect events.

// It's a handy-dandy feature included from the web-device-mux library!
// We need to tell it what type of device it's managing, and how to filter
// USB devices that are receipt printers.
Expand Down Expand Up @@ -220,9 +223,7 @@ <h4>${titleHtml}</h4>
<hr>
<p>Fix the issue, then dismiss this alert to check the status again.</p>`,
// And when the alert is dismissed, check the status again!
() => printer.sendDocument({
commands: [new WebReceipt.GetStatus()]
})
() => printer.sendDocument(WebReceipt.ReadyToPrintDocuments.getStatus),
);
});
});
Expand Down Expand Up @@ -339,30 +340,21 @@ <h4>${titleHtml}</h4>
e.preventDefault();
const printerIdx = (e.currentTarget as HTMLAnchorElement).dataset.printerIdx as unknown as number;
const printer = this.printers[printerIdx];
const doc = {
commands: [new WebReceipt.TestPrint('rolling')]
};
await printer.sendDocument(doc);
await printer.sendDocument(WebReceipt.ReadyToPrintDocuments.printTest);
});
document.getElementById(`printconfig_${idx}`)!
.addEventListener('click', async (e) => {
e.preventDefault();
const printerIdx = (e.currentTarget as HTMLAnchorElement).dataset.printerIdx as unknown as number;
const printer = this.printers[printerIdx];
const doc = {
commands: [new WebReceipt.TestPrint('printerStatus')]
};
await printer.sendDocument(doc);
await printer.sendDocument(WebReceipt.ReadyToPrintDocuments.printConfig);
});
document.getElementById(`drawerkick_${idx}`)!
.addEventListener('click', async (e) => {
e.preventDefault();
const printerIdx = (e.currentTarget as HTMLAnchorElement).dataset.printerIdx as unknown as number;
const printer = this.printers[printerIdx];
const doc = {
commands: [new WebReceipt.PulseCommand()]
};
await printer.sendDocument(doc);
await printer.sendDocument(WebReceipt.ReadyToPrintDocuments.drawerKick);
});
}

Expand Down
19 changes: 4 additions & 15 deletions demo/test_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ class BasicDocumentPrinterApp {
<hr>
<p>Fix the issue, then dismiss this alert to check the status again.</p>`,
// And when the alert is dismissed, check the status again!
() => printer.sendDocument({
commands: [new WebReceipt.GetStatus()]
})
() => printer.sendDocument(WebReceipt.ReadyToPrintDocuments.getStatus),
);
});
});
Expand Down Expand Up @@ -268,30 +266,21 @@ class BasicDocumentPrinterApp {
e.preventDefault();
const printerIdx = (e.currentTarget as HTMLAnchorElement).dataset.printerIdx as unknown as number;
const printer = this.printers[printerIdx];
const doc = {
commands: [new WebReceipt.TestPrint('rolling')]
};
await printer.sendDocument(doc);
await printer.sendDocument(WebReceipt.ReadyToPrintDocuments.printTest);
});
document.getElementById(`printconfig_${idx}`)!
.addEventListener('click', async (e) => {
e.preventDefault();
const printerIdx = (e.currentTarget as HTMLAnchorElement).dataset.printerIdx as unknown as number;
const printer = this.printers[printerIdx];
const doc = {
commands: [new WebReceipt.TestPrint('printerStatus')]
};
await printer.sendDocument(doc);
await printer.sendDocument(WebReceipt.ReadyToPrintDocuments.printConfig);
});
document.getElementById(`drawerkick_${idx}`)!
.addEventListener('click', async (e) => {
e.preventDefault();
const printerIdx = (e.currentTarget as HTMLAnchorElement).dataset.printerIdx as unknown as number;
const printer = this.printers[printerIdx];
const doc = {
commands: [new WebReceipt.PulseCommand()]
};
await printer.sendDocument(doc);
await printer.sendDocument(WebReceipt.ReadyToPrintDocuments.drawerKick);
});
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web-receiptline-printer",
"version": "0.3.0-rc1",
"version": "0.3.0-rc2",
"description": "A small library for printing ReceiptLine documents to various receipt printers from a browser.",
"type": "module",
"repository": {
Expand Down
6 changes: 6 additions & 0 deletions src/Commands/BasicCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export class QueryConfiguration extends BasicCommand {
constructor() { super(['waitsForResponse']); }
}

export class PrintConfiguration extends BasicCommand {
name = 'Print the printer configuration'
type: CommandTypeBasic = 'PrintConfiguration';
constructor() { super(['feedsPaper']); }
}

export class GetStatus extends BasicCommand {
name = 'Get the printer status'
type: CommandTypeBasic = 'GetStatus';
Expand Down
Loading
Loading